[GRASS-SVN] r40273 - in grass/trunk: display/d.colors imagery/i.pca
include lib/raster lib/rst/interp_float raster/r.carve
raster/r.category raster/r.colors raster/r.grow raster/r.lake
raster/r.param.scale raster/r.random.surface raster/r.reclass
raster/r.region raster/r.resamp.interp raster/r.resamp.stats
raster/r.support raster/r.terraflow raster/r.watershed/front
vector/v.to.rast
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 5 21:06:14 EST 2010
Author: glynn
Date: 2010-01-05 21:06:14 -0500 (Tue, 05 Jan 2010)
New Revision: 40273
Modified:
grass/trunk/display/d.colors/interact.c
grass/trunk/imagery/i.pca/local_proto.h
grass/trunk/imagery/i.pca/support.c
grass/trunk/include/rasterdefs.h
grass/trunk/lib/raster/cats.c
grass/trunk/lib/raster/color_write.c
grass/trunk/lib/raster/histogram.c
grass/trunk/lib/raster/history.c
grass/trunk/lib/raster/put_cellhd.c
grass/trunk/lib/rst/interp_float/resout2d.c
grass/trunk/raster/r.carve/enforce.h
grass/trunk/raster/r.carve/support.c
grass/trunk/raster/r.category/main.c
grass/trunk/raster/r.colors/main.c
grass/trunk/raster/r.grow/main.c
grass/trunk/raster/r.lake/main.c
grass/trunk/raster/r.param.scale/write_cats.c
grass/trunk/raster/r.random.surface/save.c
grass/trunk/raster/r.reclass/reclass.c
grass/trunk/raster/r.region/main.c
grass/trunk/raster/r.resamp.interp/main.c
grass/trunk/raster/r.resamp.stats/main.c
grass/trunk/raster/r.support/main.c
grass/trunk/raster/r.terraflow/main.cc
grass/trunk/raster/r.watershed/front/main.c
grass/trunk/vector/v.to.rast/support.c
Log:
More error handling:
Rast_write[_vector]_cats
Rast_write_colors
Rast_write_histogram[_cs]
Rast_write_history
Rast_put_cellhd
Modified: grass/trunk/display/d.colors/interact.c
===================================================================
--- grass/trunk/display/d.colors/interact.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/display/d.colors/interact.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -318,13 +318,7 @@
Clear_message();
Write_message(2, "Writing color table ");
- if (Rast_write_colors(name, mapset, colors) == -1) {
- G_sleep(1);
- Write_message(2, "Can't write color table ");
- G_sleep(2);
- return 0;
- }
- else
- Clear_message();
+ Rast_write_colors(name, mapset, colors);
+ Clear_message();
return 1;
}
Modified: grass/trunk/imagery/i.pca/local_proto.h
===================================================================
--- grass/trunk/imagery/i.pca/local_proto.h 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/imagery/i.pca/local_proto.h 2010-01-06 02:06:14 UTC (rev 40273)
@@ -2,6 +2,6 @@
#define __LOCAL_PROTO_H__
/* support.c */
-int write_support(int, char *, double **, double *);
+void write_support(int, char *, double **, double *);
#endif
Modified: grass/trunk/imagery/i.pca/support.c
===================================================================
--- grass/trunk/imagery/i.pca/support.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/imagery/i.pca/support.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -2,13 +2,13 @@
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
+#include "local_proto.h"
-
/* function prototypes */
-static int write_history(int, char *, double **, double *);
+static void write_history(int, char *, double **, double *);
-int write_support(int bands, char *outname, double **eigmat, double *eigval)
+void write_support(int bands, char *outname, double **eigmat, double *eigval)
{
const char *mapset = G_mapset();
struct Colors colors;
@@ -24,14 +24,13 @@
if (Rast_map_is_fp(outname, mapset))
Rast_mark_colors_as_fp(&colors);
- if (Rast_write_colors(outname, mapset, &colors) < 0)
- G_message(_("Unable to write color table for raster map <%s>"), outname);
+ Rast_write_colors(outname, mapset, &colors);
- return write_history(bands, outname, eigmat, eigval);
+ write_history(bands, outname, eigmat, eigval);
}
-static int write_history(int bands, char *outname, double **eigmat, double *eigval)
+static void write_history(int bands, char *outname, double **eigmat, double *eigval)
{
int i, j;
static int first_map = TRUE; /* write to stderr? */
@@ -77,5 +76,5 @@
/* only write to stderr the first time (this fn runs for every output map) */
first_map = FALSE;
- return Rast_write_history(outname, &hist);
+ Rast_write_history(outname, &hist);
}
Modified: grass/trunk/include/rasterdefs.h
===================================================================
--- grass/trunk/include/rasterdefs.h 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/include/rasterdefs.h 2010-01-06 02:06:14 UTC (rev 40273)
@@ -48,8 +48,8 @@
int Rast_set_d_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
int Rast_set_cat(const void *, const void *, const char *, struct Categories *,
RASTER_MAP_TYPE);
-int Rast_write_cats(const char *, struct Categories *);
-int Rast_write_vector_cats(const char *, struct Categories *);
+void Rast_write_cats(const char *, struct Categories *);
+void Rast_write_vector_cats(const char *, struct Categories *);
char *Rast_get_ith_d_cat(const struct Categories *, int, DCELL *,
DCELL *);
char *Rast_get_ith_f_cat(const struct Categories *, int, void *, void *);
@@ -232,7 +232,7 @@
void Rast_shift_d_colors(DCELL, struct Colors *);
/* color_write.c */
-int Rast_write_colors(const char *, const char *, struct Colors *);
+void Rast_write_colors(const char *, const char *, struct Colors *);
void Rast__write_colors(FILE *, struct Colors *);
/* color_xform.c */
@@ -318,8 +318,8 @@
/* histogram.c */
void Rast_init_histogram(struct Histogram *);
int Rast_read_histogram(const char *, const char *, struct Histogram *);
-int Rast_write_histogram(const char *, const struct Histogram *);
-int Rast_write_histogram_cs(const char *, struct Cell_stats *);
+void Rast_write_histogram(const char *, const struct Histogram *);
+void Rast_write_histogram_cs(const char *, struct Cell_stats *);
void Rast_make_histogram_cs(struct Cell_stats *, struct Histogram *);
int Rast_get_histogram_num(const struct Histogram *);
CELL Rast_get_histogram_cat(int, const struct Histogram *);
@@ -335,7 +335,7 @@
/* history.c */
int Rast_read_history(const char *, const char *, struct History *);
-int Rast_write_history(const char *, struct History *);
+void Rast_write_history(const char *, struct History *);
void Rast_short_history(const char *, const char *, struct History *);
int Rast_command_history(struct History *);
@@ -400,7 +400,7 @@
void Rast_set_quant_rules(int, struct Quant *);
/* put_cellhd.c */
-int Rast_put_cellhd(const char *, struct Cell_head *);
+void Rast_put_cellhd(const char *, struct Cell_head *);
/* put_row.c */
void Rast_put_row(int, const void *, RASTER_MAP_TYPE);
Modified: grass/trunk/lib/raster/cats.c
===================================================================
--- grass/trunk/lib/raster/cats.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/raster/cats.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -79,8 +79,8 @@
static int get_fmt(char **, char *, int *);
static int cmp(const void *, const void *);
-static int write_cats(const char *element, const char *name,
- struct Categories *cats);
+static void write_cats(const char *element, const char *name,
+ struct Categories *cats);
static CELL read_cats(const char *element, const char *name,
const char *mapset, struct Categories *pcats, int full);
@@ -925,12 +925,11 @@
* \param name map name
* \param cats pointer to Categories structure
*
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
+ * \return void
*/
-int Rast_write_cats(const char *name, struct Categories *cats)
+void Rast_write_cats(const char *name, struct Categories *cats)
{
- return write_cats("cats", name, cats);
+ write_cats("cats", name, cats);
}
/*!
@@ -943,16 +942,15 @@
* \param name map name
* \param cats pointer to Categories structure
*
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
+ * \return void
*/
-int Rast_write_vector_cats(const char *name, struct Categories *cats)
+void Rast_write_vector_cats(const char *name, struct Categories *cats)
{
- return write_cats("dig_cats", name, cats);
+ write_cats("dig_cats", name, cats);
}
-static int write_cats(const char *element, const char *name,
- struct Categories *cats)
+static void write_cats(const char *element, const char *name,
+ struct Categories *cats)
{
FILE *fd;
int i, fp_map;
@@ -960,8 +958,9 @@
DCELL val1, val2;
char str1[100], str2[100];
- if (!(fd = G_fopen_new(element, name)))
- return -1;
+ fd = G_fopen_new(element, name);
+ if (!fd)
+ G_fatal_error(_("Unable to open %s file for map <%s>"), element, name);
/* write # cats - note # indicate 3.0 or later */
fprintf(fd, "# %ld categories\n", (long)cats->num);
@@ -1003,7 +1002,6 @@
}
}
fclose(fd);
- return (1);
}
/*!
Modified: grass/trunk/lib/raster/color_write.c
===================================================================
--- grass/trunk/lib/raster/color_write.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/raster/color_write.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/glocale.h>
#include <grass/raster.h>
static void write_rules(FILE *, struct _Color_Rule_ *, DCELL, DCELL);
@@ -66,10 +67,9 @@
* \param mapset mapset name
* \param colors pointer to structure Colors which holds color info
*
- * \return 1 on success
- * \return -1 on failure
+ * \return void
*/
-int Rast_write_colors(const char *name, const char *mapset,
+void Rast_write_colors(const char *name, const char *mapset,
struct Colors *colors)
{
char element[512];
@@ -78,7 +78,8 @@
if (G_name_is_fully_qualified(name, xname, xmapset)) {
if (strcmp(xmapset, mapset) != 0)
- return -1;
+ G_fatal_error(_("Qualified name <%s> doesn't match mapset <%s>"),
+ name, mapset);
name = xname;
}
/*
@@ -92,11 +93,11 @@
strcpy(element, "colr");
}
if (!(fd = G_fopen_new(element, name)))
- return -1;
+ G_fatal_error(_("Unable to create <%s> file for map <%s>"),
+ element, name);
Rast__write_colors(fd, colors);
fclose(fd);
- return 1;
}
/*!
Modified: grass/trunk/lib/raster/histogram.c
===================================================================
--- grass/trunk/lib/raster/histogram.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/raster/histogram.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -38,8 +38,7 @@
* \param mapset: mapset that map belongs to
* \param histogram: struct for histogram
* \return 1 if successful,
- * 0 if no histogram file,
- * -1 on fail
+ * 0 if no histogram file,
*/
int Rast_read_histogram(const char *name, const char *mapset,
@@ -52,39 +51,27 @@
Rast_init_histogram(histogram);
- if (G_find_file2_misc("cell_misc", "histogram", name, mapset) == NULL) {
+ if (!G_find_file2_misc("cell_misc", "histogram", name, mapset)) {
G_warning(_("Histogram for [%s in %s] missing (run r.support)"), name,
mapset);
-
return 0;
}
fd = G_fopen_old_misc("cell_misc", "histogram", name, mapset);
- if (!fd) {
- G_warning(_("Can't read histogram for [%s in %s]"), name, mapset);
+ if (!fd)
+ G_fatal_error(_("Can't read histogram for [%s in %s]"), name, mapset);
- return -1;
- }
-
while (fgets(buf, sizeof buf, fd)) {
- if (sscanf(buf, "%ld:%ld", &cat, &count) != 2) {
- Rast_free_histogram(histogram);
- fclose(fd);
- G_warning(_("Invalid histogram file for [%s in %s]"), name,
- mapset);
-
- return -1;
- }
+ if (sscanf(buf, "%ld:%ld", &cat, &count) != 2)
+ G_fatal_error(_("Invalid histogram file for [%s in %s]"),
+ name, mapset);
Rast_extend_histogram((CELL) cat, count, histogram);
}
fclose(fd);
- if (histogram->num == 0) {
- G_warning(_("Invalid histogram file for [%s in %s]"), name, mapset);
+ if (histogram->num == 0)
+ G_fatal_error(_("Invalid histogram file for [%s in %s]"), name, mapset);
- return -1;
- }
-
Rast_sort_histogram(histogram);
return 1;
@@ -97,28 +84,24 @@
* Writes the histogram information associated with map layer "name"
* \param name: name of map
* \param histogram: struct for histogram
- * \return 1 if successful,
- * -1 on fail
+ * \return void
*/
-int Rast_write_histogram(const char *name, const struct Histogram *histogram)
+void Rast_write_histogram(const char *name, const struct Histogram *histogram)
{
- FILE *fd;
+ FILE *fp;
int n;
LIST *list;
- fd = fopen_histogram_new(name);
- if (fd == NULL)
- return -1;
+ fp = fopen_histogram_new(name);
list = histogram->list;
for (n = 0; n < histogram->num; n++) {
if (list[n].count)
- fprintf(fd, "%ld:%ld\n", (long)list[n].cat, list[n].count);
+ fprintf(fp, "%ld:%ld\n", (long)list[n].cat, list[n].count);
}
- fclose(fd);
- return 1;
+ fclose(fp);
}
@@ -127,28 +110,24 @@
*
* \param name: name of map
* \param statf: cell statistics
- * \return 1 on success
- * -1 on failure
+ * \return void
*/
-int Rast_write_histogram_cs(const char *name, struct Cell_stats *statf)
+void Rast_write_histogram_cs(const char *name, struct Cell_stats *statf)
{
- FILE *fd;
+ FILE *fp;
CELL cat;
long count;
- fd = fopen_histogram_new(name);
- if (fd == NULL)
- return -1;
+ fp = fopen_histogram_new(name);
Rast_rewind_cell_stats(statf);
while (Rast_next_cell_stat(&cat, &count, statf)) {
if (count > 0)
- fprintf(fd, "%ld:%ld\n", (long)cat, count);
+ fprintf(fp, "%ld:%ld\n", (long)cat, count);
}
- fclose(fd);
- return 1;
+ fclose(fp);
}
@@ -345,17 +324,15 @@
static FILE *fopen_histogram_new(const char *name)
{
- FILE *fd;
+ FILE *fp;
- fd = G_fopen_new_misc("cell_misc", "histogram", name);
- if (fd == NULL)
- G_warning(_("can't create histogram for [%s in %s]"), name,
- G_mapset());
+ fp = G_fopen_new_misc("cell_misc", "histogram", name);
+ if (!fp)
+ G_fatal_error(_("Unable to create histogram file for <%s>"), name);
- return fd;
+ return fp;
}
-
/*!
* \brief Removes the histogram
*
Modified: grass/trunk/lib/raster/history.c
===================================================================
--- grass/trunk/lib/raster/history.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/raster/history.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -107,18 +107,13 @@
return 0;
}
-void print_history_error(const char *name, const char *mapset, FILE * fd)
+static void print_history_error(const char *name, const char *mapset, FILE *fp)
{
- if (fd != NULL)
- fclose(fd);
+ if (fp)
+ fclose(fp);
- if (mapset) {
- G_warning(_("Unable to get history information for <%s@%s>"),
- name, mapset);
- }
- else { /* write */
- G_warning(_("Unable to write history information for <%s>"), name);
- }
+ G_warning(_("Unable to get history information for <%s@%s>"),
+ name, mapset);
}
/*!
@@ -136,35 +131,30 @@
* \param name map name
* \param[out] hist pointer to History structure which holds history info
*
- * \return -1 on error
- * \return 0 on success
+ * \return void
*/
-int Rast_write_history(const char *name, struct History *hist)
+void Rast_write_history(const char *name, struct History *hist)
{
- FILE *fd;
+ FILE *fp;
int i;
- fd = G_fopen_new("hist", name);
- if (!fd) {
- print_history_error(name, NULL, fd);
- return -1;
- }
+ fp = G_fopen_new("hist", name);
+ if (!fp)
+ G_fatal_error(_("Unable to write history information for <%s>"), name);
- fprintf(fd, "%s\n", hist->mapid);
- fprintf(fd, "%s\n", hist->title);
- fprintf(fd, "%s\n", hist->mapset);
- fprintf(fd, "%s\n", hist->creator);
- fprintf(fd, "%s\n", hist->maptype);
- fprintf(fd, "%s\n", hist->datsrc_1);
- fprintf(fd, "%s\n", hist->datsrc_2);
- fprintf(fd, "%s\n", hist->keywrd);
+ fprintf(fp, "%s\n", hist->mapid);
+ fprintf(fp, "%s\n", hist->title);
+ fprintf(fp, "%s\n", hist->mapset);
+ fprintf(fp, "%s\n", hist->creator);
+ fprintf(fp, "%s\n", hist->maptype);
+ fprintf(fp, "%s\n", hist->datsrc_1);
+ fprintf(fp, "%s\n", hist->datsrc_2);
+ fprintf(fp, "%s\n", hist->keywrd);
for (i = 0; i < hist->edlinecnt; i++)
- fprintf(fd, "%s\n", hist->edhist[i]);
+ fprintf(fp, "%s\n", hist->edhist[i]);
- fclose(fd);
-
- return 0;
+ fclose(fp);
}
/*!
Modified: grass/trunk/lib/raster/put_cellhd.c
===================================================================
--- grass/trunk/lib/raster/put_cellhd.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/raster/put_cellhd.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -23,20 +23,16 @@
\param name name of map
\param cellhd structure holding cell header info
- \return 0 on success
- \return -1 on failure
+ \return void
*/
-int Rast_put_cellhd(const char *name, struct Cell_head *cellhd)
+void Rast_put_cellhd(const char *name, struct Cell_head *cellhd)
{
- FILE *fd;
+ FILE *fp;
- if (!(fd = G_fopen_new("cellhd", name))) {
- G_warning(_("Unable to create header file for <%s>"), name);
- return -1;
- }
+ fp = G_fopen_new("cellhd", name);
+ if (!fp)
+ G_fatal_error(_("Unable to create header file for <%s>"), name);
- G__write_Cell_head(fd, cellhd, 1);
- fclose(fd);
-
- return 0;
+ G__write_Cell_head(fp, cellhd, 1);
+ fclose(fp);
}
Modified: grass/trunk/lib/rst/interp_float/resout2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/resout2d.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/lib/rst/interp_float/resout2d.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -240,11 +240,7 @@
return -1;
}
- if (Rast_write_colors(params->elev, maps, &colors2) < 0) {
- G_warning(_("Unable to write color file of raster map <%s>"),
- params->elev);
- return -1;
- }
+ Rast_write_colors(params->elev, maps, &colors2);
Rast_quantize_fp_map_range(params->elev, mapset,
zminac - 0.5, zmaxac + 0.5,
(CELL) (zminac - 0.5),
Modified: grass/trunk/raster/r.carve/enforce.h
===================================================================
--- grass/trunk/raster/r.carve/enforce.h 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.carve/enforce.h 2010-01-06 02:06:14 UTC (rev 40273)
@@ -74,7 +74,7 @@
void *write_raster(void *, const int, const RASTER_MAP_TYPE);
/* support.c */
-extern int update_rast_history(struct parms *);
+extern void update_rast_history(struct parms *);
/* vect.c */
extern int open_new_vect(struct Map_info *, char *);
Modified: grass/trunk/raster/r.carve/support.c
===================================================================
--- grass/trunk/raster/r.carve/support.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.carve/support.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -28,10 +28,8 @@
/*
* update_rast_history - Update a history file. Some of the digit file
* information is placed in the history file.
- * returns 0 - successful creation of history file
- * -1 - error
*/
-int update_rast_history(struct parms *parm)
+void update_rast_history(struct parms *parm)
{
struct History hist;
@@ -43,6 +41,5 @@
sprintf(hist.datsrc_2, "vector stream file: %s", parm->invect->answer);
hist.edlinecnt = 2;
Rast_command_history(&hist);
-
- return Rast_write_history(parm->outrast->answer, &hist);
+ Rast_write_history(parm->outrast->answer, &hist);
}
Modified: grass/trunk/raster/r.category/main.c
===================================================================
--- grass/trunk/raster/r.category/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.category/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -155,9 +155,9 @@
G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
parm.raster->answer, cmapset);
- if (Rast_write_cats(name, &cats) >= 0)
- G_message(_("Category table for <%s> set from <%s>"), name,
- parm.raster->answer);
+ Rast_write_cats(name, &cats);
+ G_message(_("Category table for <%s> set from <%s>"),
+ name, parm.raster->answer);
Rast_close(fd);
}
@@ -193,9 +193,7 @@
Rast_set_d_cat(&d1, &d1, label, &cats);
}
- if (Rast_write_cats(name, &cats) < 0)
- G_fatal_error(_("Cannot create category file for <%s>"),
- name);
+ Rast_write_cats(name, &cats);
if (!from_stdin)
fclose(fp);
@@ -239,9 +237,7 @@
Rast_set_cats_fmt(fmt_str, m1, a1, m2, a2, &cats);
- if (Rast_write_cats(name, &cats) != 1)
- G_fatal_error(_("Cannot create category file for <%s>"),
- name);
+ Rast_write_cats(name, &cats);
}
Rast_free_cats(&cats);
Modified: grass/trunk/raster/r.colors/main.c
===================================================================
--- grass/trunk/raster/r.colors/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.colors/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -378,10 +378,10 @@
if (fp)
Rast_mark_colors_as_fp(&colors);
- if (Rast_write_colors(name, mapset, &colors) >= 0)
- G_message(_("Color table for raster map <%s> set to '%s'"), name,
- is_from_stdin ? "rules" : style ? style : rules ? rules :
- cmap);
+ Rast_write_colors(name, mapset, &colors);
+ G_message(_("Color table for raster map <%s> set to '%s'"), name,
+ is_from_stdin ? "rules" : style ? style : rules ? rules :
+ cmap);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.grow/main.c
===================================================================
--- grass/trunk/raster/r.grow/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.grow/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -275,12 +275,10 @@
Rast_close(in_fd);
Rast_close(out_fd);
- if (Rast_write_cats(out_name, &cats) == -1)
- G_warning(_("Error writing category file for <%s>"), out_name);
+ Rast_write_cats(out_name, &cats);
if (colrfile)
- if (Rast_write_colors(out_name, G_mapset(), &colr) == -1)
- G_warning(_("Error writing color file for <%s>"), out_name);
+ Rast_write_colors(out_name, G_mapset(), &colr);
Rast_short_history(out_name, "raster", &history);
Rast_command_history(&history);
Modified: grass/trunk/raster/r.lake/main.c
===================================================================
--- grass/trunk/raster/r.lake/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.lake/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -365,9 +365,7 @@
&max_depth, 0, 50, 170, &colr);
}
- if (Rast_write_colors(lakemap, G_mapset(), &colr) != 1)
- G_fatal_error(_("Unable to read color file of raster map <%s>"),
- lakemap);
+ Rast_write_colors(lakemap, G_mapset(), &colr);
Rast_short_history(lakemap, "raster", &history);
Rast_command_history(&history);
Modified: grass/trunk/raster/r.param.scale/write_cats.c
===================================================================
--- grass/trunk/raster/r.param.scale/write_cats.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.param.scale/write_cats.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -51,9 +51,7 @@
/* WRITE OUT CATEGORIES STRUCTURE */
/*------------------------------------------------------------------------*/
- if (Rast_write_cats(rast_out_name, &cats) <= 0)
- G_warning(_("Cannot write category file for raster map <%s>"),
- rast_out_name);
+ Rast_write_cats(rast_out_name, &cats);
Rast_free_cats(&cats);
Modified: grass/trunk/raster/r.random.surface/save.c
===================================================================
--- grass/trunk/raster/r.random.surface/save.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.random.surface/save.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -213,7 +213,5 @@
Rast_add_c_color_rule(&Low, LowColor, LowColor, LowColor,
&High, HighColor, HighColor, HighColor, &Colr);
- if (Rast_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
- G_warning(_("Unable to write color table for raster map <%s>"),
- OutNames[NumMap]);
+ Rast_write_colors(OutNames[NumMap], G_mapset(), &Colr);
}
Modified: grass/trunk/raster/r.reclass/reclass.c
===================================================================
--- grass/trunk/raster/r.reclass/reclass.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.reclass/reclass.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -241,8 +241,7 @@
fclose(fd);
Rast_set_cats_title(title, cats);
- if (Rast_write_cats(new_name, cats) == -1)
- G_fatal_error(_("Cannot create category file of <%s>"), new_name);
+ Rast_write_cats(new_name, cats);
Rast_free_cats(cats);
Modified: grass/trunk/raster/r.region/main.c
===================================================================
--- grass/trunk/raster/r.region/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.region/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -326,8 +326,7 @@
cellhd.east = window.east;
cellhd.west = window.west;
- if (Rast_put_cellhd(parm.map->answer, &cellhd) < 0)
- G_fatal_error(_("Unable to update boundaries"));
+ Rast_put_cellhd(parm.map->answer, &cellhd);
G_done_msg(" ");
Modified: grass/trunk/raster/r.resamp.interp/main.c
===================================================================
--- grass/trunk/raster/r.resamp.interp/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.resamp.interp/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -312,9 +312,7 @@
if (Rast_read_colors(rastin->answer, "", &colors) < 0)
G_fatal_error(_("Unable to read color table for %s"), rastin->answer);
Rast_mark_colors_as_fp(&colors);
- if (Rast_write_colors(rastout->answer, G_mapset(), &colors) < 0)
- G_fatal_error(_("Unable to write color table for %s"),
- rastout->answer);
+ Rast_write_colors(rastout->answer, G_mapset(), &colors);
return (EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.resamp.stats/main.c
===================================================================
--- grass/trunk/raster/r.resamp.stats/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.resamp.stats/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -381,9 +381,7 @@
G_fatal_error(_("Unable to read color table for %s"),
parm.rastin->answer);
Rast_mark_colors_as_fp(&colors);
- if (Rast_write_colors(parm.rastout->answer, G_mapset(), &colors) < 0)
- G_fatal_error(_("Unable to write color table for %s"),
- parm.rastout->answer);
+ Rast_write_colors(parm.rastout->answer, G_mapset(), &colors);
}
return (EXIT_SUCCESS);
Modified: grass/trunk/raster/r.support/main.c
===================================================================
--- grass/trunk/raster/r.support/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.support/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -287,9 +287,9 @@
G_fatal_error(_("Unable to read category file of raster map <%s>"),
map_opt->answer);
- if (Rast_write_cats(infile, &cats) >= 0)
- G_message(_("cats table for [%s] set to %s"), infile,
- map_opt->answer);
+ Rast_write_cats(infile, &cats);
+ G_message(_("cats table for [%s] set to %s"),
+ infile, map_opt->answer);
Rast_close(fd);
Rast_free_cats(&cats);
}
Modified: grass/trunk/raster/r.terraflow/main.cc
===================================================================
--- grass/trunk/raster/r.terraflow/main.cc 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.terraflow/main.cc 2010-01-06 02:06:14 UTC (rev 40273)
@@ -360,10 +360,8 @@
Rast_add_c_color_rule(&v[3], 0,127,255, &v[4], 0,0,255, &colors);
Rast_add_c_color_rule(&v[4], 0,0,255, &v[5], 0,0,0, &colors);
-
- if (Rast_write_colors(cellname, mapset, &colors) == -1) {
- G_fatal_error(_("cannot write colors"));
- }
+ Rast_write_colors(cellname, mapset, &colors);
+
Rast_free_colors(&colors);
}
@@ -386,9 +384,8 @@
Rast_init_colors(&colors);
Rast_make_random_colors(&colors, 1, r.max);
- if (Rast_write_colors(cellname, mapset, &colors) == -1) {
- G_fatal_error(_("cannot write colors"));
- }
+ Rast_write_colors(cellname, mapset, &colors);
+
Rast_free_colors(&colors);
}
Modified: grass/trunk/raster/r.watershed/front/main.c
===================================================================
--- grass/trunk/raster/r.watershed/front/main.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/raster/r.watershed/front/main.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -22,7 +22,7 @@
#include <grass/glocale.h>
#include <grass/spawn.h>
-int write_hist(char *, char *, char *, int, int);
+static void write_hist(char *, char *, char *, int, int);
static const char *new_argv[22];
static int new_argc;
@@ -343,7 +343,7 @@
}
/* record map history info */
-int write_hist(char *map_name, char *title, char *source_name, int mode, int sfd)
+static void write_hist(char *map_name, char *title, char *source_name, int mode, int sfd)
{
struct History history;
@@ -359,5 +359,5 @@
history.edlinecnt = 2;
Rast_command_history(&history);
- return Rast_write_history(map_name, &history);
+ Rast_write_history(map_name, &history);
}
Modified: grass/trunk/vector/v.to.rast/support.c
===================================================================
--- grass/trunk/vector/v.to.rast/support.c 2010-01-06 00:41:59 UTC (rev 40272)
+++ grass/trunk/vector/v.to.rast/support.c 2010-01-06 02:06:14 UTC (rev 40273)
@@ -35,7 +35,9 @@
/* store command line options */
Rast_command_history(&hist);
- return (Rast_write_history(raster_name, &hist));
+ Rast_write_history(raster_name, &hist);
+
+ return 0;
}
@@ -482,9 +484,7 @@
}
Rast_close(fd);
- if (Rast_write_cats(rast_name, &rast_cats) <= 0)
- G_warning(_("Unable to write categories for raster map <%s>"),
- rast_name);
+ Rast_write_cats(rast_name, &rast_cats);
Rast_free_cats(&rast_cats);
return 1;
More information about the grass-commit
mailing list