[GRASS-SVN] r63197 - grass/branches/releasebranch_7_0/display/d.colorlist
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Nov 27 06:35:13 PST 2014
Author: martinl
Date: 2014-11-27 06:35:12 -0800 (Thu, 27 Nov 2014)
New Revision: 63197
Modified:
grass/branches/releasebranch_7_0/display/d.colorlist/main.c
Log:
d.colorlist: fix separator handling
(merge r63192-3 from trunk)
Modified: grass/branches/releasebranch_7_0/display/d.colorlist/main.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.colorlist/main.c 2014-11-27 14:34:21 UTC (rev 63196)
+++ grass/branches/releasebranch_7_0/display/d.colorlist/main.c 2014-11-27 14:35:12 UTC (rev 63197)
@@ -25,7 +25,7 @@
{
struct Option *sep;
struct GModule *module;
- char *colorlist;
+ char *colorlist, *sep_str;
int i;
/* Initialize the GIS calls */
@@ -34,27 +34,30 @@
module = G_define_module();
G_add_keyword(_("display"));
G_add_keyword(_("settings"));
+ G_add_keyword(_("colors"));
module->description =
- "Output a list of all available display colors with a configurable "
- "separator (default is comma).";
+ _("Outputs a list of all available display colors.");
/* set up option */
sep = G_define_standard_option(G_OPT_F_SEP);
- sep->key = "separator";
- sep->description = "Character for separation of list items";
-
+ sep->answer = "comma";
+
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