Date: Fri, 25 Aug 2006 22:31:07 -0700 From: James Long <list@museum.rain.com> To: freebsd-questions@freebsd.org, "Matti J. Karki" <mjk@iki.fi> Subject: Re: Code beautifiers, anyone? Message-ID: <20060826053106.GA81153@ns.museum.rain.com> In-Reply-To: <20060825204853.CD31D16A57C@hub.freebsd.org> References: <20060825204853.CD31D16A57C@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Fri, 25 Aug 2006 21:27:03 +0300 > From: "Matti J. Karki" <mjk@iki.fi> > Subject: Re: Code beautifiers, anyone? > To: " Kyrre Nyg?rd " <kyrreny@broadpark.no> > Cc: "W. D." <WD@us-webmasters.com>, questions@freebsd.org > Message-ID: > <1b15366e0608251127r7067e0c5wd5ba6dea29e1a011@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 8/25/06, Kyrre Nyg?rd <kyrreny@broadpark.no> wrote: > > > > In your script, do these comments look alright then? > > > > (I simplified them a bit) > > > > inbuffer = re.sub('\) *?\n\{', ') {', inbuffer) # Move curly brackets > > to the end of lines > > inbuffer = re.sub('\) *?{', ') {', inbuffer) # Remove spaces between > > closing brackets and opening curly brackets > > inbuffer = re.sub('else *?\n{', 'else {\n', inbuffer) # Fix curly > > brackets in `else' clauses > > inbuffer = re.sub('{ *?(.+?\n)', '{\n\g<1>', inbuffer) # Break up the > > content of curly brackets > > inbuffer = re.sub('(\n.+?)}', '\g<1>\n}', inbuffer) # Take care of > > closing brackets from the above rule > > Looks OK, except... > > > inbuffer = re.sub('\n +', '\n', inbuffer) # Strip trailing whitespace > > This will strip spaces at the _beginning_ of line (leading spaces). Except, possibly, lines that begin at the first byte of the buffer, such as the first line of the file, and any other lines that happen to land across the buffer boundary just so.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060826053106.GA81153>