]> thyrsus.com Git - mad.git/commitdiff
Arrays are 0-origin after all.
authorEric S. Raymond <esr@thyrsus,com>
Fri, 13 Feb 2004 20:51:01 +0000 (20:51 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Fri, 13 Feb 2004 20:51:01 +0000 (20:51 +0000)
mad

diff --git a/mad b/mad
index aaa5919283904bb42baf0f0179b5d265ff5a1ec8..16851aa2b5f06d0b3f20faef043cc8f58375ba4b 100755 (executable)
--- a/mad
+++ b/mad
@@ -651,7 +651,7 @@ def prinC1(t):
         res = t[1]
         if len(t) > 2:
             for dim in t[2]:
-                res += '[' + print_C_expr(('-', dim[1], ('intnum', '1'))) + ']'
+                res += '[' + print_C_expr(dim) + ']'
         return res
     elif t[0] == 'apply':
         madfunc = t[1][:-1]
@@ -1058,7 +1058,10 @@ if __name__ == '__main__':
     elif not target and len(arguments) > 1:
         sys.stderr.write("mad: -o is required with multiple sourcefiles.\n")
         sys.exit(1)
-    out = open(target + ".c", "w")
+    stem = target
+    if target[-2] == '.':
+        stem = target[:2]
+    out = open(stem + ".c", "w")
     generate_C_code(out)
     out.close()
     if binary:
@@ -1066,12 +1069,12 @@ if __name__ == '__main__':
         if hasmain:
             if not target:
                 target = arguments[0][:-4]
-            compile = "gcc -std=c99 %s.c -lm -o %s" % (target, target)
+            compile = "gcc -std=c99 %s.c -lm -o %s" % (stem, target)
         else:
             if not target:
                 target = arguments[0][:-4] + ".o"
-            compile = "gcc -std=c99 -c %s.c -o %s" % (target, target)
+            compile = "gcc -std=c99 -c %s.c -o %s" % (stem, target)
         if os.system(compile) == 0:
-            os.system("rm -f " + target + ".c")
+            os.system("rm -f " + stem + ".c")
 
 # end