There's no need to use sprintf () along with G_warning (), since
        the latter is already capable of the printf ()-style formatting.

        Also, the following are /not/ equivalent fragments of code:

   G_warning (FMT, <arguments...>);

   sprintf (s, FMT, <arguments...>);
   G_warning (s);

        Instead, the former is equivalent to the following:

   sprintf (s, FMT, <arguments...>);
   G_warning ("%s", s);

        While the latter behaves differently should any percent signs
        (`%') be put into `s' as a result of sprintf ().

        Hopefully, the following patch will resolve the issue.

        A few notes regarding i18n:

        * the typos and misspellings are to be fixed with a separate
          patch; that one should probably update locale/ as well;

        * I've introduced a few more _() invocations, as I deemed
          appropriate;

        * the code like the following could bring all the sorts of woe
          upon the heads of unsuspecting translators (this issue may
          deserve a mention on Trac.)

--cut--
            sprintf(buf,
                    _("Unable to read header file for raster map <%...@%s>."),
                    name, mapset);
            tail = buf + strlen(buf);
            sprintf(tail, _(" It is a reclass of raster map <%...@%s> "),
                    real_name, real_mapset);
            tail = buf + strlen(buf);
            if (!G_find_cell(real_name, real_mapset))
                sprintf(tail, _("which is missing."));
            else
                sprintf(tail, _("whose header file can't be opened."));
            G_warning ("%s", buf);
            return -1;
--cut--

Index: lib/gis/put_cellhd.c
===================================================================
--- lib/gis/put_cellhd.c        (revision 36445)
+++ lib/gis/put_cellhd.c        (working copy)
@@ -23,8 +23,7 @@
     if (!(fd = G_fopen_new("cellhd", name))) {
        char buf[1024];
 
-       sprintf(buf, _("Unable to create header file for [%s]"), name);
-       G_warning(buf);
+       G_warning (_("Unable to create header file for [%s]"), name);
        return -1;
     }
 
Index: lib/gis/put_title.c
===================================================================
--- lib/gis/put_title.c (revision 36445)
+++ lib/gis/put_title.c (working copy)
@@ -25,10 +25,9 @@
     in = out = 0;
     in = G_fopen_old("cats", name, mapset);
     if (!in) {
-       sprintf(buf,
-               _("category information for [%s] in [%s] missing or invalid"),
-               name, mapset);
-       G_warning(buf);
+       G_warning (_("category information for [%s] in [%s]"
+                    " missing or invalid"),
+                  name, mapset);
        return -1;
     }
 
@@ -36,8 +35,7 @@
     out = fopen(tempfile, "w");
     if (!out) {
        fclose(in);
-       sprintf(buf, _("G_put_title - can't create a temp file"));
-       G_warning(buf);
+       G_warning (_("G_put_title - can't create a temp file"));
        return -1;
     }
 
@@ -53,25 +51,22 @@
 
     /* must be #cats line, title line, and label for cat 0 */
     if (line < 3) {
-       sprintf(buf, _("category information for [%s] in [%s] invalid"), name,
-               mapset);
-       G_warning(buf);
+       G_warning (_("category information for [%s] in [%s] invalid"),
+                  name, mapset);
        return -1;
     }
 
     in = fopen(tempfile, "r");
     if (!in) {
-       sprintf(buf, _("G_put_title - can't reopen temp file"));
-       G_warning(buf);
+       G_warning (_("G_put_title - can't reopen temp file"));
        return -1;
     }
 
     out = G_fopen_new("cats", name);
     if (!out) {
        fclose(in);
-       sprintf(buf, _("can't write category information for [%s] in [%s]"),
-               name, mapset);
-       G_warning(buf);
+       G_warning (_("can't write category information for [%s] in [%s]"),
+                  name, mapset);
        return -1;
     }
 
Index: lib/gis/quant_io.c
===================================================================
--- lib/gis/quant_io.c  (revision 36445)
+++ lib/gis/quant_io.c  (working copy)
@@ -86,9 +86,8 @@
        return 0;
     G_get_fp_range_min_max(&fprange, &dMin, &dMax);
     if (G_is_d_null_value(&dMin) || G_is_d_null_value(&dMax)) {
-       sprintf(buf, _("The floating data range for %...@%s is empty"), name,
-               mapset);
-       G_warning(buf);
+       G_warning (_("The floating data range for %...@%s is empty"),
+                  name, mapset);
        return -3;
     }
 
@@ -96,9 +95,8 @@
        return 0;
     G_get_range_min_max(&range, &min, &max);
     if (G_is_c_null_value(&min) && G_is_c_null_value(&max)) {
-       sprintf(buf, _("The integer data range for %...@%s is empty"), name,
-               mapset);
-       G_warning(buf);
+       G_warning (_("The integer data range for %...@%s is empty"),
+                  name, mapset);
        return -3;
     }
 
@@ -121,10 +119,9 @@
     G_quant_free(quant);
 
     if (G_raster_map_type(name, mapset) == CELL_TYPE) {
-       sprintf(buf,
-               "G__quant_import: attempt to open quantization table for 
CELL_TYPE file [%s] in mapset {%s]",
-               name, mapset);
-       G_warning(buf);
+       G_warning (_("G__quant_import: attempt to open quantization"
+                    " table for CELL_TYPE file [%s] in mapset {%s]"),
+                  name, mapset);
        return -2;
     }
 
@@ -164,9 +161,8 @@
        err = "empty";
     }
 
-    sprintf(buf,
-           _("quantization file [%s] in mapset [%s] %s"), name, mapset, err);
-    G_warning(buf);
+    G_warning (_("quantization file [%s] in mapset [%s] %s"),
+              name, mapset, err);
 
     return 0;
 }
Index: lib/gis/range.c
===================================================================
--- lib/gis/range.c     (revision 36445)
+++ lib/gis/range.c     (working copy)
@@ -185,8 +185,8 @@
   error:
     if (fd > 0)
        close(fd);
-    sprintf(buf, _("can't read f_range file for [%s in %s]"), name, mapset);
-    G_warning(buf);
+    G_warning (_("can't read f_range file for [%s in %s]"),
+              name, mapset);
     return -1;
 }
 
@@ -236,10 +236,9 @@
        DCELL dmin, dmax;
 
        if (G_read_quant(name, mapset, &quant) < 0) {
-           sprintf(buf,
-                   "G_read_range(): can't read quant rules for fp map %...@%s",
-                   name, mapset);
-           G_warning(buf);
+           G_warning (_("G_read_range(): can't read quant rules"
+                        " for fp map %...@%s"),
+                      name, mapset);
            return -1;
        }
        if (G_quant_is_truncate(&quant) || G_quant_is_round(&quant)) {
@@ -301,8 +300,8 @@
   error:
     if (fd)
        fclose(fd);
-    sprintf(buf, _("can't read range file for [%s in %s]"), name, mapset);
-    G_warning(buf);
+    G_warning (_("can't read range file for [%s in %s]"),
+              name, mapset);
     return -1;
 }
 
Index: lib/gis/get_cellhd.c
===================================================================
--- lib/gis/get_cellhd.c        (revision 36445)
+++ lib/gis/get_cellhd.c        (working copy)
@@ -77,7 +77,7 @@
                sprintf(tail, _("which is missing."));
            else
                sprintf(tail, _("whose header file can't be opened."));
-           G_warning(buf);
+           G_warning ("%s", buf);
            return -1;
        }
     }
Index: lib/gis/quant_rw.c
===================================================================
--- lib/gis/quant_rw.c  (revision 36445)
+++ lib/gis/quant_rw.c  (working copy)
@@ -70,9 +70,9 @@
     G_quant_truncate(&quant);
     /* quantize the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-       sprintf(buf, "G_truncate_fp_map: can't write quant rules for map %s",
-               name);
-       G_warning(buf);
+       G_warning (_("G_truncate_fp_map: can't write quant rules"
+                    " for map %s"),
+                  name);
        return -1;
     }
     return 1;
@@ -87,9 +87,9 @@
     G_quant_round(&quant);
     /* round the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-       sprintf(buf, "G_truncate_fp_map: can't write quant rules for map %s",
-               name);
-       G_warning(buf);
+       G_warning (_("G_truncate_fp_map: can't write quant rules"
+                    " for map %s"),
+                  name);
        return -1;
     }
     return 1;
@@ -118,15 +118,14 @@
     struct FPRange fp_range;
 
     if (G_read_fp_range(name, mapset, &fp_range) < 0) {
-       sprintf(buf, "G_quantize_fp_map: can't read fp range for map %s",
-               name);
-       G_warning(buf);
+       G_warning (_("G_quantize_fp_map: can't read fp range for map %s"),
+                  name);
        return -1;
     }
     G_get_fp_range_min_max(&fp_range, &d_min, &d_max);
     if (G_is_d_null_value(&d_min) || G_is_d_null_value(&d_max)) {
-       sprintf(buf, "G_quantize_fp_map: raster map %s is empty", name);
-       G_warning(buf);
+       G_warning (_("G_quantize_fp_map: raster map %s is empty"),
+                  name);
        return -1;
     }
     return G_quantize_fp_map_range(name, mapset, d_min, d_max, min, max);
@@ -166,10 +165,9 @@
     G_quant_add_rule(&quant, d_min, d_max, min, max);
     /* quantize the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-       sprintf(buf,
-               "G_quantize_fp_map_range: can't write quant rules for map %s",
-               name);
-       G_warning(buf);
+       G_warning (_("G_quantize_fp_map_range: can't write quant rules"
+                    " for map %s"),
+                  name);
        return -1;
     }
     return 1;
@@ -203,8 +201,8 @@
     char buf[300];
 
     if (G_raster_map_type(name, mapset) == CELL_TYPE) {
-       sprintf(buf, _("Cannot write quant rules: map %s is integer"), name);
-       G_warning(buf);
+       G_warning (_("Cannot write quant rules: map %s is integer"),
+                  name);
        return -1;
     }
 
@@ -212,8 +210,7 @@
 
     /* first actually write the rules */
     if (G__quant_export(name, mapset, quant) < 0) {
-       sprintf(buf, _("Cannot write quant rules for map %s"), name);
-       G_warning(buf);
+       G_warning (_("Cannot write quant rules for map %s"), name);
        return -1;
     }
 

-- 
FSF associate member #7257
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to