[GRASS-SVN] r60742 - grass/branches/releasebranch_7_0/vector/v.in.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 8 01:53:15 PDT 2014


Author: martinl
Date: 2014-06-08 01:53:15 -0700 (Sun, 08 Jun 2014)
New Revision: 60742

Modified:
   grass/branches/releasebranch_7_0/vector/v.in.ascii/main.c
Log:
hcho:  v.in.ascii: use G_open_option_file, G_option_to_separator
       (merge r60519 from trunk)


Modified: grass/branches/releasebranch_7_0/vector/v.in.ascii/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.in.ascii/main.c	2014-06-08 08:52:19 UTC (rev 60741)
+++ grass/branches/releasebranch_7_0/vector/v.in.ascii/main.c	2014-06-08 08:53:15 UTC (rev 60742)
@@ -203,24 +203,8 @@
     if (xcol+1 < 1 || ycol+1 < 1 || zcol+1 < 0 || catcol+1 < 0)
 	G_fatal_error(_("Column numbers must not be negative"));
 
-    if (strcmp(old->answer, "-")) {
-	if ((ascii = fopen(old->answer, "r")) == NULL) {
-	    G_fatal_error(_("Unable to open ASCII file <%s>"), old->answer);
-	}
-    }
-    else {
-	ascii = stdin;
-    }
-    
-    fs = delim_opt->answer;
-    if (strcmp(fs, "\\t") == 0)
-	fs = "\t";
-    if (strcmp(fs, "tab") == 0)
-	fs = "\t";
-    if (strcmp(fs, "space") == 0)
-	fs = " ";
-    if (strcmp(fs, "comma") == 0)
-	fs = ",";
+    ascii = G_open_option_file(old);
+    fs = G_option_to_separator(delim_opt);
 
     /* check dimension */
     if (zcoorf->answer) {
@@ -537,8 +521,7 @@
             G_fatal_error(_("Import failed"));
     }
 
-    if (ascii != stdin)
-	fclose(ascii);
+    G_close_option_file(ascii);
 
     if (notopol_flag->answer) {
 	Vect_close(&Map);



More information about the grass-commit mailing list