> Date: Fri, 25 Aug 2006 21:27:03 +0300 > From: "Matti J. Karki" <[EMAIL PROTECTED]> > Subject: Re: Code beautifiers, anyone? > To: " Kyrre Nyg?rd " <[EMAIL PROTECTED]> > Cc: "W. D." <[EMAIL PROTECTED]>, [EMAIL PROTECTED] > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 8/25/06, Kyrre Nyg?rd <[EMAIL PROTECTED]> 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. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"