From: Peter Johnson Date: Wed, 9 Jan 2002 00:03:37 +0000 (-0000) Subject: LCLint-inspired cleanups. X-Git-Tag: v0.1.0~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8857243d8a511b3691e8dec1c3971328c2a90b2e;p=yasm LCLint-inspired cleanups. svn path=/trunk/yasm/; revision=427 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index ca241358..b684a287 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -117,8 +117,10 @@ main(int argc, char *argv[]) } /* if no files were specified, fallback to reading stdin */ - if (!in) { + if (!in || !in_filename) { in = stdin; + if (in_filename) + xfree(in_filename); in_filename = xstrdup(""); if (!obj) obj = stdout; @@ -229,10 +231,8 @@ not_an_option_handler(char *param) { if (in) { WarningNow("can open only one input file, only latest file will be processed"); - if(fclose(in)) + if (fclose(in)) ErrorNow("could not close old input file"); - if (in_filename) - xfree(in_filename); } in = fopen(param, "rt"); @@ -240,6 +240,8 @@ not_an_option_handler(char *param) ErrorNow(_("could not open file `%s'"), param); return 1; } + if (in_filename) + xfree(in_filename); in_filename = xstrdup(param); files_open++; diff --git a/src/main.c b/src/main.c index ca241358..b684a287 100644 --- a/src/main.c +++ b/src/main.c @@ -117,8 +117,10 @@ main(int argc, char *argv[]) } /* if no files were specified, fallback to reading stdin */ - if (!in) { + if (!in || !in_filename) { in = stdin; + if (in_filename) + xfree(in_filename); in_filename = xstrdup(""); if (!obj) obj = stdout; @@ -229,10 +231,8 @@ not_an_option_handler(char *param) { if (in) { WarningNow("can open only one input file, only latest file will be processed"); - if(fclose(in)) + if (fclose(in)) ErrorNow("could not close old input file"); - if (in_filename) - xfree(in_filename); } in = fopen(param, "rt"); @@ -240,6 +240,8 @@ not_an_option_handler(char *param) ErrorNow(_("could not open file `%s'"), param); return 1; } + if (in_filename) + xfree(in_filename); in_filename = xstrdup(param); files_open++;