Browse Source

hcho: v.in.ascii: use G_open_option_file, G_option_to_separator
(merge https://trac.osgeo.org/grass/changeset/60519 from trunk)


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

Martin Landa 11 years ago
parent
commit
1584981a0b
1 changed files with 3 additions and 20 deletions
  1. 3 20
      vector/v.in.ascii/main.c

+ 3 - 20
vector/v.in.ascii/main.c

@@ -203,24 +203,8 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
             G_fatal_error(_("Import failed"));
     }
 
-    if (ascii != stdin)
-	fclose(ascii);
+    G_close_option_file(ascii);
 
     if (notopol_flag->answer) {
 	Vect_close(&Map);