SF.net SVN: geany:[4153] trunk/scripts/fix-alignment.pl
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Sep 4 16:07:26 UTC 2009
Revision: 4153
http://geany.svn.sourceforge.net/geany/?rev=4153&view=rev
Author: ntrel
Date: 2009-09-04 16:07:23 +0000 (Fri, 04 Sep 2009)
Log Message:
-----------
Add/expand some comment info.
Modified Paths:
--------------
trunk/scripts/fix-alignment.pl
Modified: trunk/scripts/fix-alignment.pl
===================================================================
--- trunk/scripts/fix-alignment.pl 2009-09-04 16:00:15 UTC (rev 4152)
+++ trunk/scripts/fix-alignment.pl 2009-09-04 16:07:23 UTC (rev 4153)
@@ -3,7 +3,8 @@
# License: GNU GPL V2 or later, as published by the Free Software Foundation, USA.
# Warranty: NONE
-# Re-align C source code for Geany
+# Re-align C source code for Geany.
+# Doesn't handle indents/blank lines/anything complicated ;-)
use strict;
use warnings;
@@ -45,16 +46,18 @@
if (!($line =~ m,/\*|\*/|//|"|\\$|',) and !($line =~ m/^\s*[*#]/)) {
# make these operators have *one* space each side
# operators must have longer variants first
- # others require special handling: &,*,+,-,> can be (part of) unary op
+ # some require special handling below
my $ops = '<<=,<<,>>=,>>,<=,>=,<,||,|=,|,-=,+=,*=,/=,/,==,!=,%=,%,=';
$ops =~ s/([|*+])/\\$1/g; # escape regex chars
$ops =~ s/,/|/g;
$line =~ s/($ops)\s*/$1 /g; # space after op
$line =~ s/(\S)\s*($ops)/$1 $2/g; # space before op unless indent
+ # &,*,+,-,> can be (part of) unary op
# ignore no space after & address-of operator, enforce space around x & y operator
# ignore lines starting with &, ambiguous.
$line =~ s/([\w)])\s*&\s*([\w(]|$)/$1 & $2/g;
+ # TODO: other possible unarys
# 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