SF.net SVN: geany:[4185] trunk/scripts/fix-alignment.pl

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Sep 14 12:32:50 UTC 2009


Revision: 4185
          http://geany.svn.sourceforge.net/geany/?rev=4185&view=rev
Author:   ntrel
Date:     2009-09-14 12:32:50 +0000 (Mon, 14 Sep 2009)

Log Message:
-----------
Allow operators to have more than one space either side to allow alignment with other lines.
Fix spacing '&' or '-' after a ']' bracket.

Modified Paths:
--------------
    trunk/scripts/fix-alignment.pl

Modified: trunk/scripts/fix-alignment.pl
===================================================================
--- trunk/scripts/fix-alignment.pl	2009-09-14 11:53:08 UTC (rev 4184)
+++ trunk/scripts/fix-alignment.pl	2009-09-14 12:32:50 UTC (rev 4185)
@@ -52,18 +52,18 @@
 			my $ops = '<<=,<<,>>=,>>,<=,>=,<,>,||,|=,|,&&,&=,-=,+=,+,*=,/=,/,==,!=,%=,%,^=,^,=';
 			$ops =~ s/([|*+])/\\$1/g; # escape regex chars
 			$ops =~ s/,/|/g;
-			$line =~ s/([\w)\]])\s*($ops)\s*([\w(]|$)/$1 $2 $3/g;
+			$line =~ s/([\w)\]]) ?($ops) ?([\w(]|$)/$1 $2 $3/g;
 
 			# space binary operators that can conflict with unaries with cast and/or 'return -1/&foo'
 			# '-' could be unary "(gint)-j"
 			# '&' could be address-of "(type*)&foo"
-			$line =~ s/(\w)(-|&)\s*([\w(]|$)/$1 $2 $3/g;
+			$line =~ s/([\w\]])(-|&) ?([\w(]|$)/$1 $2 $3/g;
 
 			# space ternary conditional operator
-			$line =~ s/\s*\?\s*(.+?)\s*:\s*/ ? $1 : /g;
+			$line =~ s/ ?\? ?(.+?) ?: ?/ ? $1 : /g;
 
 			# space comma operator (allowing for possible alignment space afterwards)
-			$line =~ s/\s*,(\S)/, $1/g;
+			$line =~ s/ ?,(\S)/, $1/g;
 
 			# space after statements
 			my $statements = 'for|if|while|switch';


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list