LCLint-inspired cleanups.
authorPeter Johnson <peter@tortall.net>
Wed, 9 Jan 2002 00:03:37 +0000 (00:03 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 9 Jan 2002 00:03:37 +0000 (00:03 -0000)
svn path=/trunk/yasm/; revision=427

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

index ca2413587b6b8f54d1af3f4555d55b5e68b51a9a..b684a287635cbe729cf4e4c675a162b317864f73 100644 (file)
@@ -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("<STDIN>");
        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++;
index ca2413587b6b8f54d1af3f4555d55b5e68b51a9a..b684a287635cbe729cf4e4c675a162b317864f73 100644 (file)
@@ -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("<STDIN>");
        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++;