[GRASS-SVN] r32389 - in grass/trunk: lib/vector/Vlib vector/v.random

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 30 15:03:40 EDT 2008


Author: glynn
Date: 2008-07-30 15:03:39 -0400 (Wed, 30 Jul 2008)
New Revision: 32389

Modified:
   grass/trunk/lib/vector/Vlib/open.c
   grass/trunk/vector/v.random/main.c
Log:
Allow fully qualified names in Vect_open_new()
Don't call G_legal_filename() on qualified names


Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c	2008-07-30 15:30:15 UTC (rev 32388)
+++ grass/trunk/lib/vector/Vlib/open.c	2008-07-30 19:03:39 UTC (rev 32389)
@@ -481,6 +481,7 @@
 {
     int  ret, ferror;
     char errmsg[2000], buf[200];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
     G_debug ( 2, "Vect_open_new(): name = %s", name);
     
@@ -488,6 +489,16 @@
     ferror = Vect_get_fatal_error ();
     Vect_set_fatal_error (GV_FATAL_EXIT);
 
+    if (G__name_is_fully_qualified(name, xname, xmapset))
+    {
+	if (strcmp(xmapset, G_mapset()) != 0)
+	{
+	    sprintf ( errmsg, _("%s is not in the current mapset (%s)"), name, G_mapset());
+	    fatal_error (ferror , errmsg );
+	}
+	name = xname;
+    }
+
     /* check for [A-Za-z][A-Za-z0-9_]* in name */
     if (Vect_legal_filename(name) < 0 ) {
        sprintf ( errmsg, _("Vector map name is not SQL compliant") );

Modified: grass/trunk/vector/v.random/main.c
===================================================================
--- grass/trunk/vector/v.random/main.c	2008-07-30 15:30:15 UTC (rev 32388)
+++ grass/trunk/vector/v.random/main.c	2008-07-30 19:03:39 UTC (rev 32389)
@@ -119,11 +119,6 @@
     n = atoi(parm.nsites->answer);
     b = (flag.drand48->answer == '\0') ? 0 : 1;
 
-    if (G_legal_filename(output) == -1) {
-	G_fatal_error(_("<%s> is an illegal file name"),
-		      output);
-    }
-
     if (n <= 0) {
 	G_fatal_error(_("Number of points must be > 0 (%d given)"),
 		      n);



More information about the grass-commit mailing list