|
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
|
|
|
{
|
|
|
struct Option *sep;
|
|
|
struct GModule *module;
|
|
|
- char *colorlist;
|
|
|
+ char *colorlist, *sep_str;
|
|
|
int i;
|
|
|
|
|
|
/* Initialize the GIS calls */
|
|
@@ -40,21 +40,23 @@ int main(int argc, char **argv)
|
|
|
|
|
|
/* 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);
|
|
|
}
|