From: Graham Percival <graham@percival-music.ca>
Date: Fri, 10 Sep 2010 19:10:15 +0000 (+0100)
Subject: Style: don't break compiling.
X-Git-Tag: release/2.13.36-1~66
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bdd65d19e5aa806ec367a6727900d1aabf7fb83d;p=lilypond.git

Style: don't break compiling.

- 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.
---

diff --git a/scripts/auxiliar/fixcc.py b/scripts/auxiliar/fixcc.py
index 3928c60775..b77982e2c6 100755
--- a/scripts/auxiliar/fixcc.py
+++ b/scripts/auxiliar/fixcc.py
@@ -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