浏览代码

v.rectify, v.vect.stats, v.out.ascii, v.db.connect: use G_option_to_separator()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60613 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 11 年之前
父节点
当前提交
01d73e2b8e
共有 4 个文件被更改,包括 11 次插入45 次删除
  1. 3 3
      vector/v.db.connect/main.c
  2. 3 11
      vector/v.out.ascii/args.c
  3. 2 15
      vector/v.rectify/main.c
  4. 3 16
      vector/v.vect.stats/main.c

+ 3 - 3
vector/v.db.connect/main.c

@@ -44,6 +44,7 @@ int main(int argc, char **argv)
     int field, ret, num_dblinks, i, ncols, col;
     char *fieldname;
     struct Map_info Map;
+    char *sep;
 
     /* set up the options and flags for the command line parser */
 
@@ -142,6 +143,8 @@ int main(int argc, char **argv)
     }
     G_debug(1, "layer number %d, layer name %s", field, fieldname);
 
+    sep = G_option_to_separator(sep_opt);
+
     if (print->answer && shell_print->answer)
 	G_fatal_error(_("Please choose only one print style"));
 
@@ -177,9 +180,6 @@ int main(int argc, char **argv)
 			G_fatal_error(_("Database connection not defined"));
 
 		    if (shell_print->answer) {
-			const char *sep = sep_opt->answer;
-			if (!sep)
-			    sep = "|";
 			if (fi->name)
 			    fprintf(stdout, "%d/%s%s%s%s%s%s%s%s%s\n",
 				    fi->number, fi->name, sep,

+ 3 - 11
vector/v.out.ascii/args.c

@@ -107,18 +107,10 @@ void parse_args(int argc, char **argv,
 	*format = GV_ASCII_FORMAT_WKT;
     if (sscanf(dp_opt->answer, "%d", dp) != 1)
 	G_fatal_error(_("Failed to interpret 'dp' parameter as an integer"));
+
     /* the field separator */
-    if (strcmp(delim_opt->answer, "\\t") == 0)
-	*delim = G_store("\t");
-    else if (strcmp(delim_opt->answer, "tab") == 0)
-	*delim = G_store("\t");
-    else if (strcmp(delim_opt->answer, "space") == 0)
-	*delim = G_store(" ");
-    else if (strcmp(delim_opt->answer, "comma") == 0)
-	*delim = G_store(",");
-    else
-	*delim = G_store(delim_opt->answer);
-    
+    *delim = G_option_to_separator(delim_opt);
+
     *field = G_store(field_opt->answer);
     *type = Vect_option_to_types(type_opt);
     if (*type & GV_AREA) {

+ 2 - 15
vector/v.rectify/main.c

@@ -158,21 +158,8 @@ int main(int argc, char *argv[])
 	
     orthorot = ortho->answer;
 
-    if (print_rms->answer) {
-	if (sep->answer) {
-	    rms_sep = sep->answer;
-	    if (strcmp(rms_sep, "\\t") == 0)
-		rms_sep = "\t";
-	    if (strcmp(rms_sep, "tab") == 0)
-		rms_sep = "\t";
-	    if (strcmp(rms_sep, "space") == 0)
-		rms_sep = " ";
-	    if (strcmp(rms_sep, "comma") == 0)
-		rms_sep = ",";
-	}
-	else
-	    rms_sep = "|";
-    }
+    if (print_rms->answer)
+	rms_sep = G_option_to_separator(sep);
     else
 	rms_sep = NULL;
 

+ 3 - 16
vector/v.vect.stats/main.c

@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
      *stats_column_opt,		/* area column for stats result */
      *fs_opt;			/* field separator for printed output */
     struct Flag *print_flag;
-    char fs[2];
+    char *fs;
     struct Map_info PIn, AIn;
     int point_type, point_field, area_field;
     struct line_pnts *Points;
@@ -215,22 +215,9 @@ int main(int argc, char *argv[])
     point_field = atoi(point_field_opt->answer);
     area_field = atoi(area_field_opt->answer);
 
-    strcpy(fs, " ");
-    if (print_flag->answer) {
+    if (print_flag->answer)
 	/* get field separator */
-	if (fs_opt->answer) {
-	    if (strcmp(fs_opt->answer, "space") == 0)
-		*fs = ' ';
-	    else if (strcmp(fs_opt->answer, "tab") == 0)
-		*fs = '\t';
-	    else if (strcmp(fs_opt->answer, "\\t") == 0)
-		*fs = '\t';
-	    else
-		*fs = *fs_opt->answer;
-	}
-	else
-	    *fs = '|';
-    }
+	fs = G_option_to_separator(fs_opt);
 
     /* check for stats */
     if (method_opt->answer) {