From 0b6091819d27cecc27f51ba314671e62a8e8d593 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 1 Oct 2006 07:41:50 +0000 Subject: [PATCH] Improved comment processing. --- ctopy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ctopy b/ctopy index b8e70aa..4a1eadd 100755 --- a/ctopy +++ b/ctopy @@ -82,9 +82,9 @@ region_transformations = ( # externs can just disappear -- this may discard a following comment (r"extern[^;]+;.*\n", r""), # macros - (r"#define\s+(%(id)s)\s+(.*)[ \t]*\n", r"\1\t= \2\n"), - (r"#define\s+(%(id)s)\(([^)]*)\)\s+(.*\))[ \t]*\n", r"def \1(\2):\treturn \3\n"), - (r"#define\s+(%(id)s)\(([^)]*)\)\s+([^(].*)[ \t]*\n", r"def \1(\2):\t\3\n"), + (r"#define\s+(%(id)s)\s+(.*)[ \t]*(?=\n|$)", r"\1\t= \2"), + (r"#define\s+(%(id)s)\(([^)]*)\)\s+(.*\))[ \t]*(?=\n|$)", r"def \1(\2):\treturn \3"), + (r"#define\s+(%(id)s)\(([^)]*)\)\s+([^(].*)[ \t]*(?=\n|$)", r"def \1(\2):\t\3"), # function headers (r"(?:^|\n)(?:static\s+)?(?:%(type)s) +(.*\)) *\n", r"\ndef \1:\n"), (r"\(void\):\n", r"():\n"), @@ -227,8 +227,8 @@ def ctopy(input, debug=0): boundaries.append(i+1) state = "text" boundaries.append(len(input)) - if boundaries[0] == 0: - boundaries.pop(0) + if debug >= 2: + print "Boundaries:", boundaries if debug: print "Regexp transformation begins" regions = [] -- 2.43.0