[GRASS-SVN] r63192 - grass/trunk/display/d.colorlist

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 27 06:16:15 PST 2014


Author: martinl
Date: 2014-11-27 06:16:15 -0800 (Thu, 27 Nov 2014)
New Revision: 63192

Modified:
   grass/trunk/display/d.colorlist/main.c
Log:
d.colorlist: fix separator handling

Modified: grass/trunk/display/d.colorlist/main.c
===================================================================
--- grass/trunk/display/d.colorlist/main.c	2014-11-27 13:20:31 UTC (rev 63191)
+++ grass/trunk/display/d.colorlist/main.c	2014-11-27 14:16:15 UTC (rev 63192)
@@ -25,7 +25,7 @@
 {
     struct Option *sep;
     struct GModule *module;
-    char *colorlist;
+    char *colorlist, *sep_str;
     int i;
 
     /* Initialize the GIS calls */
@@ -40,21 +40,23 @@
 
     /* set up option */
     sep = G_define_standard_option(G_OPT_F_SEP);
-    sep->key = "separator";
-    sep->description = "Character for separation of list items";
-
+    
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    sep_str = G_option_to_separator(sep);
+
     colorlist = G_store(D_COLOR_LIST);
 
     /* if separator is different from ",", escape this character */
-    if (strcmp(sep->answer, ",") != 0 && strlen(sep->answer) > 0) {
-	for (i = 0; colorlist[i] != '\0'; i++)
-	    if (colorlist[i] == ',')
-		colorlist[i] = (char)sep->answer[0];
+    for (i = 0; colorlist[i] != '\0'; i++) {
+        if (colorlist[i] == ',') {
+            fprintf(stdout, "%s", sep_str);
+            continue;
+        }
+        fprintf(stdout, "%c", colorlist[i]);
     }
-
-    fprintf(stdout, "%s\n", colorlist);
-    return 0;
+    fprintf(stdout, "\n");
+    
+    exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list