[GRASS-SVN] r60519 - grass/trunk/vector/v.in.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 27 09:15:13 PDT 2014


Author: hcho
Date: 2014-05-27 09:15:13 -0700 (Tue, 27 May 2014)
New Revision: 60519

Modified:
   grass/trunk/vector/v.in.ascii/main.c
Log:
v.in.ascii: use G_open_option_file, G_option_to_separator

Modified: grass/trunk/vector/v.in.ascii/main.c
===================================================================
--- grass/trunk/vector/v.in.ascii/main.c	2014-05-27 16:14:18 UTC (rev 60518)
+++ grass/trunk/vector/v.in.ascii/main.c	2014-05-27 16:15:13 UTC (rev 60519)
@@ -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) {
@@ -539,8 +523,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