Date: Thu, 24 Aug 2006 22:09:57 +0300 From: "Matti J. Karki" <mjk@iki.fi> To: "=?ISO-8859-1?Q?Kyrre_Nyg=E5rd?=" <kyrreny@broadpark.no> Cc: questions@freebsd.org Subject: Re: Code beautifiers, anyone? Message-ID: <1b15366e0608241209t1d655b5fl98063ecb6221b0a8@mail.gmail.com> In-Reply-To: <7.0.1.0.2.20060824192439.02386de8@broadpark.no> References: <7.0.1.0.2.20060824145822.0194fc10@broadpark.no> <1b15366e0608240618j62d41ad3j537f095b2e566ed5@mail.gmail.com> <7.0.1.0.2.20060824192439.02386de8@broadpark.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On 8/24/06, Kyrre Nyg=E5rd <kyrreny@broadpark.no> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1b15366e0608241209t1d655b5fl98063ecb6221b0a8>