]> granicus.if.org Git - yasm/commitdiff
Use stdout as the default output file if stdin is the input.
authorPeter Johnson <peter@tortall.net>
Sun, 2 Dec 2001 20:11:33 +0000 (20:11 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 2 Dec 2001 20:11:33 +0000 (20:11 -0000)
svn path=/trunk/yasm/; revision=375

frontends/yasm/yasm.c
src/main.c

index 95947581692dc7c7c5b869a818aab6e5fa48229a..8dccd9d04fa07cdd7e2dd85cd190d15605816d35 100644 (file)
@@ -122,6 +122,8 @@ main(int argc, char *argv[])
     if (!in) {
        in = stdin;
        switch_filename("<STDIN>");
+       if (!obj)
+           obj = stdout;
     }
 
     /* Set x86 as the architecture */
@@ -168,7 +170,8 @@ main(int argc, char *argv[])
 
     sections = cur_parser->do_parse(cur_parser, in);
 
-    fclose(in);
+    if (in != stdin)
+       fclose(in);
 
     if (OutputAllErrorWarning() > 0) {
        sections_delete(sections);
@@ -200,7 +203,9 @@ main(int argc, char *argv[])
     /* Finalize the object output */
     cur_objfmt->finalize();
 
-    fclose(obj);
+    if (obj != stdout)
+       fclose(obj);
+
     if (obj_filename)
        xfree(obj_filename);
 
index 95947581692dc7c7c5b869a818aab6e5fa48229a..8dccd9d04fa07cdd7e2dd85cd190d15605816d35 100644 (file)
@@ -122,6 +122,8 @@ main(int argc, char *argv[])
     if (!in) {
        in = stdin;
        switch_filename("<STDIN>");
+       if (!obj)
+           obj = stdout;
     }
 
     /* Set x86 as the architecture */
@@ -168,7 +170,8 @@ main(int argc, char *argv[])
 
     sections = cur_parser->do_parse(cur_parser, in);
 
-    fclose(in);
+    if (in != stdin)
+       fclose(in);
 
     if (OutputAllErrorWarning() > 0) {
        sections_delete(sections);
@@ -200,7 +203,9 @@ main(int argc, char *argv[])
     /* Finalize the object output */
     cur_objfmt->finalize();
 
-    fclose(obj);
+    if (obj != stdout)
+       fclose(obj);
+
     if (obj_filename)
        xfree(obj_filename);