[GRASS-SVN] r48460 - in grass/branches/develbranch_6/raster: r.random r.reclass r.recode

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 25 07:50:34 EDT 2011


Author: hamish
Date: 2011-09-25 04:50:34 -0700 (Sun, 25 Sep 2011)
New Revision: 48460

Modified:
   grass/branches/develbranch_6/raster/r.random/support.c
   grass/branches/develbranch_6/raster/r.reclass/reclass.c
   grass/branches/develbranch_6/raster/r.recode/main.c
   grass/branches/develbranch_6/raster/r.recode/recode.c
Log:
don't segfault on long map names (#800),
+ G_command_history(),
fix r.recode's title= option


Modified: grass/branches/develbranch_6/raster/r.random/support.c
===================================================================
--- grass/branches/develbranch_6/raster/r.random/support.c	2011-09-25 10:01:48 UTC (rev 48459)
+++ grass/branches/develbranch_6/raster/r.random/support.c	2011-09-25 11:50:34 UTC (rev 48460)
@@ -39,15 +39,17 @@
     /* write history for output raster */
     if (G_read_history(theState->outraster, G_mapset(), &hist) >= 0) {
 	G_short_history(theState->outraster, "raster", &hist);
-	sprintf(hist.datsrc_1, "Based on map <%s@%s>", inraster, mapset);
+	G_snprintf(hist.datsrc_1, RECORD_LEN, "Based on map <%s@%s>", inraster, mapset);
 	if (percent)
-	    sprintf(hist.datsrc_2,
+	    G_snprintf(hist.datsrc_2, RECORD_LEN,
 		    "Random points over %.2f percent of the base map <%s>",
 		    percentage, inraster);
 	else
-	    sprintf(hist.datsrc_2,
+	    G_snprintf(hist.datsrc_2, RECORD_LEN,
 		    "%ld random points on the base map <%s@%s>",
 		    theState->nRand, theState->inraster, theState->mapset);
+
+	G_command_history(&hist);
 	G_write_history(theState->outraster, &hist);
 
     }

Modified: grass/branches/develbranch_6/raster/r.reclass/reclass.c
===================================================================
--- grass/branches/develbranch_6/raster/r.reclass/reclass.c	2011-09-25 10:01:48 UTC (rev 48459)
+++ grass/branches/develbranch_6/raster/r.reclass/reclass.c	2011-09-25 11:50:34 UTC (rev 48460)
@@ -229,7 +229,7 @@
 	G_fatal_error(_("Cannot create reclass file of <%s>"), new_name);
 
     if (title == NULL)
-	sprintf(title = buf, "Reclass of %s in %s", new.name, new.mapset);
+	G_snprintf(title = buf, sizeof(buf), "Reclass of %s in %s", new.name, new.mapset);
 
     if ((fd = G_fopen_new("cell", new_name)) == NULL)
 	G_fatal_error(_("Cannot create raster map <%s>"), new_name);
@@ -245,7 +245,9 @@
 
     G_short_history(new_name, "reclass", &hist);
     strcpy(hist.datsrc_1, "Reclassified map based on:");
-    sprintf(hist.datsrc_2, "  Map [%s] in mapset [%s]", new.name, new.mapset);
+    G_snprintf(hist.datsrc_2, RECORD_LEN, "  Map [%s] in mapset [%s]", new.name, new.mapset);
+
+    G_command_history(&hist);
     G_write_history(new_name, &hist);
 
     new_range(new_name, &new);

Modified: grass/branches/develbranch_6/raster/r.recode/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.recode/main.c	2011-09-25 10:01:48 UTC (rev 48459)
+++ grass/branches/develbranch_6/raster/r.recode/main.c	2011-09-25 11:50:34 UTC (rev 48460)
@@ -107,8 +107,11 @@
 
     do_recode();
 
+    if(title)
+	G_put_cell_title(result, title);
+
     G_done_msg(_("Raster map <%s> created."),
 	       result);
-    
+
     exit(EXIT_SUCCESS);
 }

Modified: grass/branches/develbranch_6/raster/r.recode/recode.c
===================================================================
--- grass/branches/develbranch_6/raster/r.recode/recode.c	2011-09-25 10:01:48 UTC (rev 48459)
+++ grass/branches/develbranch_6/raster/r.recode/recode.c	2011-09-25 11:50:34 UTC (rev 48460)
@@ -75,6 +75,8 @@
     else
 	hist.edlinecnt = nrules + 1;
     sprintf(hist.datsrc_1, "raster map %s", name);
+
+    G_command_history(&hist);
     G_write_history(result, &hist);
 
     return 0;



More information about the grass-commit mailing list