[GRASS-SVN] r74107 - grass/trunk/imagery/i.group

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 19 01:38:30 PST 2019


Author: marisn
Date: 2019-02-19 01:38:30 -0800 (Tue, 19 Feb 2019)
New Revision: 74107

Modified:
   grass/trunk/imagery/i.group/main.c
Log:
i.group: Fix editing groups with fully qualified name (fixes corner cases missed in r73633)


Modified: grass/trunk/imagery/i.group/main.c
===================================================================
--- grass/trunk/imagery/i.group/main.c	2019-02-19 04:38:14 UTC (rev 74106)
+++ grass/trunk/imagery/i.group/main.c	2019-02-19 09:38:30 UTC (rev 74107)
@@ -39,10 +39,11 @@
 
 int main(int argc, char *argv[])
 {
-    char group[GNAME_MAX];
-    const char *mapset = NULL;
+    char group[GNAME_MAX], mapset[GMAPSET_MAX];
+    char xgroup[GNAME_MAX];
     char **rasters = NULL;
     int m, k = 0;
+    int can_edit;
 
     struct Option *grp, *rast, *rastf, *sgrp;
     struct Flag *r, *l, *s, *simple_flag;
@@ -150,10 +151,10 @@
 
     /* Get groups mapset. Remove @mapset if group contains
      */
-    strcpy(group, grp->answer);
-    mapset = G_find_file("group", group, mapset);
+    strcpy(xgroup, grp->answer);
+    can_edit = G_unqualified_name(xgroup, G_mapset(), group, mapset) != -1;
     
-    if (r->answer) {
+    if (r->answer && can_edit) {
 	/* Remove files from Group */
 
 	if (I_find_group(group) == 0) {
@@ -209,6 +210,10 @@
 	    }
 	}
 	else {
+        if (!can_edit) {
+            /* GTC Group refers to an image group */
+            G_fatal_error(_("Only groups from the current mapset can be edited"));
+        }
 	    /* Create or update Group REF */
 	    if (I_find_group(group) == 0)
 		G_verbose_message(_



More information about the grass-commit mailing list