[GRASS-SVN] r60572 - grass/trunk/general/g.mlist

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 28 20:38:49 PDT 2014


Author: hcho
Date: 2014-05-28 20:38:49 -0700 (Wed, 28 May 2014)
New Revision: 60572

Modified:
   grass/trunk/general/g.mlist/main.c
Log:
g.mlist: Allow comma-separated map names for wildcard patterns

Modified: grass/trunk/general/g.mlist/main.c
===================================================================
--- grass/trunk/general/g.mlist/main.c	2014-05-29 03:19:56 UTC (rev 60571)
+++ grass/trunk/general/g.mlist/main.c	2014-05-29 03:38:49 UTC (rev 60572)
@@ -157,8 +157,19 @@
 	if (flag.regex->answer || flag.extended->answer)
 	    filter = G_ls_regex_filter(opt.pattern->answer, 0,
 			    	       (int)flag.extended->answer);
-	else
-	    filter = G_ls_glob_filter(opt.pattern->answer, 0);
+	else {
+	    /* handle individual map names */
+	    if (strchr(opt.pattern->answer, ',')) {
+		char *pattern;
+
+		pattern = (char *)G_malloc(strlen(opt.pattern->answer) + 3);
+		sprintf(pattern, "{%s}", opt.pattern->answer);
+
+		filter = G_ls_glob_filter(pattern, 0);
+	    }
+	    else
+		filter = G_ls_glob_filter(opt.pattern->answer, 0);
+	}
 	if (!filter)
 	    G_fatal_error(_("Unable to compile pattern <%s>"),
 			  opt.pattern->answer);
@@ -170,8 +181,19 @@
 	if (flag.regex->answer || flag.extended->answer)
 	    exclude = G_ls_regex_filter(opt.exclude->answer, 1,
 			    		(int)flag.extended->answer);
-	else
-	    exclude = G_ls_glob_filter(opt.exclude->answer, 1);
+	else {
+	    /* handle individual map names */
+	    if (strchr(opt.exclude->answer, ',')) {
+		char *pattern;
+
+		pattern = (char *)G_malloc(strlen(opt.exclude->answer) + 3);
+		sprintf(pattern, "{%s}", opt.exclude->answer);
+
+		exclude = G_ls_glob_filter(pattern, 1);
+	    }
+	    else
+		exclude = G_ls_glob_filter(opt.exclude->answer, 1);
+	}
 	if (!exclude)
 	    G_fatal_error(_("Unable to compile pattern <%s>"),
 			  opt.exclude->answer);



More information about the grass-commit mailing list