Explorar el Código

attempt to fix trac https://trac.osgeo.org/grass/ticket/379

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35449 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa hace 16 años
padre
commit
94a732aa89
Se han modificado 3 ficheros con 24 adiciones y 4 borrados
  1. 4 0
      general/g.mapsets/main.c
  2. 1 0
      include/gisdefs.h
  3. 19 4
      lib/gis/mapset_nme.c

+ 4 - 0
general/g.mapsets/main.c

@@ -150,6 +150,10 @@ int main(int argc, char *argv[])
 	    char *mapset;
 
 	    mapset = *ptr;
+
+	    if (G_is_mapset_in_search_path(mapset))
+		continue;
+	    
 	    if (G__mapset_permissions(mapset) < 0)
 		G_fatal_error(_("Mapset <%s> not found"), mapset);
 	    else

+ 1 - 0
include/gisdefs.h

@@ -759,6 +759,7 @@ void G__switch_search_path(void);
 void G_reset_mapsets(void);
 char **G_available_mapsets(void);
 void G_add_mapset_to_search_path(const char *);
+int G_is_mapset_in_search_path(const char *);
 
 /* mask_info.c */
 char *G_mask_info(void);

+ 19 - 4
lib/gis/mapset_nme.c

@@ -187,11 +187,26 @@ char **G_available_mapsets(void)
  */
 void G_add_mapset_to_search_path(const char *mapset)
 {
-    int i;
+    if (!G_is_mapset_in_search_path(mapset))
+	new_mapset(mapset);
+}
+
+/*!
+  \brief Check if given mapset is in search path
 
-    for (i = 0; i < st->path.count; i++)
+  \param mapset mapset name
+
+  \return 1 mapset found in search path
+  \return 0 mapset not found
+*/
+int G_is_mapset_in_search_path(const char *mapset)
+{
+    int i;
+    
+    for (i = 0; i < st->path.count; i++) {
 	if (strcmp(st->path.names[i], mapset) == 0)
-	    return;
+	    return 1;
+    }
 
-    new_mapset(mapset);
+    return 0;
 }