From owner-freebsd-questions@FreeBSD.ORG Thu Aug 24 19:10:02 2006 Return-Path: X-Original-To: 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 BD70516A4E0 for ; Thu, 24 Aug 2006 19:10:02 +0000 (UTC) (envelope-from mjkarki@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2913E43D5C for ; Thu, 24 Aug 2006 19:09:57 +0000 (GMT) (envelope-from mjkarki@gmail.com) Received: by ug-out-1314.google.com with SMTP id m2so633045uge for ; Thu, 24 Aug 2006 12:09:57 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ZDQ50Won8Qie8/zI5cAMIKcDJruCg3jVFvZCWsbbFtRebMafo/g5/UgXYr9wHWikT1Znv8TLADernVjyN32L8hXd0Vww8nWyYqBsFxenSRNrJ9fCNqRCk/nvTvr0GSw2AWRRATVLmd8RxL8AZtdO4uwkI5X9FJDBMebQSg1KKFQ= Received: by 10.67.101.8 with SMTP id d8mr1303875ugm; Thu, 24 Aug 2006 12:09:57 -0700 (PDT) Received: by 10.67.101.7 with HTTP; Thu, 24 Aug 2006 12:09:57 -0700 (PDT) Message-ID: <1b15366e0608241209t1d655b5fl98063ecb6221b0a8@mail.gmail.com> Date: Thu, 24 Aug 2006 22:09:57 +0300 From: "Matti J. Karki" Sender: mjkarki@gmail.com To: "=?ISO-8859-1?Q?Kyrre_Nyg=E5rd?=" In-Reply-To: <7.0.1.0.2.20060824192439.02386de8@broadpark.no> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <7.0.1.0.2.20060824145822.0194fc10@broadpark.no> <1b15366e0608240618j62d41ad3j537f095b2e566ed5@mail.gmail.com> <7.0.1.0.2.20060824192439.02386de8@broadpark.no> X-Google-Sender-Auth: f47aa25fa4318114 Cc: questions@freebsd.org 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: Thu, 24 Aug 2006 19:10:02 -0000 On 8/24/06, Kyrre Nyg=E5rd wrote: > > Perhaps you could share with us whatever scripts you've written? > > Thanks! > Well, my scripts aren't magic. They are pretty simple. Here's few (not scripts, these are valid Vim regexps): :%s/).*\n.*{/) {/g :%s/) *{/) {/g :%s/\t/ /g :%s/^ *$//g :%s/ *$//g 1) Move curly brackets from the next line to the end of an expression. 2) Clean up some crazy bracket placements. 3) Remove tab characters and replace them with 4 spaces. This may mess some multiline comments. 4) Clean all lines, which contain only spaces. 5) Almost same as above. Cleans up spaces at the end of the line. If you run those one after another, the C source file should be much nicer to read and manipulate. The idea should be quite clear and the same regexp rules should be possible to be applied to other regexp-savvy programs/interpreters, so it should be no problem to create a set of scripts, which use those rules to modify a set of files at one run. Some of those regexps are applicable (with minor modifications) to other target languages also. -Matti