]> thyrsus.com Git - mad.git/commitdiff
Better compile sequencing.
authorEric S. Raymond <esr@thyrsus,com>
Tue, 10 Feb 2004 18:43:24 +0000 (18:43 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Tue, 10 Feb 2004 18:43:24 +0000 (18:43 +0000)
mad

diff --git a/mad b/mad
index 8132fe1f852ebefc79363226755e91ca73735a29..84a015876712e743915d73dbf755aef2c7ab5052 100755 (executable)
--- 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