[GRASS-dev] g.mapsets revision 30712

Glynn Clements glynn at gclements.plus.com
Fri Apr 4 19:06:32 EDT 2008


Markus Neteler OSGeo wrote:

> > 	r30712 | martinl | 2008-03-24 11:19:11 +0000 (Mon, 24 Mar 2008) | 2 lines
> > 	g.mapsets: (cosmetics) message cleaning, some minor changes in manual,
> > tcl/tk-related code removed
> > 
> > Presumably g.mapsets.tcl should be removed, now that it is no longer
> > used.
> 
> The CMD line version of g.mapsets is lacking a parameter to
> remove (multiple) mapsets from the search path.

Can you test the attached patch?

> This should be added before removing the Tcl version.
> I tried but got lost in the tokenizer.

The point is that r30712 removed the code which runs the Tcl front-end
when g.mapsets is invoked without arguments. There isn't much point in
having the Tcl code when it will never be run.

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
Index: general/g.mapsets/main_cmd.c
===================================================================
--- general/g.mapsets/main_cmd.c	(revision 30860)
+++ general/g.mapsets/main_cmd.c	(working copy)
@@ -38,8 +38,8 @@
     char **tokens;
     int no_tokens;
     FILE *fp;
-	struct GModule *module;
-    struct Option *opt1, *opt2;
+    struct GModule *module;
+    struct Option *opt1, *opt2, *opt3;
     struct Flag *print;
     struct Flag *list;
 
@@ -66,6 +66,13 @@
     opt2->multiple   = YES ;
     opt2->description= _("Name(s) of existing mapset(s) to add to search list");
 
+    opt3 = G_define_option() ;
+    opt3->key        = "removemapset" ;
+    opt3->type       = TYPE_STRING ;
+    opt3->required   = NO ;
+    opt3->multiple   = YES ;
+    opt3->description= _("Name(s) of existing mapset(s) to remove from search list");
+
     list = G_define_flag();
     list->key = 'l';
     list->description = _("List all available mapsets");
@@ -128,7 +135,29 @@
 	}
     }
 
+    /* remove from existing search path */
+    if (opt3->answer)
+    {
+	char *oldname;
+	Path[0] = '\0';
+	
+	/* read existing mapsets from SEARCH_PATH */
+        for (n = 0; (oldname = G__mapset_name(n)) ; n++)
+	{
+	    int found = 0;
 
+	    for (ptr = opt3->answers; *ptr; ptr++)
+		if (strcmp(oldname, *ptr) == 0)
+		    found = 1;
+
+	    if (found)
+		continue;
+
+	    strcat (Path, oldname);
+	    strcat (Path, " "); 
+	}
+    }
+
     /* stuffem sets nchoices*/
 
     if (nchoices == 0)


More information about the grass-dev mailing list