Browse Source

Remove explicit mapset references and G_find_* calls
Miscellaneous clean-up


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@33142 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 16 years ago
parent
commit
e25469759d
75 changed files with 418 additions and 995 deletions
  1. 1 8
      raster/r.patch/main.c
  2. 3 5
      raster/r.profile/main.c
  3. 1 2
      raster/r.quant/global.h
  4. 9 14
      raster/r.quant/main.c
  5. 3 3
      raster/r.quant/read_rules.c
  6. 2 3
      raster/r.random/count.c
  7. 1 1
      raster/r.random/local_proto.h
  8. 4 15
      raster/r.random/main.c
  9. 7 9
      raster/r.random/support.c
  10. 1 1
      raster/r.recode/global.h
  11. 1 8
      raster/r.recode/main.c
  12. 3 3
      raster/r.recode/read_rules.c
  13. 2 2
      raster/r.recode/recode.c
  14. 16 45
      raster/r.region/main.c
  15. 0 3
      raster/r.resamp.rst/local_proto.h
  16. 125 255
      raster/r.resamp.rst/main.c
  17. 0 17
      raster/r.resample/diff.sh
  18. 15 19
      raster/r.resample/main.c
  19. 3 2
      raster/r.rescale.eq/get_stats.c
  20. 1 1
      raster/r.rescale.eq/local_proto.h
  21. 4 11
      raster/r.rescale.eq/main.c
  22. 4 4
      raster/r.rescale/get_range.c
  23. 1 1
      raster/r.rescale/local_proto.h
  24. 4 11
      raster/r.rescale/main.c
  25. 5 9
      raster/r.series/main.c
  26. 5 12
      raster/r.statistics/main.c
  27. 15 15
      raster/r.statistics/method.h
  28. 1 1
      raster/r.statistics/o_adev.c
  29. 1 1
      raster/r.statistics/o_average.c
  30. 1 1
      raster/r.statistics/o_distrib.c
  31. 1 1
      raster/r.statistics/o_divr.c
  32. 1 1
      raster/r.statistics/o_kurt.c
  33. 1 1
      raster/r.statistics/o_max.c
  34. 1 1
      raster/r.statistics/o_median.c
  35. 1 1
      raster/r.statistics/o_min.c
  36. 1 1
      raster/r.statistics/o_mode.c
  37. 1 1
      raster/r.statistics/o_sdev.c
  38. 1 1
      raster/r.statistics/o_skew.c
  39. 1 1
      raster/r.statistics/o_sum.c
  40. 1 1
      raster/r.statistics/o_var.c
  41. 12 20
      raster/r.stats/main.c
  42. 1 7
      raster/r.sum/main.c
  43. 8 34
      raster/r.sun/main.c
  44. 3 7
      raster/r.sunmask/main.c
  45. 5 5
      raster/r.support.stats/check.c
  46. 3 3
      raster/r.support.stats/histo.c
  47. 2 2
      raster/r.support.stats/local_proto.h
  48. 1 6
      raster/r.support.stats/main.c
  49. 1 6
      raster/r.surf.area/main.c
  50. 5 15
      raster/r.surf.gauss/main.c
  51. 2 10
      raster/r.surf.idw/main.c
  52. 2 9
      raster/r.surf.idw2/read_cell.c
  53. 4 14
      raster/r.surf.random/main.c
  54. 3 8
      raster/r.texture/main.c
  55. 3 8
      raster/r.thin/io.c
  56. 1 10
      raster/r.timestamp/main.c
  57. 7 18
      raster/r.to.rast3/main.c
  58. 21 70
      raster/r.to.rast3elev/main.c
  59. 0 16
      raster/r.topidx/check_ready.c
  60. 1 1
      raster/r.topidx/file_io.c
  61. 1 2
      raster/r.topidx/global.h
  62. 1 5
      raster/r.topidx/main.c
  63. 9 9
      raster/r.topmodel/check_ready.c
  64. 1 4
      raster/r.topmodel/main.c
  65. 9 12
      raster/r.topmodel/misc.c
  66. 1 38
      raster/r.transect/main.c
  67. 1 8
      raster/r.univar/r.univar_main.c
  68. 18 29
      raster/r.volume/main.c
  69. 25 60
      raster/r.walk/main.c
  70. 0 2
      raster/r.walk/stash.h
  71. 2 7
      raster/r.what.color/main.c
  72. 0 12
      raster/r.what/die.c
  73. 0 11
      raster/r.what/local_proto.h
  74. 16 21
      raster/r.what/main.c
  75. 0 14
      raster/r.what/usage.c

+ 1 - 8
raster/r.patch/main.c

@@ -93,19 +93,12 @@ int main(int argc, char *argv[])
 
     for (i = 0; i < nfiles; i++) {
 	const char *name = names[i];
-	const char *mapset = G_find_cell2(name, "");
 	int fd;
 
-	if (mapset == NULL) {
-	    G_warning(_("Raster map <%s> not found"), name);
-	    G_sleep(3);
-	    ok = 0;
-	}
-
 	if (!ok)
 	    continue;
 
-	fd = G_open_cell_old(name, mapset);
+	fd = G_open_cell_old(name, "");
 	if (fd < 0) {
 	    ok = 0;
 	    continue;

+ 3 - 5
raster/r.profile/main.c

@@ -21,7 +21,7 @@ static double dist, e, n;
 
 int main(int argc, char *argv[])
 {
-    char *name, *outfile, *mapset;
+    char *name, *outfile;
     int fd, projection;
     FILE *fp;
     double res;
@@ -128,14 +128,12 @@ int main(int argc, char *argv[])
 	coords = 1;
 
     /* Open Raster File */
-    if (NULL == (mapset = G_find_cell2(name, "")))
-	G_fatal_error(_("Raster map <%s> not found"), name);
-    if (0 > (fd = G_open_cell_old(name, mapset)))
+    if ((fd = G_open_cell_old(name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), name);
 
     /* initialize color structure */
     if (clr)
-	G_read_colors(name, mapset, &colors);
+	G_read_colors(name, "", &colors);
 
     /* Open ASCII file for output or stdout */
     outfile = parm.output->answer;

+ 1 - 2
raster/r.quant/global.h

@@ -3,8 +3,7 @@
 extern struct Quant quant_struct;
 extern CELL old_min, old_max;
 extern DCELL old_dmin, old_dmax;
-extern char *name[GNAME_MAX];	/* input map names */
-extern char *mapset[GMAPSET_MAX];	/* input mapsets */
+extern char **name;	/* input map names */
 extern int noi;
 
 /* read_rules.c */

+ 9 - 14
raster/r.quant/main.c

@@ -25,8 +25,7 @@
 struct Quant quant_struct;
 CELL old_min, old_max;
 DCELL old_dmin, old_dmax;
-char *name[GNAME_MAX];		/* input map names */
-char *mapset[GMAPSET_MAX];	/* input mapsets */
+char **name;		/* input map names */
 int noi;
 
 int main(int argc, char *argv[])
@@ -39,7 +38,7 @@ int main(int argc, char *argv[])
     int i;
     CELL new_min, new_max;
     DCELL new_dmin, new_dmax;
-    char *basename, *basemapset;
+    char *basename;
 
     G_gisinit(argv[0]);
 
@@ -116,14 +115,14 @@ int main(int argc, char *argv[])
     if (i == 1)
 	G_fatal_error(_("fprange= and range= must be used together"));
 
+    for (noi = 0; input->answers[noi]; noi++)
+	;
+    name = G_malloc(noi * sizeof(char *));
     /* read and check inputs */
     for (noi = 0; input->answers[noi]; noi++) {
 	name[noi] = G_store(input->answers[noi]);
-	mapset[noi] = G_find_cell2(name[noi], "");
-	if (!mapset[noi])
-	    G_fatal_error(_("%s - not found"), name[noi]);
 
-	if (G_raster_map_type(name[noi], mapset[noi]) == CELL_TYPE)
+	if (G_raster_map_type(name[noi], G_mapset()) == CELL_TYPE)
 	    G_fatal_error(_("%s is integer map, it can't be quantized"),
 			  name[noi]);
     }
@@ -144,15 +143,11 @@ int main(int argc, char *argv[])
     else if (basename)
 	/* set the quant to that of basemap */
     {
-	basemapset = G_find_cell2(basename, "");
-	if (!basemapset)
-	    G_fatal_error(_("%s - not found"), basename);
-
-	if (G_raster_map_type(basename, basemapset) == CELL_TYPE)
+	if (G_raster_map_type(basename, "") == CELL_TYPE)
 	    G_fatal_error(_("%s is integer map, it can't be used as basemap"),
 			  basename);
 
-	if (G_read_quant(basename, basemapset, &quant_struct) <= 0)
+	if (G_read_quant(basename, "", &quant_struct) <= 0)
 	    G_fatal_error(_("unable to read quant rules for basemap <%s>"),
 			  basename);
     }
@@ -183,7 +178,7 @@ int main(int argc, char *argv[])
     }				/* use rules */
 
     for (i = 0; i < noi; i++) {
-	if (G_write_quant(name[i], mapset[i], &quant_struct) < 0)
+	if (G_write_quant(name[i], G_mapset(), &quant_struct) < 0)
 	    G_message(_("Quant table not changed for %s"), name[i]);
 	else
 	    G_message(_("New quant table created for %s"), name[i]);

+ 3 - 3
raster/r.quant/read_rules.c

@@ -17,13 +17,13 @@ int read_range(void)
 
     /* read the fpranges and ranges of all input maps */
     for (i = 0; i < noi; i++) {
-	if (G_read_fp_range(name[i], mapset[i], &drange) <= 0) {
+	if (G_read_fp_range(name[i], G_mapset(), &drange) <= 0) {
 	    sprintf(buff, "Can't read f_range for map %s", name[i]);
 	    G_fatal_error(buff);
 	}
 	G_get_fp_range_min_max(&drange, &tmp_dmin, &tmp_dmax);
 
-	if (G_read_range(name[i], mapset[i], &range) <= 0) {
+	if (G_read_range(name[i], G_mapset(), &range) <= 0) {
 	    sprintf(buff, "Can't read range for map %s", name[i]);
 	    G_fatal_error(buff);
 	}
@@ -43,7 +43,7 @@ int read_range(void)
 
 int report_range(void)
 {
-    char buff[1024], buff2[300];
+    char buff[300], buff2[300];
 
     if (G_is_d_null_value(&old_dmin) || G_is_d_null_value(&old_dmax))
 	G_message(_("Old data range is empty"));

+ 2 - 3
raster/r.random/count.c

@@ -19,13 +19,12 @@ void get_stats(struct rr_state *theState)
 {
     int nrows, ncols, row, col;
 
-    theState->fd_old = G_open_cell_old(theState->inraster, theState->mapset);
+    theState->fd_old = G_open_cell_old(theState->inraster, "");
     if (theState->fd_old < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"),
 		      theState->inraster);
     if (theState->docover == 1) {
-	theState->fd_cold =
-	    G_open_cell_old(theState->inrcover, theState->cmapset);
+	theState->fd_cold = G_open_cell_old(theState->inrcover, "");
 	if (theState->fd_cold < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"),
 			  theState->inrcover);

+ 1 - 1
raster/r.random/local_proto.h

@@ -23,7 +23,7 @@ int is_null_value(struct RASTER_MAP_PTR buf, int col);
 /* Put all the state infomation into a struct */
 struct rr_state
 {
-    char *inraster, *inrcover, *outraster, *mapset, *cmapset, *outvector;
+    char *inraster, *inrcover, *outraster, *outvector;
     int use_nulls, docover, fd_old, fd_cold, fd_new;
     long nCells, nNulls, nRand, cnCells, cnNulls;
     struct RASTER_MAP_PTR nulls, cnulls, buf, cover, min, max, cmin, cmax;

+ 4 - 15
raster/r.random/main.c

@@ -101,33 +101,22 @@ int main(int argc, char *argv[])
     }
     else {
 	myState.docover = 0;
-	myState.cmapset = NULL;
 	myState.inrcover = NULL;
     }
     myState.outraster = parm.raster->answer;
     myState.outvector = parm.sites->answer;
     myState.z_geometry = flag.z_geometry->answer;
 
-    myState.mapset = G_find_cell(myState.inraster, "");
-    if (myState.mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), myState.inraster);
-
-    if (myState.docover == 1) {
-	myState.cmapset = G_find_cell(myState.inrcover, "");
-	if (myState.cmapset == NULL)
-	    G_fatal_error(_("Raster map <%s> not found"), myState.inrcover);
-    }
-
     /* If they only want info we ignore the rest */
     get_stats(&myState);
 
     if (flag.info->answer) {
-	G_message("Raster:      %s@%s\n"
-		  "Cover:       %s@%s\n"
+	G_message("Raster:      %s\n"
+		  "Cover:       %s\n"
 		  "Cell Count:  %d\n"
 		  "Null Cells:  %d\n\n",
-		  myState.inraster, myState.mapset, myState.inrcover,
-		  myState.cmapset, (int)myState.nCells, (int)myState.nNulls);
+		  myState.inraster, myState.inrcover,
+		  (int)myState.nCells, (int)myState.nNulls);
 
 	exit(EXIT_SUCCESS);
     }

+ 7 - 9
raster/r.random/support.c

@@ -9,7 +9,7 @@ int make_support(struct rr_state *theState, int percent, double percentage)
     struct History hist;
     struct Categories cats;
     struct Colors clr;
-    char *inraster, *mapset;
+    char *inraster;
     struct RASTER_MAP_PTR nulls;
 
     /* write categories for output raster 
@@ -17,16 +17,14 @@ int make_support(struct rr_state *theState, int percent, double percentage)
      */
     if (theState->docover == 1) {
 	inraster = theState->inrcover;
-	mapset = theState->cmapset;
 	nulls = theState->cnulls;
     }
     else {
 	inraster = theState->inraster;
-	mapset = theState->mapset;
 	nulls = theState->nulls;
     }
-    if (G_read_raster_cats(inraster, mapset, &cats) >= 0) {
-	sprintf(title, "Random points on [%s in %s]", inraster, mapset);
+    if (G_read_raster_cats(inraster, "", &cats) >= 0) {
+	sprintf(title, "Random points on <%s>", inraster);
 	G_set_cats_title(title, &cats);
 	if (theState->use_nulls)
 	    G_set_raster_cat(nulls.data.v,
@@ -39,15 +37,15 @@ int make_support(struct rr_state *theState, int percent, double percentage)
     /* write history for output raster */
     if (G_read_history(theState->outraster, G_mapset(), &hist) >= 0) {
 	G_short_history(theState->outraster, "raster", &hist);
-	sprintf(hist.datsrc_1, "Based on map <%s@%s>", inraster, mapset);
+	sprintf(hist.datsrc_1, "Based on map <%s>", inraster);
 	if (percent)
 	    sprintf(hist.datsrc_2,
 		    "Random points over %.2f percent of the base map <%s>",
 		    percentage, inraster);
 	else
 	    sprintf(hist.datsrc_2,
-		    "%ld random points on the base map <%s@%s>",
-		    theState->nRand, theState->inraster, theState->mapset);
+		    "%ld random points on the base map <%s>",
+		    theState->nRand, theState->inraster);
 	G_write_history(theState->outraster, &hist);
 
     }
@@ -62,7 +60,7 @@ int make_support(struct rr_state *theState, int percent, double percentage)
     }
 
     /* set colors for output raster */
-    if (G_read_colors(inraster, mapset, &clr) >= 0) {
+    if (G_read_colors(inraster, "", &clr) >= 0) {
 	if (theState->use_nulls) {
 	    G_add_raster_color_rule(nulls.data.v, 127, 127, 127,
 				    nulls.data.v, 127, 127, 127, &clr,

+ 1 - 1
raster/r.recode/global.h

@@ -7,7 +7,7 @@ extern struct FPReclass rcl_struct;
 extern CELL old_min, old_max;
 extern DCELL old_dmin, old_dmax;
 extern int in_fd, out_fd, no_mask, align_wind, make_dcell, nrules, rule_size;
-extern char *name, *mapset, *result, *title;
+extern char *name, *result, *title;
 extern char **rules;
 
 /* read_rules.c */

+ 1 - 8
raster/r.recode/main.c

@@ -28,7 +28,7 @@ struct FPReclass rcl_struct;
 CELL old_min, old_max;
 DCELL old_dmin, old_dmax;
 int in_fd, out_fd, no_mask, align_wind, make_dcell, nrules, rule_size;
-char *name, *mapset, *result, *title;
+char *name, *result, *title;
 char **rules;
 
 int main(int argc, char *argv[])
@@ -86,13 +86,6 @@ int main(int argc, char *argv[])
     align_wind = parm.a->answer;
     make_dcell = parm.d->answer;
 
-    mapset = G_find_cell2(name, "");
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), name);
-
-    if (strcmp(name, result) == 0 && strcmp(mapset, G_mapset()) == 0)
-	G_fatal_error(_("Input map can NOT be the same as output map"));
-
     srcfp = stdin;
     if (parm.rules->answer) {
 	srcfp = fopen(parm.rules->answer, "r");

+ 3 - 3
raster/r.recode/read_rules.c

@@ -13,9 +13,9 @@ int report_range(void)
     char buff[1024], buff2[300];
     RASTER_MAP_TYPE inp_type;
 
-    inp_type = G_raster_map_type(name, mapset);
+    inp_type = G_raster_map_type(name, "");
     if (inp_type != CELL_TYPE) {
-	if (G_read_fp_range(name, mapset, &drange) <= 0)
+	if (G_read_fp_range(name, "", &drange) <= 0)
 	    G_fatal_error(_("Unable to read f_range for map %s"), name);
 
 	G_get_fp_range_min_max(&drange, &old_dmin, &old_dmax);
@@ -30,7 +30,7 @@ int report_range(void)
 		      buff, buff2);
 	}
     }
-    if (G_read_range(name, mapset, &range) <= 0)
+    if (G_read_range(name, "", &range) <= 0)
 	G_fatal_error(_("Unable to read range for map <%s>"), name);
 
     G_get_range_min_max(&range, &old_min, &old_max);

+ 2 - 2
raster/r.recode/recode.c

@@ -28,7 +28,7 @@ int do_recode(void)
     /* set the window from the header for the input file */
     if (align_wind) {
 	G_get_window(&window);
-	if (G_get_cellhd(name, mapset, &cellhd) >= 0) {
+	if (G_get_cellhd(name, "", &cellhd) >= 0) {
 	    G_align_window(&window, &cellhd);
 	    G_set_window(&window);
 	}
@@ -40,7 +40,7 @@ int do_recode(void)
     ncols = G_window_cols();
 
     /* open the input file for reading */
-    in_fd = G_open_cell_old(name, mapset);
+    in_fd = G_open_cell_old(name, "");
     if (in_fd < 0)
 	G_fatal_error("Can't open input map");
 

+ 16 - 45
raster/r.region/main.c

@@ -30,7 +30,6 @@ int main(int argc, char *argv[])
     struct Cell_head cellhd, window;
     char *value;
     char *name;
-    char *mapset;
     char *err;
 
     struct GModule *module;
@@ -153,12 +152,8 @@ int main(int argc, char *argv[])
 
     name = parm.map->answer;
 
-    mapset = G_find_cell2(name, "");
-    if (!mapset)
-	G_fatal_error(_("Raster map <%s> not found"), name);
-    if (G_get_cellhd(name, mapset, &cellhd) < 0)
-	G_fatal_error(_("Unable to read header of raster map <%s@%s>"), name,
-		      mapset);
+    if (G_get_cellhd(name, G_mapset(), &cellhd) < 0)
+	G_fatal_error(_("Unable to read header of raster map <%s>"), name);
 
     G_copy(&window, &cellhd, sizeof(window));
 
@@ -169,12 +164,8 @@ int main(int argc, char *argv[])
 	G_get_window(&window);
 
     if ((name = parm.region->answer)) {	/* region= */
-	mapset = G_find_file("windows", name, "");
-	if (!mapset)
-	    G_fatal_error(_("Region <%s> not found"), name);
-	if (G__get_window(&window, "windows", name, mapset) != NULL)
-	    G_fatal_error(_("Unable to read region <%s> in <%s>"), name,
-			  mapset);
+	if (G__get_window(&window, "windows", name, "") != NULL)
+	    G_fatal_error(_("Unable to read region <%s>"), name);
     }
 
     if ((name = parm.view->answer)) {	/* 3dview= */
@@ -182,24 +173,17 @@ int main(int argc, char *argv[])
 	FILE *fp;
 	int ret;
 
-	mapset = G_find_file2("3d.view", name, "");
-	if (!mapset)
-	    G_fatal_error(_("3dview file <%s> not found"), name);
-
 	G_3dview_warning(0);	/* suppress boundary mismatch warning */
 
-	fp = G_fopen_old("3d.view", name, mapset);
+	fp = G_fopen_old("3d.view", name, "");
 	if (!fp)
-	    G_fatal_error(_("Unable to open 3dview file <%s> in <%s>"), name,
-			  mapset);
+	    G_fatal_error(_("Unable to open 3dview file <%s>"), name);
 
-	ret = G_get_3dview(name, mapset, &v);
+	ret = G_get_3dview(name, "", &v);
 	if (ret < 0)
-	    G_fatal_error(_("Unable to read 3dview file <%s> in <%s>"), name,
-			  mapset);
+	    G_fatal_error(_("Unable to read 3dview file <%s>"), name);
 	if (ret == 0)
-	    G_fatal_error(_("Old 3dview file. Region <%s> not found in <%s>"),
-			  name, mapset);
+	    G_fatal_error(_("Old 3dview file. Region <%s> not found"), name);
 
 
 	window.north = v.vwin.north;
@@ -212,26 +196,17 @@ int main(int argc, char *argv[])
     }
 
     if ((name = parm.raster->answer)) {	/* raster= */
-	mapset = G_find_cell2(name, "");
-	if (!mapset)
-	    G_fatal_error(_("Raster map <%s> not found"), name);
-	if (G_get_cellhd(name, mapset, &window) < 0)
-	    G_fatal_error(_("Unable to read header of raster map <%s@%s>"),
-			  name, mapset);
+	if (G_get_cellhd(name, "", &window) < 0)
+	    G_fatal_error(_("Unable to read header of raster map <%s>"), name);
     }
 
     if ((name = parm.vect->answer)) {	/* vect= */
 	struct Map_info Map;
 	BOUND_BOX box;
 
-	mapset = G_find_vector2(name, "");
-	if (!mapset)
-	    G_fatal_error(_("Vector map <%s> not found"), name);
-
 	Vect_set_open_level(1);
-	if (Vect_open_old(&Map, name, mapset) != 1)
-	    G_fatal_error(_("Unable to open vector map <%s> in <%s>"), name,
-			  mapset);
+	if (Vect_open_old(&Map, name, "") != 1)
+	    G_fatal_error(_("Unable to open vector map <%s>"), name);
 
 	Vect_get_map_box(&Map, &box);
 	window.north = box.N;
@@ -335,14 +310,10 @@ int main(int argc, char *argv[])
     if ((name = parm.align->answer)) {	/* align= */
 	struct Cell_head temp_window;
 
-	mapset = G_find_cell2(name, "");
-	if (!mapset)
-	    G_fatal_error(_("Raster map <%s> not found"), name);
-	if (G_get_cellhd(name, mapset, &temp_window) < 0)
-	    G_fatal_error(_("Unable to read header of raster map <%s@%s>"),
-			  name, mapset);
+	if (G_get_cellhd(name, "", &temp_window) < 0)
+	    G_fatal_error(_("Unable to read header of raster map <%s>"), name);
 	if ((err = G_align_window(&window, &temp_window)))
-	    G_fatal_error("%s in %s: %s", name, mapset, err);
+	    G_fatal_error("%s: %s", name, err);
     }
 
     window.rows = cellhd.rows;

+ 0 - 3
raster/r.resamp.rst/local_proto.h

@@ -1,3 +0,0 @@
-/* main.c */
-void create_temp_files(void);
-void clean_fatal_error(char *);

+ 125 - 255
raster/r.resamp.rst/main.c

@@ -43,44 +43,32 @@
 #include <grass/interpf.h>
 #include <grass/glocale.h>
 
-#include "local_proto.h"
-
-
-double /* pargr */ ns_res, ew_res, inp_ew_res, inp_ns_res;
-int inp_rows, inp_cols;
-double x_orig, y_orig;
-double inp_x_orig, inp_y_orig;
-double dmin, ertre, deltx, delty;
-int nsizr, nsizc;
-int KMAX2 /* , KMIN, KMAX */ ;
-
-double /* datgr */ *az, *adx, *ady, *adxx, *adyy, *adxy;
-double /* error */ ertot, ertre, zminac, zmaxac, zmult;
-
-int total = 0;
-int NPOINT = 0;
-int OUTRANGE = 0;
-int NPT = 0;
-int deriv, overlap, cursegm, dtens;
-double fi;
-
-double DETERM;
-int NERROR, cond1, cond2;
-char fncdsm[32];
-char filnam[10];
-char msg[1024];
-double fstar2, tfsta2, xmin, xmax, ymin, ymax, zmin, zmax, gmin, gmax, c1min,
-    c1max, c2min, c2max;
-double dnorm;
-double smc;
-double theta, scalex;
-
-FCELL *zero_array_cell;
-struct interp_params params;
-
-FILE *fdredinp, *fdzout, *fddxout, *fddyout, *fdxxout, *fdyyout, *fxyout;
-FILE *fd4;			/* unused? */
-int fdinp, fdsmooth = -1;
+static double /* pargr */ ns_res, ew_res, inp_ew_res, inp_ns_res;
+static int inp_rows, inp_cols;
+
+static double inp_x_orig, inp_y_orig;
+static double dmin, ertre, deltx, delty;
+static int nsizr, nsizc;
+
+static double /* datgr */ *az, *adx, *ady, *adxx, *adyy, *adxy;
+static double /* error */ ertot, ertre, zminac, zmaxac, zmult;
+
+static int NPOINT;
+static int deriv, overlap, cursegm, dtens;
+static double fi;
+
+static int cond1, cond2;
+static double fstar2, tfsta2, xmin, xmax, ymin, ymax, zmin, zmax, gmin, gmax,
+    c1min, c1max, c2min, c2max;
+static double dnorm;
+static double smc;
+static double theta, scalex;
+
+static FCELL *zero_array_cell;
+static struct interp_params params;
+
+static FILE *fd4;			/* unused? */
+static int fdinp, fdsmooth = -1;
 
 /*
  * x,y,z - input data npoint - number of input data fi - tension parameter
@@ -96,36 +84,41 @@ int fdinp, fdsmooth = -1;
  * interpolation of z-values to given point x,y
  */
 
-char *input;
-char *smooth = NULL;
-char *mapset;
-char *elev = NULL;
-char *slope = NULL;
-char *aspect = NULL;
-char *pcurv = NULL;
-char *tcurv = NULL;
-char *mcurv = NULL;
-char *maskmap = NULL;
-char *redinp = NULL;
-int sdisk, disk;
-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;
-
-struct BM *bitmask;
-struct Cell_head winhd;
-struct Cell_head inphd;
-struct Cell_head outhd;
-struct Cell_head smhd;
+static char *input;
+static char *smooth;
+static char *elev;
+static char *slope;
+static char *aspect;
+static char *pcurv;
+static char *tcurv;
+static char *mcurv;
+static char *maskmap;
+
+static int sdisk, disk;
+
+static char *Tmp_file_z;
+static char *Tmp_file_dx;
+static char *Tmp_file_dy;
+static char *Tmp_file_xx;
+static char *Tmp_file_yy;
+static char *Tmp_file_xy;
+
+static FILE *Tmp_fd_z;
+static FILE *Tmp_fd_dx;
+static FILE *Tmp_fd_dy;
+static FILE *Tmp_fd_xx;
+static FILE *Tmp_fd_yy;
+static FILE *Tmp_fd_xy;
+static FILE *Tmp_fd_z;
+
+static struct BM *bitmask;
+static struct Cell_head winhd;
+static struct Cell_head inphd;
+static struct Cell_head outhd;
+static struct Cell_head smhd;
+
+static void create_temp_files(void);
+static void clean(void);
 
 int main(int argc, char *argv[])
 {
@@ -319,10 +312,10 @@ int main(int argc, char *argv[])
     ertre = 0.1;
 
     if (!G_scan_resolution(parm.res_ew->answer, &ew_res, winhd.proj))
-	G_fatal_error(_("Cannot read ew_res value"));
+	G_fatal_error(_("Unable to read ew_res value"));
 
     if (!G_scan_resolution(parm.res_ns->answer, &ns_res, winhd.proj))
-	G_fatal_error(_("Cannot read ns_res value"));
+	G_fatal_error(_("Unable to read ns_res value"));
 
     if (sscanf(parm.fi->answer, "%lf", &fi) != 1)
 	G_fatal_error(_("Invalid value for tension"));
@@ -363,52 +356,29 @@ int main(int argc, char *argv[])
     disk = nsizc * nsizr * sizeof(int);
 
     az = G_alloc_vector(nsizc + 1);
-    if (!az)
-	G_fatal_error(_("Not enough memory for az"));
 
     if (cond1) {
 	adx = G_alloc_vector(nsizc + 1);
-	if (!adx)
-	    G_fatal_error(_("Not enough memory for adx"));
-
 	ady = G_alloc_vector(nsizc + 1);
-	if (!ady)
-	    G_fatal_error(_("Not enough memory for ady"));
-
 	if (cond2) {
 	    adxx = G_alloc_vector(nsizc + 1);
-	    if (!adxx)
-		G_fatal_error(_("Not enough memory for adxx"));
-
 	    adyy = G_alloc_vector(nsizc + 1);
-	    if (!adyy)
-		G_fatal_error(_("Not enough memory for adyy"));
-
 	    adxy = G_alloc_vector(nsizc + 1);
-	    if (!adxy)
-		G_fatal_error(_("Not enough memory for adxy"));
 	}
     }
-    mapset = NULL;
-    if (smooth != NULL) {
-
-	mapset = G_find_file("cell", smooth, "");
 
-	if (mapset == NULL)
-	    G_fatal_error(_("Raster map <%s> not found"), smooth);
-
-	G_debug(1, "mapset for smooth map is [%s]", mapset);
+    if (smooth != NULL) {
 
-	if ((fdsmooth = G_open_cell_old(smooth, mapset)) < 0)
+	if ((fdsmooth = G_open_cell_old(smooth, "")) < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"), smooth);
 
-	if (G_get_cellhd(smooth, mapset, &smhd) < 0)
-	    G_fatal_error(_("[%s]: Cannot read map header"), smooth);
+	if (G_get_cellhd(smooth, "", &smhd) < 0)
+	    G_fatal_error(_("Unable to read header for <%s>"), smooth);
 
 	if ((winhd.ew_res != smhd.ew_res) || (winhd.ns_res != smhd.ns_res))
-	    G_fatal_error(_("[%s]: Map is the wrong resolution"), smooth);
+	    G_fatal_error(_("Map <%s> is the wrong resolution"), smooth);
 
-	if (G_read_fp_range(smooth, mapset, &range) >= 0)
+	if (G_read_fp_range(smooth, "", &range) >= 0)
 	    G_get_fp_range_min_max(&range, &cellmin, &cellmax);
 
 	fcellmin = (float)cellmin;
@@ -417,21 +387,13 @@ int main(int argc, char *argv[])
 	    G_fatal_error(_("Smoothing values can not be negative or NULL"));
     }
 
-    mapset = NULL;
-    mapset = G_find_file("cell", input, "");
-
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), input);
-
-    G_debug(1, "mapset for input map is [%s]", mapset);
-
-    if (G_get_cellhd(input, mapset, &inphd) < 0)
-	G_fatal_error(_("[%s]: Cannot read map header"), input);
+    if (G_get_cellhd(input, "", &inphd) < 0)
+	G_fatal_error(_("Unable to read header for <%s>"), input);
 
     if ((winhd.ew_res != inphd.ew_res) || (winhd.ns_res != inphd.ns_res))
 	G_fatal_error(_("Input map resolution differs from current region resolution!"));
 
-    if ((fdinp = G_open_cell_old(input, mapset)) < 0)
+    if ((fdinp = G_open_cell_old(input, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), input);
 
 
@@ -467,7 +429,7 @@ int main(int argc, char *argv[])
 	smc = 0.01;
 
 
-    if (G_read_fp_range(input, mapset, &range) >= 0) {
+    if (G_read_fp_range(input, "", &range) >= 0) {
 	G_get_fp_range_min_max(&range, &cellmin, &cellmax);
     }
     else {
@@ -475,8 +437,8 @@ int main(int argc, char *argv[])
 	for (m1 = 0; m1 < inp_rows; m1++) {
 	    ret_val = G_get_f_raster_row(fdinp, cellrow, m1);
 	    if (ret_val < 0)
-		G_fatal_error(_("Cannot get row %d (error = %d)"), m1,
-			      ret_val);
+		G_fatal_error(_("Error reading row %d (error = %d)"),
+			      m1, ret_val);
 
 	    G_row_update_fp_range(cellrow, m1, &range, FCELL_TYPE);
 	}
@@ -515,13 +477,13 @@ int main(int argc, char *argv[])
 
     G_message(_("Temporarily changing the region to desired resolution ..."));
     if (G_set_window(&outhd) < 0)
-	G_fatal_error("Cannot set region to output region!");
+	G_fatal_error(_("Cannot set region to output region"));
 
     bitmask = IL_create_bitmask(&params);
     /* change region to initial region */
     G_message(_("Changing back to the original region ..."));
     if (G_set_window(&winhd) < 0)
-	G_fatal_error(_("Cannot set region to back to the initial region !!!"));
+	G_fatal_error(_("Cannot set region to back to the initial region"));
 
     ertot = 0.;
     cursegm = 0;
@@ -539,8 +501,10 @@ int main(int argc, char *argv[])
 
     G_message(_("dnorm in mainc after grid before out1= %f"), dnorm);
 
-    if (NPOINT < 0)
-	clean_fatal_error("split_and_interpolate() failed");
+    if (NPOINT < 0) {
+	clean();
+	G_fatal_error(_("split_and_interpolate() failed"));
+    }
 
     if (fd4 != NULL)
 	fprintf(fd4, "max. error found = %f \n", ertot);
@@ -558,36 +522,13 @@ int main(int argc, char *argv[])
 
     if (IL_resample_output_2d(&params, zmin, zmax, zminac, zmaxac, c1min,
 			      c1max, c2min, c2max, gmin, gmax, ertot, input,
-			      &dnorm, &outhd, &winhd, smooth, NPOINT) < 0)
-	clean_fatal_error
-	    ("Can not write raster maps -- try increasing cell size");
+			      &dnorm, &outhd, &winhd, smooth, NPOINT) < 0) {
+	clean();
+	G_fatal_error(_("Unable to write raster maps -- try increasing cell size"));
+    }
 
     G_free(zero_array_cell);
-    if (elev != NULL)
-	fclose(Tmp_fd_z);
-    if (slope != NULL)
-	fclose(Tmp_fd_dx);
-    if (aspect != NULL)
-	fclose(Tmp_fd_dy);
-    if (pcurv != NULL)
-	fclose(Tmp_fd_xx);
-    if (tcurv != NULL)
-	fclose(Tmp_fd_yy);
-    if (mcurv != NULL)
-	fclose(Tmp_fd_xy);
-
-    if (elev != NULL)
-	unlink(Tmp_file_z);
-    if (slope != NULL)
-	unlink(Tmp_file_dx);
-    if (aspect != NULL)
-	unlink(Tmp_file_dy);
-    if (pcurv != NULL)
-	unlink(Tmp_file_xx);
-    if (tcurv != NULL)
-	unlink(Tmp_file_yy);
-    if (mcurv != NULL)
-	unlink(Tmp_file_xy);
+    clean();
     if (fd4)
 	fclose(fd4);
     G_close_cell(fdinp);
@@ -598,126 +539,55 @@ int main(int argc, char *argv[])
     exit(EXIT_SUCCESS);
 }
 
-
-void create_temp_files(void)
+static FILE *create_temp_file(const char *name, char **tmpname)
 {
+    FILE *fp;
+    char *tmp;
     int i;
 
-    zero_array_cell = (FCELL *) G_malloc(sizeof(FCELL) * nsizc);
-    if (!zero_array_cell)
-	G_fatal_error(_("Not enough memory for zero_array_cell"));
+    if (!name)
+	return NULL;
 
-    for (i = 0; i < nsizc; i++) {
-	zero_array_cell[i] = (FCELL) 0;
-    }
-
-    if (elev != NULL) {
-	Tmp_file_z = G_tempfile();
-	if (NULL == (Tmp_fd_z = fopen(Tmp_file_z, "w+")))
-	    G_fatal_error(_("Unable to open temporary file <%s>"),
-			  Tmp_file_z);
+    *tmpname = tmp = G_tempfile();
+    fp = fopen(tmp, "w+");
+    if (!fp)
+	G_fatal_error(_("Unable to open temporary file <%s>"), tmpname);
 
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_z)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (slope != NULL) {
-	Tmp_file_dx = G_tempfile();
-	if (NULL == (Tmp_fd_dx = fopen(Tmp_file_dx, "w+"))) {
-	    sprintf(msg, _("Unable to open temporary file <%s>"),
-		    Tmp_file_dx);
-	    clean_fatal_error(msg);
-	}
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_dx)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (aspect != NULL) {
-	Tmp_file_dy = G_tempfile();
-	if (NULL == (Tmp_fd_dy = fopen(Tmp_file_dy, "w+"))) {
-	    sprintf(msg, _("Unable to open temporary file <%s>"),
-		    Tmp_file_dy);
-	    clean_fatal_error(msg);
-	}
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_dy)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
+    for (i = 0; i < nsizr; i++) {
+	if (fwrite(zero_array_cell, sizeof(FCELL), nsizc, fp) != nsizc) {
+	    clean();
+	    G_fatal_error(_("Error writing temporary file <%s>"), tmpname);
 	}
     }
 
-    if (pcurv != NULL) {
-	Tmp_file_xx = G_tempfile();
-	if (NULL == (Tmp_fd_xx = fopen(Tmp_file_xx, "w+"))) {
-	    sprintf(msg, _("Unable to open temporary file <%s>"),
-		    Tmp_file_xx);
-	    clean_fatal_error(msg);
-	}
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_xx)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (tcurv != NULL) {
-	Tmp_file_yy = G_tempfile();
-	if (NULL == (Tmp_fd_yy = fopen(Tmp_file_yy, "w+"))) {
-	    sprintf(msg, _("Unable to open temporary file <%s>"),
-		    Tmp_file_yy);
-	    clean_fatal_error(msg);
-	}
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_yy)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
-	}
-    }
-    if (mcurv != NULL) {
-	Tmp_file_xy = G_tempfile();
-	if (NULL == (Tmp_fd_xy = fopen(Tmp_file_xy, "w+"))) {
-	    sprintf(msg, _("Unable to open temporary file <%s>"),
-		    Tmp_file_xy);
-	    clean_fatal_error(msg);
-	}
-	for (i = 0; i < nsizr; i++) {
-	    if (!(fwrite(zero_array_cell, sizeof(FCELL), nsizc, Tmp_fd_xy)))
-		clean_fatal_error
-		    (_("Not enough disk space -- cannot write files"));
-	}
-    }
+    return fp;
+}
 
-    return;
+static void create_temp_files(void)
+{
+    zero_array_cell = (FCELL *) G_calloc(nsizc, 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);
 }
 
-void clean_fatal_error(char *str)
+static void clean(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);
+    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 - 17
raster/r.resample/diff.sh

@@ -1,17 +0,0 @@
-u_UPDIR=`pwd`
-echo making diffs in directory
-SRC_DIR=/sd1h/grass.data/fp_null/r.resample
-
-for i in `ls *.c`
-do
-  echo $i
-  diff -b $i $SRC_DIR/$i
-done
-
-for i in `ls *.h`
-do
-   echo $i
-   diff -b $i $SRC_DIR/$i
-done
-
-exit 0

+ 15 - 19
raster/r.resample/main.c

@@ -34,8 +34,8 @@ int main(int argc, char *argv[])
     struct Cell_head cellhd;
     struct Range range;
     int hist_ok, colr_ok, cats_ok;
-    char name[GNAME_MAX], *mapset;
-    char result[GNAME_MAX];
+    char *name;
+    char *result;
     void *rast;
     int nrows, ncols;
     int row;
@@ -75,24 +75,20 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    strcpy(name, option.input->answer);
-    strcpy(result, option.output->answer);
+    name = option.input->answer;
+    result = option.output->answer;
 
-    mapset = G_find_cell2(name, "");
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), name);
-
-    hist_ok = G_read_history(name, mapset, &hist) >= 0;
-    colr_ok = G_read_colors(name, mapset, &colr) > 0;
-    cats_ok = G_read_cats(name, mapset, &cats) >= 0;
+    hist_ok = G_read_history(name, "", &hist) >= 0;
+    colr_ok = G_read_colors(name, "", &colr) > 0;
+    cats_ok = G_read_cats(name, "", &cats) >= 0;
     if (cats_ok) {
 	G_unmark_raster_cats(&cats);
 	G_init_cats((CELL) 0, G_get_cats_title(&cats), &newcats);
     }
 
-    infd = G_open_cell_old(name, mapset);
+    infd = G_open_cell_old(name, "");
     if (infd < 0)
-	exit(EXIT_FAILURE);
+	G_fatal_error(_("Unable to open input map <%s>"), name);
 
     /* determine the map type;
        data_type is the type of data being processed,
@@ -100,31 +96,31 @@ int main(int argc, char *argv[])
     data_type = G_get_raster_map_type(infd);
     out_type = data_type;
 
-    if (G_get_cellhd(name, mapset, &cellhd) < 0)
-	exit(EXIT_FAILURE);
+    if (G_get_cellhd(name, "", &cellhd) < 0)
+	G_fatal_error(_("Unable to read header for <%s>"), name);
 
     /* raster buffer is big enough to hold data */
     rast = G_allocate_raster_buf(data_type);
     nrows = G_window_rows();
     ncols = G_window_cols();
     if (ncols <= 1)
-	rast = (void *)G_realloc((char *)rast, 2 * G_raster_size(data_type));
+	rast = G_realloc(rast, 2 * G_raster_size(data_type));
     /* we need the buffer at least 2 cells large */
 
     outfd = G_open_raster_new(result, out_type);
     G_set_null_value(rast, ncols, out_type);
 
     if (outfd < 0)
-	exit(EXIT_FAILURE);
+	G_fatal_error(_("Unable to open output map <%s>"), name);
 
     G_message(_("Percent complete: "));
 
     for (row = 0; row < nrows; row++) {
 	G_percent(row, nrows, 2);
 	if (G_get_raster_row(infd, rast, row, data_type) < 0)
-	    exit(EXIT_FAILURE);
+	    G_fatal_error(_("Error reading row %d"), row);
 	if (G_put_raster_row(outfd, rast, out_type) < 0)
-	    exit(EXIT_FAILURE);
+	    G_fatal_error(_("Error writing row %d"), row);
 	G_mark_raster_cats(rast, ncols, &cats, data_type);
     }
 

+ 3 - 2
raster/r.rescale.eq/get_stats.c

@@ -1,14 +1,15 @@
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include "local_proto.h"
 
-int get_stats(char *name, char *mapset, struct Cell_stats *statf)
+int get_stats(const char *name, struct Cell_stats *statf)
 {
     int fd;
     CELL *cell;
     int row, nrows, ncols;
 
-    fd = G_open_cell_old(name, mapset);
+    fd = G_open_cell_old(name, "");
     if (fd < 0)
 	exit(1);
     nrows = G_window_rows();

+ 1 - 1
raster/r.rescale.eq/local_proto.h

@@ -2,4 +2,4 @@
 int get_range(struct Cell_stats *, CELL *, CELL *, int);
 
 /* get_stats.c */
-int get_stats(char *, char *, struct Cell_stats *);
+int get_stats(const char *, struct Cell_stats *);

+ 4 - 11
raster/r.rescale.eq/main.c

@@ -25,14 +25,13 @@ static void reclass(CELL, CELL, CELL);
 
 int main(int argc, char *argv[])
 {
-    char buf[512];
+    char buf[GPATH_MAX];
     CELL old_min, old_max;
     CELL new_min, new_max;
     long cat;
     struct Cell_stats statf;
     char *old_name;
     char *new_name;
-    char *mapset;
     struct
     {
 	struct Option *input, *from, *output, *to, *title;
@@ -93,13 +92,7 @@ int main(int argc, char *argv[])
     old_name = parm.input->answer;
     new_name = parm.output->answer;
 
-    mapset = G_find_cell(old_name, "");
-    if (mapset == NULL) {
-	sprintf(buf, "%s - not found\n", old_name);
-	G_fatal_error(buf);
-    }
-
-    get_stats(old_name, mapset, &statf);
+    get_stats(old_name, &statf);
     if (parm.from->answer) {
 	sscanf(parm.from->answers[0], "%d", &old_min);
 	sscanf(parm.from->answers[1], "%d", &old_max);
@@ -123,8 +116,8 @@ int main(int argc, char *argv[])
     G_message(_("Rescale %s[%d,%d] to %s[%d,%d]"),
 	      old_name, old_min, old_max, new_name, new_min, new_max);
 
-    sprintf(buf, "r.reclass input=\"%s\" output=\"%s\" title=\"", old_name,
-	    new_name);
+    sprintf(buf, "r.reclass input=\"%s\" output=\"%s\" title=\"",
+	    old_name, new_name);
     if (parm.title->answer)
 	strcat(buf, parm.title->answer);
     else {

+ 4 - 4
raster/r.rescale/get_range.c

@@ -3,7 +3,7 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
-int get_range(char *name, char *mapset, long *min, long *max)
+int get_range(const char *name, long *min, long *max)
 {
     struct Range range;
     int nrows, ncols, row, col;
@@ -12,12 +12,12 @@ int get_range(char *name, char *mapset, long *min, long *max)
     CELL cmin, cmax;
     struct Cell_head cellhd;
 
-    if (G_read_range(name, mapset, &range) < 0) {
+    if (G_read_range(name, "", &range) < 0) {
 	G_init_range(&range);	/* read the file to get the range */
-	G_get_cellhd(name, mapset, &cellhd);
+	G_get_cellhd(name, "", &cellhd);
 	G_set_window(&cellhd);
 	cell = G_allocate_cell_buf();
-	fd = G_open_cell_old(name, mapset);
+	fd = G_open_cell_old(name, "");
 	if (fd < 0)
 	    exit(1);
 	nrows = G_window_rows();

+ 1 - 1
raster/r.rescale/local_proto.h

@@ -1,2 +1,2 @@
 /* get_range.c */
-int get_range(char *, char *, long *, long *);
+int get_range(const char *, long *, long *);

+ 4 - 11
raster/r.rescale/main.c

@@ -21,7 +21,7 @@
 
 int main(int argc, char *argv[])
 {
-    char buf[512];
+    char buf[GPATH_MAX];
     FILE *fd;
     long old_min, old_max;
     long new_min, new_max;
@@ -31,7 +31,6 @@ int main(int argc, char *argv[])
     float divisor;
     char *old_name;
     char *new_name;
-    char *mapset;
     struct GModule *module;
     struct
     {
@@ -89,19 +88,13 @@ int main(int argc, char *argv[])
     old_name = parm.input->answer;
     new_name = parm.output->answer;
 
-    mapset = G_find_cell(old_name, "");
-    if (mapset == NULL) {
-	sprintf(buf, "%s - not found\n", old_name);
-	G_fatal_error(buf);
-    }
-
     if (parm.from->answer) {
 	sscanf(parm.from->answers[0], "%ld", &old_min);
 	sscanf(parm.from->answers[1], "%ld", &old_max);
 
     }
     else
-	get_range(old_name, mapset, &old_min, &old_max);
+	get_range(old_name, &old_min, &old_max);
     if (old_min > old_max) {
 	value = old_min;	/* swap */
 	old_min = old_max;
@@ -119,8 +112,8 @@ int main(int argc, char *argv[])
     G_message(_("Rescale %s[%ld,%ld] to %s[%ld,%ld]"),
 	      old_name, old_min, old_max, new_name, new_min, new_max);
 
-    sprintf(buf, "r.reclass input=\"%s\" output=\"%s\" title=\"", old_name,
-	    new_name);
+    sprintf(buf, "r.reclass input=\"%s\" output=\"%s\" title=\"",
+	    old_name, new_name);
     if (parm.title->answer)
 	strcat(buf, parm.title->answer);
     else {

+ 5 - 9
raster/r.series/main.c

@@ -54,7 +54,7 @@ struct menu
 
 struct input
 {
-    char *name, *mapset;
+    char *name;
     int fd;
     DCELL *buf;
 };
@@ -154,15 +154,11 @@ int main(int argc, char *argv[])
 	struct input *p = &inputs[i];
 
 	p->name = parm.input->answers[i];
-	p->mapset = G_find_cell2(p->name, "");
-	if (!p->mapset)
-	    G_fatal_error(_("Raster map <%s> not found"), p->name);
-	else
-	    G_message(_("Reading raster map <%s>..."), p->name);
-	p->fd = G_open_cell_old(p->name, p->mapset);
+	G_message(_("Reading raster map <%s>..."), p->name);
+	p->fd = G_open_cell_old(p->name, "");
 	if (p->fd < 0)
-	    G_fatal_error(_("Unable to open raster map <%s> in mapset <%s>"),
-			  p->name, p->mapset);
+	    G_fatal_error(_("Unable to open raster map <%s>"),
+			  p->name);
 	p->buf = G_allocate_d_raster_buf();
     }
 

+ 5 - 12
raster/r.statistics/main.c

@@ -46,7 +46,6 @@ static int is_ok(char *, char *);
 
 int main(int argc, char **argv)
 {
-    char *mapset;
     int o_method;
     struct GModule *module;
     struct Option *method, *basemap, *covermap, *outputmap;
@@ -93,21 +92,15 @@ int main(int argc, char **argv)
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    if ((mapset = G_find_cell2(basemap->answer, "")) == 0)
-	G_fatal_error(_("Raster map <%s> not found"), basemap->answer);
-
-    if (G_raster_map_is_fp(basemap->answer, mapset) != 0)
+    if (G_raster_map_is_fp(basemap->answer, "") != 0)
 	G_fatal_error(_("This module currently only works for integer (CELL) maps"));
 
-    if ((mapset = G_find_cell2(covermap->answer, "")) == 0)
-	G_fatal_error(_("Raster map <%s> not found"), covermap->answer);
-
-    if (G_raster_map_is_fp(covermap->answer, mapset) != 0)
+    if (G_raster_map_is_fp(covermap->answer, "") != 0)
 	G_fatal_error(_("This module currently only works for integer (CELL) maps"));
 
-    if (G_read_cats(covermap->answer, mapset, &cats) < 0) {
-	G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
-		      covermap->answer, mapset);
+    if (G_read_cats(covermap->answer, "", &cats) < 0) {
+	G_fatal_error(_("Unable to read category file of raster map <%s>"),
+		      covermap->answer);
     }
 
     for (o_method = 0; menu[o_method].name; o_method++)

+ 15 - 15
raster/r.statistics/method.h

@@ -22,51 +22,51 @@ struct stats
 
 struct menu
 {
-    char *name;			/* method name */
+    const char *name;		/* method name */
     int val;			/* number of function */
-    char *text;			/* menu display - full description */
+    const char *text;		/* menu display - full description */
 };
 
 extern struct menu menu[];
 
 /* o_adev.c */
-int o_adev(char *, char *, char *, int, struct Categories *);
+int o_adev(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_average.c */
-int o_average(char *, char *, char *, int, struct Categories *);
+int o_average(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_distrib.c */
-int o_distrib(char *, char *, char *, int);
+int o_distrib(const char *, const char *, const char *, int);
 
 /* o_kurt.c */
-int o_kurt(char *, char *, char *, int, struct Categories *);
+int o_kurt(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_max.c */
-int o_max(char *, char *, char *, int, struct Categories *);
+int o_max(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_median.c */
-int o_median(char *, char *, char *, int, struct Categories *);
+int o_median(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_min.c */
-int o_min(char *, char *, char *, int, struct Categories *);
+int o_min(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_mode.c */
-int o_mode(char *, char *, char *, int, struct Categories *);
+int o_mode(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_sdev.c */
-int o_sdev(char *, char *, char *, int, struct Categories *);
+int o_sdev(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_skew.c */
-int o_skew(char *, char *, char *, int, struct Categories *);
+int o_skew(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_sum.c */
-int o_sum(char *, char *, char *, int, struct Categories *);
+int o_sum(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_var.c */
-int o_var(char *, char *, char *, int, struct Categories *);
+int o_var(const char *, const char *, const char *, int, struct Categories *);
 
 /* o_divr.c */
-int o_divr(char *, char *, char *, int, struct Categories *);
+int o_divr(const char *, const char *, const char *, int, struct Categories *);
 
 /* read_stats.c */
 int read_stats(FILE *, long *, long *, double *);

+ 1 - 1
raster/r.statistics/o_adev.c

@@ -13,7 +13,7 @@ static int a_dev(double *, int, double *);
 
 
 int
-o_adev(char *basemap, char *covermap, char *outputmap, int usecats,
+o_adev(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_average.c

@@ -12,7 +12,7 @@ static int out(FILE *, long, double, double);
 
 
 int
-o_average(char *basemap, char *covermap, char *outputmap, int usecats,
+o_average(const char *basemap, const char *covermap, const char *outputmap, int usecats,
 	  struct Categories *cats)
 {
     char *me = "o_average";

+ 1 - 1
raster/r.statistics/o_distrib.c

@@ -10,7 +10,7 @@
 static int o_out(FILE *, long, long);
 
 
-int o_distrib(char *basemap, char *covermap, char *outputmap, int usecats)
+int o_distrib(const char *basemap, const char *covermap, const char *outputmap, int usecats)
 {
     char *me = "o_distrib";
     char command[1024];

+ 1 - 1
raster/r.statistics/o_divr.c

@@ -4,7 +4,7 @@
 #include "method.h"
 
 int
-o_divr(char *basemap, char *covermap, char *outputmap, int usecats,
+o_divr(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_kurt.c

@@ -13,7 +13,7 @@ static int kurt(double *, int, double *);
 
 
 int
-o_kurt(char *basemap, char *covermap, char *outputmap, int usecats,
+o_kurt(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_max.c

@@ -4,7 +4,7 @@
 #include "method.h"
 
 int
-o_max(char *basemap, char *covermap, char *outputmap, int usecats,
+o_max(const char *basemap, const char *covermap, const char *outputmap, int usecats,
       struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_median.c

@@ -8,7 +8,7 @@ static long median(struct stats *);
 
 
 int
-o_median(char *basemap, char *covermap, char *outputmap, int usecats,
+o_median(const char *basemap, const char *covermap, const char *outputmap, int usecats,
 	 struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_min.c

@@ -4,7 +4,7 @@
 #include "method.h"
 
 int
-o_min(char *basemap, char *covermap, char *outputmap, int usecats,
+o_min(const char *basemap, const char *covermap, const char *outputmap, int usecats,
       struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_mode.c

@@ -4,7 +4,7 @@
 #include "method.h"
 
 int
-o_mode(char *basemap, char *covermap, char *outputmap, int usecats,
+o_mode(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_sdev.c

@@ -13,7 +13,7 @@ static int s_dev(double *, int, double *);
 
 
 int
-o_sdev(char *basemap, char *covermap, char *outputmap, int usecats,
+o_sdev(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_skew.c

@@ -13,7 +13,7 @@ static int skew(double *, int, double *);
 
 
 int
-o_skew(char *basemap, char *covermap, char *outputmap, int usecats,
+o_skew(const char *basemap, const char *covermap, const char *outputmap, int usecats,
        struct Categories *cats)
 {
     char command[1024];

+ 1 - 1
raster/r.statistics/o_sum.c

@@ -12,7 +12,7 @@ static void sum_out(FILE *, long, double);
 
 
 int
-o_sum(char *basemap, char *covermap, char *outputmap, int usecats,
+o_sum(const char *basemap, const char *covermap, const char *outputmap, int usecats,
       struct Categories *cats)
 {
     char *me = "o_sum";

+ 1 - 1
raster/r.statistics/o_var.c

@@ -13,7 +13,7 @@ static int m_var(double *, int, double *);
 
 
 int
-o_var(char *basemap, char *covermap, char *outputmap, int usecats,
+o_var(const char *basemap, const char *covermap, const char *outputmap, int usecats,
       struct Categories *cats)
 {
     char command[1024];

+ 12 - 20
raster/r.stats/main.c

@@ -32,7 +32,6 @@ int main(int argc, char *argv[])
     char **names;
     char **ptr;
     char *name;
-    char *mapset;
 
     /* flags */
     int raw_data;
@@ -254,31 +253,27 @@ int main(int argc, char *argv[])
 
     for (; *ptr != NULL; ptr++) {
 	name = *ptr;
-	mapset = G_find_cell2(name, "");
-	if (!mapset)
-	    G_fatal_error(_("Raster map <%s> not found"), name);
 	fd = (int *)G_realloc(fd, (nfiles + 1) * sizeof(int));
 	is_fp = (int *)G_realloc(is_fp, (nfiles + 1) * sizeof(int));
 	DMAX = (DCELL *) G_realloc(DMAX, (nfiles + 1) * sizeof(DCELL));
 	DMIN = (DCELL *) G_realloc(DMIN, (nfiles + 1) * sizeof(DCELL));
 
-	fd[nfiles] = G_open_cell_old(name, mapset);
+	fd[nfiles] = G_open_cell_old(name, "");
 	if (fd[nfiles] < 0)
 	    exit(1);
 	if (!as_int)
-	    is_fp[nfiles] = G_raster_map_is_fp(name, mapset);
+	    is_fp[nfiles] = G_raster_map_is_fp(name, "");
 	else {
 	    is_fp[nfiles] = 0;
 	    if (cat_ranges || nsteps != 255)
 		G_warning(_("Raster map <%s> is reading as integer map! "
 			    "Flag '-%c' and/or '%s' option will be ignored."),
-			  G_fully_qualified_name(name, mapset), flag.C->key,
-			  option.nsteps->key);
+			  name, flag.C->key, option.nsteps->key);
 	}
 	if (with_labels || (cat_ranges && is_fp[nfiles])) {
 	    labels = (struct Categories *)
 		G_realloc(labels, (nfiles + 1) * sizeof(struct Categories));
-	    if (G_read_cats(name, mapset, &labels[nfiles]) < 0)
+	    if (G_read_cats(name, "", &labels[nfiles]) < 0)
 		G_init_cats((CELL) 0, "", &labels[nfiles]);
 	}
 	if (is_fp[nfiles])
@@ -288,21 +283,19 @@ int main(int argc, char *argv[])
 	    if (cat_ranges) {
 		if (!G_quant_nof_rules(&labels[nfiles].q)) {
 		    G_warning(_("Cats for raster map <%s> are either missing or have no explicit labels. "
-			       "Using %s=%d."), G_fully_qualified_name(name,
-								       mapset),
-			      option.nsteps->key, nsteps);
+			       "Using %s=%d."),
+			      name, option.nsteps->key, nsteps);
 		    cat_ranges = 0;
 		}
 		else if (nsteps != 255)
 		    G_warning(_("Flag '-%c' was given, using cats fp ranges of raster map <%s>, "
-			       "ignoring '%s' option"), flag.C->key,
-			      G_fully_qualified_name(name, mapset),
-			      option.nsteps->key);
+			       "ignoring '%s' option"),
+			      flag.C->key, name, option.nsteps->key);
 	    }
 	    if (!cat_ranges) {	/* DO NOT use else here, cat_ranges can change */
-		if (G_read_fp_range(name, mapset, &fp_range) < 0)
+		if (G_read_fp_range(name, "", &fp_range) < 0)
 		    G_fatal_error(_("Unable to read fp range of raster map <%s>"),
-				  G_fully_qualified_name(name, mapset));
+				  name);
 		G_get_fp_range_min_max(&fp_range, &DMIN[nfiles],
 				       &DMAX[nfiles]);
 		G_quant_add_rule(&q, DMIN[nfiles], DMAX[nfiles], 1, nsteps);
@@ -320,9 +313,8 @@ int main(int argc, char *argv[])
 	    }
 	}
 	else {
-	    if (G_read_range(name, mapset, &range) < 0)
-		G_fatal_error(_("Unable to read range for map <%s>"),
-			      G_fully_qualified_name(name, mapset));
+	    if (G_read_range(name, "", &range) < 0)
+		G_fatal_error(_("Unable to read range for map <%s>"), name);
 	    G_get_range_min_max(&range, &min, &max);
 	}
 	if (!null_set) {

+ 1 - 7
raster/r.sum/main.c

@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
 
     struct GModule *module;
     struct Option *rast;
-    char *cellmap;
     FILEDESC cellfile = 0;
     FCELL *dbuf, *ibuf;
     int row, col, shh = 0;
@@ -57,13 +56,8 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    cellmap = G_find_file2("cell", rast->answer, "");
-    if (!cellmap) {
-	G_fatal_error(_("Raster map <%s> not found"), rast->answer);
-    }
-    if ((cellfile = G_open_cell_old(rast->answer, cellmap)) == -1) {
+    if ((cellfile = G_open_cell_old(rast->answer, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), rast->answer);
-    }
 
 
     G_get_set_window(&w);

+ 8 - 34
raster/r.sun/main.c

@@ -78,8 +78,6 @@ char *beam_rad = NULL;
 char *insol_time = NULL;
 char *diff_rad = NULL;
 char *refl_rad = NULL;
-char *mapset1 = NULL, *mapset2 = NULL, *mapset3 = NULL, *mapset4 = NULL,
-    *mapset5 = NULL, *mapset6 = NULL, *mapset7 = NULL, *mapset8 = NULL;
 char *per;
 char *shade;
 
@@ -518,18 +516,9 @@ int INPUT(void)
 
     }
 
-    if ((mapset1 = G_find_cell(elevin, "")) == NULL)
-	G_fatal_error(_("elevin raster map <%s> not found"), elevin);
-
-    if ((mapset2 = G_find_cell(aspin, "")) == NULL)
-	G_fatal_error(_("aspin raster map <%s> not found"), aspin);
-
-    if ((mapset3 = G_find_cell(slopein, "")) == NULL)
-	G_fatal_error(_("slopein raster map <%s> not found"), slopein);
-
-    fd1 = G_open_cell_old(elevin, mapset1);
-    fd2 = G_open_cell_old(aspin, mapset2);
-    fd3 = G_open_cell_old(slopein, mapset3);
+    fd1 = G_open_cell_old(elevin, "");
+    fd2 = G_open_cell_old(aspin, "");
+    fd3 = G_open_cell_old(slopein, "");
 
     if (linkein != NULL) {
 	cell4 = G_allocate_f_raster_buf();
@@ -537,10 +526,7 @@ int INPUT(void)
 	for (l = 0; l < m; l++)
 	    li[l] = (float *)G_malloc(sizeof(float) * (n));
 
-	if ((mapset4 = G_find_cell(linkein, "")) == NULL)
-	    G_fatal_error(_("linkein raster map <%s> not found"), linkein);
-
-	fd4 = G_open_cell_old(linkein, mapset4);
+	fd4 = G_open_cell_old(linkein, "");
     }
 
     if (albedo != NULL) {
@@ -549,10 +535,7 @@ int INPUT(void)
 	for (l = 0; l < m; l++)
 	    a[l] = (float *)G_malloc(sizeof(float) * (n));
 
-	if ((mapset5 = G_find_cell(albedo, "")) == NULL)
-	    G_fatal_error(_("albedo raster map <%s> not found"), albedo);
-
-	fd5 = G_open_cell_old(albedo, mapset5);
+	fd5 = G_open_cell_old(albedo, "");
     }
 
     if (latin != NULL) {
@@ -561,10 +544,7 @@ int INPUT(void)
 	for (l = 0; l < m; l++)
 	    la[l] = (float *)G_malloc(sizeof(float) * (n));
 
-	if ((mapset6 = G_find_cell(latin, "")) == NULL)
-	    G_fatal_error(_("latin raster map <%s> not found"), latin);
-
-	fd6 = G_open_cell_old(latin, mapset6);
+	fd6 = G_open_cell_old(latin, "");
     }
 
     if (coefbh != NULL) {
@@ -573,10 +553,7 @@ int INPUT(void)
 	for (l = 0; l < m; l++)
 	    cbhr[l] = (float *)G_malloc(sizeof(float) * (n));
 
-	if ((mapset7 = G_find_cell(coefbh, "")) == NULL)
-	    G_fatal_error(_("coefbh raster map <%s> not found"), coefbh);
-
-	fr1 = G_open_cell_old(coefbh, mapset7);
+	fr1 = G_open_cell_old(coefbh, "");
     }
 
     if (coefdh != NULL) {
@@ -585,10 +562,7 @@ int INPUT(void)
 	for (l = 0; l < m; l++)
 	    cdhr[l] = (float *)G_malloc(sizeof(float) * (n));
 
-	if ((mapset8 = G_find_cell(coefdh, "")) == NULL)
-	    G_fatal_error(_("coefdh raster map <%s> not found"), coefdh);
-
-	fr2 = G_open_cell_old(coefdh, mapset8);
+	fr2 = G_open_cell_old(coefdh, "");
     }
 
 

+ 3 - 7
raster/r.sunmask/main.c

@@ -86,7 +86,6 @@ double raster_value(union RASTER_PTR buf, int data_type, int col);
 
 int main(int argc, char *argv[])
 {
-    char *mapset;
     extern struct Cell_head window;
     union RASTER_PTR elevbuf, tmpbuf, outbuf;
     CELL min, max;
@@ -451,10 +450,7 @@ int main(int argc, char *argv[])
 	exit(EXIT_SUCCESS);
     }
 
-    /* Search for output layer in all mapsets ? yes. */
-    mapset = G_find_cell2(name, "");
-
-    if ((elev_fd = G_open_cell_old(name, mapset)) < 0)
+    if ((elev_fd = G_open_cell_old(name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), name);
     if ((output_fd = G_open_cell_new(outname)) < 0)
 	G_fatal_error(_("Unable to create raster map <%s>"), outname);
@@ -465,14 +461,14 @@ int main(int argc, char *argv[])
     outbuf.v = G_allocate_raster_buf(CELL_TYPE);	/* binary map */
 
     if (data_type == CELL_TYPE) {
-	if ((G_read_range(name, mapset, &range)) < 0)
+	if ((G_read_range(name, "", &range)) < 0)
 	    G_fatal_error(_("Can't open range file for %s"), name);
 	G_get_range_min_max(&range, &min, &max);
 	dmin = (double)min;
 	dmax = (double)max;
     }
     else {
-	G_read_fp_range(name, mapset, &fprange);
+	G_read_fp_range(name, "", &fprange);
 	G_get_fp_range_min_max(&fprange, &dmin, &dmax);
     }
 

+ 5 - 5
raster/r.support.stats/check.c

@@ -26,7 +26,7 @@
  *
  * RETURN: 0 on success / 1 on failure
  */
-int check_stats(char *name, char *mapset)
+int check_stats(const char *name)
 {
     RASTER_MAP_TYPE data_type;
     struct Histogram histogram;
@@ -37,13 +37,13 @@ int check_stats(char *name, char *mapset)
     int cats_ok;
     int max;
 
-    data_type = G_raster_map_type(name, mapset);
+    data_type = G_raster_map_type(name, "");
 
     G_message(_("Updating statistics for [%s]..."), name);
 
-    if (!do_histogram(name, mapset))
+    if (!do_histogram(name))
 	return 1;
-    if (G_read_histogram(name, mapset, &histogram) <= 0)
+    if (G_read_histogram(name, "", &histogram) <= 0)
 	return 1;
 
     /* Init histogram range */
@@ -71,7 +71,7 @@ int check_stats(char *name, char *mapset)
 	G_write_fp_range(name, &fprange);
 
     /* Get category status and max */
-    cats_ok = (G_read_cats(name, mapset, &cats) >= 0);
+    cats_ok = (G_read_cats(name, "", &cats) >= 0);
     max = (data_type == CELL_TYPE ? range.max : fprange.max);
 
     /* Further category checks */

+ 3 - 3
raster/r.support.stats/histo.c

@@ -24,7 +24,7 @@
  *
  * RETURN: 0 on success / 1 on failure
  */
-int do_histogram(char *name, char *mapset)
+int do_histogram(const char *name)
 {
     CELL *cell;
     struct Cell_head cellhd;
@@ -33,11 +33,11 @@ int do_histogram(char *name, char *mapset)
     int row;
     int fd;
 
-    if (G_get_cellhd(name, mapset, &cellhd) < 0)
+    if (G_get_cellhd(name, "", &cellhd) < 0)
 	return 1;
 
     G_set_window(&cellhd);
-    if ((fd = G_open_cell_old(name, mapset)) < 0)
+    if ((fd = G_open_cell_old(name, "")) < 0)
 	return 1;
 
     nrows = G_window_rows();

+ 2 - 2
raster/r.support.stats/local_proto.h

@@ -21,10 +21,10 @@
 
 
 /* check.c */
-int check_stats(char *, char *);
+int check_stats(const char *);
 
 /* histo.c */
-int do_histogram(char *, char *);
+int do_histogram(const char *);
 
 
 #endif /* __LOCAL_PROTO_H__ */

+ 1 - 6
raster/r.support.stats/main.c

@@ -24,7 +24,6 @@
 
 int main(int argc, char *argv[])
 {
-    char *mapset;
     struct GModule *module;
     struct
     {
@@ -43,11 +42,7 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    mapset = G_find_cell2(parm.raster->answer, G_mapset());
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), parm.raster->answer);
-
-    check_stats(parm.raster->answer, mapset);
+    check_stats(parm.raster->answer);
 
     G_message(_("Statistics for <%s> updated"), parm.raster->answer);
 

+ 1 - 6
raster/r.surf.area/main.c

@@ -75,7 +75,6 @@ int main(int argc, char *argv[])
 {
     struct GModule *module;
     struct Option *surf, *vscale;
-    char *cellmap;
     DCELL *cell_buf[2];
     int row;
     struct Cell_head w;
@@ -115,11 +114,7 @@ int main(int argc, char *argv[])
 
     /* open raster map for reading */
     {
-	cellmap = G_find_file2("cell", surf->answer, "");
-	if (!cellmap)
-	    G_fatal_error(_("Raster map <%s> not found"), surf->answer);
-
-	if ((cellfile = G_open_cell_old(surf->answer, cellmap)) == -1)
+	if ((cellfile = G_open_cell_old(surf->answer, "")) == -1)
 	    G_fatal_error(_("Unable to open raster map <%s>"), surf->answer);
     }
 

+ 5 - 15
raster/r.surf.gauss/main.c

@@ -28,19 +28,11 @@ int main(int argc, char *argv[])
     double gauss_mean, gauss_sigma;
 
     struct GModule *module;
-    struct Option *out;		/* Structures required for the G_parser()       */
-
-    /* call. These can be filled with the           */
-    struct Option *mean;	/* various defaults, mandatory paramters        */
-
-    /* etc. for the GRASS user interface.           */
+    struct Option *out;
+    struct Option *mean;
     struct Option *sigma;
 
-    G_gisinit(argv[0]);		/*      This GRASS library function MUST
-				   be called first to check for valid
-				   database and mapset. As usual argv[0]
-				   is the program name. This can be
-				   recalled using G_program_name(). */
+    G_gisinit(argv[0]);
 
     module = G_define_module();
     module->keywords = _("raster");
@@ -50,17 +42,16 @@ int main(int argc, char *argv[])
 	  "can be expressed by the user. It uses a gaussian "
 	  "random number generator.");
 
-    /****** SET PARSER OPTIONS ******/
     out = G_define_standard_option(G_OPT_R_OUTPUT);
     out->description = _("Name of the output random surface");
 
-    mean = G_define_option();	/*      Mean of the distribution  */
+    mean = G_define_option();
     mean->key = "mean";
     mean->description = _("Distribution mean");
     mean->type = TYPE_DOUBLE;
     mean->answer = "0.0";
 
-    sigma = G_define_option();	/*      Standard deviation of the distribution  */
+    sigma = G_define_option();
     sigma->key = "sigma";
     sigma->description = _("Standard deviation");
     sigma->type = TYPE_DOUBLE;
@@ -72,7 +63,6 @@ int main(int argc, char *argv[])
     sscanf(mean->answer, "%lf", &gauss_mean);
     sscanf(sigma->answer, "%lf", &gauss_sigma);
 
-    /****** CREATE THE RANDOM CELL FILE  ******/
     gaussurf(out->answer, gauss_mean, gauss_sigma);
 
     exit(EXIT_SUCCESS);

+ 2 - 10
raster/r.surf.idw/main.c

@@ -80,7 +80,6 @@ static char *output;
 
 int main(int argc, char **argv)
 {
-    char *layer_mapset, *current_mapset;
     MELEMENT *rowlist;
     SHORT nrows, ncols;
     SHORT datarows;
@@ -132,17 +131,10 @@ int main(int argc, char **argv)
     input = parm.input->answer;
     output = parm.output->answer;
 
-    current_mapset = G_mapset();
-
     /*  Get database window parameters                              */
     if (G_get_window(&window) < 0)
 	G_fatal_error(_("Unable to read current region parameters"));
 
-    /* Make sure layer_map is available                                     */
-    layer_mapset = G_find_cell(input, "");
-    if (layer_mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), input);
-
     /*  find number of rows and columns in window                   */
     nrows = G_window_rows();
     ncols = G_window_cols();
@@ -155,14 +147,14 @@ int main(int argc, char **argv)
     cell = G_allocate_cell_buf();
     if ((maskfd = G_maskfd()) >= 0 || error_flag) {	/* apply mask to output */
 	if (error_flag)		/* use input as mask when -e option chosen */
-	    maskfd = G_open_cell_old(input, layer_mapset);
+	    maskfd = G_open_cell_old(input, "");
 	mask = G_allocate_cell_buf();
     }
     else
 	mask = NULL;
 
     /*  Open input cell layer for reading                           */
-    fd = G_open_cell_old(input, layer_mapset);
+    fd = G_open_cell_old(input, "");
     if (fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), input);
 

+ 2 - 9
raster/r.surf.idw2/read_cell.c

@@ -12,24 +12,17 @@ int read_cell(char *name)
     struct Cell_head window, cellhd;
     int row, col;
     double z, north;
-    char *mapset;
-
-    mapset = G_find_cell(name, "");
-    if (mapset == NULL) {
-	G_fatal_error(_("Raster map <%s> not found"), name);
-	exit(EXIT_FAILURE);
-    }
 
     G_get_window(&window);
 
     /* Set window to align with input raster map */
-    G_get_cellhd(name, mapset, &cellhd);
+    G_get_cellhd(name, "", &cellhd);
     G_align_window(&window, &cellhd);
     G_set_window(&window);
 
     cell = G_allocate_cell_buf();
 
-    fd = G_open_cell_old(name, mapset);
+    fd = G_open_cell_old(name, "");
     if (fd < 0) {
 	G_fatal_error(_("Unable to open raster map <%s>"), name);
 	exit(EXIT_FAILURE);

+ 4 - 14
raster/r.surf.random/main.c

@@ -25,20 +25,12 @@ int main(int argc, char *argv[])
     /****** INITIALISE ******/
 
     struct GModule *module;
-    struct Option *out;		/* Structures required for the G_parser()       */
-
-    /* call. These can be filled with the           */
-    struct Option *min;		/* various defaults, mandatory paramters        */
-
-    /* etc. for the GRASS user interface.           */
+    struct Option *out;
+    struct Option *min;
     struct Option *max;
     struct Flag *i_flag;
 
-    G_gisinit(argv[0]);		/* This GRASS library function MUST
-				   be called first to check for valid
-				   database and mapset. As usual argv[0]
-				   is the program name. This can be
-				   recalled using G_program_name(). */
+    G_gisinit(argv[0]);
 
     module = G_define_module();
     module->keywords = _("raster");
@@ -66,12 +58,10 @@ int main(int argc, char *argv[])
     i_flag->description = _("Create an integer map");
 
     if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);	/* Returns a 0 if sucessful */
-
+	exit(EXIT_FAILURE);
 
     randsurf(out->answer, atoi(min->answer), atoi(max->answer),
 	     i_flag->answer);
 
-
     exit(EXIT_SUCCESS);
 }

+ 3 - 8
raster/r.texture/main.c

@@ -48,7 +48,7 @@ static const char *suffixes[56] = {
 int main(int argc, char *argv[])
 {
     struct Cell_head cellhd;
-    char *name, *result, *mapset, *filename;
+    char *name, *result, *filename;
     unsigned char *outrast;
     int nrows, ncols;
     int row, col, i, j;
@@ -207,18 +207,13 @@ int main(int argc, char *argv[])
 	&& moc2 && mcc)
 	G_fatal_error(_("Nothing to compute. Use at least one of the flags."));
 
-    /* find map in mapset */
-    mapset = G_find_cell2(name, "");
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), name);
-
-    if ((infd = G_open_cell_old(name, mapset)) < 0)
+    if ((infd = G_open_cell_old(name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), name);
 
     /* determine the inputmap type (CELL/FCELL/DCELL) */
     data_type = G_get_raster_map_type(infd);
 
-    if (G_get_cellhd(name, mapset, &cellhd) < 0)
+    if (G_get_cellhd(name, "", &cellhd) < 0)
 	G_fatal_error(_("Unable to read header of raster map <%s>"), name);
 
     out_data_type = FCELL_TYPE;

+ 3 - 8
raster/r.thin/io.c

@@ -83,7 +83,6 @@ static int write_row(int file, const void *buf, int row, int buf_len)
 
 int open_file(char *name)
 {
-    char *mapset;
     int cell_file, buf_len;
     int i, row, col;
     char cell[100];
@@ -91,11 +90,7 @@ int open_file(char *name)
 
     /* open raster map */
     strcpy(cell, name);
-    if ((mapset = G_find_cell2(cell, "")) == NULL) {
-	unlink(work_file_name);
-	G_fatal_error(_("Raster map <%s> not found"), name);
-    }
-    if ((cell_file = G_open_cell_old(cell, mapset)) < 0) {
+    if ((cell_file = G_open_cell_old(cell, "")) < 0) {
 	unlink(work_file_name);
 	G_fatal_error(_("Unable to open raster map <%s>"), cell);
     }
@@ -128,8 +123,8 @@ int open_file(char *name)
     for (row = 0; row < n_rows; row++) {
 	if (G_get_map_row(cell_file, buf + PAD, row) < 0) {
 	    unlink(work_file_name);
-	    G_fatal_error(_("%s: Error reading from raster map <%s> in mapset <%s>"),
-			  error_prefix, cell, mapset);
+	    G_fatal_error(_("%s: Error reading from raster map <%s>"),
+			  error_prefix, cell);
 	}
 	if (write(work_file, buf, buf_len) != buf_len) {
 	    unlink(work_file_name);

+ 1 - 10
raster/r.timestamp/main.c

@@ -26,7 +26,6 @@ int main(int argc, char *argv[])
     struct Option *map, *date;
     struct TimeStamp ts;
     char *name;
-    char *mapset;
     int modify;
 
     G_gisinit(argv[0]);
@@ -51,16 +50,8 @@ int main(int argc, char *argv[])
 
     modify = date->answer != NULL;
 
-    if (modify)
-	mapset = G_find_cell(name, G_mapset());
-    else
-	mapset = G_find_cell(name, "");
-    if (mapset == NULL)
-	G_fatal_error("Map <%s> not found %s", name,
-		      modify ? "in current mapset" : "");
-
     if (!modify) {
-	if (G_read_raster_timestamp(name, mapset, &ts) == 1) {
+	if (G_read_raster_timestamp(name, "", &ts) == 1) {
 	    G__write_timestamp(stdout, &ts);
 	    exit(EXIT_SUCCESS);
 	}

+ 7 - 18
raster/r.to.rast3/main.c

@@ -39,7 +39,7 @@ int globalG3dMapType;
 void fatal_error(void *map, int *fd, int depths, char *errorMsg);	/*Simple Error message */
 void set_params();		/*Fill the paramType structure */
 void raster_to_g3d(void *map, G3D_Region region, int *fd);	/*Write the raster */
-int open_input_raster_map(char *name, char *mapset);	/*opens the outputmap */
+int open_input_raster_map(const char *name);	/*opens the outputmap */
 void close_input_raster_map(int fd);	/*close the map */
 
 
@@ -183,7 +183,6 @@ int main(int argc, char *argv[])
     int *fd = NULL;		/*The filehandler array for the 2D inputmaps */
     int cols, rows, opencells;
     char *name;
-    char *mapset;
     int changemask = 0;
     int maptype_tmp, nofile = 0;
 
@@ -235,7 +234,6 @@ int main(int argc, char *argv[])
     if (fd == NULL)
 	fatal_error(map, NULL, 0, _("Out of memory"));
 
-    mapset = NULL;
     name = NULL;
 
     globalRastMapType = DCELL_TYPE;
@@ -246,24 +244,15 @@ int main(int argc, char *argv[])
     /*Loop over all output maps! open */
     for (i = 0; i < region.depths; i++) {
 	/*Open only existing maps */
-	if (param.input->answers[i] != NULL && nofile == 0) {
-	    mapset = NULL;
-	    name = NULL;
+	if (nofile == 0 && param.input->answers[i])
 	    name = param.input->answers[i];
-	    mapset = G_find_cell2(name, "");
-
-	    if (mapset == NULL) {
-		fatal_error(map, fd, opencells, _("Cell file not found"));
-	    }
-	}
-	else {
+	else
 	    nofile = 1;
-	}
 
 	/*if only one map is given, open it depths - times */
 	G_message(_("Open raster map %s - one time for each depth (%d/%d)"),
 		  name, i + 1, region.depths);
-	fd[i] = open_input_raster_map(name, mapset);
+	fd[i] = open_input_raster_map(name);
 	opencells++;
 
 	maptype_tmp = G_get_raster_map_type(fd[i]);
@@ -348,15 +337,15 @@ int main(int argc, char *argv[])
 /* ************************************************************************* */
 /* Open the raster input map *********************************************** */
 /* ************************************************************************* */
-int open_input_raster_map(char *name, char *mapset)
+int open_input_raster_map(const char *name)
 {
     int fd;
 
-    G_debug(3, "Open Raster file %s in Mapset %s", name, mapset);
+    G_debug(3, "Open Raster file %s", name);
 
 
     /* open raster map */
-    fd = G_open_cell_old(name, mapset);
+    fd = G_open_cell_old(name, "");
 
     if (fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), name);

+ 21 - 70
raster/r.to.rast3elev/main.c

@@ -52,7 +52,7 @@ paramType param;		/*params */
 void fatal_error(Database db, char *errorMsg);	/*Simple Error message */
 void set_params();		/*Fill the paramType structure */
 void elev_raster_to_g3d(Database db, G3D_Region region);	/*Write the raster */
-int open_input_raster_map(char *name, char *mapset);	/*opens the outputmap */
+int open_input_raster_map(const char *name);	/*opens the outputmap */
 void close_input_raster_map(int fd);	/*close the map */
 double get_raster_value_as_double(int maptype, void *ptr, double nullval);
 void check_input_maps(Database * db);	/*Check input maps */
@@ -63,34 +63,15 @@ void check_input_maps(Database * db);	/*Check input maps */
 /* ************************************************************************* */
 double get_raster_value_as_double(int MapType, void *ptr, double nullval)
 {
-    double val = nullval;
-
-    if (MapType == CELL_TYPE) {
-	if (G_is_null_value(ptr, MapType)) {
-	    val = nullval;
-	}
-	else {
-	    val = *(CELL *) ptr;
-	}
-    }
-    if (MapType == FCELL_TYPE) {
-	if (G_is_null_value(ptr, MapType)) {
-	    val = nullval;
-	}
-	else {
-	    val = *(FCELL *) ptr;
-	}
-    }
-    if (MapType == DCELL_TYPE) {
-	if (G_is_null_value(ptr, MapType)) {
-	    val = nullval;
-	}
-	else {
-	    val = *(DCELL *) ptr;
-	}
+    if (G_is_null_value(ptr, MapType))
+	return nullval;
+
+    switch (MapType) {
+    case CELL_TYPE:	return *(CELL *) ptr;
+    case FCELL_TYPE:	return *(FCELL *) ptr;
+    case DCELL_TYPE:	return *(DCELL *) ptr;
+    default:		return nullval;
     }
-
-    return val;
 }
 
 /* ************************************************************************* */
@@ -98,46 +79,23 @@ double get_raster_value_as_double(int MapType, void *ptr, double nullval)
 /* ************************************************************************* */
 void check_input_maps(Database * db)
 {
-    char *mapset = NULL;
     int i;
     int elevcount = 0, inputcount = 0;
 
     G_debug(2, "Checking input maps");
 
     /*Check elev maps */
-    if (param.elev->answers != NULL) {
-	for (i = 0; param.elev->answers[i] != NULL; i++) {
-
-	    mapset = NULL;
-	    mapset = G_find_cell2(param.elev->answers[i], "");
-	    if (mapset == NULL) {
-		G_fatal_error(_("Raster map <%s> not found"),
-			      param.elev->answers[i]);
-		exit(EXIT_FAILURE);
-	    }
+    if (param.elev->answers != NULL)
+	for (i = 0; param.elev->answers[i] != NULL; i++)
 	    elevcount++;
-	}
-    }
 
     /*Check input maps */
-    if (param.input->answers != NULL) {
-	for (i = 0; param.input->answers[i] != NULL; i++) {
-
-	    mapset = NULL;
-	    mapset = G_find_cell2(param.input->answers[i], "");
-	    if (mapset == NULL) {
-		G_fatal_error(_("Raster map <%s> not found"),
-			      param.input->answers[i]);
-		exit(EXIT_FAILURE);
-	    }
+    if (param.input->answers != NULL)
+	for (i = 0; param.input->answers[i] != NULL; i++)
 	    inputcount++;
-	}
-    }
 
-    if (elevcount != inputcount) {
+    if (elevcount != inputcount)
 	G_fatal_error(_("The number of input and elevation maps is not equal"));
-	exit(EXIT_FAILURE);
-    }
 
     db->mapnum = inputcount;
 
@@ -147,14 +105,14 @@ void check_input_maps(Database * db)
 /* ************************************************************************* */
 /* Open the raster input map *********************************************** */
 /* ************************************************************************* */
-int open_input_raster_map(char *name, char *mapset)
+int open_input_raster_map(const char *name)
 {
     int fd;
 
-    G_debug(3, "Open Raster file %s in Mapset %s", name, mapset);
+    G_debug(3, "Open Raster file %s", name);
 
     /* open raster map */
-    fd = G_open_cell_old(name, mapset);
+    fd = G_open_cell_old(name, "");
 
     if (fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), name);
@@ -382,7 +340,6 @@ int main(int argc, char *argv[])
     struct GModule *module;
     int cols, rows, i;
     char *name = NULL;
-    char *mapset = NULL;
     int changemask = 0;
     Database db;
 
@@ -501,22 +458,16 @@ int main(int argc, char *argv[])
 
 	db.count = i;
 	/*Open input map */
-	mapset = NULL;
-	name = NULL;
 	name = param.input->answers[i];
-	mapset = G_find_cell2(name, "");
-	db.input = open_input_raster_map(name, mapset);
-	db.inputmaptype = G_raster_map_type(name, mapset);
+	db.input = open_input_raster_map(name);
+	db.inputmaptype = G_raster_map_type(name, "");
 
 	G_debug(2, "Open elev raster map %s", param.elev->answers[i]);
 
 	/*Open elev map */
-	mapset = NULL;
-	name = NULL;
 	name = param.elev->answers[i];
-	mapset = G_find_cell2(name, "");
-	db.elev = open_input_raster_map(name, mapset);
-	db.elevmaptype = G_raster_map_type(name, mapset);
+	db.elev = open_input_raster_map(name);
+	db.elevmaptype = G_raster_map_type(name, "");
 
 	/****************************************/
 	/*Write the data into the G3D Rastermap */

+ 0 - 16
raster/r.topidx/check_ready.c

@@ -1,16 +0,0 @@
-#include "global.h"
-#include <grass/glocale.h>
-
-int check_ready(void)
-{
-    int retval;
-
-    retval = 0;
-
-    if (!G_find_file("cell", iname, mapset)) {
-	G_fatal_error(_("Raster map <%s> not found"), iname);
-	retval = 1;
-    }
-
-    return retval;
-}

+ 1 - 1
raster/r.topidx/file_io.c

@@ -12,7 +12,7 @@ void getcells(void)
     FCELL *fcell = NULL;
 
 
-    if ((fd = G_open_cell_old(iname, mapset)) < 0)
+    if ((fd = G_open_cell_old(iname, "")) < 0)
 	G_fatal_error(_("Cannot open raster map <%s>"), iname);
 
     data_type = G_get_raster_map_type(fd);

+ 1 - 2
raster/r.topidx/global.h

@@ -12,13 +12,12 @@
 #define	ZERO		0.0000001
 
 
-int check_ready(void);
 void getcells(void);
 void putcells(void);
 void initialize(void);
 void atanb(void);
 
-extern char *mapset, *iname, *oname;
+extern char *iname, *oname;
 extern struct Cell_head window;
 extern DCELL **cell;
 extern DCELL **atb, **a;

+ 1 - 5
raster/r.topidx/main.c

@@ -21,7 +21,7 @@
 #include <grass/glocale.h>
 #include "global.h"
 
-char *mapset, *iname, *oname;
+char *iname, *oname;
 struct Cell_head window;
 DCELL **cell;
 DCELL **atb, **a;
@@ -58,12 +58,8 @@ int main(int argc, char **argv)
 		      G_program_name());
 
     iname = params.input->answer;
-    mapset = G_find_cell2(iname, "");
     oname = params.output->answer;
 
-    if (check_ready())
-	exit(EXIT_FAILURE);
-
     G_get_window(&window);
 
     getcells();

+ 9 - 9
raster/r.topmodel/check_ready.c

@@ -246,17 +246,17 @@ int check_io(void)
     retval = 0;
 
     if (!flg.input) {
-	if (map.elev && !G_find_file("cell", map.elev, mapset)) {
+	if (map.elev && !G_find_cell(map.elev, mapset)) {
 	    G_warning("%s - not exists", map.elev);
 	    retval = 1;
 	}
 
-	if (map.basin && !G_find_file("cell", map.basin, mapset)) {
+	if (map.basin && !G_find_cell(map.basin, mapset)) {
 	    G_warning("%s - not exists", map.basin);
 	    retval = 1;
 	}
 
-	if (map.fill && G_find_file("cell", map.fill, mapset)) {
+	if (map.fill && G_find_cell(map.fill, mapset)) {
 	    if (flg.overwr) {
 		flg.overwrlist |= FILL;
 	    }
@@ -266,7 +266,7 @@ int check_io(void)
 	    }
 	}
 
-	if (map.dir && G_find_file("cell", map.dir, mapset)) {
+	if (map.dir && G_find_cell(map.dir, mapset)) {
 	    if (flg.overwr) {
 		flg.overwrlist |= DIR;
 	    }
@@ -276,7 +276,7 @@ int check_io(void)
 	    }
 	}
 
-	if (map.belev && G_find_file("cell", map.belev, mapset)) {
+	if (map.belev && G_find_cell(map.belev, mapset)) {
 	    if (flg.overwr) {
 		flg.overwrlist |= BELEV;
 	    }
@@ -286,7 +286,7 @@ int check_io(void)
 	    }
 	}
 
-	if (map.topidx && G_find_file("cell", map.topidx, mapset)) {
+	if (map.topidx && G_find_cell(map.topidx, mapset)) {
 	    if (flg.overwr) {
 		flg.overwrlist |= TOPIDX;
 	    }
@@ -309,12 +309,12 @@ int check_io(void)
     }
     else {
 	if (map.belev) {
-	    if (!G_find_file("cell", map.belev, mapset)) {
+	    if (!G_find_cell(map.belev, mapset)) {
 		G_warning("%s - not exists", map.belev);
 		retval = 1;
 	    }
 	    else {
-		if (map.topidx && G_find_file("cell", map.topidx, mapset)) {
+		if (map.topidx && G_find_cell(map.topidx, mapset)) {
 		    if (flg.overwr) {
 			flg.overwrlist |= TOPIDX;
 		    }
@@ -338,7 +338,7 @@ int check_io(void)
 	    }
 	}
 	else if (map.topidx) {
-	    if (!G_find_file("cell", map.topidx, mapset)) {
+	    if (!G_find_cell(map.topidx, mapset)) {
 		G_warning("%s - not exists", map.topidx);
 		retval = 1;
 	    }

+ 1 - 4
raster/r.topmodel/main.c

@@ -26,7 +26,7 @@ struct map map;
 struct file file;
 struct misc misc;
 struct flg flg;
-char *gisbase, *mapset;
+char *mapset;
 
 int main(int argc, char **argv)
 {
@@ -198,11 +198,8 @@ int main(int argc, char **argv)
     flg.input = flag.input->answer;
     flg.overwr = module->overwrite;
 
-
-    gisbase = G_gisbase();
     mapset = G_mapset();
 
-
     /* Check run conditions */
     if (check_ready())
 	exit(1);

+ 9 - 12
raster/r.topmodel/misc.c

@@ -38,7 +38,7 @@ void gregion(void)
     }
 
     if (hdmap) {
-	sprintf(buf, "%s/bin/g.region rast=%s > /dev/null", gisbase, hdmap);
+	sprintf(buf, "g.region rast=%s > /dev/null", hdmap);
 	G_message("g.region rast=%s ... ", hdmap);
 
 	if (run(buf))
@@ -50,9 +50,8 @@ void gregion(void)
 void depressionless(void)
 {
     char buf[GPATH_MAX];
-    sprintf(buf, "%s/bin/r.fill.dir "
-	    "input=%s elev=%s dir=%s type=grass > /dev/null",
-	    gisbase, map.elev, map.fill, map.dir);
+    sprintf(buf, "r.fill.dir input=%s elev=%s dir=%s type=grass > /dev/null",
+	    map.elev, map.fill, map.dir);
     G_message("r.fill.dir input=%s elev=%s dir=%s type=grass ... ",
 	      map.elev, map.fill, map.dir);
 
@@ -69,9 +68,8 @@ void depressionless(void)
 void basin_elevation(void)
 {
     char buf[GPATH_MAX];
-    sprintf(buf, "%s/bin/r.mapcalc "
-	    "'%s = if(%s == 0 || isnull(%s), null(), %s)' > /dev/null",
-	    gisbase, map.belev, map.basin, map.basin, map.elev);
+    sprintf(buf, "r.mapcalc '%s = if(%s == 0 || isnull(%s), null(), %s)' > /dev/null",
+	    map.belev, map.basin, map.basin, map.elev);
     G_message("r.mapcalc '%s = if(%s == 0 || isnull(%s), null(), %s)'"
 	      " ... ", map.belev, map.basin, map.basin, map.elev);
 
@@ -87,9 +85,8 @@ void top_index(void)
 {
     char buf[GPATH_MAX];
     if (map.belev) {
-	sprintf(buf, "%s/bin/r.topidx "
-		"input=%s output=%s > /dev/null",
-		gisbase, map.belev, map.topidx);
+	sprintf(buf, "r.topidx input=%s output=%s > /dev/null",
+		map.belev, map.topidx);
 	G_message("r.topidx input=%s output=%s ... ", map.belev, map.topidx);
 
 	if (run(buf))
@@ -97,9 +94,9 @@ void top_index(void)
     }
 
     if (map.topidx) {
-	sprintf(buf, "%s/bin/r.stats -Anc "
+	sprintf(buf, "r.stats -Anc "
 		"input=%s nsteps=%d > %s",
-		gisbase, map.topidx, misc.nidxclass, file.idxstats);
+		map.topidx, misc.nidxclass, file.idxstats);
 	G_message("r.stats -Anc input=%s nsteps=%d > %s ... ",
 		  map.topidx, misc.nidxclass, file.idxstats);
 

+ 1 - 38
raster/r.transect/main.c

@@ -29,12 +29,10 @@ int main(int argc, char *argv[])
 {
     double e1, n1, e2, n2;
     char buf[256];
-    char command[2048];
+    char command[GPATH_MAX];
 
     int n, err;
     int projection;
-    char *mapset;
-    char name[GNAME_MAX];
 
     struct GModule *module;
     struct
@@ -42,8 +40,6 @@ int main(int argc, char *argv[])
 	struct Option *map;
 	struct Option *line;
 	struct Option *null_str;
-	/*      struct Option *width;
-	   struct Option *result; */
     } parms;
     struct Flag *coord;
     char coord_str[3];
@@ -59,16 +55,6 @@ int main(int argc, char *argv[])
     parms.map = G_define_standard_option(G_OPT_R_MAP);
     parms.map->description = _("Raster map to be queried");
 
-    /*  parms.result = G_define_option();
-       parms.result->key = "result";
-       parms.result->key_desc = "type";
-       parms.result->type = TYPE_STRING;
-       parms.result->description = _("Type of result to be output");
-       parms.result->required = NO;
-       parms.result->multiple = NO;
-       parms.result->options = "raw,median,average";
-       parms.result->answer = "raw";
-     */
     parms.line = G_define_option();
     parms.line->key = "line";
     parms.line->key_desc = "east,north,azimuth,distance";
@@ -84,13 +70,6 @@ int main(int argc, char *argv[])
     parms.null_str->answer = "*";
     parms.null_str->description = _("Char string to represent no data cell");
 
-    /*  parms.width = G_define_option();
-       parms.width->key = "width";
-       parms.width->type = TYPE_INTEGER;
-       parms.width->description = _("Transect width, in cells (odd number)");
-       parms.width->answer = "1";
-     */
-
     coord = G_define_flag();
     coord->key = 'g';
     coord->description =
@@ -101,22 +80,6 @@ int main(int argc, char *argv[])
 
     projection = G_projection();
 
-    /*  sscanf (parms.width->answer, "%d", &n);
-       if (n <= 0 || n%2 == 0)
-       {
-       fprintf(stderr,"<%s=%s> ** illegal value **\n",
-       parms.width->key, parms.width->answer);
-       G_usage();
-       exit(EXIT_FAILURE);
-       }
-     */
-
-    strncpy(name, parms.map->answer, 255);
-    mapset = G_find_cell(name, "");
-
-    if (mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), name);
-
     if (coord->answer)
 	strcpy(coord_str, "-g");
     else

+ 1 - 8
raster/r.univar/r.univar_main.c

@@ -138,19 +138,12 @@ int main(int argc, char *argv[])
 
 static int open_raster(const char *infile)
 {
-    char *mapset;
     int fd;
 
-    mapset = G_find_cell2(infile, "");
-    if (mapset == NULL) {
-	G_fatal_error(_("Raster map <%s> not found"), infile);
-    }
-
-    fd = G_open_cell_old(infile, mapset);
+    fd = G_open_cell_old(infile, "");
     if (fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), infile);
 
-    /* . */
     return fd;
 }
 

+ 18 - 29
raster/r.volume/main.c

@@ -39,8 +39,8 @@ int main(int argc, char *argv[])
     int out_mode, use_MASK, *n, *e;
     long int *count;
     int fd_data, fd_clump;
-    char buf[200], datamap[100], clumpmap[100], site_list[100];
-    char *curr_mapset, *data_mapset, *clump_mapset;
+    char *datamap, *clumpmap, *site_list;
+    char *clump_mapset;
     double avg, vol, total_vol, east, north, *sum;
     struct Cell_head window;
     struct Map_info *fd_sites = NULL;
@@ -99,17 +99,17 @@ int main(int argc, char *argv[])
     mysite = G_site_new_struct(CELL_TYPE, 2, 0, 4);
 
     /* get arguments */
-    strcpy(datamap, opt1->answer);
+    datamap = opt1->answer;
 
-    if (opt2->answer != NULL)
-	strcpy(clumpmap, opt2->answer);
+    if (opt2->answer)
+	clumpmap = opt2->answer;
     else
-	clumpmap[0] = '\0';
+	clumpmap = "";
 
-    if (opt3->answer != NULL)
-	strcpy(site_list, opt3->answer);
+    if (opt3->answer)
+	site_list = opt3->answer;
     else
-	site_list[0] = '\0';
+	site_list = "";
 
     out_mode = (!flag1->answer);
 
@@ -122,23 +122,14 @@ int main(int argc, char *argv[])
      */
     use_MASK = 0;
     if (*clumpmap == '\0') {
-	strcpy(clumpmap, "MASK");
+	clumpmap = "MASK";
 	use_MASK = 1;
-	if (G_find_cell(clumpmap, G_mapset()) == NULL)
-	    G_fatal_error(_("No clump map specified and MASK not set."));
     }
-    curr_mapset = G_mapset();
-    data_mapset = G_find_cell2(datamap, "");
-    if (!data_mapset)
-	G_fatal_error(_("Unable to find data map"));
-
-    fd_data = G_open_cell_old(datamap, data_mapset);
+    fd_data = G_open_cell_old(datamap, "");
     if (use_MASK)
-	clump_mapset = curr_mapset;
+	clump_mapset = G_mapset();
     else
-	clump_mapset = G_find_cell2(clumpmap, "");
-    if (!clump_mapset)
-	G_fatal_error(_("Unable to find clump map"));
+	clump_mapset = "";
 
     fd_clump = G_open_cell_old(clumpmap, clump_mapset);
 
@@ -178,13 +169,11 @@ int main(int argc, char *argv[])
 	G_get_map_row(fd_clump, clump_buf, row);
 	for (col = 0; col < cols; col++) {
 	    i = clump_buf[col];
-	    if (i > max) {
-		sprintf(buf,
-			"Row=%d Col=%d Cat=%d in clump map [%s]; max=%d.\n",
-			row, col, i, clumpmap, max);
-		strcat(buf, "Cat value > max returned by G_number_of_cats.");
-		G_fatal_error(buf);
-	    }
+	    if (i > max)
+		G_fatal_error(
+		    "Row=%d Col=%d Cat=%d in clump map [%s]; max=%d.\n"
+		    "Cat value > max returned by G_number_of_cats.",
+		    row, col, i, clumpmap, max);
 	    if (i < 1)
 		continue;	/* ignore zeros and negs */
 	    count[i]++;

+ 25 - 60
raster/r.walk/main.c

@@ -115,8 +115,6 @@ struct variables
     {"coor", START_PT}
 };
 
-char cum_cost_layer[64];
-char cost_layer[64], dtm_layer[64];
 struct start_pt *head_start_pt = NULL;
 struct start_pt *head_end_pt = NULL;
 
@@ -128,13 +126,11 @@ struct Cell_head window;
 /* *************************************************************** */
 int main(int argc, char *argv[])
 {
+    const char *cum_cost_layer;
+    const char *start_layer, *cost_layer, *dtm_layer;
     void *dtm_cell, *cost_cell, *cum_cell, *cell2 = NULL;
     SEGMENT dtm_in_seg, cost_in_seg, out_seg;
-    char *dtm_mapset, *cost_mapset;
-    char *cum_cost_mapset;
-    char *current_mapset;
     char *dtm_in_file, *cost_in_file, *out_file;
-    char *search_mapset;
     double *dtm_value, *cost_value, *value_start_pt;
     char buf[400];
     extern struct Cell_head window;
@@ -215,6 +211,14 @@ int main(int argc, char *argv[])
     opt1->gisprompt = "new,cell,raster";
     opt1->description = _("Name of raster map to contain results");
 
+    opt14 = G_define_option();
+    opt14->key = "start_map";
+    opt14->type = TYPE_STRING;
+    opt14->required = NO;
+    opt14->gisprompt = "old,cell,raster";
+    opt14->description =
+	_("Name of input raster map containing starting points");
+
     opt7 = G_define_option();
     opt7->key = "start_points";
     opt7->type = TYPE_STRING;
@@ -416,15 +420,10 @@ int main(int argc, char *argv[])
 	Site *site = NULL;	/* pointer to Site */
 	int dims, strs, dbls;
 
-	search_mapset = "";
-	search_mapset = G_find_sites(opt7->answer, "");
-	if (search_mapset == NULL)
-	    G_fatal_error(_("Unable to find starting vector <%s> "),
-			  opt7->answer);
-	fp = G_fopen_sites_old(opt7->answer, search_mapset);
+	fp = G_fopen_sites_old(opt7->answer, "");
 
 	if (G_site_describe(fp, &dims, &cat, &strs, &dbls))
-	    G_fatal_error("Failed to guess site file format\n");
+	    G_fatal_error("Failed to guess site file format");
 	site = G_site_new_struct(cat, dims, strs, dbls);
 
 	for (; (G_site_get(fp, site) != EOF);) {
@@ -463,11 +462,7 @@ int main(int argc, char *argv[])
 	Site *site = NULL;	/* pointer to Site */
 	int dims, strs, dbls;
 
-	search_mapset = "";
-	search_mapset = G_find_sites(opt8->answer, "");
-	if (search_mapset == NULL)
-	    G_fatal_error(_("Unable to find stop vector <%s>"), opt8->answer);
-	fp = G_fopen_sites_old(opt8->answer, search_mapset);
+	fp = G_fopen_sites_old(opt8->answer, "");
 
 	if (G_site_describe(fp, &dims, &cat, &strs, &dbls))
 	    G_fatal_error("Failed to guess site file format\n");
@@ -513,30 +508,10 @@ int main(int argc, char *argv[])
 	keep_nulls = 0;		/* handled automagically... */
     }
 
-    strcpy(cum_cost_layer, opt1->answer);
-    current_mapset = G_mapset();
-
-    /*  Search for output layer (cum_cost_layer) in all mapsets */
-
-    search_mapset = "";
-    cum_cost_mapset = G_find_cell2(cum_cost_layer, search_mapset);
-
-
-    /*  Check if dtm  layer exists in data base  */
-
-    strcpy(dtm_layer, opt2->answer);
-    dtm_mapset = G_find_cell2(dtm_layer, search_mapset);
-
-    /* Handling new cost layer */
-
-    strcpy(cost_layer, opt12->answer);
-    cost_mapset = G_find_cell2(cost_layer, search_mapset);
-
-    if (dtm_mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), dtm_layer);
-
-    if (cost_mapset == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), cost_layer);
+    start_layer = opt14->answer;
+    dtm_layer = opt2->answer;
+    cost_layer = opt12->answer;
+    cum_cost_layer = opt1->answer;
 
     /*  Find number of rows and columns in window    */
 
@@ -546,8 +521,8 @@ int main(int argc, char *argv[])
 
     /*  Open cost cell layer for reading  */
 
-    dtm_fd = G_open_cell_old(dtm_layer, dtm_mapset);
-    cost_fd = G_open_cell_old(cost_layer, cost_mapset);
+    dtm_fd = G_open_cell_old(dtm_layer, "");
+    cost_fd = G_open_cell_old(cost_layer, "");
 
     if (dtm_fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), dtm_layer);
@@ -555,8 +530,8 @@ int main(int argc, char *argv[])
     if (cost_fd < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), cost_layer);
 
-    dtm_head_ok = G_get_cellhd(dtm_layer, dtm_mapset, &dtm_cellhd) >= 0;
-    cost_head_ok = G_get_cellhd(cost_layer, cost_mapset, &cost_cellhd) >= 0;
+    dtm_head_ok = G_get_cellhd(dtm_layer, "", &dtm_cellhd) >= 0;
+    cost_head_ok = G_get_cellhd(cost_layer, "", &cost_cellhd) >= 0;
 
     /*Reading headers from maps */
 
@@ -851,16 +826,10 @@ int main(int argc, char *argv[])
 
 	int dsize2;
 
-	cum_cost_mapset = G_find_cell2(cum_cost_layer, search_mapset);
-
-	if (cum_cost_mapset == NULL)
-	    G_fatal_error(_("Raster output map <%s> not found (no start_points given)"),
-			  cum_cost_layer);
-
-	cum_fd = G_open_cell_old(cum_cost_layer, cum_cost_mapset);
+	cum_fd = G_open_cell_old(start_layer, "");
 	if (cum_fd < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"),
-			  cum_cost_layer);
+			  start_layer);
 
 	data_type2 = G_get_raster_map_type(cum_fd);
 
@@ -868,10 +837,6 @@ int main(int argc, char *argv[])
 
 	cell2 = G_allocate_raster_buf(data_type2);
 
-	if (cell2 == NULL)
-	    G_fatal_error(_("Memory allocation error on reading start points from raster map %s"),
-			  cum_cost_layer);
-
 	G_message(_("Reading %s... "), cum_cost_layer);
 	for (row = 0; row < nrows; row++) {
 
@@ -1535,10 +1500,10 @@ int main(int argc, char *argv[])
     /*  Create colours for output map    */
 
     /*
-     * G_read_range (cum_cost_layer, current_mapset, &range);
+     * G_read_range (cum_cost_layer, "", &range);
      * G_get_range_min_max(&range, &min, &max);
      * G_make_color_wave(&colors,min, max);
-     * G_write_colors (cum_cost_layer,current_mapset,&colors);
+     * G_write_colors (cum_cost_layer,"",&colors);
      */
 
     /* writing history file */

+ 0 - 2
raster/r.walk/stash.h

@@ -25,8 +25,6 @@ struct start_pt
     struct start_pt *next;
 };
 
-extern char cum_cost_layer[];
-extern char cost_layer[], dtm_layer[];
 extern struct start_pt *head_start_pt;
 extern struct start_pt *head_end_pt;
 

+ 2 - 7
raster/r.what.color/main.c

@@ -78,7 +78,6 @@ int main(int argc, char **argv)
 	struct Flag *i;
     } flag;
     const char *name;
-    const char *mapset;
     struct Colors colors;
     RASTER_MAP_TYPE type;
 
@@ -121,16 +120,12 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Either \"-i\" or \"value=\" must be given"));
 
     name = opt.input->answer;
-    mapset = G_find_cell2(name, "");
 
-    if (!mapset)
-	G_fatal_error("Raster map <%s> not found", name);
-
-    type = G_raster_map_type(name, mapset);
+    type = G_raster_map_type(name, "");
     if (type < 0)
 	G_fatal_error("Unable to determine type of input map %s", name);
 
-    if (G_read_colors(name, mapset, &colors) < 0)
+    if (G_read_colors(name, "", &colors) < 0)
 	G_fatal_error("Unable to read colors for input map %s", name);
 
     fmt = opt.format->answer;

+ 0 - 12
raster/r.what/die.c

@@ -1,12 +0,0 @@
-#include <grass/gis.h>
-#include "local_proto.h"
-
-void die(char *a, char *b)
-{
-    char *message;
-
-    G_asprintf(&message, "%s: %s %s", G_program_name(), a, b);
-    G_fatal_error(message);
-
-    return;
-}

+ 0 - 11
raster/r.what/local_proto.h

@@ -1,11 +0,0 @@
-#ifndef _LOCAL_PROTO_H_
-#define _LOCAL_PROTO_H_
-/* die.c */
-void die(char *, char *);
-
-/* main.c */
-int oops(int, char *, char *);
-
-/* usage.c */
-void usage(void);
-#endif

+ 16 - 21
raster/r.what/main.c

@@ -21,7 +21,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <grass/gis.h>
-#include "local_proto.h"
 #include <grass/glocale.h>
 
 struct order
@@ -37,6 +36,7 @@ struct order
     DCELL dvalue[NFILES];
 };
 
+static int oops(int, const char *, const char *);
 static int by_row(const void *, const void *);
 static int by_point(const void *, const void *);
 
@@ -47,7 +47,6 @@ static int tty = 0;
 /* *************************************************************** */
 int main(int argc, char *argv[])
 {
-    char *mapset;
     int i, j;
     int nfiles;
     int withcats;
@@ -188,26 +187,24 @@ int main(int argc, char *argv[])
 	char name[GNAME_MAX];
 
 	if (nfiles >= NFILES)
-	    G_fatal_error(_("%s: can only do up to %d raster maps, sorry\n"),
-			  G_program_name(), NFILES);
+	    G_fatal_error(_("can only do up to %d raster maps"),
+			  NFILES);
 
 	strcpy(name, *ptr);
-	if (NULL == (mapset = G_find_cell2(name, "")))
-	    die(name, " - not found");
-	if (0 > (fd[nfiles] = G_open_cell_old(name, mapset)))
-	    die("can't open", name);
+	if ((fd[nfiles] = G_open_cell_old(name, "")) < 0)
+	    G_fatal_error(_("Unable to open <%s>"), name);
 
 	out_type[nfiles] = G_get_raster_map_type(fd[nfiles]);
 	if (flag3->answer)
 	    out_type[nfiles] = CELL_TYPE;
 
 	if (flag4->answer) {
-	    G_read_colors(name, mapset, &colors);
+	    G_read_colors(name, "", &colors);
 	    ncolor[nfiles] = colors;
 	}
 
-	if (withcats && G_read_cats(name, mapset, &cats[nfiles]) < 0)
-	    die(name, " - can't read category file");
+	if (withcats && G_read_cats(name, "", &cats[nfiles]) < 0)
+	    G_fatal_error(_("Unable to read category file for <%s>"), name);
 	nfiles++;
     }
 
@@ -330,14 +327,12 @@ int main(int argc, char *argv[])
 		cache_miss++;
 		if (row_in_window)
 		    for (i = 0; i < nfiles; i++) {
-			if (G_get_c_raster_row
-			    (fd[i], cell[i], cache[point].row) < 0)
-			    die(argv[i + 1], " - can't read");
+			if (G_get_c_raster_row(fd[i], cell[i], cache[point].row) < 0)
+			    G_fatal_error(_("Error reading <%s>"), argv[i + 1]);
 
 			if (out_type[i] != CELL_TYPE) {
-			    if (G_get_d_raster_row
-				(fd[i], dcell[i], cache[point].row) < 0)
-				die(argv[i + 1], " - can't read");
+			    if (G_get_d_raster_row(fd[i], dcell[i], cache[point].row) < 0)
+				G_fatal_error(_("Error reading <%s>"), argv[i + 1]);
 			}
 		    }
 
@@ -432,18 +427,18 @@ int main(int argc, char *argv[])
 /* *************************************************************** */
 /* *************************************************************** */
 /* *************************************************************** */
-int oops(int line, char *buf, char *msg)
+static int oops(int line, const char *buf, const char *msg)
 {
     static int first = 1;
 
     if (!tty) {
 	if (first) {
-	    G_warning("%s: ** input errors **\n", G_program_name());
+	    G_warning("Input errors:");
 	    first = 0;
 	}
-	G_warning("line %d: %s\n", line, buf);
+	G_warning("line %d: %s", line, buf);
     }
-    G_warning("** %s **\n", msg);
+    G_warning("%s", msg);
 
     return 0;
 }

+ 0 - 14
raster/r.what/usage.c

@@ -1,14 +0,0 @@
-#include <stdlib.h>
-#include <grass/gis.h>
-#include "local_proto.h"
-
-void usage(void)
-{
-    char *message;
-
-    G_asprintf(&message, "%s [-fci] [null=string] layer1 [layer2] ...",
-	       G_program_name());
-    G_fatal_error(message);
-
-    return;
-}