]> thyrsus.com Git - ctopy.git/commitdiff
Another step towards correct class processing.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 02:00:47 +0000 (02:00 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 02:00:47 +0000 (02:00 +0000)
ctopy

diff --git a/ctopy b/ctopy
index 30ce14743d1ba9c3449899202e743bdc3606f041..31c04f891b56f4c4820d0ceb7ba283a81d721487 100755 (executable)
--- a/ctopy
+++ b/ctopy
@@ -52,7 +52,7 @@ repeat_transformations = (
     (
     # What we're doing here is trying to get rid of variable
     # declarations that don't have initializer parts.
-    # First, bare ids between a comma and a trailing semicolon go away.
+    # First, bare types between a comma and a trailing semicolon go away.
     (r"(\n[ \t]*)((?:%(type)s).*)(,\s*%(id)s\s*);", r"\1\2;"),
     # But bare classes between comma and semicolon get a following initializer 
     (r"(\n[ \t]*)(%(cls)s)(.*,\s)*(%(id)s)(\s*;)", r"\1\2\3\4 = \2()\5;"),
@@ -60,10 +60,10 @@ repeat_transformations = (
     (r"(\n[ \t]*(?:%(type)s)\s+.*,)(%(id)s),(.*);", r"\1\3"),
     # But bare class names between commas get an initializer
     (r"(\n[ \t]*)(%(cls)s)(\s+.*,)(%(id)s),(.*);", r"\1\2\3\4 =\2(),\5"),
-    # Bare ids just after the type and before a comma go away.
-    (r"(\n[ \t]*(?:%(type)s))(\s*%(id)s),(.*);", r"\1\3"),
-    # Bare class names after the type and before comma get an initializer.
-    (r"(\n[ \t]*)(%(cls)s)(\s*%(id)s),(.*);", r"\1\2\3 = \2(),\4"),
+    # Bare ids just after the type and before a comma or semi go away.
+    (r"(\n[ \t]*(?:%(type)s))(\s*%(id)s)([;,])", r"\1\3"),
+    # Bare ids after class names and before comma or semi get an initializer.
+    (r"(\n[ \t]*)(%(cls)s)(\s*%(id)s)([;,])", r"\1\2\3 = \2()\4"),
     # Any declaration line not containing an initializer goes away.
     (r"\n[ \t]*(?:%(type)s|%(cls)s)[^=;]*;", ""),
     ),
@@ -80,7 +80,7 @@ repeat_transformations = (
     # This will strip remaining type declarators out of formal parameter lists.
     # It will also remove types from the beginning of declaration lines.
     # Won't nuke casts because it looks for at least one following whitespace.
-    (r"(?:%(type)s|%(cls)s)\s\s*", ""),
+    (r"(?:%(type)s|%(cls)s)[\s;]\s*", ""),
     ),
 )