[GRASS-SVN] r45681 - grass/trunk/lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 16 15:09:47 EDT 2011


Author: glynn
Date: 2011-03-16 12:09:47 -0700 (Wed, 16 Mar 2011)
New Revision: 45681

Modified:
   grass/trunk/lib/raster/reclass.c
Log:
Fix bugs in reclassed_to handling


Modified: grass/trunk/lib/raster/reclass.c
===================================================================
--- grass/trunk/lib/raster/reclass.c	2011-03-16 14:28:48 UTC (rev 45680)
+++ grass/trunk/lib/raster/reclass.c	2011-03-16 19:09:47 UTC (rev 45681)
@@ -122,6 +122,8 @@
 	(*rmaps)[i - 1] = NULL;
     }
 
+    fclose(fd);
+
     return i;
 }
 
@@ -261,8 +263,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:
@@ -334,18 +337,22 @@
 
     G_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