From c4df171e9856b790b311484a457992e01879dd0c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 4 Oct 2006 03:40:41 +0000 Subject: [PATCH] Checkpoint before adding curses mappings. --- ctopy | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ctopy b/ctopy index 1c5490b..1021c03 100755 --- a/ctopy +++ b/ctopy @@ -185,11 +185,11 @@ post_transformations = ( (r"\batol\(", r"long("), (r"\bfclose\((%(id)s)\)", r"\1.close()"), (r"\bfopen\(", r"open("), - (r"\bfprintf\((%(id)s), *", r"\1.write("), + (r"\bfprintf\((%(id)s),\s*", r"\1.write("), (r"\bstrlen\(", r"len("), - (r"\bstrcmp\((%(exp)s), *(%(exp)s)\) *== *0", r"\1 == \2"), - (r"\bstrcmp\((%(exp)s), *(%(exp)s)\) *!= *0", r"\1 != \2"), - (r"\bstrcpy\((%(exp)s), *(%(exp)s)\)", r"\1 = \2"), + (r"\bstrcmp\((%(exp)s),\s*(%(exp)s)\)\s*==\s*0", r"\1 == \2"), + (r"\bstrcmp\((%(exp)s),\s*(%(exp)s)\)\s*!=\s*0", r"\1 != \2"), + (r"\bstrcpy\((%(exp)s),\s*(%(exp)s)\)", r"\1 = \2"), # Python string library (r"\btoupper\(", r"string.upper("), (r"\btolower\(", r"string.lower("), @@ -216,6 +216,7 @@ final_transformations = ( (r";(%(eol)s)", r"\1"), (r"\n[ \t]*}%(eol)s", r""), (r"(?= 2: print "Hint: %s" % `line` - (cmd, tok) = line.split() - if cmd == "stringify": - stringify.append(tok) - elif cmd == "type": - shorthands["type"] += r"|\b" + tok + r"\b" - elif cmd == "class": - shorthands["class"] += r"|\b" + tok + r"\b" - elif cmd == "printflike": - printflike.append(tok) + lst = line.replace(",", " ").split() + if lst[0] == "stringify": + stringify += lst[1:] + elif lst[0] == "type": + for tok in lst[1:]: + shorthands["type"] += r"|\b" + tok + r"\b" + elif lst[0] == "class": + for tok in lst[1:]: + shorthands["class"] += r"|\b" + tok + r"\b" + elif lst[0] == "printflike": + printflike += lst[1:] if __name__ == "__main__": import getopt -- 2.43.0