Selaa lähdekoodia

hcho: g.mlist: Use G_open/close_option_file
(merge https://trac.osgeo.org/grass/changeset/60516 from trunk)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60740 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 11 vuotta sitten
vanhempi
commit
706da407bb
1 muutettua tiedostoa jossa 2 lisäystä ja 7 poistoa
  1. 2 7
      general/g.mlist/main.c

+ 2 - 7
general/g.mlist/main.c

@@ -170,11 +170,7 @@ int main(int argc, char *argv[])
     }
 
     separator = G_option_to_separator(opt.separator);
-
-    if (!opt.output->answer || strcmp(opt.output->answer, "-") == 0)
-	fp = stdout;
-    else if ((fp = fopen(opt.output->answer, "w")) == NULL)
-	G_fatal_error(_("Failed to create file [%s]"), opt.output->answer);
+    fp = G_open_option_file(opt.output);
 
     if ((mapset = opt.mapset->answer) == NULL)
 	mapset = "";
@@ -223,8 +219,7 @@ int main(int argc, char *argv[])
     if (any)
 	fprintf(fp, "\n");
 
-    if (fp != stdout)
-	fclose(fp);
+    G_close_option_file(fp);
 
     if (filter)
 	G_free_ls_filter(filter);