Browse Source

Remove explicit mapset references and G_find_* calls

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@33177 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 năm trước cách đây
mục cha
commit
f5941d2f92
45 tập tin đã thay đổi với 219 bổ sung538 xóa
  1. 2 33
      vector/v.in.dxf/main.c
  2. 1 6
      vector/v.kcv/main.c
  3. 2 11
      vector/v.kernel/main.c
  4. 1 7
      vector/v.label.sa/labels.c
  5. 1 6
      vector/v.label/main.c
  6. 1 7
      vector/v.neighbors/main.c
  7. 1 7
      vector/v.net.alloc/main.c
  8. 1 7
      vector/v.net.iso/main.c
  9. 1 7
      vector/v.net.path/main.c
  10. 1 7
      vector/v.net.salesman/main.c
  11. 1 7
      vector/v.net.steiner/main.c
  12. 5 16
      vector/v.net.visibility/main.c
  13. 2 11
      vector/v.net/main.c
  14. 1 5
      vector/v.normal/main.c
  15. 4 18
      vector/v.out.dxf/main.c
  16. 1 6
      vector/v.out.ogr/main.c
  17. 1 6
      vector/v.out.pov/main.c
  18. 1 6
      vector/v.out.svg/main.c
  19. 1 8
      vector/v.overlay/main.c
  20. 1 2
      vector/v.patch/main.c
  21. 1 5
      vector/v.perturb/main.c
  22. 1 5
      vector/v.qcount/main.c
  23. 2 5
      vector/v.reclass/main.c
  24. 2 9
      vector/v.sample/main.c
  25. 2 5
      vector/v.segment/main.c
  26. 2 8
      vector/v.select/main.c
  27. 1 7
      vector/v.support/main.c
  28. 132 191
      vector/v.surf.rst/main.c
  29. 0 1
      vector/v.surf.rst/surf.h
  30. 0 1
      vector/v.to.db/global.h
  31. 1 1
      vector/v.to.db/main.c
  32. 0 4
      vector/v.to.db/parse.c
  33. 1 6
      vector/v.to.points/main.c
  34. 8 8
      vector/v.to.rast/local.h
  35. 14 21
      vector/v.to.rast/support.c
  36. 6 9
      vector/v.to.rast/vect2rast.c
  37. 2 5
      vector/v.transform/main.c
  38. 1 6
      vector/v.type/main.c
  39. 1 5
      vector/v.univar/main.c
  40. 1 6
      vector/v.voronoi/dt_main.c
  41. 2 8
      vector/v.voronoi/vo_main.c
  42. 3 10
      vector/v.what.rast/main.c
  43. 4 24
      vector/v.what/main.c
  44. 1 4
      vector/v.what/what.c
  45. 1 1
      vector/v.what/what.h

+ 2 - 33
vector/v.in.dxf/main.c

@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
     opt.input->description = _("Name of input DXF file");
     opt.input->description = _("Name of input DXF file");
 
 
     opt.output = G_define_standard_option(G_OPT_V_OUTPUT);
     opt.output = G_define_standard_option(G_OPT_V_OUTPUT);
-    opt.output->required = NO;
+    opt.output->required = YES;
 
 
     opt.layers = G_define_option();
     opt.layers = G_define_option();
     opt.layers->key = "layers";
     opt.layers->key = "layers";
@@ -136,41 +136,10 @@ int main(int argc, char *argv[])
 	G_verbose_message(_("Layer number: layer name / GRASS compliant name"));
 	G_verbose_message(_("Layer number: layer name / GRASS compliant name"));
     }
     }
     else {
     else {
-	/* make vector map name SQL compliant */
-	if (opt.output->answer) {
-	    output = G_store(opt.output->answer);
-	}
-	else {
-	    char *p, *p2;
-
-	    if ((p = G_rindex(dxf->name, '/')))
-		p++;
-	    else
-		p = dxf->name;
-	    output = G_store(p);
-	    if ((p2 = G_rindex(p, '.')))
-		output[p2 - p] = 0;
-	}
-	{
-	    char *p;
-
-	    for (p = output; *p; p++)
-		if (*p == '.')
-		    *p = '_';
-	}
+	output = G_store(opt.output->answer);
 
 
 	layers = opt.layers->answers;
 	layers = opt.layers->answers;
 
 
-	if (!G_check_overwrite(argc, argv) &&
-	    G_find_vector2(output, G_mapset())) {
-	    G_fatal_error(_("Option <%s>: <%s> exists."), opt.output->key,
-			  output);
-	}
-
-	if (Vect_legal_filename(output) < 0)
-	    G_fatal_error(_("Use '%s' option to change vector map name"),
-			  opt.output->key);
-
 	/* create vector map */
 	/* create vector map */
 	Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
 	Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
 	if (Vect_open_new(Map, output, 1) < 0)
 	if (Vect_open_new(Map, output, 1) < 0)

+ 1 - 6
vector/v.kcv/main.c

@@ -59,7 +59,6 @@ int main(int argc, char *argv[])
     struct Map_info In, Out;
     struct Map_info In, Out;
     static struct line_pnts *Points;
     static struct line_pnts *Points;
     struct line_cats *Cats;
     struct line_cats *Cats;
-    char *mapset;
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt, *out_opt, *col_opt, *npart_opt;
     struct Option *in_opt, *out_opt, *col_opt, *npart_opt;
     struct Flag *drand48_flag, *q_flag;
     struct Flag *drand48_flag, *q_flag;
@@ -128,12 +127,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    if (Vect_open_old(&In, in_opt->answer, mapset) < 2) {
+    if (Vect_open_old(&In, in_opt->answer, "") < 2) {
 	G_fatal_error(_("Unable to open vector map <%s> at topological level %d"),
 	G_fatal_error(_("Unable to open vector map <%s> at topological level %d"),
 		      in_opt->answer, 2);
 		      in_opt->answer, 2);
     }
     }

+ 2 - 11
vector/v.kernel/main.c

@@ -82,8 +82,6 @@ int main(int argc, char **argv)
     struct Option *stddev_opt, *dsize_opt, *segmax_opt, *netmax_opt,
     struct Option *stddev_opt, *dsize_opt, *segmax_opt, *netmax_opt,
 	*multip_opt;
 	*multip_opt;
     struct Flag *flag_o, *flag_q;
     struct Flag *flag_o, *flag_q;
-
-    char *mapset;
     struct Map_info In, Net, Out;
     struct Map_info In, Net, Out;
     int fdout = 0, maskfd = 0;
     int fdout = 0, maskfd = 0;
     int row, col;
     int row, col;
@@ -197,11 +195,8 @@ int main(int argc, char **argv)
 	      sigma, window.ew_res, window.rows, window.cols);
 	      sigma, window.ew_res, window.rows, window.cols);
 
 
     /* Open input vector */
     /* Open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
 
 
     if (net_opt->answer) {
     if (net_opt->answer) {
@@ -213,12 +208,8 @@ int main(int argc, char **argv)
 	net = 1;
 	net = 1;
 	dimension = 1.;
 	dimension = 1.;
 	/* Open input network */
 	/* Open input network */
-	if ((mapset = G_find_vector2(net_opt->answer, "")) == NULL)
-	    G_fatal_error(_("Network input map <%s> not found"),
-			  net_opt->answer);
-
 	Vect_set_open_level(2);
 	Vect_set_open_level(2);
-	Vect_open_old(&Net, net_opt->answer, mapset);
+	Vect_open_old(&Net, net_opt->answer, "");
 	Vect_net_build_graph(&Net, GV_LINES, 0, 0, NULL, NULL, NULL, 0, 0);
 	Vect_net_build_graph(&Net, GV_LINES, 0, 0, NULL, NULL, NULL, 0, 0);
 
 
 	if (!flag_q->answer) {
 	if (!flag_q->answer) {

+ 1 - 7
vector/v.label.sa/labels.c

@@ -42,7 +42,6 @@ static double buffer = 0.0;
 label_t *labels_init(struct params *p, int *n_labels)
 label_t *labels_init(struct params *p, int *n_labels)
 {
 {
     label_t *labels;
     label_t *labels;
-    char *mapset;
     int legal_types, layer, i = 0, error, sql_len;
     int legal_types, layer, i = 0, error, sql_len;
     size_t label_sz;
     size_t label_sz;
     struct field_info *fi;
     struct field_info *fi;
@@ -54,13 +53,8 @@ label_t *labels_init(struct params *p, int *n_labels)
     fprintf(stderr, "Initialising labels...");
     fprintf(stderr, "Initialising labels...");
     legal_types = Vect_option_to_types(p->type);
     legal_types = Vect_option_to_types(p->type);
 
 
-    /* open vector */
-    mapset = G_find_vector2(p->map->answer, NULL);
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), p->map->answer);
-
     /* open vector for read only */
     /* open vector for read only */
-    Vect_open_old(&Map, p->map->answer, mapset);
+    Vect_open_old(&Map, p->map->answer, "");
 
 
     label_sz = Vect_get_num_primitives(&Map, legal_types);
     label_sz = Vect_get_num_primitives(&Map, legal_types);
 
 

+ 1 - 6
vector/v.label/main.c

@@ -37,7 +37,6 @@ int main(int argc, char **argv)
     int cat, direction;
     int cat, direction;
     double x, y, linlength, lablength, size, space, ldist;
     double x, y, linlength, lablength, size, space, ldist;
     double rotate, rot;
     double rotate, rot;
-    char *mapset;
     char *txt, buf[2000];
     char *txt, buf[2000];
     struct line_pnts *Points;
     struct line_pnts *Points;
     struct line_cats *Cats;
     struct line_cats *Cats;
@@ -265,11 +264,7 @@ int main(int argc, char **argv)
     }
     }
 
 
     /* open vector */
     /* open vector */
-    mapset = G_find_vector2(Vectfile->answer, NULL);
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), Vectfile->answer);
-
-    Vect_open_old(&Map, Vectfile->answer, mapset);
+    Vect_open_old(&Map, Vectfile->answer, "");
 
 
     /* open database */
     /* open database */
     field = atoi(Fieldopt->answer);
     field = atoi(Fieldopt->answer);

+ 1 - 7
vector/v.neighbors/main.c

@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt, *out_opt;
     struct Option *in_opt, *out_opt;
     struct Option *method_opt, *size_opt;
     struct Option *method_opt, *size_opt;
-    char *mapset;
     struct Map_info In;
     struct Map_info In;
     double radius;
     double radius;
     struct ilist *List;
     struct ilist *List;
@@ -73,13 +72,8 @@ int main(int argc, char *argv[])
     radius = atof(size_opt->answer) / 2;
     radius = atof(size_opt->answer) / 2;
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found in the current mapset"),
-		      in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     G_get_set_window(&region);
     G_get_set_window(&region);
     nrows = G_window_rows();
     nrows = G_window_rows();

+ 1 - 7
vector/v.net.alloc/main.c

@@ -46,7 +46,6 @@ int main(int argc, char **argv)
 	*term_opt;
 	*term_opt;
     struct Flag *geo_f;
     struct Flag *geo_f;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info Map, Out;
     struct Map_info Map, Out;
     struct cat_list *catlist;
     struct cat_list *catlist;
     CENTER *Centers = NULL;
     CENTER *Centers = NULL;
@@ -137,13 +136,8 @@ int main(int argc, char **argv)
     else
     else
 	geo = 0;
 	geo = 0;
 
 
-    mapset = G_find_vector2(map->answer, NULL);
-
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), map->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, mapset);
+    Vect_open_old(&Map, map->answer, "");
 
 
     /* Build graph */
     /* Build graph */
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,

+ 1 - 7
vector/v.net.iso/main.c

@@ -52,7 +52,6 @@ int main(int argc, char **argv)
 	*term_opt, *cost_opt;
 	*term_opt, *cost_opt;
     struct Flag *geo_f;
     struct Flag *geo_f;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info Map, Out;
     struct Map_info Map, Out;
     struct cat_list *catlist;
     struct cat_list *catlist;
     CENTER *Centers = NULL;
     CENTER *Centers = NULL;
@@ -181,13 +180,8 @@ int main(int argc, char **argv)
     else
     else
 	geo = 0;
 	geo = 0;
 
 
-    mapset = G_find_vector2(map->answer, NULL);
-
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), map->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, mapset);
+    Vect_open_old(&Map, map->answer, "");
 
 
     /* Build graph */
     /* Build graph */
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,

+ 1 - 7
vector/v.net.path/main.c

@@ -29,7 +29,6 @@ int main(int argc, char **argv)
     struct Option *max_dist, *file_opt;
     struct Option *max_dist, *file_opt;
     struct Flag *geo_f, *segments_f;
     struct Flag *geo_f, *segments_f;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info In, Out;
     struct Map_info In, Out;
     int type, afield, nfield, geo;
     int type, afield, nfield, geo;
     double maxdist;
     double maxdist;
@@ -125,13 +124,8 @@ int main(int argc, char **argv)
     Vect_check_input_output_name(input_opt->answer, output_opt->answer,
     Vect_check_input_output_name(input_opt->answer, output_opt->answer,
 				 GV_FATAL_EXIT);
 				 GV_FATAL_EXIT);
 
 
-    mapset = G_find_vector2(input_opt->answer, NULL);
-
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), input_opt->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, input_opt->answer, mapset);
+    Vect_open_old(&In, input_opt->answer, "");
 
 
     Vect_set_fatal_error(GV_FATAL_PRINT);
     Vect_set_fatal_error(GV_FATAL_PRINT);
     if (1 > Vect_open_new(&Out, output_opt->answer, Vect_is_3d(&In))) {
     if (1 > Vect_open_new(&Out, output_opt->answer, Vect_is_3d(&In))) {

+ 1 - 7
vector/v.net.salesman/main.c

@@ -79,7 +79,6 @@ int main(int argc, char **argv)
 	*term_opt;
 	*term_opt;
     struct Flag *geo_f;
     struct Flag *geo_f;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info Map, Out;
     struct Map_info Map, Out;
     struct ilist *TList;	/* list of terminal nodes */
     struct ilist *TList;	/* list of terminal nodes */
     struct ilist *List;
     struct ilist *List;
@@ -165,13 +164,8 @@ int main(int argc, char **argv)
 
 
     Vect_check_input_output_name(map->answer, output->answer, GV_FATAL_EXIT);
     Vect_check_input_output_name(map->answer, output->answer, GV_FATAL_EXIT);
 
 
-    mapset = G_find_vector2(map->answer, NULL);
-
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), map->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, mapset);
+    Vect_open_old(&Map, map->answer, "");
     nnodes = Vect_get_num_nodes(&Map);
     nnodes = Vect_get_num_nodes(&Map);
 
 
     /* Create list of terminals based on list of categories */
     /* Create list of terminals based on list of categories */

+ 1 - 7
vector/v.net.steiner/main.c

@@ -326,7 +326,6 @@ int main(int argc, char **argv)
 	*term_opt, *nsp_opt;
 	*term_opt, *nsp_opt;
     struct Flag *geo_f;
     struct Flag *geo_f;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info Map, Out;
     struct Map_info Map, Out;
     int *testnode;		/* array all nodes: 1 - should be tested as Steiner, 
     int *testnode;		/* array all nodes: 1 - should be tested as Steiner, 
 				 * 0 - no need to test (unreachable or terminal) */
 				 * 0 - no need to test (unreachable or terminal) */
@@ -422,13 +421,8 @@ int main(int argc, char **argv)
 
 
     Vect_check_input_output_name(map->answer, output->answer, GV_FATAL_EXIT);
     Vect_check_input_output_name(map->answer, output->answer, GV_FATAL_EXIT);
 
 
-    mapset = G_find_vector2(map->answer, NULL);
-
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), map->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, mapset);
+    Vect_open_old(&Map, map->answer, "");
     nnodes = Vect_get_num_nodes(&Map);
     nnodes = Vect_get_num_nodes(&Map);
 
 
     /* Create list of terminals based on list of categories */
     /* Create list of terminals based on list of categories */

+ 5 - 16
vector/v.net.visibility/main.c

@@ -29,7 +29,6 @@ int main(int argc, char *argv[])
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *input, *output;	/* The input map */
     struct Option *input, *output;	/* The input map */
     struct Option *coor, *ovis;
     struct Option *coor, *ovis;
-    char *mapset;
 
 
     struct Point *points;
     struct Point *points;
     struct Line *lines;
     struct Line *lines;
@@ -73,14 +72,8 @@ int main(int argc, char *argv[])
 
 
     Vect_set_open_level(2);
     Vect_set_open_level(2);
 
 
-    mapset = G_find_vector2(input->answer, NULL);	/* finds the map */
-
-    if (mapset == NULL)
-	G_fatal_error("Vector map <%s> not found", input->answer);
-
-    if (Vect_open_old(&in, input->answer, mapset) < 1)	/* opens the map */
-	G_fatal_error(_("Unable to open vector map <%s>"),
-		      G_fully_qualified_name(input->answer, mapset));
+    if (Vect_open_old(&in, input->answer, "") < 1)	/* opens the map */
+	G_fatal_error(_("Unable to open vector map <%s>"), input->answer);
 
 
     if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0) {
     if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0) {
 	Vect_close(&in);
 	Vect_close(&in);
@@ -88,18 +81,14 @@ int main(int argc, char *argv[])
     }
     }
 
 
     if (ovis->answer != NULL) {
     if (ovis->answer != NULL) {
-	mapset = G_find_vector2(ovis->answer, NULL);
-
-	if (Vect_open_old(&vis, ovis->answer, mapset) < 1)
-	    G_fatal_error(_("Unable to open vector map <%s>"),
-			  G_fully_qualified_name(ovis->answer, mapset));
+	if (Vect_open_old(&vis, ovis->answer, "") < 1)
+	    G_fatal_error(_("Unable to open vector map <%s>"), ovis->answer);
 
 
 	if (Vect_copy_map_lines(&vis, &out) > 0)
 	if (Vect_copy_map_lines(&vis, &out) > 0)
 	    G_fatal_error(_("Unable to copy elements from vector map <%s>"),
 	    G_fatal_error(_("Unable to copy elements from vector map <%s>"),
-			  G_fully_qualified_name(ovis->answer, mapset));
+			  ovis->answer);
     }
     }
 
 
-
     if (G_projection() == PROJECTION_LL)
     if (G_projection() == PROJECTION_LL)
 	G_warning(_("Lat-long projection"));
 	G_warning(_("Lat-long projection"));
 
 

+ 2 - 11
vector/v.net/main.c

@@ -35,7 +35,6 @@ int main(int argc, char **argv)
     struct Flag *cats_flag;
     struct Flag *cats_flag;
     struct Map_info In, Out, Points;
     struct Map_info In, Out, Points;
 
 
-    char *mapset;
     int afield, nfield;
     int afield, nfield;
     int act;
     int act;
     double thresh;
     double thresh;
@@ -136,12 +135,8 @@ int main(int argc, char **argv)
     }
     }
 
 
     /* open input map */
     /* open input map */
-    mapset = G_find_vector2(input->answer, "");
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), input->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, input->answer, mapset);
+    Vect_open_old(&In, input->answer, "");
 
 
     if (act == TOOL_NODES || act == TOOL_CONNECT) {	/* nodes */
     if (act == TOOL_NODES || act == TOOL_CONNECT) {	/* nodes */
 	int is3d;
 	int is3d;
@@ -151,13 +146,9 @@ int main(int argc, char **argv)
 
 
 	if (act == TOOL_CONNECT) {
 	if (act == TOOL_CONNECT) {
 	    /* open points map */
 	    /* open points map */
-	    mapset = G_find_vector2(points->answer, "");
-	    if (mapset == NULL)
-		G_fatal_error(_("Vector map <%s> not found"), points->answer);
-
 	    Vect_set_open_level(1);
 	    Vect_set_open_level(1);
 	    Vect_set_fatal_error(GV_FATAL_PRINT);
 	    Vect_set_fatal_error(GV_FATAL_PRINT);
-	    if (Vect_open_old(&Points, points->answer, mapset) == -1) {
+	    if (Vect_open_old(&Points, points->answer, "") == -1) {
 		Vect_close(&In);
 		Vect_close(&In);
 		G_fatal_error(_("Unable to open vector map <%s>"),
 		G_fatal_error(_("Unable to open vector map <%s>"),
 			      points->answer);
 			      points->answer);

+ 1 - 5
vector/v.normal/main.c

@@ -44,7 +44,6 @@ int scan_cats(char *, long *, long *);
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-    char *mapset;
     int i, nsites, verbose, warn_once = 0;
     int i, nsites, verbose, warn_once = 0;
     int all;
     int all;
     long x, y;
     long x, y;
@@ -124,11 +123,8 @@ int main(int argc, char **argv)
     verbose = (flag.q->answer == (char)NULL) ? 1 : 0;
     verbose = (flag.q->answer == (char)NULL) ? 1 : 0;
 
 
     /* Open input */
     /* Open input */
-    if ((mapset = G_find_vector2(parm.input->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), parm.input->answer);
-    }
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, parm.input->answer, mapset);
+    Vect_open_old(&Map, parm.input->answer, "");
 
 
     /* Read attributes */
     /* Read attributes */
     Fi = Vect_get_field(&Map, 1);
     Fi = Vect_get_field(&Map, 1);

+ 4 - 18
vector/v.out.dxf/main.c

@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
 {
 {
     int nlines;
     int nlines;
     double textsize;
     double textsize;
-    char *mapset, *dxf_file;
+    char *dxf_file;
     struct Map_info In;
     struct Map_info In;
     struct GModule *module;
     struct GModule *module;
     struct Option *input, *output;
     struct Option *input, *output;
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
     output = G_define_option();
     output = G_define_option();
     output->key = "output";
     output->key = "output";
     output->type = TYPE_STRING;
     output->type = TYPE_STRING;
-    output->required = NO;
+    output->required = YES;
     output->multiple = NO;
     output->multiple = NO;
     output->gisprompt = "new_file,file,output";
     output->gisprompt = "new_file,file,output";
     output->description = _("DXF output file");
     output->description = _("DXF output file");
@@ -67,24 +67,10 @@ int main(int argc, char *argv[])
     overwrite = module->overwrite;
     overwrite = module->overwrite;
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(input->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), input->answer);
-
-    if (output->answer)
-	dxf_file = G_store(output->answer);
-    else {
-	char fname[GNAME_MAX];
-	char fmapset[GMAPSET_MAX];
-
-	dxf_file = G_malloc(strlen(input->answer) + 5);
-	if (G__name_is_fully_qualified(input->answer, fname, fmapset))
-	    sprintf(dxf_file, "%s.dxf", fname);
-	else
-	    sprintf(dxf_file, "%s.dxf", input->answer);
-    }
+    dxf_file = G_store(output->answer);
 
 
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, input->answer, mapset);
+    Vect_open_old(&In, input->answer, "");
 
 
     dxf_open(dxf_file);		/* open output */
     dxf_open(dxf_file);		/* open output */
 
 

+ 1 - 6
vector/v.out.ogr/main.c

@@ -39,7 +39,6 @@ char OGRdrivers[2000];
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     int i, j, k, centroid, otype, donocat;
     int i, j, k, centroid, otype, donocat;
-    char *mapset;
     int field;
     int field;
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt, *dsn_opt, *layer_opt, *type_opt, *frmt_opt,
     struct Option *in_opt, *dsn_opt, *layer_opt, *type_opt, *frmt_opt,
@@ -207,12 +206,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* fetch PROJ info */
     /* fetch PROJ info */
     G_get_default_window(&cellhd);
     G_get_default_window(&cellhd);

+ 1 - 6
vector/v.out.pov/main.c

@@ -23,7 +23,6 @@
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     int i, j, centroid, otype, count;
     int i, j, centroid, otype, count;
-    char *mapset;
     int field = 1;
     int field = 1;
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt, *out_opt, *type_opt;
     struct Option *in_opt, *out_opt, *type_opt;
@@ -92,12 +91,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* Open output file */
     /* Open output file */
     if ((fd = fopen(out_opt->answer, "w")) == NULL) {
     if ((fd = fopen(out_opt->answer, "w")) == NULL) {

+ 1 - 6
vector/v.out.svg/main.c

@@ -46,7 +46,6 @@ int main(int argc, char *argv[])
     int do_attr = 0, attr_cols[8], attr_size = 0, db_open = 0, cnt = 0;
     int do_attr = 0, attr_cols[8], attr_size = 0, db_open = 0, cnt = 0;
 
 
     double width, radius;
     double width, radius;
-    char *mapset;
     struct Option *in_opt, *out_opt, *prec_opt, *type_opt, *attr_opt,
     struct Option *in_opt, *out_opt, *prec_opt, *type_opt, *attr_opt,
 	*field_opt;
 	*field_opt;
     struct GModule *module;
     struct GModule *module;
@@ -123,12 +122,8 @@ int main(int argc, char *argv[])
     field = atoi(field_opt->answer);
     field = atoi(field_opt->answer);
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* open db-driver to attribs */
     /* open db-driver to attribs */
     db_init_string(&dbstring);
     db_init_string(&dbstring);

+ 1 - 8
vector/v.overlay/main.c

@@ -29,7 +29,6 @@ int main(int argc, char *argv[])
 {
 {
     int i, input, line, nlines, operator;
     int i, input, line, nlines, operator;
     int type[2], field[2], ofield[3];
     int type[2], field[2], ofield[3];
-    char *mapset[2];
     char *pre[2];
     char *pre[2];
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt[2], *out_opt, *type_opt[2], *field_opt[2],
     struct Option *in_opt[2], *out_opt, *type_opt[2], *field_opt[2],
@@ -193,14 +192,8 @@ int main(int argc, char *argv[])
 	G_message(_("Copying vector objects from vector map <%s>..."),
 	G_message(_("Copying vector objects from vector map <%s>..."),
 		  in_opt[input]->answer);
 		  in_opt[input]->answer);
 
 
-	if ((mapset[input] =
-	     G_find_vector2(in_opt[input]->answer, NULL)) == NULL) {
-	    G_fatal_error(_("Vector map <%s> not found"),
-			  in_opt[input]->answer);
-	}
-
 	Vect_set_open_level(2);
 	Vect_set_open_level(2);
-	Vect_open_old(&(In[input]), in_opt[input]->answer, mapset[input]);
+	Vect_open_old(&(In[input]), in_opt[input]->answer, "");
 
 
 	nlines = Vect_get_num_lines(&(In[input]));
 	nlines = Vect_get_num_lines(&(In[input]));
 
 

+ 1 - 2
vector/v.patch/main.c

@@ -295,8 +295,7 @@ int main(int argc, char *argv[])
 	int add_cat;
 	int add_cat;
 
 
 	in_name = old->answers[i++];
 	in_name = old->answers[i++];
-	G_important_message(_("Patching vector map <%s@%s>..."), in_name,
-			    G_find_vector2(in_name, ""));
+	G_important_message(_("Patching vector map <%s>..."), in_name);
 	if (bbox_name)
 	if (bbox_name)
 	    Vect_set_open_level(2);	/* needed for Vect_map_box() */
 	    Vect_set_open_level(2);	/* needed for Vect_map_box() */
 	else
 	else

+ 1 - 5
vector/v.perturb/main.c

@@ -42,7 +42,6 @@
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-    char *mapset;
     double p1, p2, numbers[1000], numbers2[1000];
     double p1, p2, numbers[1000], numbers2[1000];
     int (*rng) ();
     int (*rng) ();
     int i, verbose;
     int i, verbose;
@@ -150,11 +149,8 @@ int main(int argc, char **argv)
     G_get_window(&window);
     G_get_window(&window);
 
 
     /* Open input */
     /* Open input */
-    if ((mapset = G_find_vector2(parm.in->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), parm.in->answer);
-    }
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, parm.in->answer, mapset);
+    Vect_open_old(&In, parm.in->answer, "");
 
 
     /* Open output */
     /* Open output */
     Vect_open_new(&Out, parm.out->answer, 0);	/* TODO add z support ? */
     Vect_open_new(&Out, parm.out->answer, 0);	/* TODO add z support ? */

+ 1 - 5
vector/v.qcount/main.c

@@ -43,7 +43,6 @@
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-    char *mapset;
     double radius;
     double radius;
     double fisher, david, douglas, lloyd, lloydip, morisita;
     double fisher, david, douglas, lloyd, lloydip, morisita;
     int i, nquads, *counts;
     int i, nquads, *counts;
@@ -110,11 +109,8 @@ int main(int argc, char **argv)
     G_get_window(&window);
     G_get_window(&window);
 
 
     /* Open input */
     /* Open input */
-    if ((mapset = G_find_vector2(parm.input->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), parm.input->answer);
-    }
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, parm.input->answer, mapset);
+    Vect_open_old(&Map, parm.input->answer, "");
 
 
     /* Get the quadrats */
     /* Get the quadrats */
     G_message(_("Finding quadrats..."));
     G_message(_("Finding quadrats..."));

+ 2 - 5
vector/v.reclass/main.c

@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
     /*    struct Flag *d_flag; */
     /*    struct Flag *d_flag; */
     struct Option *in_opt, *out_opt, *type_opt, *field_opt, *rules_opt,
     struct Option *in_opt, *out_opt, *type_opt, *field_opt, *rules_opt,
 	*col_opt;
 	*col_opt;
-    char *mapset, *key, *data, buf[1024];
+    char *key, *data, buf[1024];
     int rclelem, type, field;
     int rclelem, type, field;
     struct Map_info In, Out;
     struct Map_info In, Out;
 
 
@@ -102,11 +102,8 @@ int main(int argc, char *argv[])
     Vect_check_input_output_name(in_opt->answer, out_opt->answer,
     Vect_check_input_output_name(in_opt->answer, out_opt->answer,
 				 GV_FATAL_EXIT);
 				 GV_FATAL_EXIT);
 
 
-    mapset = G_find_vector2(in_opt->answer, NULL);
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
     Vect_copy_head_data(&In, &Out);
     Vect_copy_head_data(&In, &Out);

+ 2 - 9
vector/v.sample/main.c

@@ -50,7 +50,6 @@
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-    char *mapset;
     double scale, predicted, actual;
     double scale, predicted, actual;
     INTERP_TYPE method = UNKNOWN;
     INTERP_TYPE method = UNKNOWN;
     int fdrast;			/* file descriptor for raster map is int */
     int fdrast;			/* file descriptor for raster map is int */
@@ -143,16 +142,10 @@ int main(int argc, char **argv)
     G_get_window(&window);
     G_get_window(&window);
 
 
     /* Open input */
     /* Open input */
-    if ((mapset = G_find_vector2(parm.input->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), parm.input->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, parm.input->answer, mapset);
-
-    if ((mapset = G_find_cell2(parm.rast->answer, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), parm.rast->answer);
+    Vect_open_old(&In, parm.input->answer, "");
 
 
-    if ((fdrast = G_open_cell_old(parm.rast->answer, mapset)) < 0)
+    if ((fdrast = G_open_cell_old(parm.rast->answer, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), parm.rast->answer);
 	G_fatal_error(_("Unable to open raster map <%s>"), parm.rast->answer);
 
 
     /* Read attributes */
     /* Read attributes */

+ 2 - 5
vector/v.segment/main.c

@@ -41,7 +41,7 @@ int main(int argc, char **argv)
     struct Option *in_opt, *out_opt;
     struct Option *in_opt, *out_opt;
     struct Option *lfield_opt, *file_opt;
     struct Option *lfield_opt, *file_opt;
     struct GModule *module;
     struct GModule *module;
-    char *mapset, buf[2000];
+    char buf[2000];
     struct Map_info In, Out;
     struct Map_info In, Out;
     struct line_cats *LCats, *SCats;
     struct line_cats *LCats, *SCats;
     struct line_pnts *LPoints, *SPoints, *PlPoints;
     struct line_pnts *LPoints, *SPoints, *PlPoints;
@@ -94,11 +94,8 @@ int main(int argc, char **argv)
     }
     }
 
 
     /* Open input lines */
     /* Open input lines */
-    mapset = G_find_vector2(in_opt->answer, NULL);
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* Open output segments */
     /* Open output segments */
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));

+ 2 - 8
vector/v.select/main.c

@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
     int aline, nalines;
     int aline, nalines;
     int type[2], field[2];
     int type[2], field[2];
     int **cats, *ncats, nfields, *fields;
     int **cats, *ncats, nfields, *fields;
-    char *mapset[2], *pre[2];
+    char *pre[2];
     struct GModule *module;
     struct GModule *module;
     struct Option *in_opt[2], *out_opt, *type_opt[2], *field_opt[2],
     struct Option *in_opt[2], *out_opt, *type_opt[2], *field_opt[2],
 	*operator_opt;
 	*operator_opt;
@@ -183,14 +183,8 @@ int main(int argc, char *argv[])
 	Vect_check_input_output_name(in_opt[input]->answer, out_opt->answer,
 	Vect_check_input_output_name(in_opt[input]->answer, out_opt->answer,
 				     GV_FATAL_EXIT);
 				     GV_FATAL_EXIT);
 
 
-	if ((mapset[input] =
-	     G_find_vector2(in_opt[input]->answer, NULL)) == NULL) {
-	    G_fatal_error(_("Vector map <%s> not found"),
-			  in_opt[input]->answer);
-	}
-
 	Vect_set_open_level(2);
 	Vect_set_open_level(2);
-	Vect_open_old(&(In[input]), in_opt[input]->answer, mapset[input]);
+	Vect_open_old(&(In[input]), in_opt[input]->answer, "");
     }
     }
 
 
     /* Read field info */
     /* Read field info */

+ 1 - 7
vector/v.support/main.c

@@ -26,7 +26,6 @@
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     struct Map_info Map;
     struct Map_info Map;
-    char *mapset;
     struct GModule *module;
     struct GModule *module;
     struct Option *map, *organization, *date, *person, *map_name, *map_date,
     struct Option *map, *organization, *date, *person, *map_name, *map_date,
 	*scale, *comment, *zone, *thresh, *cmdhist;
 	*scale, *comment, *zone, *thresh, *cmdhist;
@@ -125,13 +124,8 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 	exit(EXIT_FAILURE);
 
 
-    if ((mapset = G_find_vector2(map->answer, G_mapset())) == NULL)
-	G_fatal_error(_("Vector map <%s> not found in the current mapset"),
-		      map->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-
-    if (1 > Vect_open_old(&Map, map->answer, mapset))
+    if (Vect_open_old(&Map, map->answer, "") < 1)
 	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
 	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
 
 
     /* modify 'head' file */
     /* modify 'head' file */

+ 132 - 191
vector/v.surf.rst/main.c

@@ -50,86 +50,73 @@
 #define SCIK2 1			/*100000 */
 #define SCIK2 1			/*100000 */
 #define SCIK3 1			/*100000 */
 #define SCIK3 1			/*100000 */
 
 
-double /* pargr */ ns_res, ew_res;
-double dmin, dmax, ertre;
-int KMAX2, KMIN, KMAX, totsegm, deriv, dtens, cv;
-struct Map_info Map;
-struct Map_info TreeMap, OverMap;
-struct Categories cats;
+static double /* pargr */ ns_res, ew_res;
+static double dmin, dmax, ertre;
+static int KMAX2, KMIN, KMAX, totsegm, deriv, dtens, cv;
+static struct Map_info Map;
+static struct Map_info TreeMap, OverMap;
 
 
-struct interp_params params;
-struct tree_info *info;
+static struct interp_params params;
+static struct tree_info *info;
 
 
-void clean_fatal_error();
+static void create_temp_files(void);
+static void clean(void);
 
 
-double *az = NULL, *adx = NULL, *ady = NULL, *adxx = NULL, *adyy = NULL,
+static double *az = NULL, *adx = NULL, *ady = NULL, *adxx = NULL, *adyy = NULL,
     *adxy = NULL;
     *adxy = NULL;
-double /* error */ ertot, ertre, zminac, zmaxac, zmult;
+static double /* error */ ertot, ertre, zminac, zmaxac, zmult;
 struct multtree *root;
 struct multtree *root;
 
 
-int total = 0;
-int NPOINT = 0;
-int OUTRANGE = 0;
-int NPT = 0;
-
-double DETERM;
-int NERROR, cond1, cond2;
-char fncdsm[32];
-char filnam[10];
-
-char *treefile = NULL;
-char *overfile = NULL;
-
-FILE *fdinp, *fdredinp, *fdzout, *fddxout, *fddyout, *fdxxout, *fdyyout,
-    *fd4, *fxyout, *fddevi = NULL, *fdcvdev = NULL;
-
-FCELL *zero_array_cell;
-
-char *input;
-int field;
-char *zcol;
-char *scol;
-char *wheresql;
-char *mapset = NULL;
-char *mapset1 = NULL;
-char *elev = NULL;
-char *slope = NULL;
-char *aspect = NULL;
-char *pcurv = NULL;
-char *tcurv = NULL;
-char *mcurv = NULL;
-char *maskmap = NULL;
-char *redinp = NULL;
-char *devi = NULL;
-char *cvdev = NULL;
-int sdisk, disk, ddisk, sddisk;
-FILE *Tmp_fd_z = NULL;
-char *Tmp_file_z = NULL;
-FILE *Tmp_fd_dx = NULL;
-char *Tmp_file_dx = NULL;
-FILE *Tmp_fd_dy = NULL;
-char *Tmp_file_dy = NULL;
-FILE *Tmp_fd_xx = NULL;
-char *Tmp_file_xx = NULL;
-FILE *Tmp_fd_yy = NULL;
-char *Tmp_file_yy = NULL;
-FILE *Tmp_fd_xy = NULL;
-char *Tmp_file_xy = NULL;
-
-double gmin, gmax, c1min, c1max, c2min, c2max, fi, rsm;
-double xmin, xmax, ymin, ymax, zmin, zmax;
-double theta, scalex;
-
-struct BM *bitmask;
-struct Cell_head cellhd;
-
-char msg[1024];
-
+static int NPOINT = 0;
+
+static int cond1, cond2;
+
+static char *treefile = NULL;
+static char *overfile = NULL;
+
+static FCELL *zero_array_cell;
+
+static char *input;
+static int field;
+static char *zcol;
+static char *scol;
+static char *wheresql;
+static char *elev = NULL;
+static char *slope = NULL;
+static char *aspect = NULL;
+static char *pcurv = NULL;
+static char *tcurv = NULL;
+static char *mcurv = NULL;
+static char *maskmap = NULL;
+static char *devi = NULL;
+static char *cvdev = NULL;
+static int sdisk, disk, ddisk, sddisk;
+static FILE *Tmp_fd_z = NULL;
+static char *Tmp_file_z = NULL;
+static FILE *Tmp_fd_dx = NULL;
+static char *Tmp_file_dx = NULL;
+static FILE *Tmp_fd_dy = NULL;
+static char *Tmp_file_dy = NULL;
+static FILE *Tmp_fd_xx = NULL;
+static char *Tmp_file_xx = NULL;
+static FILE *Tmp_fd_yy = NULL;
+static char *Tmp_file_yy = NULL;
+static FILE *Tmp_fd_xy = NULL;
+static char *Tmp_file_xy = NULL;
+
+static double gmin, gmax, c1min, c1max, c2min, c2max, fi, rsm;
+static double xmin, xmax, ymin, ymax, zmin, zmax;
+static double theta, scalex;
+
+static struct BM *bitmask;
+static struct Cell_head cellhd;
+
+static int n_rows, n_cols;
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     int per, npmin;
     int per, npmin;
-    int ii, i, n_rows, n_cols;
+    int ii;
     double x_orig, y_orig, dnorm, deltx, delty, xm, ym;
     double x_orig, y_orig, dnorm, deltx, delty, xm, ym;
     char dmaxchar[200];
     char dmaxchar[200];
     char dminchar[200];
     char dminchar[200];
@@ -514,10 +501,7 @@ int main(int argc, char *argv[])
     if ((info = MT_tree_info_new(root, functions, dmin, KMAX)) == NULL)
     if ((info = MT_tree_info_new(root, functions, dmin, KMAX)) == NULL)
 	G_fatal_error(_("Cannot create tree info"));
 	G_fatal_error(_("Cannot create tree info"));
 
 
-    if ((mapset = G_find_vector2(input, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), input);
-
-    open_check = Vect_open_old(&Map, input, mapset);
+    open_check = Vect_open_old(&Map, input, "");
     if (open_check < 1)
     if (open_check < 1)
 	G_fatal_error(_("Unable to open vector map <%s>"), input);
 	G_fatal_error(_("Unable to open vector map <%s>"), input);
     /*    if (open_check < 2)
     /*    if (open_check < 2)
@@ -572,82 +556,8 @@ int main(int argc, char *argv[])
     ertot = 0.;
     ertot = 0.;
     if (per)
     if (per)
 	G_message(_("Percent complete: "));
 	G_message(_("Percent complete: "));
-    if (elev != NULL)
-	Tmp_file_z = G_tempfile();
-    if (slope != NULL)
-	Tmp_file_dx = G_tempfile();
-    if (aspect != NULL)
-	Tmp_file_dy = G_tempfile();
-    if (pcurv != NULL)
-	Tmp_file_xx = G_tempfile();
-    if (tcurv != NULL)
-	Tmp_file_yy = G_tempfile();
-    if (mcurv != NULL)
-	Tmp_file_xy = G_tempfile();
-
-    zero_array_cell = (FCELL *) G_malloc(sizeof(FCELL) * n_cols);
-    if (!zero_array_cell)
-	G_fatal_error(_("Not enough memory for zero_array_cell"));
-
-    for (i = 0; i < n_cols; i++) {
-	zero_array_cell[i] = (FCELL) 0;
-    }
-
-    if (Tmp_file_z != NULL) {
-	if (NULL == (Tmp_fd_z = fopen(Tmp_file_z, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_z);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_z)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (Tmp_file_dx != NULL) {
-	if (NULL == (Tmp_fd_dx = fopen(Tmp_file_dx, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_dx);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_dx)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (Tmp_file_dy != NULL) {
-	if (NULL == (Tmp_fd_dy = fopen(Tmp_file_dy, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_dy);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_dy)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
 
 
-    if (Tmp_file_xx != NULL) {
-	if (NULL == (Tmp_fd_xx = fopen(Tmp_file_xx, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_xx);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_xx)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (Tmp_file_yy != NULL) {
-	if (NULL == (Tmp_fd_yy = fopen(Tmp_file_yy, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_yy);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_yy)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (Tmp_file_xy != NULL) {
-	if (NULL == (Tmp_fd_xy = fopen(Tmp_file_xy, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_xy);
-	for (i = 0; i < n_rows; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_xy)))
-		G_fatal_error(_("Not enough disk space -- cannot write files"));
-	}
-    }
+    create_temp_files();
 
 
     IL_init_params_2d(&params, NULL, 1, 1, zmult, KMIN, KMAX, maskmap, n_rows,
     IL_init_params_2d(&params, NULL, 1, 1, zmult, KMIN, KMAX, maskmap, n_rows,
 		      n_cols, az, adx, ady, adxx, adyy, adxy, fi, KMAX2,
 		      n_cols, az, adx, ady, adxx, adyy, adxy, fi, KMAX2,
@@ -665,16 +575,18 @@ int main(int argc, char *argv[])
 	IL_vector_input_data_2d(&params, &Map, field, zcol, scol,
 	IL_vector_input_data_2d(&params, &Map, field, zcol, scol,
 				info, &xmin, &xmax,
 				info, &xmin, &xmax,
 				&ymin, &ymax, &zmin, &zmax, &NPOINT, &dmax);
 				&ymin, &ymax, &zmin, &zmax, &NPOINT, &dmax);
-    if (totsegm <= 0)
-	clean_fatal_error(_("Input failed"));
+    if (totsegm <= 0) {
+	clean();
+	G_fatal_error(_("Input failed"));
+    }
 
 
     /*Vect_set_release_support(&Map); */
     /*Vect_set_release_support(&Map); */
     Vect_close(&Map);
     Vect_close(&Map);
 
 
     if (treefile != NULL) {
     if (treefile != NULL) {
 	if (0 > Vect_open_new(&TreeMap, treefile, 0)) {
 	if (0 > Vect_open_new(&TreeMap, treefile, 0)) {
-	    sprintf(msg, _("Unable to open vector map <%s>"), treefile);
-	    clean_fatal_error(msg);
+	    clean();
+	    G_fatal_error(_("Unable to open vector map <%s>"), treefile);
 	}
 	}
 	Vect_hist_command(&TreeMap);
 	Vect_hist_command(&TreeMap);
 
 
@@ -717,8 +629,10 @@ int main(int argc, char *argv[])
     }
     }
 
 
     bitmask = IL_create_bitmask(&params);
     bitmask = IL_create_bitmask(&params);
-    if (totsegm <= 0)
-	clean_fatal_error(_("Input failed"));
+    if (totsegm <= 0) {
+	clean();
+	G_fatal_error(_("Input failed"));
+    }
 
 
     ertot = 0.;
     ertot = 0.;
     if (per)
     if (per)
@@ -726,9 +640,10 @@ int main(int argc, char *argv[])
     if (IL_interp_segments_2d(&params, info, info->root, bitmask,
     if (IL_interp_segments_2d(&params, info, info->root, bitmask,
 			      zmin, zmax, &zminac, &zmaxac, &gmin, &gmax,
 			      zmin, zmax, &zminac, &zmaxac, &gmin, &gmax,
 			      &c1min, &c1max, &c2min, &c2max, &ertot, totsegm,
 			      &c1min, &c1max, &c2min, &c2max, &ertot, totsegm,
-			      n_cols, dnorm) < 0)
-
-	clean_fatal_error(_("Interp_segmets failed"));
+			      n_cols, dnorm) < 0) {
+	clean();
+	G_fatal_error(_("Interp_segmets failed"));
+    }
 
 
     G_free_vector(az);
     G_free_vector(az);
     if (cond1) {
     if (cond1) {
@@ -743,9 +658,11 @@ int main(int argc, char *argv[])
     ii = IL_output_2d(&params, &cellhd, zmin, zmax, zminac, zmaxac, c1min,
     ii = IL_output_2d(&params, &cellhd, zmin, zmax, zminac, zmaxac, c1min,
 		      c1max, c2min, c2max, gmin, gmax, ertot, input, dnorm,
 		      c1max, c2min, c2max, gmin, gmax, ertot, input, dnorm,
 		      dtens, 1, NPOINT);
 		      dtens, 1, NPOINT);
-    if (ii < 0)
-	clean_fatal_error
-	    (_("Cannot write raster maps -- try to increase resolution"));
+    if (ii < 0) {
+	clean();
+	G_fatal_error(_("Cannot write raster maps -- try to increase resolution"));
+    }
+
     G_free(zero_array_cell);
     G_free(zero_array_cell);
     if (elev != NULL)
     if (elev != NULL)
 	fclose(Tmp_fd_z);
 	fclose(Tmp_fd_z);
@@ -762,8 +679,8 @@ int main(int argc, char *argv[])
 
 
     if (overfile != NULL) {
     if (overfile != NULL) {
 	if (0 > Vect_open_new(&OverMap, overfile, 0)) {
 	if (0 > Vect_open_new(&OverMap, overfile, 0)) {
-	    sprintf(msg, _("Unable to open vector map <%s>"), overfile);
-	    clean_fatal_error(msg);
+	    clean();
+	    G_fatal_error(_("Unable to open vector map <%s>"), overfile);
 	}
 	}
 	Vect_hist_command(&OverMap);
 	Vect_hist_command(&OverMap);
 
 
@@ -835,8 +752,10 @@ int print_tree(struct multtree *tree,
 	xarray[2] = xarray[3];
 	xarray[2] = xarray[3];
 	yarray[4] = yarray[0];
 	yarray[4] = yarray[0];
 	xarray[4] = xarray[0];
 	xarray[4] = xarray[0];
-	if (0 > Vect_copy_xyz_to_pnts(Points, xarray, yarray, zarray, 5))
-	    clean_fatal_error(_("Out of memory"));
+	if (Vect_copy_xyz_to_pnts(Points, xarray, yarray, zarray, 5) < 0) {
+	    clean();
+	    G_fatal_error(_("Out of memory"));
+	}
 	Vect_write_line(Map, (unsigned int)type, Points, Cats);
 	Vect_write_line(Map, (unsigned int)type, Points, Cats);
 
 
 	G_free(Points);
 	G_free(Points);
@@ -844,33 +763,55 @@ int print_tree(struct multtree *tree,
     return 1;
     return 1;
 }
 }
 
 
+static FILE *create_temp_file(const char *name, char **tmpname)
+{
+    FILE *fp;
+    char *tmp;
+    int i;
+
+    if (!name)
+	return NULL;
+
+    *tmpname = tmp = G_tempfile();
+    fp = fopen(tmp, "w+");
+    if (!fp)
+	G_fatal_error(_("Unable to open temporary file <%s>"), tmpname);
+
+    for (i = 0; i < n_rows; i++) {
+	if (fwrite(zero_array_cell, sizeof(FCELL), n_cols, fp) != n_cols) {
+	    clean();
+	    G_fatal_error(_("Error writing temporary file <%s>"), tmpname);
+	}
+    }
 
 
+    return fp;
+}
 
 
-void clean_fatal_error(char *str)
+static void create_temp_files(void)
 {
 {
-    if (Tmp_fd_z) {
-	fclose(Tmp_fd_z);
-	unlink(Tmp_file_z);
-    }
-    if (Tmp_fd_dx) {
-	fclose(Tmp_fd_dx);
-	unlink(Tmp_file_dx);
-    }
-    if (Tmp_fd_dy) {
-	fclose(Tmp_fd_dy);
-	unlink(Tmp_file_dy);
-    }
-    if (Tmp_fd_xx) {
-	fclose(Tmp_fd_xx);
-	unlink(Tmp_file_xx);
-    }
-    if (Tmp_fd_yy) {
-	fclose(Tmp_fd_yy);
-	unlink(Tmp_file_yy);
-    }
-    if (Tmp_fd_xy) {
-	fclose(Tmp_fd_xy);
-	unlink(Tmp_file_xy);
-    }
-    G_fatal_error(str);
+    zero_array_cell = (FCELL *) G_calloc(n_cols, sizeof(FCELL));
+
+    Tmp_fd_z  = create_temp_file(elev,   &Tmp_file_z );
+    Tmp_fd_dx = create_temp_file(slope,  &Tmp_file_dx);
+    Tmp_fd_dy = create_temp_file(aspect, &Tmp_file_dy);
+    Tmp_fd_xx = create_temp_file(pcurv,  &Tmp_file_xx);
+    Tmp_fd_yy = create_temp_file(tcurv,  &Tmp_file_yy);
+    Tmp_fd_xy = create_temp_file(mcurv,  &Tmp_file_xy);
+}
+
+static void clean(void)
+{
+    if (Tmp_fd_z)	fclose(Tmp_fd_z);
+    if (Tmp_fd_dx)	fclose(Tmp_fd_dx);
+    if (Tmp_fd_dy)	fclose(Tmp_fd_dy);
+    if (Tmp_fd_xx)	fclose(Tmp_fd_xx);
+    if (Tmp_fd_yy)	fclose(Tmp_fd_yy);
+    if (Tmp_fd_xy)	fclose(Tmp_fd_xy);
+
+    if (Tmp_file_z)	unlink(Tmp_file_z);
+    if (Tmp_file_dx)	unlink(Tmp_file_dx);
+    if (Tmp_file_dy)	unlink(Tmp_file_dy);
+    if (Tmp_file_xx)	unlink(Tmp_file_xx);
+    if (Tmp_file_yy)	unlink(Tmp_file_yy);
+    if (Tmp_file_xy)	unlink(Tmp_file_xy);
 }
 }

+ 0 - 1
vector/v.surf.rst/surf.h

@@ -33,4 +33,3 @@
 #define ZMULT   "1.0"
 #define ZMULT   "1.0"
 
 
 int print_tree(struct multtree *, double, double, struct Map_info *);
 int print_tree(struct multtree *, double, double, struct Map_info *);
-void clean_fatal_error(char *);

+ 0 - 1
vector/v.to.db/global.h

@@ -21,7 +21,6 @@ extern struct value *Values;
 struct options
 struct options
 {
 {
     char *name;
     char *name;
-    char *mapset;
     int field;
     int field;
     char *col[3];
     char *col[3];
     char *qcol;
     char *qcol;

+ 1 - 1
vector/v.to.db/main.c

@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
 
 
     /* open map */
     /* open map */
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, options.name, options.mapset);
+    Vect_open_old(&Map, options.name, "");
 
 
     Fi = Vect_get_field(&Map, options.field);
     Fi = Vect_get_field(&Map, options.field);
 
 

+ 0 - 4
vector/v.to.db/parse.c

@@ -114,10 +114,6 @@ int parse_command_line(int argc, char *argv[])
     options.total = flags.t->answer;
     options.total = flags.t->answer;
 
 
     options.name = parms.vect->answer;
     options.name = parms.vect->answer;
-    options.mapset = G_find_vector2(options.name, NULL);
-
-    if (options.mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), options.name);
 
 
     options.type = Vect_option_to_types(parms.type);
     options.type = Vect_option_to_types(parms.type);
     options.field = atoi(parms.field->answer);
     options.field = atoi(parms.field->answer);

+ 1 - 6
vector/v.to.points/main.c

@@ -161,7 +161,6 @@ int main(int argc, char **argv)
     struct Option *in_opt, *out_opt, *type_opt, *dmax_opt, *lfield_opt;
     struct Option *in_opt, *out_opt, *type_opt, *dmax_opt, *lfield_opt;
     struct Flag *inter_flag, *vertex_flag, *table_flag, *node_flag;
     struct Flag *inter_flag, *vertex_flag, *table_flag, *node_flag;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
     struct Map_info In, Out;
     struct Map_info In, Out;
     struct line_cats *LCats;
     struct line_cats *LCats;
     struct line_pnts *LPoints;
     struct line_pnts *LPoints;
@@ -239,12 +238,8 @@ int main(int argc, char **argv)
 				 GV_FATAL_EXIT);
 				 GV_FATAL_EXIT);
 
 
     /* Open input lines */
     /* Open input lines */
-    mapset = G_find_vector2(in_opt->answer, NULL);
-    if (mapset == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* Open output segments */
     /* Open output segments */
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
     Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));

+ 8 - 8
vector/v.to.rast/local.h

@@ -44,15 +44,15 @@ int set_cat(CELL);
 int set_dcat(DCELL);
 int set_dcat(DCELL);
 
 
 /* support.c */
 /* support.c */
-int update_hist(char *, char *, char *, long);
-int update_colors(char *);
-int update_dbcolors(char *, char *, int, char *, int, char *);
-int update_labels(char *, char *, int, char *, int, int, char *);
-int update_cats(char *);
-int update_fcolors(char *raster_name);
+int update_hist(const char *, const char *, long);
+int update_colors(const char *);
+int update_dbcolors(const char *, const char *, int, const char *, int, const char *);
+int update_labels(const char *, const char *, int, const char *, int, int, const char *);
+int update_cats(const char *);
+int update_fcolors(const char *);
 
 
 /* vect2rast.c */
 /* vect2rast.c */
-int vect_to_rast(char *, char *, int, char *, int, int, double, int, char *,
-		 char *, int);
+int vect_to_rast(const char *, const char *, int, const char *, int, int,
+		 double, int, const char *, const char *, int);
 
 
 #endif
 #endif

+ 14 - 21
vector/v.to.rast/support.c

@@ -14,8 +14,7 @@
 #include "local.h"
 #include "local.h"
 
 
 
 
-int update_hist(char *raster_name, char *vector_name,
-		char *vector_mapset, long scale)
+int update_hist(const char *raster_name, const char *vector_name, long scale)
 {
 {
     struct History hist;
     struct History hist;
 
 
@@ -28,8 +27,7 @@ int update_hist(char *raster_name, char *vector_name,
     strcpy(hist.title, raster_name);
     strcpy(hist.title, raster_name);
 
 
     /* store information from digit file into history */
     /* store information from digit file into history */
-    sprintf(hist.datsrc_1, "Vector Map: %s in mapset %s", vector_name,
-	    vector_mapset);
+    sprintf(hist.datsrc_1, "Vector Map: %s", vector_name);
     sprintf(hist.datsrc_2, "Original scale from vector map: 1:%ld", scale);	/* 4.0 */
     sprintf(hist.datsrc_2, "Original scale from vector map: 1:%ld", scale);	/* 4.0 */
 
 
     /* store command line options */
     /* store command line options */
@@ -39,7 +37,7 @@ int update_hist(char *raster_name, char *vector_name,
 }
 }
 
 
 
 
-int update_colors(char *raster_name)
+int update_colors(const char *raster_name)
 {
 {
     struct Range range;
     struct Range range;
     struct Colors colors;
     struct Colors colors;
@@ -54,7 +52,7 @@ int update_colors(char *raster_name)
 }
 }
 
 
 
 
-int update_fcolors(char *raster_name)
+int update_fcolors(const char *raster_name)
 {
 {
     struct FPRange range;
     struct FPRange range;
     struct Colors colors;
     struct Colors colors;
@@ -69,22 +67,21 @@ int update_fcolors(char *raster_name)
 }
 }
 
 
 
 
-int update_cats(char *raster_name)
+int update_cats(const char *raster_name)
 {
 {
     /* TODO: maybe attribute transfer from vector map? 
     /* TODO: maybe attribute transfer from vector map? 
        Use G_set_raster_cat() somewhere */
        Use G_set_raster_cat() somewhere */
 
 
     struct Categories cats;
     struct Categories cats;
 
 
-    G_strip(raster_name);
     G_init_cats((CELL) 0, raster_name, &cats);
     G_init_cats((CELL) 0, raster_name, &cats);
     G_write_cats(raster_name, &cats);
     G_write_cats(raster_name, &cats);
 
 
     return 0;
     return 0;
 }
 }
 
 
-int update_dbcolors(char *rast_name, char *vector_map, int field,
-		    char *rgb_column, int is_fp, char *attr_column)
+int update_dbcolors(const char *rast_name, const char *vector_map, int field,
+		    const char *rgb_column, int is_fp, const char *attr_column)
 {
 {
     int i;
     int i;
 
 
@@ -119,7 +116,7 @@ int update_dbcolors(char *rast_name, char *vector_map, int field,
     G_init_colors(&colors);
     G_init_colors(&colors);
 
 
     /* open vector map and database driver */
     /* open vector map and database driver */
-    Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, ""));
+    Vect_open_old(&Map, vector_map, "");
 
 
     db_CatValArray_init(&cvarr);
     db_CatValArray_init(&cvarr);
     if ((Fi = Vect_get_field(&Map, field)) == NULL)
     if ((Fi = Vect_get_field(&Map, field)) == NULL)
@@ -231,8 +228,9 @@ int update_dbcolors(char *rast_name, char *vector_map, int field,
 
 
 
 
 /* add labels to raster cells */
 /* add labels to raster cells */
-int update_labels(char *rast_name, char *vector_map, int field,
-		  char *label_column, int use, int val, char *attr_column)
+int update_labels(const char *rast_name, const char *vector_map, int field,
+		  const char *label_column, int use, int val,
+		  const char *attr_column)
 {
 {
     int i;
     int i;
     int fd;
     int fd;
@@ -414,15 +412,12 @@ int update_labels(char *rast_name, char *vector_map, int field,
 	    struct Cell_stats stats;
 	    struct Cell_stats stats;
 	    CELL n;
 	    CELL n;
 	    RASTER_MAP_TYPE map_type;
 	    RASTER_MAP_TYPE map_type;
-	    char *mapset;
 	    long count;
 	    long count;
 
 
-	    mapset = G_mapset();
-
-	    if (!(fd = G_open_cell_old(rast_name, mapset)))
+	    if (!(fd = G_open_cell_old(rast_name, G_mapset())))
 		G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
 		G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
 
 
-	    map_type = G_raster_map_type(rast_name, mapset);
+	    map_type = G_raster_map_type(rast_name, G_mapset());
 
 
 	    if (!(rowbuf = G_allocate_raster_buf(map_type)))
 	    if (!(rowbuf = G_allocate_raster_buf(map_type)))
 		G_fatal_error(_("Cannot allocate memory for row buffer"));
 		G_fatal_error(_("Cannot allocate memory for row buffer"));
@@ -456,12 +451,10 @@ int update_labels(char *rast_name, char *vector_map, int field,
 	{
 	{
 	    DCELL fmin, fmax;
 	    DCELL fmin, fmax;
 	    RASTER_MAP_TYPE map_type;
 	    RASTER_MAP_TYPE map_type;
-	    char *mapset;
 	    int i;
 	    int i;
 	    char msg[64];
 	    char msg[64];
 
 
-	    mapset = G_mapset();
-	    map_type = G_raster_map_type(rast_name, mapset);
+	    map_type = G_raster_map_type(rast_name, G_mapset());
 	    G_set_raster_cats_title("Degrees", &rast_cats);
 	    G_set_raster_cats_title("Degrees", &rast_cats);
 
 
 	    for (i = 1; i <= 360; i++) {
 	    for (i = 1; i <= 360; i++) {

+ 6 - 9
vector/v.to.rast/vect2rast.c

@@ -6,14 +6,14 @@
 #include "local.h"
 #include "local.h"
 
 
 
 
-int vect_to_rast(char *vector_map, char *raster_map, int field, char *column,
-		 int nrows, int use, double value, int value_type,
-		 char *rgbcolumn, char *labelcolumn, int ftype)
+int vect_to_rast(const char *vector_map, const char *raster_map, int field,
+		 const char *column, int nrows, int use, double value,
+		 int value_type, const char *rgbcolumn, const char *labelcolumn,
+		 int ftype)
 {
 {
 #ifdef DEBUG
 #ifdef DEBUG
     int i;
     int i;
 #endif
 #endif
-    char *vector_mapset;
     struct Map_info Map;
     struct Map_info Map;
     struct line_pnts *Points;
     struct line_pnts *Points;
     int fd;			/* for raster map */
     int fd;			/* for raster map */
@@ -33,12 +33,9 @@ int vect_to_rast(char *vector_map, char *raster_map, int field, char *column,
 
 
     nareas = 0;
     nareas = 0;
 
 
-    if ((vector_mapset = G_find_vector2(vector_map, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), vector_map);
-
     G_debug(1, "Loading vector information...");
     G_debug(1, "Loading vector information...");
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, vector_map, vector_mapset);
+    Vect_open_old(&Map, vector_map, "");
 
 
     if ((use == USE_Z) && !(Vect_is_3d(&Map)))
     if ((use == USE_Z) && !(Vect_is_3d(&Map)))
 	G_fatal_error(_("Vector map <%s> is not 3D"),
 	G_fatal_error(_("Vector map <%s> is not 3D"),
@@ -201,7 +198,7 @@ int vect_to_rast(char *vector_map, char *raster_map, int field, char *column,
 
 
     G_debug(1, "Creating support files for raster map...");
     G_debug(1, "Creating support files for raster map...");
     G_close_cell(fd);
     G_close_cell(fd);
-    update_hist(raster_map, vector_map, vector_mapset, Map.head.orig_scale);
+    update_hist(raster_map, vector_map, Map.head.orig_scale);
 
 
     /* colors */
     /* colors */
     if (rgbcolumn) {
     if (rgbcolumn) {

+ 2 - 5
vector/v.transform/main.c

@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
 	*xscale, *yscale, *zscale, *zrot, *columns, *table, *field;
 	*xscale, *yscale, *zscale, *zrot, *columns, *table, *field;
     struct Flag *quiet_flag, *tozero_flag, *shift_flag, *print_mat_flag;
     struct Flag *quiet_flag, *tozero_flag, *shift_flag, *print_mat_flag;
 
 
-    char *mapset, mon[4], date[40], buf[1000];
+    char mon[4], date[40], buf[1000];
     struct Map_info Old, New;
     struct Map_info Old, New;
     int day, yr;
     int day, yr;
     BOUND_BOX box;
     BOUND_BOX box;
@@ -244,10 +244,7 @@ int main(int argc, char *argv[])
     }
     }
 
 
     /* open vector maps */
     /* open vector maps */
-    if ((mapset = G_find_vector2(vold->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), vold->answer);
-
-    Vect_open_old(&Old, vold->answer, mapset);
+    Vect_open_old(&Old, vold->answer, "");
 
 
     Vect_open_new(&New, vnew->answer, Vect_is_3d(&Old) || zshift->answer);
     Vect_open_new(&New, vnew->answer, Vect_is_3d(&Old) || zshift->answer);
 
 

+ 1 - 6
vector/v.type/main.c

@@ -30,7 +30,6 @@ int main(int argc, char *argv[])
     static struct line_pnts *Points;
     static struct line_pnts *Points;
     struct line_cats *Cats;
     struct line_cats *Cats;
     int type;
     int type;
-    char *mapset;
     struct GModule *module;
     struct GModule *module;
 
 
 #ifdef FOR_GRASS7
 #ifdef FOR_GRASS7
@@ -198,12 +197,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(1);
     Vect_set_open_level(1);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     Vect_set_fatal_error(GV_FATAL_PRINT);
     Vect_set_fatal_error(GV_FATAL_PRINT);
     if (0 > Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In))) {
     if (0 > Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In))) {

+ 1 - 5
vector/v.univar/main.c

@@ -31,7 +31,6 @@ int main(int argc, char *argv[])
     struct Option *map_opt, *type_opt, *field_opt, *col_opt, *where_opt,
     struct Option *map_opt, *type_opt, *field_opt, *col_opt, *where_opt,
 	*percentile;
 	*percentile;
     struct Flag *shell_flag, *extended;
     struct Flag *shell_flag, *extended;
-    char *mapset;
     struct Map_info Map;
     struct Map_info Map;
     struct field_info *Fi;
     struct field_info *Fi;
     dbDriver *Driver;
     dbDriver *Driver;
@@ -112,11 +111,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open input vector */
     /* open input vector */
-    if ((mapset = G_find_vector2(map_opt->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), map_opt->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map_opt->answer, mapset);
+    Vect_open_old(&Map, map_opt->answer, "");
 
 
     /* Check if types are compatible */
     /* Check if types are compatible */
     if ((otype & GV_POINTS) && ((otype & GV_LINES) || (otype & GV_AREA)))
     if ((otype & GV_POINTS) && ((otype & GV_LINES) || (otype & GV_AREA)))

+ 1 - 6
vector/v.voronoi/dt_main.c

@@ -31,7 +31,6 @@
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-    char *mapset;
     struct Flag *reg_flag, *line_flag;
     struct Flag *reg_flag, *line_flag;
     struct Option *in_opt, *out_opt;
     struct Option *in_opt, *out_opt;
     struct GModule *module;
     struct GModule *module;
@@ -72,12 +71,8 @@ int main(int argc, char **argv)
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open files */
     /* open files */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
     /* check if we have a 3D input points map */
     /* check if we have a 3D input points map */
     mode3d = 0;
     mode3d = 0;

+ 2 - 8
vector/v.voronoi/vo_main.c

@@ -99,7 +99,6 @@ int main(int argc, char **argv)
 {
 {
     int i;
     int i;
     int **cats, *ncats, nfields, *fields;
     int **cats, *ncats, nfields, *fields;
-    char *mapset;
     struct Flag *line_flag;
     struct Flag *line_flag;
 
 
     /* struct Flag *all_flag; */
     /* struct Flag *all_flag; */
@@ -152,16 +151,11 @@ int main(int argc, char **argv)
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
 
 
     /* open files */
     /* open files */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    Vect_open_old(&In, in_opt->answer, "");
 
 
-    if (0 > Vect_open_new(&Out, out_opt->answer, 0)) {
+    if (Vect_open_new(&Out, out_opt->answer, 0) < 0)
 	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
-    }
 
 
     Vect_hist_copy(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
     Vect_hist_command(&Out);

+ 3 - 10
vector/v.what.rast/main.c

@@ -41,7 +41,6 @@ static int srch_cat(const void *, const void *);
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
-    char *mapset;
     int i, j, nlines, type, field, cat;
     int i, j, nlines, type, field, cat;
     int fd;
     int fd;
 
 
@@ -115,11 +114,8 @@ int main(int argc, char *argv[])
     Vect_region_box(&window, &box);	/* T and B set to +/- PORT_DOUBLE_MAX */
     Vect_region_box(&window, &box);	/* T and B set to +/- PORT_DOUBLE_MAX */
 
 
     /* Open vector */
     /* Open vector */
-    if ((mapset = G_find_vector2(vect_opt->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), vect_opt->answer);
-
     Vect_set_open_level(2);
     Vect_set_open_level(2);
-    Vect_open_old(&Map, vect_opt->answer, mapset);
+    Vect_open_old(&Map, vect_opt->answer, "");
 
 
     Fi = Vect_get_field(&Map, field);
     Fi = Vect_get_field(&Map, field);
     if (Fi == NULL)
     if (Fi == NULL)
@@ -134,17 +130,14 @@ int main(int argc, char *argv[])
     }
     }
 
 
     /* Open raster */
     /* Open raster */
-    if ((mapset = G_find_cell2(rast_opt->answer, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), rast_opt->answer);
-
-    if ((fd = G_open_cell_old(rast_opt->answer, mapset)) < 0)
+    if ((fd = G_open_cell_old(rast_opt->answer, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), rast_opt->answer);
 	G_fatal_error(_("Unable to open raster map <%s>"), rast_opt->answer);
 
 
     out_type = G_get_raster_map_type(fd);
     out_type = G_get_raster_map_type(fd);
 
 
     /* TODO: Later possibly category labels */
     /* TODO: Later possibly category labels */
     /* 
     /* 
-       if ( G_read_cats (name, mapset, &RCats) < 0 )
+       if ( G_read_cats (name, "", &RCats) < 0 )
        G_fatal_error ( "Cannot read category file");
        G_fatal_error ( "Cannot read category file");
      */
      */
 
 

+ 4 - 24
vector/v.what/main.c

@@ -40,10 +40,8 @@ int main(int argc, char **argv)
     struct Option *opt1, *coords_opt, *maxdistance;
     struct Option *opt1, *coords_opt, *maxdistance;
     struct Cell_head window;
     struct Cell_head window;
     struct GModule *module;
     struct GModule *module;
-    char *mapset;
-    char *str;
     char buf[2000];
     char buf[2000];
-    int i, j, level, width = 0, mwidth = 0, ret;
+    int i, level, ret;
     double xval, yval, xres, yres, maxd, x;
     double xval, yval, xres, yres, maxd, x;
     double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
     double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
     char nsres[30], ewres[30];
     char nsres[30], ewres[30];
@@ -132,25 +130,8 @@ int main(int argc, char **argv)
 
 
 	Map = (struct Map_info *)G_malloc(nvects * sizeof(struct Map_info));
 	Map = (struct Map_info *)G_malloc(nvects * sizeof(struct Map_info));
 
 
-	width = mwidth = 0;
 	for (i = 0; i < nvects; i++) {
 	for (i = 0; i < nvects; i++) {
-	    str = strchr(vect[i], '@');
-	    if (str)
-		j = str - vect[i];
-	    else
-		j = strlen(vect[i]);
-	    if (j > width)
-		width = j;
-
-	    mapset = G_find_vector2(vect[i], "");
-	    if (!mapset)
-		G_fatal_error(_("Vector map <%s> not found"), vect[i]);
-
-	    j = strlen(mapset);
-	    if (j > mwidth)
-		mwidth = j;
-
-	    level = Vect_open_old(&Map[i], vect[i], mapset);
+	    level = Vect_open_old(&Map[i], vect[i], "");
 	    if (level < 2)
 	    if (level < 2)
 		G_fatal_error(_("You must build topology on vector map <%s>"),
 		G_fatal_error(_("You must build topology on vector map <%s>"),
 			      vect[i]);
 			      vect[i]);
@@ -167,7 +148,7 @@ int main(int argc, char **argv)
 	while (fgets(buf, sizeof(buf), stdin) != NULL) {
 	while (fgets(buf, sizeof(buf), stdin) != NULL) {
 	    ret = sscanf(buf, "%lf%c%lf", &xval, &ch, &yval);
 	    ret = sscanf(buf, "%lf%c%lf", &xval, &ch, &yval);
 	    if (ret == 3 && (ch == ',' || ch == ' ' || ch == '\t')) {
 	    if (ret == 3 && (ch == ',' || ch == ' ' || ch == '\t')) {
-		what(xval, yval, maxd, width, mwidth, topo_flag->answer,
+		what(xval, yval, maxd, topo_flag->answer,
 		     printattributes->answer);
 		     printattributes->answer);
 	    }
 	    }
 	    else {
 	    else {
@@ -181,8 +162,7 @@ int main(int argc, char **argv)
 	for (i = 0; coords_opt->answers[i] != NULL; i += 2) {
 	for (i = 0; coords_opt->answers[i] != NULL; i += 2) {
 	    xval = atof(coords_opt->answers[i]);
 	    xval = atof(coords_opt->answers[i]);
 	    yval = atof(coords_opt->answers[i + 1]);
 	    yval = atof(coords_opt->answers[i + 1]);
-	    what(xval, yval, maxd, width, mwidth, topo_flag->answer,
-		 printattributes->answer);
+	    what(xval, yval, maxd, topo_flag->answer, printattributes->answer);
 	}
 	}
     }
     }
 
 

+ 1 - 4
vector/v.what/what.c

@@ -14,8 +14,7 @@ static int nlines = 50;
 
 
 #define WDTH 5
 #define WDTH 5
 
 
-int what(double east, double north, double maxdist, int width,
-	 int mwidth, int topo, int showextra)
+int what(double east, double north, double maxdist, int topo, int showextra)
 {
 {
     int type;
     int type;
     char east_buf[40], north_buf[40];
     char east_buf[40], north_buf[40];
@@ -75,11 +74,9 @@ int what(double east, double north, double maxdist, int width,
 	    *str = 0;
 	    *str = 0;
 
 
 	if (line + area > 0 || G_verbose() >= G_verbose_std()) {
 	if (line + area > 0 || G_verbose() >= G_verbose_std()) {
-	    /* fprintf(stdout, "Map: %*s \nMapset: %-*s\n", width, Map[i].name, mwidth, Map[i].mapset); */
 	    fprintf(stdout, "\nMap: %s \nMapset: %s\n", Map[i].name,
 	    fprintf(stdout, "\nMap: %s \nMapset: %s\n", Map[i].name,
 		    Map[i].mapset);
 		    Map[i].mapset);
 	    if (notty)
 	    if (notty)
-		/* fprintf(stderr, "Map: %*s \nMapset: %-*s\n", width, Map[i].name, mwidth, Map[i].mapset); */
 		fprintf(stderr, "\nMap: %s \nMapset: %s\n", Map[i].name,
 		fprintf(stderr, "\nMap: %s \nMapset: %s\n", Map[i].name,
 			Map[i].mapset);
 			Map[i].mapset);
 	}
 	}

+ 1 - 1
vector/v.what/what.h

@@ -1,5 +1,5 @@
 /* what.c */
 /* what.c */
-extern int what(double, double, double, int, int, int, int);
+extern int what(double, double, double, int, int);
 
 
 extern char **vect;
 extern char **vect;
 extern int nvects;
 extern int nvects;