Allow operators to have more than one space either side to allow alignment with other lines.

Fix spacing '&' or '-' after a ']' bracket.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4185 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-09-14 12:32:50 +00:00
parent 683e09aae5
commit 13859cbd4c

View File

@ -52,18 +52,18 @@ sub parse($)
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';