[GRASS-SVN] r45698 - grass/branches/releasebranch_6_4/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 18 04:17:58 EDT 2011


Author: neteler
Date: 2011-03-18 01:17:58 -0700 (Fri, 18 Mar 2011)
New Revision: 45698

Modified:
   grass/branches/releasebranch_6_4/lib/gis/reclass.c
Log:
glynn: Fix bugs in reclassed_to handling (backport from trunk, r45681)

Modified: grass/branches/releasebranch_6_4/lib/gis/reclass.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/gis/reclass.c	2011-03-18 02:02:03 UTC (rev 45697)
+++ grass/branches/releasebranch_6_4/lib/gis/reclass.c	2011-03-18 08:17:58 UTC (rev 45698)
@@ -109,6 +109,8 @@
 	(*rmaps)[i - 1] = NULL;
     }
 
+    fclose(fd);
+
     return i;
 }
 
@@ -226,8 +228,9 @@
 {
     FILE *fd;
     long min, max;
-    int i;
-    char buf1[GPATH_MAX], buf2[GNAME_MAX], buf3[GNAME_MAX], *p;
+    int found;
+    char buf1[GPATH_MAX], buf2[GNAME_MAX], *p;
+    char *xname;
 
     switch (reclass->type) {
     case RECLASS_TABLE:
@@ -299,18 +302,22 @@
 
     fseek(fd, 0L, SEEK_SET);
 
-    sprintf(buf2, "%s@%s\n", name, G_mapset());
-    for (i = 0; !feof(fd) && fgets(buf3, 255, fd);) {
-	if (!(strcmp(buf2, buf3))) {
-	    i = 1;
+    xname = G_fully_qualified_name(name, G_mapset());
+    found = 0;
+    for (;;) {
+	char buf[GNAME_MAX + GMAPSET_MAX];
+	if (!G_getl2(buf, sizeof(buf), fd))
 	    break;
+	if (strcmp(xname, buf) == 0) {
+	    found = 1;
+	    break;
 	}
     }
 
-    if (!i) {
-	fprintf(fd, "%s@%s\n", name, G_mapset());
-    }
+    if (!found)
+	fprintf(fd, "%s\n", xname);
 
+    G_free(xname);
     fclose(fd);
 
     return 1;



More information about the grass-commit mailing list