[GRASS-SVN] r48464 -
grass/branches/develbranch_6/raster/simwe/simlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 26 01:36:00 EDT 2011
Author: hamish
Date: 2011-09-25 22:36:00 -0700 (Sun, 25 Sep 2011)
New Revision: 48464
Modified:
grass/branches/develbranch_6/raster/simwe/simlib/output.c
Log:
don't segfault on long map names (#800);
i18n/std'ize error messages;
+ G_command_history()
Modified: grass/branches/develbranch_6/raster/simwe/simlib/output.c
===================================================================
--- grass/branches/develbranch_6/raster/simwe/simlib/output.c 2011-09-25 12:38:14 UTC (rev 48463)
+++ grass/branches/develbranch_6/raster/simwe/simlib/output.c 2011-09-26 05:36:00 UTC (rev 48464)
@@ -7,6 +7,7 @@
/* #include <grass/site.h> */
#include <grass/bitmap.h>
#include <grass/linkm.h>
+#include <grass/glocale.h>
#include <grass/waterglobs.h>
@@ -28,7 +29,7 @@
char *erdep0 = NULL;
char *mapst = NULL;
char *type;
- char buf[256];
+ char buf[GNAME_MAX + 10];
int ndigit;
FCELL dat1, dat2;
float a1, a2;
@@ -38,6 +39,8 @@
ndigit = 2;
+ /* more compact but harder to read:
+ ndigit = (int)floor(log10(timesec)) + 2 */
if (timesec >= 10)
ndigit = 3;
if (timesec >= 100)
@@ -98,7 +101,7 @@
else
fd6 = G_open_fp_cell_new(depth);
if (fd6 < 0)
- G_fatal_error("unable to create raster map %s", depth);
+ G_fatal_error(_("Cannot create raster map <%s>"), depth);
}
if (disch != NULL) {
@@ -111,7 +114,7 @@
else
fd7 = G_open_fp_cell_new(disch);
if (fd7 < 0)
- G_fatal_error("unable to create raster map %s", disch);
+ G_fatal_error(_("Cannot create raster map <%s>"), disch);
}
if (err != NULL) {
@@ -125,7 +128,7 @@
fd8 = G_open_fp_cell_new(err);
if (fd8 < 0)
- G_fatal_error("unable to create raster map %s", err);
+ G_fatal_error(_("Cannot create raster map <%s>"), err);
}
@@ -140,7 +143,7 @@
fd14 = G_open_fp_cell_new(conc);
if (fd14 < 0)
- G_fatal_error("unable to create raster map %s", conc);
+ G_fatal_error(_("Cannot create raster map <%s>"), conc);
}
if (flux != NULL) {
@@ -154,7 +157,7 @@
fd15 = G_open_fp_cell_new(flux);
if (fd15 < 0)
- G_fatal_error("unable to create raster map %s", flux);
+ G_fatal_error(_("Cannot create raster map <%s>"), flux);
}
if (erdep != NULL) {
@@ -168,7 +171,7 @@
fd16 = G_open_fp_cell_new(erdep);
if (fd16 < 0)
- G_fatal_error("unable to create raster map %s", erdep);
+ G_fatal_error(_("Cannot create raster map <%s>"), erdep);
}
@@ -307,7 +310,7 @@
if (ts == 1) {
if ((mapst = G_find_file("fcell", depth0, "")) == NULL)
- G_fatal_error("cannot find file %s", depth0);
+ G_fatal_error(_("FP raster map <%s> not found"), depth0);
G_write_colors(depth0, mapst, &colors);
G_quantize_fp_map_range(depth0, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
@@ -315,7 +318,7 @@
}
else {
if ((mapst = G_find_file("fcell", depth, "")) == NULL)
- G_fatal_error("cannot find file %s", depth);
+ G_fatal_error(_("FP raster map <%s> not found"), depth);
G_write_colors(depth, mapst, &colors);
G_quantize_fp_map_range(depth, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
@@ -350,7 +353,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", disch0, "")) == NULL)
- G_fatal_error("cannot find file %s", disch0);
+ G_fatal_error(_("Raster map <%s> not found"), disch0);
G_write_colors(disch0, mapst, &colors);
G_quantize_fp_map_range(disch0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -359,7 +362,7 @@
else {
if ((mapst = G_find_file("cell", disch, "")) == NULL)
- G_fatal_error("cannot find file %s", disch);
+ G_fatal_error(_("Raster map <%s> not found"), disch);
G_write_colors(disch, mapst, &colors);
G_quantize_fp_map_range(disch, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -390,7 +393,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", flux0, "")) == NULL)
- G_fatal_error("cannot find file %s", flux0);
+ G_fatal_error(_("Raster map <%s> not found"), flux0);
G_write_colors(flux0, mapst, &colors);
G_quantize_fp_map_range(flux0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -399,7 +402,7 @@
else {
if ((mapst = G_find_file("cell", flux, "")) == NULL)
- G_fatal_error("cannot find file %s", flux);
+ G_fatal_error(_("Raster map <%s> not found"), flux);
G_write_colors(flux, mapst, &colors);
G_quantize_fp_map_range(flux, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -446,7 +449,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", erdep0, "")) == NULL)
- G_fatal_error("cannot find file %s", erdep0);
+ G_fatal_error(_("Raster map <%s> not found"), erdep0);
G_write_colors(erdep0, mapst, &colors);
G_quantize_fp_map_range(erdep0, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
@@ -455,14 +458,16 @@
type = "raster";
G_short_history(erdep0, type, &hist1);
- sprintf(hist1.edhist[0], "The sediment flux file is %s", flux0);
+ G_snprintf(hist1.edhist[0], RECORD_LEN,
+ "The sediment flux file is %s", flux0);
hist1.edlinecnt = 1;
+ G_command_history(&hist1);
G_write_history(erdep0, &hist1);
}
else {
if ((mapst = G_find_file("cell", erdep, "")) == NULL)
- G_fatal_error("cannot find file %s", erdep);
+ G_fatal_error(_("Raster map <%s> not found"), erdep);
G_write_colors(erdep, mapst, &colors);
G_quantize_fp_map_range(erdep, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
@@ -471,8 +476,10 @@
type = "raster";
G_short_history(erdep, type, &hist1);
- sprintf(hist1.edhist[0], "The sediment flux file is %s", flux);
+ G_snprintf(hist1.edhist[0], RECORD_LEN,
+ "The sediment flux file is %s", flux);
hist1.edlinecnt = 1;
+ G_command_history(&hist1);
G_write_history(erdep, &hist1);
}
}
@@ -484,7 +491,7 @@
if (ts == 0) {
mapst = G_find_file("cell", depth, "");
if (mapst == NULL) {
- G_warning("File [%s] not found", depth);
+ G_warning(_("Raster map <%s> not found"), depth);
return -1;
}
G_short_history(depth, type, &hist);
@@ -507,8 +514,10 @@
sprintf(hist.edhist[3], "mean source (si)=%e, mean infil=%e", si0,
infmean);
- sprintf(hist.datsrc_1, "input files: %s %s %s", elevin, dxin, dyin);
- sprintf(hist.datsrc_2, "input files: %s %s %s", rain, infil, manin);
+ G_snprintf(hist.datsrc_1, RECORD_LEN,
+ "input files: %s %s %s", elevin, dxin, dyin);
+ G_snprintf(hist.datsrc_2, RECORD_LEN,
+ "input files: %s %s %s", rain, infil, manin);
hist.edlinecnt = 4;
G_command_history(&hist);
@@ -524,7 +533,7 @@
if (ts == 0) {
mapst = G_find_file("cell", disch, "");
if (mapst == NULL)
- G_fatal_error("file [%s] not found\n", disch);
+ G_fatal_error(_("Raster map <%s> not found"), disch);
G_short_history(disch, type, &hist);
}
else
@@ -562,7 +571,7 @@
if (ts == 0) {
mapst = G_find_file("cell", flux, "");
if (mapst == NULL)
- G_fatal_error("file [%s] not found\n", flux);
+ G_fatal_error(_("Raster map <%s> not found"), flux);
G_short_history(flux, type, &hist);
}
else
@@ -611,7 +620,7 @@
struct Colors colors;
const char *mapst = NULL;
- /* char buf[256]; */
+ /* char buf[GNAME_MAX + 10]; */
FCELL dat1, dat2;
/* float a1,a2; */
@@ -620,30 +629,30 @@
if (et != NULL) {
cell17 = G_allocate_f_raster_buf();
- /* if (ts == 1) {
- sprintf(buf,"%s.%.*d",et,ndigit,tt);
+ /* if (ts == 1) {
+ sprintf(buf, "%s.%.*d", et, ndigit, tt);
et0 = G_store(buf);
- fd17 = G_open_fp_cell_new (et0);
+ fd17 = G_open_fp_cell_new(et0);
}
else */
fd17 = G_open_fp_cell_new(et);
if (fd17 < 0)
- G_fatal_error("unable to create raster map %s", et);
+ G_fatal_error(_("Cannot create raster map <%s>"), et);
}
if (tc != NULL) {
cell13 = G_allocate_f_raster_buf();
/* if (ts == 1) {
- sprintf(buf,"%s.%.*d",tc,ndigit,tt);
+ sprintf(buf, "%s.%.*d", tc, ndigit, tt);
tc0 = G_store(buf);
- fd13 = G_open_fp_cell_new (tc0);
+ fd13 = G_open_fp_cell_new(tc0);
}
else */
fd13 = G_open_fp_cell_new(tc);
if (fd13 < 0)
- G_fatal_error("unable to create raster map %s", tc);
+ G_fatal_error(_("Cannot create raster map <%s>"), tc);
}
@@ -735,7 +744,7 @@
/* if (ts == 1) {
if ((mapst = G_find_file("cell", et0, "")) == NULL)
- G_fatal_error ("cannot find file %s", et0);
+ G_fatal_error (_("Raster map <%s> not found"), et0);
G_write_colors(et0, mapst, &colors);
G_quantize_fp_map_range(et0,mapst,(FCELL)etmin,(FCELL)etmax,(CELL)etmin,(CELL)etmax);
G_free_colors(&colors);
@@ -743,7 +752,7 @@
else { */
if ((mapst = G_find_file("cell", et, "")) == NULL)
- G_fatal_error("cannot find file %s", et);
+ G_fatal_error(_("Raster map <%s> not found"), et);
G_write_colors(et, mapst, &colors);
G_quantize_fp_map_range(et, mapst, (FCELL) etmin, (FCELL) etmax,
(CELL) etmin, (CELL) etmax);
More information about the grass-commit
mailing list