[GRASS-SVN] r36444 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 21 05:13:16 EDT 2009


Author: mmetz
Date: 2009-03-21 05:13:16 -0400 (Sat, 21 Mar 2009)
New Revision: 36444

Modified:
   grass/trunk/lib/vector/Vlib/map.c
Log:
safer name handling for Vect_copy and Vect_delete

Modified: grass/trunk/lib/vector/Vlib/map.c
===================================================================
--- grass/trunk/lib/vector/Vlib/map.c	2009-03-21 06:50:54 UTC (rev 36443)
+++ grass/trunk/lib/vector/Vlib/map.c	2009-03-21 09:13:16 UTC (rev 36444)
@@ -165,7 +165,8 @@
 	GV_TOPO_ELEMENT, GV_SIDX_ELEMENT, GV_CIDX_ELEMENT,
 	NULL
     };
-    const char *xmapset;
+    const char *inmapset;
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
     dbDriver *driver;
 
@@ -174,14 +175,18 @@
     if (Vect_legal_filename(out) < 0)
 	G_fatal_error(_("Vector map name is not SQL compliant"));
 
-    /* remove mapset from fully qualified name with G_find_vector(), confuses G__file_name() */
-    xmapset = G_find_vector(in, mapset);
-    if (!xmapset) {
+    inmapset = G_find_vector2(in, mapset);
+    if (!inmapset) {
 	G_warning(_("Unable to find vector map <%s> in <%s>"), in, mapset);
 	return -1;
     }
-    mapset = xmapset;
+    mapset = inmapset;
 
+    /* remove mapset from fully qualified name, confuses G__file_name() */
+    if (G__name_is_fully_qualified(in, xname, xmapset)) {
+	in = xname;
+    }
+
     /* Delete old vector if it exists */
     if (G_find_vector2(out, G_mapset())) {
 	G_warning(_("Vector map <%s> already exists and will be overwritten"),
@@ -305,6 +310,7 @@
     struct field_info *Fin, *Fout;
     int *fields;
     dbDriver *driver;
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
     G_debug(2, "Rename vector '%s' to '%s'", in, out);
     /* check for [A-Za-z][A-Za-z0-9_]* in name */
@@ -318,6 +324,11 @@
 	Vect_delete(out);
     }
 
+    /* remove mapset from fully qualified name */
+    if (G__name_is_fully_qualified(in, xname, xmapset)) {
+	in = xname;
+    }
+
     /* Move the directory */
     ret = G_rename(GRASS_VECT_DIRECTORY, in, out);
 
@@ -435,9 +446,15 @@
     DIR *dir;
     struct dirent *ent;
     const char *tmp;
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
     G_debug(3, "Delete vector '%s'", map);
 
+    /* remove mapset from fully qualified name */
+    if (G__name_is_fully_qualified(map, xname, xmapset)) {
+	map = xname;
+    }
+
     if (map == NULL || strlen(map) == 0) {
 	G_warning(_("Invalid vector map name <%s>"), map ? map : "null");
 	return -1;



More information about the grass-commit mailing list