]> thyrsus.com Git - ctopy.git/commitdiff
Hints processing.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 16:17:38 +0000 (16:17 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 16:17:38 +0000 (16:17 +0000)
ctopy

diff --git a/ctopy b/ctopy
index 808572ddbebb359028f51c4e6b43e68d4642e74c..27653f92b7c2e33315172af34ac6995dd0e43641 100755 (executable)
--- a/ctopy
+++ b/ctopy
@@ -363,7 +363,7 @@ def ctopy(input):
                 regions[i] = "\n".join(txt)
     if debug:
         "Final transformations begin"
-    regions = map(lambda r: single_apply(final_transformations, r),regions)
+    regions = map(lambda r: repeat_apply(final_transformations, r),regions)
     if debug:
         print "Import checks begin"
     importlist = []
@@ -384,15 +384,31 @@ def ctopy(input):
     # Emit what we got.  Preserve imports in case this is a .h file 
     return text
 
+def process_hints(filename):
+    "Process a translation-hints file."
+    for line in open(filename):
+        if line[0] == "#":
+            pass
+        else:
+            (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" 
+
 if __name__ == "__main__":
     import getopt
-    (options, arguments) = getopt.getopt(sys.argv[1:], "c:ds:t:")
+    (options, arguments) = getopt.getopt(sys.argv[1:], "c:h:ds:t:")
     debug = 0;
     for (switch, val) in options:
        if (switch == '-c'):
             shorthands["class"] += r"|\b" + val + r"\b"
        elif (switch == '-d'):
            debug += 1
+       elif (switch == '-h'):
+            process_hints(val)
        elif (switch == '-s'):
             stringify.append(val)
        elif (switch == '-t'):