Hi,

2008/4/4, Markus Neteler OSGeo <[EMAIL PROTECTED]>:
>  >       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
Glynn:
>  > 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.
>
>  This should be added before removing the Tcl version.
>  I tried but got lost in the tokenizer.

try the attached patch (for review), Martin

-- 
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *
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        = "delmapset" ;
+    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");
@@ -129,6 +136,36 @@
     }
 
 
+    /* remove from existing search path */
+    if (opt3->answer)
+    {
+	char *oldname;
+
+	Path[0] = '\0';
+	
+	tokens = G_tokenize (opt3->answer, ",");
+	/* read existing mapsets from SEARCH_PATH */
+        for (n = 0; (oldname = G__mapset_name(n)) ; n++)
+	{
+	    skip = 0;
+	    for(i = 0; i < G_number_of_tokens(tokens); i++) {
+		if (strcmp(oldname, tokens[i]) == 0) {
+		    G_verbose_message(_("Mapset <%s> removed from search path"),
+				      oldname);
+		    skip = 1;
+		    break;
+		}
+	    }
+	    
+	    if (!skip) {
+		nchoices++;
+		strcat (Path, oldname);
+		strcat (Path, " "); 
+	    }
+	}
+	G_free_tokens(tokens);
+    }
+
     /* stuffem sets nchoices*/
 
     if (nchoices == 0)
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to