[GRASS-SVN] r49405 - in grass/trunk: include/defs lib/vector/Vlib
ps/ps.map vector/v.category vector/v.clean vector/v.convert
vector/v.kcv vector/v.net.path vector/v.type visualization/nviz/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 28 03:33:09 EST 2011
Author: martinl
Date: 2011-11-28 00:33:09 -0800 (Mon, 28 Nov 2011)
New Revision: 49405
Removed:
grass/trunk/lib/vector/Vlib/error.c
Modified:
grass/trunk/include/defs/vector.h
grass/trunk/lib/vector/Vlib/open.c
grass/trunk/ps/ps.map/do_vectors.c
grass/trunk/ps/ps.map/r_vareas.c
grass/trunk/ps/ps.map/r_vlines.c
grass/trunk/ps/ps.map/r_vpoints.c
grass/trunk/vector/v.category/main.c
grass/trunk/vector/v.clean/main.c
grass/trunk/vector/v.convert/old2new.c
grass/trunk/vector/v.kcv/main.c
grass/trunk/vector/v.net.path/main.c
grass/trunk/vector/v.type/main.c
grass/trunk/visualization/nviz/src/query_vect.c
Log:
vlib: remove Vect_get/set_fatal_error() - replaced by G_fatal_error() / G_warning()
Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/include/defs/vector.h 2011-11-28 08:33:09 UTC (rev 49405)
@@ -209,10 +209,6 @@
void Vect_set_release_support(struct Map_info *);
void Vect_set_category_index_update(struct Map_info *);
-/* Set/get fatal error behaviour */
-int Vect_set_fatal_error(int);
-int Vect_get_fatal_error();
-
/* Open/close/rewind/set_constraints for map */
int Vect_check_input_output_name(const char *, const char *, int);
int Vect_legal_filename(const char *);
Deleted: grass/trunk/lib/vector/Vlib/error.c
===================================================================
--- grass/trunk/lib/vector/Vlib/error.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/lib/vector/Vlib/error.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -1,51 +0,0 @@
-/*!
- \file lib/vector/Vlib/error.c
-
- \brief Vector library - error management
-
- Higher level functions for reading/writing/manipulating vectors.
-
- (C) 2001-2009 by the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Original author CERL, probably Dave Gerdes or Mike Higgins.
- \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
-*/
-
-#include <string.h>
-#include <grass/vector.h>
-
-static int fatal_err = GV_FATAL_EXIT;
-
-/*!
- \brief Set behaviour if fatal error occurs in some functions
-
- - GV_FATAL_EXIT(default): print error message and exit,
- - GV_FATAL_PRINT: print error message and return error,
- - GV_FATAL_RETURN: return error
-
- \param err error type
-
- \return 0
- */
-int Vect_set_fatal_error(int err)
-{
- fatal_err = err;
- return 0;
-}
-
-/*!
- \brief Get behaviour for fatal error
-
- \todo Remove or move to GIS Library?
-
- \return GV_FATAL_EXIT(default): print error message and exit,
- \return GV_FATAL_PRINT: print error message and return error,
- \return GV_FATAL_RETURN: return error
- */
-int Vect_get_fatal_error(void)
-{
- return (fatal_err);
-}
Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/lib/vector/Vlib/open.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -82,20 +82,6 @@
#endif
};
-static void fatal_error(int ferror, char *errmsg)
-{
- switch (ferror) {
- case GV_FATAL_EXIT:
- G_fatal_error(errmsg);
- break;
- case GV_FATAL_PRINT:
- G_warning(errmsg);
- break;
- case GV_FATAL_RETURN:
- break;
- }
-}
-
/*!
* \brief Predetermine level at which a vector map will be opened for
* reading.
@@ -151,9 +137,9 @@
int update, int head_only)
{
char buf[GNAME_MAX + 10], buf2[GMAPSET_MAX + 10], xname[GNAME_MAX],
- xmapset[GMAPSET_MAX], errmsg[2000];
+ xmapset[GMAPSET_MAX];
FILE *fp;
- int level, level_request, ferror;
+ int level, level_request;
int format, ret;
int ogr_mapset;
const char *fmapset;
@@ -166,9 +152,6 @@
/* TODO: Open header for update ('dbln') */
- ferror = Vect_get_fatal_error();
- Vect_set_fatal_error(GV_FATAL_EXIT);
-
level_request = Open_level;
Open_level = 0;
@@ -215,12 +198,11 @@
fmapset = G_find_vector2(Map->name, Map->mapset);
if (fmapset == NULL) {
if (mapset && strcmp(mapset, G_mapset()) == 0)
- sprintf(errmsg, _("Vector map <%s> not found in current mapset"),
- Vect_get_name(Map));
+ G_fatal_error(_("Vector map <%s> not found in current mapset"),
+ Vect_get_name(Map));
else
- sprintf(errmsg, _("Vector map <%s> not found"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
+ G_fatal_error(_("Vector map <%s> not found"),
+ Vect_get_full_name(Map));
return -1;
}
Map->mapset = G_store(fmapset);
@@ -257,9 +239,8 @@
G_debug(1, "Vector format: %d (non-native)", format);
if (format < 0) {
- sprintf(errmsg, _("Unable to open vector map <%s>"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
+ G_fatal_error(_("Unable to open vector map <%s>"),
+ Vect_get_full_name(Map));
return -1;
}
}
@@ -272,12 +253,8 @@
/* read vector head (ignored for OGR mapset) */
if (!ogr_mapset && Vect__read_head(Map) != 0) {
- sprintf(errmsg,
- _("Unable to open vector map <%s> on level %d. "
- "Try to rebuild vector topology by v.build."),
- Vect_get_full_name(Map), level_request);
- G_warning(_("Unable to read header file of vector map <%s>"),
- Vect_get_full_name(Map));
+ G_fatal_error(_("Unable to read header file of vector map <%s>"),
+ Vect_get_full_name(Map));
}
/* projection is not written to head but zone ??? */
@@ -362,11 +339,9 @@
if (level_request == 2 && level < 2) {
if (!ogr_mapset) {
/* for direct OGR read access is built pseudo-topology on the fly */
- sprintf(errmsg,
- _("Unable to open vector map <%s> on level %d. "
- "Try to rebuild vector topology by v.build."),
- Vect_get_full_name(Map), level_request);
- fatal_error(ferror, errmsg);
+ G_warning(_("Unable to open vector map <%s> on level %d. "
+ "Try to rebuild vector topology by v.build."),
+ Vect_get_full_name(Map), level_request);
return -1;
}
}
@@ -383,11 +358,9 @@
dig_spidx_free(&(Map->plus));
dig_cidx_free(&(Map->plus));
}
- sprintf(errmsg,
- _("Unable to open vector map <%s> on level %d. "
- "Try to rebuild vector topology by v.build."),
- Vect_get_full_name(Map), level_request);
- fatal_error(ferror, errmsg);
+ G_warning(_("Unable to open vector map <%s> on level %d. "
+ "Try to rebuild vector topology by v.build."),
+ Vect_get_full_name(Map), level_request);
return -1;
}
if (ogr_mapset && !head_only && level_request != 1) {
@@ -450,11 +423,9 @@
if (update && !ogr_mapset) { /* native only */
Map->hist_fp = G_fopen_modify(buf, GV_HIST_ELEMENT);
if (Map->hist_fp == NULL) {
- sprintf(errmsg,
- _("Unable to open history file for vector map <%s>"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
- return (-1);
+ G_warning(_("Unable to open history file for vector map <%s>"),
+ Vect_get_full_name(Map));
+ return -1;
}
G_fseek(Map->hist_fp, (off_t) 0, SEEK_END);
Vect_hist_write(Map,
@@ -689,8 +660,8 @@
*/
int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
{
- int ret, ferror;
- char errmsg[2000], buf[500];
+ int ret;
+ char buf[500];
char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
G_debug(2, "Vect_open_new(): name = %s", name);
@@ -700,23 +671,18 @@
/* init header */
Vect__init_head(Map);
- /* error handling */
- ferror = Vect_get_fatal_error();
- Vect_set_fatal_error(GV_FATAL_EXIT);
-
if (G_name_is_fully_qualified(name, xname, xmapset)) {
if (strcmp(xmapset, G_mapset()) != 0) {
- sprintf(errmsg, _("%s is not in the current mapset (%s)"), name,
- G_mapset());
- fatal_error(ferror, errmsg);
+ G_fatal_error(_("<%s> is not the current mapset (%s)"), name,
+ G_mapset());
+ return -1;
}
name = xname;
}
/* check for [A-Za-z][A-Za-z0-9_]* in name */
if (Vect_legal_filename(name) < 0) {
- sprintf(errmsg, _("Vector map name is not SQL compliant"));
- fatal_error(ferror, errmsg);
+ G_fatal_error(_("Vector map name is not SQL compliant"));
return -1;
}
@@ -732,8 +698,7 @@
Map->format = GV_FORMAT_OGR_DIRECT;
fp = G_fopen_old("", "OGR", G_mapset());
if (!fp) {
- sprintf(errmsg, _("Unable to open OGR file"));
- fatal_error(ferror, errmsg);
+ G_warning(_("Unable to open OGR file"));
}
key_val = G_fread_key_value(fp);
fclose(fp);
@@ -758,8 +723,7 @@
ret = Vect_delete(name);
if (ret == -1) {
- sprintf(errmsg, _("Unable to delete vector map <%s>"), name);
- fatal_error(ferror, errmsg);
+ G_warning(_("Unable to delete vector map <%s>"), name);
return -1;
}
}
@@ -774,9 +738,8 @@
Map->plus.spidx_with_z = Map->plus.with_z = Map->head.with_z = (with_z != 0);
if ((*Open_new_array[Map->format][1]) (Map, name, with_z) < 0) {
- sprintf(errmsg, _("Unable to create vector map <%s>"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
+ G_fatal_error(_("Unable to create vector map <%s>"),
+ name);
return -1;
}
@@ -785,9 +748,8 @@
sprintf(buf, "%s/%s", GV_DIRECTORY, Map->name);
Map->hist_fp = G_fopen_new(buf, GV_HIST_ELEMENT);
if (Map->hist_fp == NULL) {
- sprintf(errmsg, _("Unable to open history file of vector map <%s>"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
+ G_warning(_("Unable to open history file of vector map <%s>"),
+ name);
return -1;
}
}
Modified: grass/trunk/ps/ps.map/do_vectors.c
===================================================================
--- grass/trunk/ps/ps.map/do_vectors.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/ps/ps.map/do_vectors.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -34,7 +34,6 @@
vector.layer[n].name, vector.layer[n].mapset);
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (2 >
Vect_open_old(&Map, vector.layer[n].name,
vector.layer[n].mapset)) {
@@ -139,7 +138,6 @@
vector.layer[n].name, vector.layer[n].mapset);
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (2 >
Vect_open_old(&Map, vector.layer[n].name,
vector.layer[n].mapset)) {
Modified: grass/trunk/ps/ps.map/r_vareas.c
===================================================================
--- grass/trunk/ps/ps.map/r_vareas.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/ps/ps.map/r_vareas.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -48,7 +48,6 @@
sprintf(fullname, "%s in %s", name, mapset);
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (2 > Vect_open_old(&Map, name, mapset)) {
error(fullname, "", "can't open vector map");
gobble_input();
Modified: grass/trunk/ps/ps.map/r_vlines.c
===================================================================
--- grass/trunk/ps/ps.map/r_vlines.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/ps/ps.map/r_vlines.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -54,7 +54,6 @@
sprintf(fullname, "%s in %s", name, mapset);
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (2 > Vect_open_old(&Map, name, mapset)) {
error(fullname, "", "can't open vector map");
gobble_input();
Modified: grass/trunk/ps/ps.map/r_vpoints.c
===================================================================
--- grass/trunk/ps/ps.map/r_vpoints.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/ps/ps.map/r_vpoints.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -54,7 +54,6 @@
sprintf(fullname, "%s in %s", name, mapset);
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (2 > Vect_open_old(&Map, name, mapset)) {
error(fullname, "", "can't open vector map");
gobble_input();
Modified: grass/trunk/vector/v.category/main.c
===================================================================
--- grass/trunk/vector/v.category/main.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.category/main.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -206,7 +206,6 @@
option == O_SUM) {
with_z = In.head.with_z;
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (0 > Vect_open_new(&Out, out_opt->answer, with_z)) {
Vect_close(&In);
exit(EXIT_FAILURE);
Modified: grass/trunk/vector/v.clean/main.c
===================================================================
--- grass/trunk/vector/v.clean/main.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.clean/main.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -273,15 +273,13 @@
Vect_open_old2(&In, opt.in->answer, "", opt.field->answer);
with_z = Vect_is_3d(&In);
-
- Vect_set_fatal_error(GV_FATAL_PRINT);
+
if (0 > Vect_open_new(&Out, opt.out->answer, with_z)) {
Vect_close(&In);
exit(EXIT_FAILURE);
}
if (opt.err->answer) {
- Vect_set_fatal_error(GV_FATAL_PRINT);
Vect_set_open_level(2);
if (0 > Vect_open_new(&Err, opt.err->answer, with_z)) {
Vect_close(&In);
Modified: grass/trunk/vector/v.convert/old2new.c
===================================================================
--- grass/trunk/vector/v.convert/old2new.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.convert/old2new.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -32,7 +32,6 @@
}
/* open new output file */
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (Vect_open_new(&Mapout, out, WITHOUT_Z) < 0) {
fclose(Digin);
exit(EXIT_FAILURE);
Modified: grass/trunk/vector/v.kcv/main.c
===================================================================
--- grass/trunk/vector/v.kcv/main.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.kcv/main.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -46,7 +46,7 @@
{
int line, nlines, nlinks;
double east, north, (*rng) (), max, myrand();
- int i, j, n, nsites, np, *p, dcmp();
+ int i, j, nsites, np, *p, dcmp();
int *pnt_part;
struct Map_info In, Out;
static struct line_pnts *Points;
@@ -132,7 +132,6 @@
G_fatal_error(_("More partitions than points (%d)"), nsites);
}
- Vect_set_fatal_error(GV_FATAL_PRINT);
Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
Vect_copy_head_data(&In, &Out);
@@ -192,7 +191,7 @@
* number of sites will not always be a multiple of the number of
* partitions. make_histo() returns the maximum bin size.
*/
- n = make_histo(&p, np, nsites);
+ make_histo(&p, np, nsites);
nlines = Vect_get_num_lines(&In);
pnt_part = (int *)G_calloc(nlines + 1, sizeof(int));
Modified: grass/trunk/vector/v.net.path/main.c
===================================================================
--- grass/trunk/vector/v.net.path/main.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.net.path/main.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -129,7 +129,6 @@
Vect_set_open_level(2);
Vect_open_old(&In, input_opt->answer, "");
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (1 > Vect_open_new(&Out, output_opt->answer, Vect_is_3d(&In))) {
Vect_close(&In);
G_fatal_error(_("Unable to create vector map <%s>"),
Modified: grass/trunk/vector/v.type/main.c
===================================================================
--- grass/trunk/vector/v.type/main.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/vector/v.type/main.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -125,7 +125,6 @@
Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
field = Vect_get_field_number(&In, field_opt->answer);
- Vect_set_fatal_error(GV_FATAL_PRINT);
if (0 > Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In))) {
Vect_close(&In);
exit(EXIT_FAILURE);
Modified: grass/trunk/visualization/nviz/src/query_vect.c
===================================================================
--- grass/trunk/visualization/nviz/src/query_vect.c 2011-11-28 04:58:36 UTC (rev 49404)
+++ grass/trunk/visualization/nviz/src/query_vect.c 2011-11-28 08:33:09 UTC (rev 49405)
@@ -36,7 +36,6 @@
}
Vect_set_open_level(2);
- Vect_set_fatal_error(GV_FATAL_PRINT);
level = Vect_open_old(&Map, name, mapset);
if (level < 2) {
return ("Could not open map on level 2.\n");
More information about the grass-commit
mailing list