]> git.donarmstrong.com Git - lilypond.git/commitdiff
Style: don't break compiling.
authorGraham Percival <graham@percival-music.ca>
Fri, 10 Sep 2010 19:10:15 +0000 (20:10 +0100)
committerGraham Percival <gperciva@gperciva-desktop.(none)>
Mon, 4 Oct 2010 15:41:22 +0000 (16:41 +0100)
- Given a "define blah {" line, we *don't* want to move the { to
  the next line.

- given a:
    =
   include "foo.h"
    ;
  don't move the include onto the = line, or the ; onto the
  include line.

scripts/auxiliar/fixcc.py

index 3928c60775b753747249b3f4a65fa203a5d3c01a..b77982e2c652ac0ee1ad23649c96945c21593df0 100755 (executable)
@@ -91,8 +91,8 @@ rules = {
     # space around +/-; exponent
     ('([\w\)\]])(\+|-)([_A-Za-z\(])', '\\1 \\2 \\3'),
     ('([_\dA-Za-df-z\)\]])(\+|-)([\w\(])', '\\1 \\2 \\3'),
-    # trailing operator
-    (' (::|&&|\|\||<=|>=|!=|\|=|==|\+=|-=|\*=|/=|\?|<|>|\+|-|=|/|:|&XXX|\||\*XXX)[ \t]*\n([ \t]*)', '\n\\2\\1 '),
+    # trailing operator, but don't un-trail #include
+    (' (::|&&|\|\||<=|>=|!=|\|=|==|\+=|-=|\*=|/=|\?|<|>|\+|-|=|/|:|&XXX|\||\*XXX)[ \t]*\n([ \t]*)(?!#include)', '\n\\2\\1 '),
     # pointer
     ##('(bool|char|const|delete|int|stream|unsigned|void|size_t|struct \w+|[A-Z]\w*|,|;|&&|<|[^-]>|\|\||-|\+)[ \t]*(\*|&)[ \t]*', '\\1 \\2'),
     ('(bool|char|const|delete|int|stream|unsigned|void|vsize|size_t|struct \w+|[A-Z]\w*|,|;|:|=|\?\)|&&|<|[^-]>|\|\||-|\+)[ \t]*(\*|&)[ \t]*', '\\1 \\2'),
@@ -115,10 +115,10 @@ rules = {
     ('\n[ \t]*\)', ')'),
     # dangling comma
     ('\n[ \t]*,', ','),
-    # dangling semicolon
-    ('\n[ \t]*;', ';'),
-    # brace open
-    ('(\w)[ \t]*([^\s]*){([ \t]*\n)', '\\1\\2\n{\n'),
+    # dangling semicolon, but don't un-dangle it onto #include
+    ('(\n.*\n[ \t]*;)(?!\n#include)', '\\1'),
+    # brace open, but not changing a #define... line
+    ('(\w)[ \t]*([^\s]*){([ \t]*\n)(?!#define)', '\\1\\2\n{\n'),
     # brace open backslash
     ('(\w[^\n]*){[ \t]*\\\\\n', '\\1\\\n{\\\n'),
     # brace close