On Tue, May 3, 2011 at 9:13 PM, Glynn Clements <[email protected]> wrote:
>
> Markus Neteler wrote:
>
>> > Realistically, I think that the current mapset must always be at the
>> > head of the search path. Allowing it to be otherwise will be
>> > error-prone.
>> >
>> > Otherwise, we have to fix existing scripts to explicitly add the
>> > current mapset to any temporary map names. It's much simpler to change
>> > the library to match existing practice.
>>
>> Definitely - I'd vote for a library update.
>
> Try r46173.

Thanks.
Attached the backport to GRASS 6 for a review.

Markus
Index: lib/gis/mapset_nme.c
===================================================================
--- lib/gis/mapset_nme.c	(revision 46173)
+++ lib/gis/mapset_nme.c	(working copy)
@@ -54,29 +54,30 @@
 {
     char name[GNAME_MAX];
     FILE *fd;
+    const char *cur;
 
     /*
      * the list of mapsets is in SEARCH_PATH file in the mapset
      */
     mapset_name = NULL;
+    cur = G_mapset();
     if ((fd = G_fopen_old("", "SEARCH_PATH", G_mapset()))) {
-	while (fscanf(fd, "%s", name) == 1)
+	while (fscanf(fd, "%s", name) == 1) {
+            if (strcmp(name, cur) == 0)
+                continue;
 	    if (G__mapset_permissions(name) >= 0)
 		new_mapset(name);
+        }
 	fclose(fd);
     }
     /*
      * if no list, then set the list to the current mapset followed
      * by PERMANENT
      */
-    if (!nmapset) {
+    else {
 	char *perm;
-	char *cur;
 
-	cur = G_mapset();
 	perm = "PERMANENT";
-
-	new_mapset(cur);
 	if (strcmp(perm, cur) != 0 && G__mapset_permissions(perm) >= 0)
 	    new_mapset(perm);
     }
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to