[GRASS-SVN] r60613 - in grass/trunk/vector: v.db.connect v.out.ascii v.rectify v.vect.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 30 08:54:39 PDT 2014


Author: hcho
Date: 2014-05-30 08:54:39 -0700 (Fri, 30 May 2014)
New Revision: 60613

Modified:
   grass/trunk/vector/v.db.connect/main.c
   grass/trunk/vector/v.out.ascii/args.c
   grass/trunk/vector/v.rectify/main.c
   grass/trunk/vector/v.vect.stats/main.c
Log:
v.rectify, v.vect.stats, v.out.ascii, v.db.connect: use G_option_to_separator()


Modified: grass/trunk/vector/v.db.connect/main.c
===================================================================
--- grass/trunk/vector/v.db.connect/main.c	2014-05-30 15:53:52 UTC (rev 60612)
+++ grass/trunk/vector/v.db.connect/main.c	2014-05-30 15:54:39 UTC (rev 60613)
@@ -44,6 +44,7 @@
     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 @@
     }
     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 @@
 			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,

Modified: grass/trunk/vector/v.out.ascii/args.c
===================================================================
--- grass/trunk/vector/v.out.ascii/args.c	2014-05-30 15:53:52 UTC (rev 60612)
+++ grass/trunk/vector/v.out.ascii/args.c	2014-05-30 15:54:39 UTC (rev 60613)
@@ -107,18 +107,10 @@
 	*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) {

Modified: grass/trunk/vector/v.rectify/main.c
===================================================================
--- grass/trunk/vector/v.rectify/main.c	2014-05-30 15:53:52 UTC (rev 60612)
+++ grass/trunk/vector/v.rectify/main.c	2014-05-30 15:54:39 UTC (rev 60613)
@@ -158,21 +158,8 @@
 	
     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;
 

Modified: grass/trunk/vector/v.vect.stats/main.c
===================================================================
--- grass/trunk/vector/v.vect.stats/main.c	2014-05-30 15:53:52 UTC (rev 60612)
+++ grass/trunk/vector/v.vect.stats/main.c	2014-05-30 15:54:39 UTC (rev 60613)
@@ -93,7 +93,7 @@
      *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 @@
     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) {



More information about the grass-commit mailing list