From: Peter Johnson Date: Sun, 2 Dec 2001 20:11:33 +0000 (-0000) Subject: Use stdout as the default output file if stdin is the input. X-Git-Tag: v0.1.0~155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fda44f76702ef841d8d74188871188892911a363;p=yasm Use stdout as the default output file if stdin is the input. svn path=/trunk/yasm/; revision=375 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 95947581..8dccd9d0 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -122,6 +122,8 @@ main(int argc, char *argv[]) if (!in) { in = stdin; switch_filename(""); + 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); diff --git a/src/main.c b/src/main.c index 95947581..8dccd9d0 100644 --- a/src/main.c +++ b/src/main.c @@ -122,6 +122,8 @@ main(int argc, char *argv[]) if (!in) { in = stdin; switch_filename(""); + 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);