From: Eric S. Raymond Date: Tue, 10 Feb 2004 18:43:24 +0000 (+0000) Subject: Better compile sequencing. X-Git-Tag: 1.0~127 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=b68d66e7e3b9521ae1d6eab896298969fe0c9faf;p=mad.git Better compile sequencing. --- diff --git a/mad b/mad index 8132fe1..84a0158 100755 --- a/mad +++ b/mad @@ -260,7 +260,7 @@ def p_exprlist_continue(t): t[0] = t[1] + [t[3]] def p_print_format0(t): 'statement : PRINT_FORMAT NAME' - t[0] = ('print', t[3]) + t[0] = ('print', t[2]) ## R def p_remark1(t): @@ -985,24 +985,27 @@ if __name__ == '__main__': # Generate code if arguments == ['-']: generate(sys.stdout) + sys.exit(0) + + if not target and len(arguments) == 1: + target = arguments[0][:-4] elif not target and len(arguments) > 1: sys.stderr.write("mad: -o is required with multiple sourcefiles.\n") sys.exit(1) - else: - out = open(target + ".c", "w") - generate(out) - out.close() - if binary: - # Must be gcc, else compilation of internal functions will fail - if hasmain: - if not target: - target = arguments[0][:-4] - compile = "gcc -std=c99 %s.c -lm -o %s" % (target, target) - else: - if not target: - target = arguments[0][:-4] + ".o" - compile = "gcc -std=c99 -c %s.c -o %s" % (target, target) - if os.system(compile) == 0: - os.system("rm -f " + target + ".c") + out = open(target + ".c", "w") + generate(out) + out.close() + if binary: + # Must be gcc, else compilation of internal functions will fail + if hasmain: + if not target: + target = arguments[0][:-4] + compile = "gcc -std=c99 %s.c -lm -o %s" % (target, target) + else: + if not target: + target = arguments[0][:-4] + ".o" + compile = "gcc -std=c99 -c %s.c -o %s" % (target, target) + if os.system(compile) == 0: + os.system("rm -f " + target + ".c") # end