From owner-freebsd-questions@FreeBSD.ORG Sat Aug 26 05:31:10 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C4D4616A4E1 for ; Sat, 26 Aug 2006 05:31:10 +0000 (UTC) (envelope-from james_mapson@umpquanet.com) Received: from ns.museum.rain.com (gw-ipinc.museum.rain.com [65.75.192.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A74643D4C for ; Sat, 26 Aug 2006 05:31:10 +0000 (GMT) (envelope-from james_mapson@umpquanet.com) Received: from ns.museum.rain.com (localhost [127.0.0.1]) by ns.museum.rain.com (8.13.6/8.13.6) with ESMTP id k7Q5V8hi082904 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Fri, 25 Aug 2006 22:31:08 -0700 (PDT) (envelope-from james@umpquanet.com) Received: (from james@localhost) by ns.museum.rain.com (8.13.6/8.13.6/Submit) id k7Q5V7nQ082903; Fri, 25 Aug 2006 22:31:07 -0700 (PDT) (envelope-from james) Date: Fri, 25 Aug 2006 22:31:07 -0700 From: James Long To: freebsd-questions@freebsd.org, "Matti J. Karki" Message-ID: <20060826053106.GA81153@ns.museum.rain.com> References: <20060825204853.CD31D16A57C@hub.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060825204853.CD31D16A57C@hub.freebsd.org> User-Agent: Mutt/1.5.12-2006-07-14 X-Greylist: Sender is SPF-compliant, not delayed by milter-greylist-2.0.2 (ns.museum.rain.com [127.0.0.1]); Fri, 25 Aug 2006 22:31:08 -0700 (PDT) Cc: Subject: Re: Code beautifiers, anyone? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2006 05:31:10 -0000 > Date: Fri, 25 Aug 2006 21:27:03 +0300 > From: "Matti J. Karki" > Subject: Re: Code beautifiers, anyone? > To: " Kyrre Nyg?rd " > Cc: "W. D." , 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 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.