From 62a815429186b18b8cd7ba56e585f1ff44e5ba6b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 13 Feb 2004 20:51:01 +0000 Subject: [PATCH] Arrays are 0-origin after all. --- mad | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mad b/mad index aaa5919..16851aa 100755 --- 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 -- 2.43.0