[GRASS-SVN] r62085 - in grass/trunk/general: g.list manage/lister
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 25 07:49:41 PDT 2014
Author: hcho
Date: 2014-09-25 07:49:41 -0700 (Thu, 25 Sep 2014)
New Revision: 62085
Modified:
grass/trunk/general/g.list/main.c
grass/trunk/general/manage/lister/cell.c
grass/trunk/general/manage/lister/vector.c
Log:
lister, g.list: Add support for multiple mapsets to listers, Fix g.list -f mapset=... (ticket #2432)
Modified: grass/trunk/general/g.list/main.c
===================================================================
--- grass/trunk/general/g.list/main.c 2014-09-25 14:42:37 UTC (rev 62084)
+++ grass/trunk/general/g.list/main.c 2014-09-25 14:49:41 UTC (rev 62085)
@@ -67,7 +67,6 @@
void *filter, *exclude;
struct Popen pager;
FILE *fp;
- const char *mapset;
char *separator;
int use_region;
struct Cell_head window;
@@ -264,6 +263,8 @@
}
if (opt.mapset->answers && opt.mapset->answers[0]) {
+ const char *mapset;
+
G_create_alt_search_path();
for (i = 0; (mapset = opt.mapset->answers[i]); i++) {
if (strcmp(mapset, "*") == 0) {
@@ -303,14 +304,27 @@
G_debug(3, "lister CMD: %s", lister);
- if (access(lister, X_OK) == 0) /* execute permission? */
- G_spawn(lister, lister, mapset, NULL);
- else
+ if (access(lister, X_OK) == 0) { /* execute permission? */
+ const char **args;
+ const char *mapset;
+
+ for (j = 0; (mapset = G_get_mapset_name(j)); j++);
+ args = (const char **)G_calloc(j + 2, sizeof(char *));
+
+ args[0] = lister;
+ for (j = 0; (mapset = G_get_mapset_name(j)); j++)
+ args[j + 1] = mapset;
+ args[j + 1] = NULL;
+
+ G_vspawn_ex(lister, args);
+ } else
M_do_list(n, "");
}
else if (flag.pretty->answer)
M_do_list(n, "");
else {
+ const char *mapset;
+
for (j = 0; (mapset = G_get_mapset_name(j)); j++)
make_list(fp, elem, mapset, separator, flag.type->answer,
flag.mapset->answer, use_region ? &window : NULL);
Modified: grass/trunk/general/manage/lister/cell.c
===================================================================
--- grass/trunk/general/manage/lister/cell.c 2014-09-25 14:42:37 UTC (rev 62084)
+++ grass/trunk/general/manage/lister/cell.c 2014-09-25 14:49:41 UTC (rev 62085)
@@ -9,7 +9,15 @@
G_gisinit(argv[0]);
- G_list_element("cell", "raster", argc > 1 ? argv[1] : "", lister);
+ if (argc == 1)
+ G_list_element("cell", "raster", "", lister);
+ else {
+ int i;
+
+ for (i = 1; i < argc; ++i)
+ G_list_element("cell", "raster", argv[i], lister);
+ }
+
exit(0);
}
Modified: grass/trunk/general/manage/lister/vector.c
===================================================================
--- grass/trunk/general/manage/lister/vector.c 2014-09-25 14:42:37 UTC (rev 62084)
+++ grass/trunk/general/manage/lister/vector.c 2014-09-25 14:49:41 UTC (rev 62085)
@@ -10,7 +10,15 @@
G_gisinit(argv[0]);
- G_list_element("vector", "vector", argc > 1 ? argv[1] : "", lister);
+ if (argc == 1)
+ G_list_element("vector", "vector", "", lister);
+ else {
+ int i;
+
+ for (i = 1; i < argc; ++i)
+ G_list_element("vector", "vector", argv[i], lister);
+ }
+
exit(0);
}
More information about the grass-commit
mailing list