lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Style: don't break compiling freetype-errors.cc (issue2144047)


From: percival . music . ca
Subject: Style: don't break compiling freetype-errors.cc (issue2144047)
Date: Fri, 10 Sep 2010 19:46:57 +0000

Reviewers: ,

Message:
I'd appreciate it if a python guru / regex person  could take a quick
glance at this.  These changes will stop fixcc.py rendering
lily/freetype-errors.cc uncompilable, but this is the most complicated
regex I've ever attempted (which doesn't say much; I've never needed to
use them before).

This doesn't imply that we will necessarily be using an automatic style
program, nor that we will use fixcc.py even if we decide to use such a
program.  This is just part of the homework that should be done before
we can have a sensible, well-informed debate about the question.

This isn't an urgent issue.

Description:
Style: don't break compiling freetype-errors.cc

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

Please review this at http://codereview.appspot.com/2144047/

Affected files:
  M scripts/auxiliar/fixcc.py


Index: scripts/auxiliar/fixcc.py
diff --git a/scripts/auxiliar/fixcc.py b/scripts/auxiliar/fixcc.py
index 3928c60775b753747249b3f4a65fa203a5d3c01a..b77982e2c652ac0ee1ad23649c96945c21593df0 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]