Code beautifiers, anyone?

James Long list at museum.rain.com
Sat Aug 26 05:31:10 UTC 2006


> Date: Fri, 25 Aug 2006 21:27:03 +0300
> From: "Matti J. Karki" <mjk at iki.fi>
> Subject: Re: Code beautifiers, anyone?
> To: " Kyrre Nyg?rd " <kyrreny at broadpark.no>
> Cc: "W. D." <WD at us-webmasters.com>, questions at freebsd.org
> Message-ID:
> 	<1b15366e0608251127r7067e0c5wd5ba6dea29e1a011 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> On 8/25/06, Kyrre Nyg?rd <kyrreny at 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.


More information about the freebsd-questions mailing list