Browse Source

Add "const" where appropriate to libgis return types

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34539 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 năm trước cách đây
mục cha
commit
ab082da4e0
100 tập tin đã thay đổi với 321 bổ sung395 xóa
  1. 1 1
      db/drivers/mysql/create_table.c
  2. 2 5
      db/drivers/mysql/db.c
  3. 1 1
      db/drivers/mysql/parse.c
  4. 1 1
      db/drivers/mysql/proto.h
  5. 1 1
      display/d.labels/main.c
  6. 1 1
      display/d.nviz/local.h
  7. 3 4
      display/d.nviz/main.c
  8. 1 1
      general/g.copy/copy.c
  9. 3 3
      general/g.filename/main.c
  10. 2 2
      general/g.findfile/main.c
  11. 2 1
      general/g.gisenv/main.c
  12. 1 1
      general/g.gui/main.c
  13. 17 14
      general/g.list/list.c
  14. 4 4
      general/g.mapset/main.c
  15. 1 1
      general/g.mapsets/dsply_path.c
  16. 4 4
      general/g.mapsets/main.c
  17. 11 7
      general/g.mlist/main.c
  18. 2 1
      general/g.mremove/main.c
  19. 3 2
      general/g.proj/output.c
  20. 4 8
      general/g.region/adjust.c
  21. 3 3
      general/g.region/local_proto.h
  22. 7 7
      general/g.region/main.c
  23. 1 3
      general/g.region/printwindow.c
  24. 1 1
      general/g.region/zoom.c
  25. 2 2
      general/g.remove/remove.c
  26. 2 1
      general/g.rename/rename.c
  27. 2 2
      gui/wxpython/nviz/load.cpp
  28. 5 5
      imagery/i.atcorr/main.cpp
  29. 1 1
      imagery/i.find/main.c
  30. 1 1
      imagery/i.gensig/files.h
  31. 4 6
      imagery/i.gensig/labels.c
  32. 1 1
      imagery/i.gensig/openfiles.c
  33. 4 6
      imagery/i.gensigset/labels.c
  34. 1 1
      imagery/i.gensigset/openfiles.c
  35. 1 1
      imagery/i.gensigset/parms.h
  36. 4 4
      imagery/i.group/main.c
  37. 1 1
      imagery/i.his.rgb/closefiles.c
  38. 3 13
      imagery/i.his.rgb/openfiles.c
  39. 1 5
      imagery/i.pca/main.c
  40. 1 1
      imagery/i.pca/support.c
  41. 1 1
      imagery/i.rgb.his/closefiles.c
  42. 3 14
      imagery/i.rgb.his/openfiles.c
  43. 1 3
      imagery/i.smap/shapiro/history.c
  44. 3 3
      imagery/i.smap/shapiro/local_proto.h
  45. 3 3
      imagery/i.smap/shapiro/opencell.c
  46. 1 5
      imagery/i.zc/main.c
  47. 2 2
      include/P_site.h
  48. 40 40
      include/gisdefs.h
  49. 1 1
      lib/form/generate.c
  50. 1 1
      lib/g3d/find_grid3.c
  51. 4 6
      lib/g3d/g3dkeys.c
  52. 3 3
      lib/gis/adj_cellhd.c
  53. 1 1
      lib/gis/align_window.c
  54. 13 4
      lib/gis/date.c
  55. 3 3
      lib/gis/datum.c
  56. 11 11
      lib/gis/env.c
  57. 2 2
      lib/gis/error.c
  58. 2 2
      lib/gis/find_cell.c
  59. 14 13
      lib/gis/find_file.c
  60. 2 2
      lib/gis/find_vect.c
  61. 2 22
      lib/gis/get_cellhd.c
  62. 3 3
      lib/gis/get_ellipse.c
  63. 2 2
      lib/gis/get_row.c
  64. 1 1
      lib/gis/gisbase.c
  65. 1 1
      lib/gis/gisdbase.c
  66. 3 2
      lib/gis/gisinit.c
  67. 4 4
      lib/gis/home.c
  68. 1 1
      lib/gis/key_value1.c
  69. 1 1
      lib/gis/key_value4.c
  70. 1 1
      lib/gis/legal_name.c
  71. 3 3
      lib/gis/ll_format.c
  72. 20 23
      lib/gis/location.c
  73. 1 1
      lib/gis/mach_name.c
  74. 2 2
      lib/gis/make_loc.c
  75. 5 27
      lib/gis/mapset.c
  76. 1 1
      lib/gis/mapset_nme.c
  77. 1 3
      lib/gis/opencell.c
  78. 1 1
      lib/gis/overwrite.c
  79. 2 2
      lib/gis/parser.c
  80. 2 2
      lib/gis/proj2.c
  81. 1 1
      lib/gis/put_title.c
  82. 1 1
      lib/gis/put_window.c
  83. 1 2
      lib/gis/rd_cellhd.c
  84. 1 1
      lib/gis/remove.c
  85. 1 1
      lib/gis/set_window.c
  86. 2 2
      lib/gis/whoami.c
  87. 1 1
      lib/init/clean_temp.c
  88. 3 5
      lib/manage/add_elem.c
  89. 1 1
      lib/manage/do_copy.c
  90. 1 3
      lib/manage/do_list.c
  91. 2 2
      lib/manage/do_remove.c
  92. 2 2
      lib/manage/do_rename.c
  93. 3 3
      lib/manage/find.c
  94. 8 8
      lib/manage/list.h
  95. 6 5
      lib/proj/convert.c
  96. 5 3
      lib/proj/ellipse.c
  97. 1 1
      lib/proj/get_proj.c
  98. 1 1
      lib/rst/interp_float/input2d.c
  99. 1 1
      lib/rst/interp_float/output2d.c
  100. 0 0
      lib/rst/interp_float/resout2d.c

+ 1 - 1
db/drivers/mysql/create_table.c

@@ -20,7 +20,7 @@ int db__driver_create_table(dbTable * table)
 {
     int col, ncols;
     dbColumn *column;
-    char *colname;
+    const char *colname;
     int sqltype;
     char buf[500];
     dbString sql;

+ 2 - 5
db/drivers/mysql/db.c

@@ -21,7 +21,7 @@
 
 int db__driver_open_database(dbHandle * handle)
 {
-    char *name;
+    const char *name;
     dbConnection default_connection;
     MYSQL *res;
 
@@ -38,7 +38,7 @@ int db__driver_open_database(dbHandle * handle)
 
     {
 	/* Client version */
-	char *user, *password;
+	const char *user, *password;
 	CONNPAR connpar;
 
 	if (parse_conn(name, &connpar) == DB_FAILED) {
@@ -57,9 +57,6 @@ int db__driver_open_database(dbHandle * handle)
 	res = mysql_real_connect(connection, connpar.host, user, password,
 				 connpar.dbname, connpar.port, NULL, 0);
 
-	G_free(user);
-	G_free(password);
-
 	if (res == NULL) {
 	    append_error(_("Cannot connect to MySQL: "));
 	    append_error(mysql_error(connection));

+ 1 - 1
db/drivers/mysql/parse.c

@@ -26,7 +26,7 @@
  *  \return DB_OK Success
  *  \return DB_FAILED Failed to parse database
  */
-int parse_conn(char *str, CONNPAR * conn)
+int parse_conn(const char *str, CONNPAR * conn)
 {
     int i;
     char **tokens, delm[2];

+ 1 - 1
db/drivers/mysql/proto.h

@@ -12,7 +12,7 @@ int describe_table(MYSQL_RES *, dbTable **, cursor *);
 void field_info(MYSQL_FIELD *, int *, int *);
 
 /* parse.c */
-int parse_conn(char *, CONNPAR *);
+int parse_conn(const char *, CONNPAR *);
 
 /* replace.c */
 int replace_variables(char *, char **, char **);

+ 1 - 1
display/d.labels/main.c

@@ -28,7 +28,7 @@ int main(int argc, char **argv)
 {
     struct Cell_head window;
     char *label_name;
-    char *mapset;
+    const char *mapset;
     double minreg, maxreg, reg, dx, dy;
     FILE *infile;
     struct Option *opt1;

+ 1 - 1
display/d.nviz/local.h

@@ -1,4 +1,4 @@
 static double dist, e = 0, n = 0;
 static double DIST, HT;
-int do_profile(double, double, double, double, char *, int, int);
+int do_profile(double, double, double, double, const char *, int, int);
 int read_rast(double, double, double, int, int, RASTER_MAP_TYPE);

+ 3 - 4
display/d.nviz/main.c

@@ -42,7 +42,7 @@ FILE *fp, *fp2;
 
 int main(int argc, char *argv[])
 {
-    char *name, *mapset;
+    const char *name, *mapset;
     char outfile[GNAME_MAX];
     int fd, projection;
     char buf[512], buf1[1024], buf2[1024];
@@ -330,9 +330,8 @@ int main(int argc, char *argv[])
 /* ************************************
  * Claculate camera and eye coordinates
  **************************************/
-int do_profile
-    (double e1,
-     double e2, double n1, double n2, char *name, int fd, int data_type)
+int do_profile(double e1, double e2, double n1, double n2,
+	       const char *name, int fd, int data_type)
 {
     float rows, cols, LEN;
     double Y, X, AZI;

+ 1 - 1
general/g.copy/copy.c

@@ -26,7 +26,7 @@
 int main(int argc, char *argv[])
 {
     int i, n;
-    char *mapset;
+    const char *mapset;
     struct GModule *module;
     struct Option **parm, *p;
     char *from, *to;

+ 3 - 3
general/g.filename/main.c

@@ -25,9 +25,9 @@
 int main(int argc, char *argv[])
 {
     char path[1024];
-    char *element;
-    char *mapset;
-    char *name;
+    const char *element;
+    const char *mapset;
+    const char *name;
     struct GModule *module;
     struct Option *opt1;
     struct Option *opt2;

+ 2 - 2
general/g.findfile/main.c

@@ -23,8 +23,8 @@
 
 int main(int argc, char *argv[])
 {
-    char file[GPATH_MAX], name[GNAME_MAX], *mapset;
-    char *search_mapset;
+    char file[GPATH_MAX], name[GNAME_MAX];
+    const char *search_mapset, *mapset;
     struct GModule *module;
     struct Option *elem_opt;
     struct Option *mapset_opt;

+ 2 - 1
general/g.gisenv/main.c

@@ -25,7 +25,8 @@
 int main(int argc, char *argv[])
 {
     int n, store;
-    char *name, *value, *ptr;
+    const char *name, *value;
+    char *ptr;
     struct Option *get, *set, *store_opt;
     struct Flag *flag_s, *flag_n;
     struct GModule *module;

+ 1 - 1
general/g.gui/main.c

@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
     struct Option *type, *rc_file;
     struct Flag *oneoff;
     struct GModule *module;
-    char *gui_type_env;
+    const char *gui_type_env;
     char progname[GPATH_MAX];
 
     G_gisinit(argv[0]);

+ 17 - 14
general/g.list/list.c

@@ -31,8 +31,9 @@ int main(int argc, char *argv[])
 {
     int i, n, len;
     struct GModule *module;
-    struct Option *mapset;
+    struct Option *mapset_opt;
     struct Flag *full;
+    const char *mapset;
     char *str;
 
     G_gisinit(argv[0]);
@@ -52,6 +53,7 @@ int main(int argc, char *argv[])
     element->required = YES;
     element->multiple = YES;
     element->description = "Data type";
+
     for (len = 0, n = 0; n < nlist; n++)
 	len += strlen(list[n].alias) + 1;
     str = G_malloc(len);
@@ -66,12 +68,12 @@ int main(int argc, char *argv[])
     }
     element->options = str;
 
-    mapset = G_define_option();
-    mapset->key = "mapset";
-    mapset->type = TYPE_STRING;
-    mapset->required = NO;
-    mapset->multiple = NO;
-    mapset->description = _("Mapset to list (default: current search path)");
+    mapset_opt = G_define_option();
+    mapset_opt->key = "mapset";
+    mapset_opt->type = TYPE_STRING;
+    mapset_opt->required = NO;
+    mapset_opt->multiple = NO;
+    mapset_opt->description = _("Mapset to list (default: current search path)");
 
     full = G_define_flag();
     full->key = 'f';
@@ -80,11 +82,12 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    if (mapset->answer == NULL)
-	mapset->answer = "";
+    mapset = mapset_opt->answer;
+    if (!mapset)
+	mapset = "";
 
-    if (G_strcasecmp(mapset->answer, ".") == 0)
-	mapset->answer = G_mapset();
+    if (G_strcasecmp(mapset, ".") == 0)
+	mapset = G_mapset();
 
     i = 0;
     while (element->answers[i]) {
@@ -97,12 +100,12 @@ int main(int argc, char *argv[])
 		    list[n].element[0]);
 	    G_debug(3, "lister CMD: %s", lister);
 	    if (access(lister, 1) == 0)	/* execute permission? */
-		G_spawn(lister, lister, mapset->answer, NULL);
+		G_spawn(lister, lister, mapset, NULL);
 	    else
-		do_list(n, mapset->answer);
+		do_list(n, mapset);
 	}
 	else {
-	    do_list(n, mapset->answer);
+	    do_list(n, mapset);
 	}
 
 	i++;

+ 4 - 4
general/g.mapset/main.c

@@ -31,13 +31,13 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct Option *gisdbase_opt, *location_opt, *mapset_opt;
     struct Flag *f_add, *f_list;
-    char *gisdbase_old, *location_old, *mapset_old;
-    char *gisdbase_new, *location_new, *mapset_new;
-    char *gis_lock;
+    const char *gisdbase_old, *location_old, *mapset_old;
+    const char *gisdbase_new, *location_new, *mapset_new;
+    const char *gis_lock;
     char *mapset_old_path, *mapset_new_path;
     char *lock_prog;
+    const char *shell;
     char path[GPATH_MAX];
-    char *shell;
 
     G_gisinit(argv[0]);
 

+ 1 - 1
general/g.mapsets/dsply_path.c

@@ -7,7 +7,7 @@ int display_mapset_path(int verbose)
     int n;
     int map;			/* pointer into list of available mapsets */
     int offset = 6;		/* accounts for " <x>, " */
-    char *name;
+    const char *name;
     int len;
     int nleft;
 

+ 4 - 4
general/g.mapsets/main.c

@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
     int n;
     int i;
     int skip;
-    char *cur_mapset;
+    const char *cur_mapset;
     char **ptr;
     char **tokens;
     int no_tokens;
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
 
     if (opt1->answer) {
 	for (ptr = opt1->answers; *ptr != NULL; ptr++) {
-	    char *mapset;
+	    const char *mapset;
 
 	    mapset = *ptr;
 	    if (G__mapset_permissions(mapset) < 0)
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
 
     /* add to existing search path */
     if (opt2->answer) {
-	char *oldname;
+	const char *oldname;
 
 	Path[0] = '\0';
 
@@ -156,7 +156,7 @@ int main(int argc, char *argv[])
 
     /* remove from existing search path */
     if (opt3->answer) {
-	char *oldname;
+	const char *oldname;
 
 	Path[0] = '\0';
 

+ 11 - 7
general/g.mlist/main.c

@@ -54,7 +54,9 @@ int main(int argc, char *argv[])
 	struct Flag *full;
     } flag;
     int i, n, all, num_types;
-    char *pattern = NULL, *exclude = NULL, separator[2], *buf;
+    char *pattern = NULL, *exclude = NULL;
+    const char *mapset;
+    char separator[2], *buf;
     regex_t regex, regex_ex;
 
     G_gisinit(argv[0]);
@@ -186,11 +188,13 @@ int main(int argc, char *argv[])
 	separator[0] = opt.separator->answer[0];
     separator[1] = 0;
 
-    if (opt.mapset->answer == NULL)
-	opt.mapset->answer = "";
+    mapset = opt.mapset->answer;
 
-    if (G_strcasecmp(opt.mapset->answer, ".") == 0)
-	opt.mapset->answer = G_mapset();
+    if (mapset == NULL)
+	mapset = "";
+
+    if (G_strcasecmp(mapset, ".") == 0)
+	mapset = G_mapset();
 
     for (i = 0; opt.type->answers[i]; i++) {
 	if (strcmp(opt.type->answers[i], "all") == 0)
@@ -217,12 +221,12 @@ int main(int argc, char *argv[])
 	    G_debug(3, "lister CMD: %s", lister);
 
 	    if (access(lister, 1) == 0) {	/* execute permission? */
-		G_spawn(lister, lister, opt.mapset->answer, NULL);
+		G_spawn(lister, lister, mapset, NULL);
 		continue;
 	    }
 	}
 	else
-	    make_list(&list[n], opt.mapset->answer, separator,
+	    make_list(&list[n], mapset, separator,
 		      flag.pretty->answer, flag.type->answer,
 		      flag.mapset->answer);
     }

+ 2 - 1
general/g.mremove/main.c

@@ -43,7 +43,8 @@ int main(int argc, char *argv[])
 	struct Flag *force;
 	struct Flag *basemap;
     } flag;
-    char *name, *mapset, *location_path, path[GPATH_MAX], **files;
+    const char *mapset, *location_path;
+    char *name, path[GPATH_MAX], **files;
     char *buf, *buf2;
     int num_files, rast, result = EXIT_SUCCESS;
     int i, j, n;

+ 3 - 2
general/g.proj/output.c

@@ -94,7 +94,8 @@ void print_datuminfo(void)
 void print_proj4(int dontprettify)
 {
     struct pj_info pjinfo;
-    char *proj4, *proj4mod, *i, *unfact;
+    char *proj4, *proj4mod, *i;
+    const char *unfact;
 
     if (check_xy())
 	return;
@@ -168,7 +169,7 @@ void create_location(char *location)
 	/* Create flag given but no location specified; overwrite
 	 * projection files for current location */
 
-	char *mapset = G_mapset();
+	const char *mapset = G_mapset();
 	struct Key_Value *old_projinfo = NULL, *old_projunits = NULL;
 	struct Cell_head old_cellhd;
 

+ 4 - 8
general/g.region/adjust.c

@@ -1,15 +1,11 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include "local_proto.h"
 
-int
-adjust_window(struct Cell_head *window, int row_flag, int col_flag,
-	      int depth_flag)
+void adjust_window(struct Cell_head *window, int row_flag, int col_flag, int depth_flag)
 {
-    char *err = G_adjust_Cell_head3(window, row_flag, col_flag, depth_flag);
+    const char *err = G_adjust_Cell_head3(window, row_flag, col_flag, depth_flag);
 
-    if (err) {
+    if (err)
 	G_fatal_error(_("Invalid region: %s"), err);
-    }
-
-    return 0;
 }

+ 3 - 3
general/g.region/local_proto.h

@@ -12,12 +12,12 @@
 #define PRINT_NANGLE 0x100
 
 /* adjust.c */
-int adjust_window(struct Cell_head *, int, int, int);
+void adjust_window(struct Cell_head *, int, int, int);
 
 /* zoom.c */
-int zoom(struct Cell_head *, char *, char *);
+int zoom(struct Cell_head *, const char *, const char *);
 
 /* printwindow.c */
-int print_window(struct Cell_head *, int);
+void print_window(struct Cell_head *, int);
 
 #endif

+ 7 - 7
general/g.region/main.c

@@ -21,7 +21,7 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
-static int nsew(char *, char *, char *, char *);
+static int nsew(const char *, const char *, const char *, const char *);
 static void die(struct Option *);
 
 int main(int argc, char *argv[])
@@ -33,10 +33,10 @@ int main(int argc, char *argv[])
     int ival;
     int row_flag = 0, col_flag = 0;
     struct Cell_head window, temp_window;
-    char *value;
-    char *name;
-    char *mapset;
-    char *err;
+    const char *value;
+    const char *name;
+    const char *mapset;
+    const char *err;
     char **rast_ptr, **vect_ptr;
 
     struct GModule *module;
@@ -381,7 +381,7 @@ int main(int argc, char *argv[])
 
     /* region= */
     if ((name = parm.region->answer)) {
-	mapset = G_find_file("windows", name, "");
+	mapset = G_find_file2("windows", name, "");
 	if (!mapset)
 	    G_fatal_error(_("Region <%s> not found"), name);
 	if (G__get_window(&window, "windows", name, mapset) != NULL)
@@ -821,7 +821,7 @@ static void die(struct Option *parm)
     G_fatal_error(_("Invalid input <%s=%s>"), parm->key, parm->answer);
 }
 
-static int nsew(char *value, char *a, char *b, char *c)
+static int nsew(const char *value, const char *a, const char *b, const char *c)
 {
     if (strncmp(value, a, strlen(a)) == 0)
 	return 1;

+ 1 - 3
general/g.region/printwindow.c

@@ -10,7 +10,7 @@
 #define RAD2DEG(a) ((a) * 180.0 / M_PI)
 
 
-int print_window(struct Cell_head *window, int print_flag)
+void print_window(struct Cell_head *window, int print_flag)
 {
     const char *prj, *datum, *ellps;
     int x, width = 11;
@@ -769,6 +769,4 @@ int print_window(struct Cell_head *window, int print_flag)
 	    G_warning(_("Lat/Long calculations are not possible from a simple XY system"));
 	}
     }
-
-    return 0;
 }

+ 1 - 1
general/g.region/zoom.c

@@ -3,7 +3,7 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
-int zoom(struct Cell_head *window, char *name, char *mapset)
+int zoom(struct Cell_head *window, const char *name, const char *mapset)
 {
     int fd;
     void *raster, *rast_ptr;

+ 2 - 2
general/g.remove/remove.c

@@ -86,8 +86,8 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct Option **parm, *p;
     struct Flag *force_flag;
-    char *name, *mapset;
-    char *location_path;
+    const char *name, *mapset;
+    const char *location_path;
     int result = EXIT_SUCCESS;
     int force = 0;
 

+ 2 - 1
general/g.rename/rename.c

@@ -30,7 +30,8 @@ int main(int argc, char *argv[])
     struct Option **parm, *p;
     char *old, *new;
     int nrmaps;
-    char *mapset, *location_path, **rmaps;
+    const char *mapset, *location_path;
+    char **rmaps;
     int result = EXIT_SUCCESS;
 
     G_gisinit(argv[0]);

+ 2 - 2
gui/wxpython/nviz/load.cpp

@@ -35,7 +35,7 @@ extern "C" {
 */
 int Nviz::LoadSurface(const char* name, const char *color_name, const char *color_value)
 {
-    char *mapset;
+    const char *mapset;
     int id;
 
     mapset = G_find_cell2 (name, "");
@@ -121,7 +121,7 @@ int Nviz::UnloadSurface(int id)
 int Nviz::LoadVector(const char *name, bool points)
 {
     int id;
-    char *mapset;
+    const char *mapset;
 
     if (GS_num_surfs() == 0) { /* load base surface if no loaded */
 	int *surf_list, nsurf;

+ 5 - 5
imagery/i.atcorr/main.cpp

@@ -69,11 +69,11 @@ int hit = 0;
 int mis = 0;
 
 /* function prototypes */
-static void adjust_region (char *, char *);
+static void adjust_region (char *, const char *);
 static CELL round_c (FCELL);
 static void write_fp_to_cell (int, FCELL *);
 static void process_raster (int, InputMask, ScaleRange, int, int, int, bool, ScaleRange, bool);
-static void copy_colors (char *, char *, char *);
+static void copy_colors (char *, const char *, char *);
 static void define_module (void);
 static struct Options define_options (void);
 static void read_scale (Option *, ScaleRange &);
@@ -84,7 +84,7 @@ static void read_scale (Option *, ScaleRange &);
    Atmospheric corrections should be done on the whole
    satelite image, not just portions.
 */
-static void adjust_region (char *name, char *mapset)
+static void adjust_region (char *name, const char *mapset)
 {
     struct Cell_head iimg_head;	/* the input image header file */
 
@@ -397,7 +397,7 @@ static void process_raster (int ifd, InputMask imask, ScaleRange iscale,
 
 
 /* Copy the colors from map named iname to the map named oname */
-static void copy_colors (char *iname, char *imapset, char *oname)
+static void copy_colors (char *iname, const char *imapset, char *oname)
 {
     struct Colors colors;
 
@@ -551,7 +551,7 @@ int main(int argc, char* argv[])
     int oimg_fd;	        /* output image's file descriptor */
     int ialt_fd = -1;       /* input elevation map's file descriptor */
     int ivis_fd = -1;       /* input visibility map's file descriptor */
-    char *iimg_mapset, *ialt_mapset, *iviz_mapset;
+    const char *iimg_mapset, *ialt_mapset, *iviz_mapset;
     
     /* Define module */
     define_module();

+ 1 - 1
imagery/i.find/main.c

@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
 static int find(FILE * fd, char *element)
 {
     int len1 = 0, len2 = 0;
-    char *mapset;
+    const char *mapset;
     int n;
 
     fseek(fd, 0L, SEEK_SET);

+ 1 - 1
imagery/i.gensig/files.h

@@ -17,6 +17,6 @@ int compute_means(struct files *, struct Signature *);
 int read_training_map(CELL *, int, int, struct files *);
 
 #ifdef _l_parms_h
-int read_training_labels(struct parms *, struct files *);
+void read_training_labels(struct parms *, struct files *);
 int openfiles(struct parms *, struct files *);
 #endif

+ 4 - 6
imagery/i.gensig/labels.c

@@ -2,15 +2,13 @@
 #include "parms.h"
 #include "files.h"
 
-int read_training_labels(struct parms *parms, struct files *files)
+void read_training_labels(struct parms *parms, struct files *files)
 {
-    char *mapset;
-    char *map;
+    const char *mapset;
+    const char *map;
 
     map = parms->training_map;
-    mapset = G_find_cell(map, "");
+    mapset = G_find_cell2(map, "");
     if (G_read_cats(map, mapset, &files->training_labels) < 0)
 	G_init_cats((CELL) 0, "", &files->training_labels);
-
-    return 0;
 }

+ 1 - 1
imagery/i.gensig/openfiles.c

@@ -8,7 +8,7 @@
 int openfiles(struct parms *parms, struct files *files)
 {
     struct Ref Ref;		/* subgroup reference list */
-    char *mapset;
+    const char *mapset;
     int n;
 
 

+ 4 - 6
imagery/i.gensigset/labels.c

@@ -2,15 +2,13 @@
 #include "parms.h"
 #include "files.h"
 
-int read_training_labels(struct parms *parms, struct files *files)
+void read_training_labels(struct parms *parms, struct files *files)
 {
-    char *mapset;
-    char *map;
+    const char *mapset;
+    const char *map;
 
     map = parms->training_map;
-    mapset = G_find_cell(map, "");
+    mapset = G_find_cell2(map, "");
     if (G_read_cats(map, mapset, &files->training_labels) < 0)
 	G_init_cats((CELL) 0, "", &files->training_labels);
-
-    return 0;
 }

+ 1 - 1
imagery/i.gensigset/openfiles.c

@@ -7,7 +7,7 @@
 int openfiles(struct parms *parms, struct files *files)
 {
     struct Ref Ref;		/* subgroup reference list */
-    char *mapset;
+    const char *mapset;
     int n;
 
 

+ 1 - 1
imagery/i.gensigset/parms.h

@@ -18,7 +18,7 @@ int write_sigfile(struct parms *, struct SigSet *);
 int get_training_classes(struct parms *, struct files *, struct SigSet *);
 
 /* labels.c */
-int read_training_labels(struct parms *, struct files *);
+void read_training_labels(struct parms *, struct files *);
 
 /* openfiles.c */
 int openfiles(struct parms *, struct files *);

+ 4 - 4
imagery/i.group/main.c

@@ -195,7 +195,7 @@ static int add_or_update_group(char group[INAME_LEN], char **rasters, int k)
 {
     int m, n, skip;
     struct Ref ref;
-    char *mapset;
+    const char *mapset;
 
     I_get_group_ref(group, &ref);
 
@@ -234,7 +234,7 @@ static int add_or_update_subgroup(char group[INAME_LEN],
 {
     int m, n, skip;
     struct Ref ref;
-    char *mapset;
+    const char *mapset;
 
     I_get_subgroup_ref(group, subgroup, &ref);
 
@@ -272,7 +272,7 @@ static int remove_group_files(char group[INAME_LEN], char **rasters, int k)
     int m, n, skip;
     struct Ref ref;
     struct Ref ref_tmp;
-    char *mapset;
+    const char *mapset;
     char tmp_name[INAME_LEN];
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
@@ -330,7 +330,7 @@ static int remove_subgroup_files(char group[INAME_LEN],
     int m, n, skip;
     struct Ref ref;
     struct Ref ref_tmp;
-    char *mapset;
+    const char *mapset;
     char tmp_name[INAME_LEN];
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 

+ 1 - 1
imagery/i.his.rgb/closefiles.c

@@ -13,7 +13,7 @@ int closefiles(char *r_name, char *g_name, char *b_name,
     struct Colors colors;
     struct Range range;
     CELL min, max;
-    char *mapset;
+    const char *mapset;
 
     for (i = 0; i < 3; i++) {
 	G_close_cell(fd_output[i]);

+ 3 - 13
imagery/i.his.rgb/openfiles.c

@@ -8,8 +8,6 @@ void openfiles(char *h_name, char *i_name, char *s_name,
 	       char *r_name, char *g_name, char *b_name,
 	       int fd_input[3], int fd_output[3], CELL * rowbuf[3])
 {
-    char *mapset;
-
     /* open output files */
     if ((fd_output[0] = G_open_cell_new(r_name)) < 0)
 	G_fatal_error(_("Unable to create raster map <%s>"), r_name);
@@ -27,20 +25,12 @@ void openfiles(char *h_name, char *i_name, char *s_name,
 	G_fatal_error(_("Unable to allocate the input row buffer"));
 
     /* open input files (maps can be in different mapsets) */
-    if ((mapset = G_find_cell(h_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), h_name);
-    if ((fd_input[0] = G_open_cell_old(h_name, mapset)) < 0)
+    if ((fd_input[0] = G_open_cell_old(h_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), h_name);
 
-    if ((mapset = G_find_cell(i_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), i_name);
-    if ((fd_input[1] = G_open_cell_old(i_name, mapset)) < 0)
+    if ((fd_input[1] = G_open_cell_old(i_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), i_name);
 
-    if ((mapset = G_find_cell(s_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), s_name);
-    if ((fd_input[2] = G_open_cell_old(s_name, mapset)) < 0)
+    if ((fd_input[2] = G_open_cell_old(s_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), s_name);
-
-    return;
 }

+ 1 - 5
imagery/i.pca/main.c

@@ -114,15 +114,11 @@ int main(int argc, char *argv[])
     /* open and check input/output files */
     for (i = 0; i < bands; i++) {
 	char tmpbuf[128];
-	char *mapset;
 
 	sprintf(tmpbuf, "%s.%d", opt_out->answer, i + 1);
 	G_check_input_output_name(opt_in->answers[i], tmpbuf, GR_FATAL_EXIT);
 
-	if ((mapset = G_find_cell(opt_in->answers[i], "")) == NULL)
-	    G_fatal_error(_("Raster map <%s> not found"), opt_in->answers[i]);
-
-	if ((inp_fd[i] = G_open_cell_old(opt_in->answers[i], mapset)) < 0)
+	if ((inp_fd[i] = G_open_cell_old(opt_in->answers[i], "")) < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"),
 			  opt_in->answers[i]);
     }

+ 1 - 1
imagery/i.pca/support.c

@@ -9,7 +9,7 @@ static int write_history(int, char *, double **);
 
 int write_support(int bands, char *outname, double **eigmat)
 {
-    char *mapset = G_mapset();
+    const char *mapset = G_mapset();
     struct Colors colors;
     struct FPRange range;
     DCELL min, max;

+ 1 - 1
imagery/i.rgb.his/closefiles.c

@@ -13,7 +13,7 @@ int closefiles(char *h_name, char *i_name, char *s_name,
     struct Colors colors;
     struct Range range;
     CELL min, max;
-    char *mapset;
+    const char *mapset;
 
     for (i = 0; i < 3; i++) {
 	G_close_cell(fd_output[i]);

+ 3 - 14
imagery/i.rgb.his/openfiles.c

@@ -8,20 +8,11 @@ void openfiles(char *r_name, char *g_name, char *b_name,
 	       char *h_name, char *i_name, char *s_name,
 	       int fd_input[3], int fd_output[3], CELL * rowbuf[3])
 {
-    char *mapset;
-
-    if ((mapset = G_find_cell(r_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), r_name);
-    if ((mapset = G_find_cell(g_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), g_name);
-    if ((mapset = G_find_cell(b_name, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), b_name);
-
-    if ((fd_input[0] = G_open_cell_old(r_name, mapset)) < 0)
+    if ((fd_input[0] = G_open_cell_old(r_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), r_name);
-    if ((fd_input[1] = G_open_cell_old(g_name, mapset)) < 0)
+    if ((fd_input[1] = G_open_cell_old(g_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), g_name);
-    if ((fd_input[2] = G_open_cell_old(b_name, mapset)) < 0)
+    if ((fd_input[2] = G_open_cell_old(b_name, "")) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"), b_name);
 
     /* open output files */
@@ -39,6 +30,4 @@ void openfiles(char *r_name, char *g_name, char *b_name,
 	G_fatal_error(_("Unable to allocate the input row buffer"));
     if ((rowbuf[2] = G_allocate_cell_buf()) == NULL)
 	G_fatal_error(_("Unable to allocate the input row buffer"));
-
-    return;
 }

+ 1 - 3
imagery/i.smap/shapiro/history.c

@@ -1,6 +1,6 @@
 #include <grass/gis.h>
 
-int make_history(char *name, char *group, char *subgroup, char *sigfile)
+void make_history(const char *name, const char *group, const char *subgroup, const char *sigfile)
 {
     struct History hist;
 
@@ -9,6 +9,4 @@ int make_history(char *name, char *group, char *subgroup, char *sigfile)
 	sprintf(hist.datsrc_2, "Sigset file: %s", sigfile);
 	G_write_history(name, &hist);
     }
-
-    return 0;
 }

+ 3 - 3
imagery/i.smap/shapiro/local_proto.h

@@ -1,6 +1,6 @@
 /* history.c */
-int make_history(char *, char *, char *, char *);
+void make_history(const char *, const char *, const char *, const char *);
 
 /* opencell.c */
-int open_cell_old(char *, char *);
-int open_cell_new(char *);
+int open_cell_old(const char *, const char *);
+int open_cell_new(const char *);

+ 3 - 3
imagery/i.smap/shapiro/opencell.c

@@ -3,12 +3,12 @@
 #include <grass/glocale.h>
 
 
-int open_cell_old(char *name, char *mapset)
+int open_cell_old(const char *name, const char *mapset)
 {
     int fd;
 
     if (mapset == NULL)
-	mapset = G_find_cell(name, "");
+	mapset = G_find_cell2(name, "");
     fd = G_open_cell_old(name, mapset);
     if (fd >= 0)
 	return fd;
@@ -19,7 +19,7 @@ int open_cell_old(char *name, char *mapset)
     return -1;
 }
 
-int open_cell_new(char *name)
+int open_cell_new(const char *name)
 {
     int fd;
 

+ 1 - 5
imagery/i.zc/main.c

@@ -32,7 +32,6 @@ int main(int argc, char *argv[])
     double Thresh;
     int NumOrients;
     int inputfd, zcfd;		/* the input and output file descriptors */
-    char *inmapset;		/* the input mapset name */
     struct Cell_head window;
     CELL *cell_row;
     float Width;
@@ -100,10 +99,7 @@ int main(int argc, char *argv[])
 	exit(EXIT_FAILURE);
 
     /* open input cell map */
-    if ((inmapset = G_find_cell(input_map->answer, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), input_map->answer);
-
-    inputfd = G_open_cell_old(input_map->answer, inmapset);
+    inputfd = G_open_cell_old(input_map->answer, "");
     if (inputfd < 0)
 	exit(EXIT_FAILURE);
 

+ 2 - 2
include/P_site.h

@@ -34,8 +34,8 @@ int G_site_put_head(struct Map_info *p, Site_head * head);
 struct Map_info *G_sites_open_old(const char *name, const char *mapset);
 struct Map_info *G_sites_open_new(const char *name);
 void G_sites_close(struct Map_info *);
-char *G_find_sites(char *name, const char *mapset);
-char *G_find_sites2(const char *name, const char *mapset);
+const char *G_find_sites(char *name, const char *mapset);
+const char *G_find_sites2(const char *name, const char *mapset);
 int G__site_put(struct Map_info *, Site *, int);
 
 struct Map_info *G_fopen_sites_old(const char *, const char *);

+ 40 - 40
include/gisdefs.h

@@ -45,11 +45,11 @@
 #endif
 
 /* adj_cellhd.c */
-char *G_adjust_Cell_head(struct Cell_head *, int, int);
-char *G_adjust_Cell_head3(struct Cell_head *, int, int, int);
+const char *G_adjust_Cell_head(struct Cell_head *, int, int);
+const char *G_adjust_Cell_head3(struct Cell_head *, int, int, int);
 
 /* align_window.c */
-char *G_align_window(struct Cell_head *, const struct Cell_head *);
+const char *G_align_window(struct Cell_head *, const struct Cell_head *);
 
 /* alloc.c */
 void *G__malloc(const char *, int, size_t);
@@ -404,13 +404,13 @@ void G_free_fvector(float *);
 void G_free_fmatrix(float **);
 
 /* date.c */
-char *G_date(void);
+const char *G_date(void);
 
 /* datum.c */
 int G_get_datum_by_name(const char *);
-char *G_datum_name(int);
-char *G_datum_description(int);
-char *G_datum_ellipsoid(int);
+const char *G_datum_name(int);
+const char *G_datum_description(int);
+const char *G_datum_ellipsoid(int);
 int G_get_datumparams_from_projinfo(const struct Key_Value *, char *, char *);
 void G_read_datum_table(void);
 
@@ -439,10 +439,10 @@ int G_is_little_endian(void);
 
 /* env.c */
 void G_init_env(void);
-char *G_getenv(const char *);
-char *G_getenv2(const char *, int);
-char *G__getenv(const char *);
-char *G__getenv2(const char *, int);
+const char *G_getenv(const char *);
+const char *G_getenv2(const char *, int);
+const char *G__getenv(const char *);
+const char *G__getenv2(const char *, int);
 void G_setenv(const char *, const char *);
 void G_setenv2(const char *, const char *, int);
 void G__setenv(const char *, const char *);
@@ -450,7 +450,7 @@ void G__setenv2(const char *, const char *, int);
 void G_unsetenv(const char *);
 void G_unsetenv2(const char *, int);
 void G__write_env(void);
-char *G__env_name(int);
+const char *G__env_name(int);
 void G__read_env(void);
 void G_set_gisrc_mode(int);
 int G_get_gisrc_mode(void);
@@ -479,22 +479,22 @@ char *G__file_name_misc(char *, const char *, const char *, const char *,
 			const char *);
 
 /* find_cell.c */
-char *G_find_cell(char *, const char *);
-char *G_find_cell2(const char *, const char *);
+const char *G_find_cell(char *, const char *);
+const char *G_find_cell2(const char *, const char *);
 
 /* find_file.c */
-char *G_find_file(const char *, char *, const char *);
-char *G_find_file2(const char *, const char *, const char *);
-char *G_find_file_misc(const char *, const char *, char *, const char *);
-char *G_find_file2_misc(const char *, const char *, const char *,
-			const char *);
+const char *G_find_file(const char *, char *, const char *);
+const char *G_find_file2(const char *, const char *, const char *);
+const char *G_find_file_misc(const char *, const char *, char *, const char *);
+const char *G_find_file2_misc(const char *, const char *, const char *,
+			      const char *);
 
 /* find_etc.c */
 char *G_find_etc(const char *);
 
 /* find_vect.c */
-char *G_find_vector(char *, const char *);
-char *G_find_vector2(const char *, const char *);
+const char *G_find_vector(char *, const char *);
+const char *G_find_vector2(const char *, const char *);
 
 /* flate.c */
 int G_zlib_compress(const unsigned char *, int, unsigned char *, int);
@@ -569,8 +569,8 @@ int G_get_cellhd(const char *, const char *, struct Cell_head *);
 int G_get_ellipsoid_parameters(double *, double *);
 int G_get_spheroid_by_name(const char *, double *, double *, double *);
 int G_get_ellipsoid_by_name(const char *, double *, double *);
-char *G_ellipsoid_name(int);
-char *G_ellipsoid_description(int);
+const char *G_ellipsoid_name(int);
+const char *G_ellipsoid_description(int);
 int G_read_ellipsoid_table(int);
 
 /* get_projinfo.c */
@@ -606,10 +606,10 @@ int G_getl(char *, int, FILE *);
 int G_getl2(char *, int, FILE *);
 
 /* gisbase.c */
-char *G_gisbase(void);
+const char *G_gisbase(void);
 
 /* gisdbase.c */
-char *G_gisdbase(void);
+const char *G_gisdbase(void);
 
 /* gisinit.c */
 void G__gisinit(const char *, const char *);
@@ -646,8 +646,8 @@ void G_short_history(const char *, const char *, struct History *);
 int G_command_history(struct History *);
 
 /* home.c */
-char *G_home(void);
-char *G__home(void);
+const char *G_home(void);
+const char *G__home(void);
 
 /* ialloc.c */
 int *G_alloc_ivector(size_t);
@@ -681,7 +681,7 @@ int G_is_mapset(const char *);
 /* key_value1.c */
 struct Key_Value *G_create_key_value(void);
 int G_set_key_value(const char *, const char *, struct Key_Value *);
-char *G_find_key_value(const char *, const struct Key_Value *);
+const char *G_find_key_value(const char *, const struct Key_Value *);
 void G_free_key_value(struct Key_Value *);
 
 /* key_value2.c */
@@ -713,11 +713,11 @@ void G_free_list(char **);
 
 /* ll_format.c */
 void G_lat_format(double, char *);
-char *G_lat_format_string(void);
+const char *G_lat_format_string(void);
 void G_lon_format(double, char *);
-char *G_lon_format_string(void);
+const char *G_lon_format_string(void);
 void G_llres_format(double, char *);
-char *G_llres_format_string(void);
+const char *G_llres_format_string(void);
 void G_lat_parts(double, int *, int *, double *, char *);
 void G_lon_parts(double, int *, int *, double *, char *);
 
@@ -727,8 +727,8 @@ int G_lon_scan(const char *, double *);
 int G_llres_scan(const char *, double *);
 
 /* location.c */
+const char *G_location(void);
 char *G_location_path(void);
-char *G_location(void);
 char *G__location_path(void);
 
 /* ls.c */
@@ -743,7 +743,7 @@ int G_ludcmp(double **, int, int *, double *);
 void G_lubksb(double **, int, int *, double[]);
 
 /* mach_name.c */
-char *G__machine_name(void);
+const char *G__machine_name(void);
 
 /* make_loc.c */
 int G__make_location(const char *, struct Cell_head *, struct Key_Value *,
@@ -764,8 +764,8 @@ char *G_tolcase(char *);
 char *G_toucase(char *);
 
 /* mapset.c */
-char *G_mapset(void);
-char *G__mapset(void);
+const char *G_mapset(void);
+const char *G__mapset(void);
 
 /* mapset_msc.c */
 int G__make_mapset_element(const char *);
@@ -774,7 +774,7 @@ int G__mapset_permissions(const char *);
 int G__mapset_permissions2(const char *, const char *, const char *);
 
 /* mapset_nme.c */
-char *G__mapset_name(int);
+const char *G__mapset_name(int);
 void G_get_list_of_mapsets(void);
 void G__create_alt_search_path(void);
 void G__switch_search_path(void);
@@ -917,8 +917,8 @@ int G_projection(void);
 
 /* proj2.c */
 int G__projection_units(int);
-char *G__unit_name(int, int);
-char *G__projection_name(int);
+const char *G__unit_name(int, int);
+const char *G__projection_name(int);
 
 /* proj3.c */
 const char *G_database_unit_name(int);
@@ -945,7 +945,7 @@ int G_put_cell_title(const char *, const char *);
 
 /* put_window.c */
 int G_put_window(const struct Cell_head *);
-int G__put_window(const struct Cell_head *, char *, char *);
+int G__put_window(const struct Cell_head *, const char *, const char *);
 
 /* putenv.c */
 void G_putenv(const char *, const char *);
@@ -1156,7 +1156,7 @@ int G_put_3dview(const char *, const char *, const struct G_3dview *,
 int G_get_3dview(const char *, const char *, struct G_3dview *);
 
 /* whoami.c */
-char *G_whoami(void);
+const char *G_whoami(void);
 
 /* wind_2_box.c */
 void G_adjust_window_to_box(const struct Cell_head *, struct Cell_head *, int,

+ 1 - 1
lib/form/generate.c

@@ -40,7 +40,7 @@ F_generate(char *drvname, char *dbname, char *tblname, char *key, int keyval,
 	"euc-jp",
 	NULL
     };
-    char *enc_env;
+    const char *enc_env;
 
     G__read_env();
     enc_env = G__getenv("GRASS_DB_ENCODING");

+ 1 - 1
lib/g3d/find_grid3.c

@@ -18,7 +18,7 @@
  *              where cell file was found, or NULL if not found
  */
 
-char *G_find_grid3(const char *name, const char *mapset)
+const char *G_find_grid3(const char *name, const char *mapset)
 {
     return G_find_file2_misc("grid3", "cell", name, mapset);
 }

+ 4 - 6
lib/g3d/g3dkeys.c

@@ -6,7 +6,7 @@
 
 int G3d_keyGetInt(struct Key_Value *keys, const char *key, int *i)
 {
-    char *str;
+    const char *str;
 
     if ((str = G_find_key_value(key, keys)) == NULL) {
 	G3d_error("G3d_keyGetInt: cannot find field %s in key structure",
@@ -25,7 +25,7 @@ int G3d_keyGetInt(struct Key_Value *keys, const char *key, int *i)
 
 int G3d_keyGetDouble(struct Key_Value *keys, const char *key, double *d)
 {
-    char *str;
+    const char *str;
 
     if ((str = G_find_key_value(key, keys)) == NULL) {
 	G3d_error("G3d_keyGetDouble: cannot find field %s in key structure",
@@ -46,7 +46,7 @@ int G3d_keyGetDouble(struct Key_Value *keys, const char *key, double *d)
 int
 G3d_keyGetString(struct Key_Value *keys, const char *key, char **returnStr)
 {
-    char *str;
+    const char *str;
 
     if ((str = G_find_key_value(key, keys)) == NULL) {
 	G3d_error("G3d_keyGetString: cannot find field %s in key structure",
@@ -54,7 +54,6 @@ G3d_keyGetString(struct Key_Value *keys, const char *key, char **returnStr)
 	return 0;
     }
 
-    G_strip(str);
     *returnStr = G_store(str);
     return 1;
 }
@@ -65,7 +64,7 @@ int
 G3d_keyGetValue(struct Key_Value *keys, const char *key, char *val1,
 		char *val2, int result1, int result2, int *resultVar)
 {
-    char *str;
+    const char *str;
 
     if ((str = G_find_key_value(key, keys)) == NULL) {
 	G3d_error("G3d_keyGetValue: cannot find field %s in key structure",
@@ -73,7 +72,6 @@ G3d_keyGetValue(struct Key_Value *keys, const char *key, char *val1,
 	return 0;
     }
 
-    G_strip(str);
     if (strcmp(str, val1) == 0) {
 	*resultVar = result1;
 	return 1;

+ 3 - 3
lib/gis/adj_cellhd.c

@@ -40,7 +40,7 @@
  * \return Localized text string on error
  */
 
-char *G_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
+const char *G_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
 {
     if (!row_flag) {
 	if (cellhd->ns_res <= 0)
@@ -191,8 +191,8 @@ char *G_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
  * \return Localized text string on error
  */
 
-char *G_adjust_Cell_head3(struct Cell_head *cellhd, int row_flag,
-			  int col_flag, int depth_flag)
+const char *G_adjust_Cell_head3(struct Cell_head *cellhd, int row_flag,
+				int col_flag, int depth_flag)
 {
     if (!row_flag) {
 	if (cellhd->ns_res <= 0)

+ 1 - 1
lib/gis/align_window.c

@@ -38,7 +38,7 @@
  * \return Pointer to an error string on failure
  */
 
-char *G_align_window(struct Cell_head *window, const struct Cell_head *ref)
+const char *G_align_window(struct Cell_head *window, const struct Cell_head *ref)
 {
     int preserve;
 

+ 13 - 4
lib/gis/date.c

@@ -27,20 +27,29 @@
  * \return Pointer to a string holding date/time
  */
 
-char *G_date(void)
+const char *G_date(void)
 {
+    static int initialized;
+    static char *date;
     time_t clock;
     struct tm *local;
-    char *date;
+    char *tdate;
     char *d;
 
+    if (G_is_initialized(&initialized))
+	return date;
+
     time(&clock);
 
     local = localtime(&clock);
-    date = asctime(local);
-    for (d = date; *d; d++)
+    tdate = asctime(local);
+    for (d = tdate; *d; d++)
 	if (*d == '\n')
 	    *d = 0;
 
+    date = G_store(tdate);
+
+    G_initialize_done(&initialized);
+
     return date;
 }

+ 3 - 3
lib/gis/datum.c

@@ -55,7 +55,7 @@ int G_get_datum_by_name(const char *name)
     return -1;
 }
 
-char *G_datum_name(int n)
+const char *G_datum_name(int n)
 {
     G_read_datum_table();
 
@@ -65,7 +65,7 @@ char *G_datum_name(int n)
     return table.datums[n].name;
 }
 
-char *G_datum_description(int n)
+const char *G_datum_description(int n)
 {
     G_read_datum_table();
 
@@ -75,7 +75,7 @@ char *G_datum_description(int n)
     return table.datums[n].descr;
 }
 
-char *G_datum_ellipsoid(int n)
+const char *G_datum_ellipsoid(int n)
 {
     G_read_datum_table();
 

+ 11 - 11
lib/gis/env.c

@@ -47,7 +47,7 @@ static struct state *st = &state;
 static int read_env(int);
 static int set_env(const char *, const char *, int);
 static int unset_env(const char *, int);
-static char *get_env(const char *, int);
+static const char *get_env(const char *, int);
 static void write_env(int);
 static FILE *open_env(const char *, int);
 
@@ -198,7 +198,7 @@ static int unset_env(const char *name, int loc)
     return 0;
 }
 
-static char *get_env(const char *name, int loc)
+static const char *get_env(const char *name, int loc)
 {
     int n;
 
@@ -283,11 +283,11 @@ static FILE *open_env(const char *mode, int loc)
 
    \return char pointer to value for name
 */
-char *G_getenv(const char *name)
+const char *G_getenv(const char *name)
 {
-    char *value;
+    const char *value = G__getenv(name);
 
-    if ((value = G__getenv(name)))
+    if (value)
 	return value;
 
     G_fatal_error(_("G_getenv(): Variable %s not set"), name);
@@ -309,11 +309,11 @@ char *G_getenv(const char *name)
    \return variable value
    \return NULL if not found
 */
-char *G_getenv2(const char *name, int loc)
+const char *G_getenv2(const char *name, int loc)
 {
-    char *value;
+    const char *value = G__getenv2(name, loc);
 
-    if ((value = G__getenv2(name, loc)))
+    if (value)
 	return value;
 
     G_fatal_error(_("%s not set"), name);
@@ -328,7 +328,7 @@ char *G_getenv2(const char *name, int loc)
    \return char pointer to value for name
    \return NULL if name not set
 */
-char *G__getenv(const char *name)
+const char *G__getenv(const char *name)
 {
     if (strcmp(name, "GISBASE") == 0)
 	return getenv(name);
@@ -347,7 +347,7 @@ char *G__getenv(const char *name)
    \return char pointer to value for name
    \return NULL if name not set
 */
-char *G__getenv2(const char *name, int loc)
+const char *G__getenv2(const char *name, int loc)
 {
     if (strcmp(name, "GISBASE") == 0)
 	return getenv(name);
@@ -482,7 +482,7 @@ void G__write_env(void)
 
    \return pointer to variable name
 */
-char *G__env_name(int n)
+const char *G__env_name(int n)
 {
     int i;
 

+ 2 - 2
lib/gis/error.c

@@ -290,7 +290,7 @@ static void log_error(const char *msg, int fatal)
 {
     char cwd[GPATH_MAX];
     time_t clock;
-    char *gisbase;
+    const char *gisbase;
 
     /* get time */
     clock = time(NULL);
@@ -374,7 +374,7 @@ static int mail_msg(const char *msg, int fatal)
 {
     FILE *mail;
     char command[64];
-    char *user;
+    const char *user;
 
     user = G_whoami();
     if (user == 0 || *user == 0)

+ 2 - 2
lib/gis/find_cell.c

@@ -60,7 +60,7 @@
  *  \return char * 
  */
 
-char *G_find_cell(char *name, const char *mapset)
+const char *G_find_cell(char *name, const char *mapset)
 {
     return G_find_file("cell", name, mapset);
 }
@@ -80,7 +80,7 @@ char *G_find_cell(char *name, const char *mapset)
  *  \return char *
  */
 
-char *G_find_cell2(const char *name, const char *mapset)
+const char *G_find_cell2(const char *name, const char *mapset)
 {
     return G_find_file2("cell", name, mapset);
 }

+ 14 - 13
lib/gis/find_file.c

@@ -18,10 +18,10 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-static char *find_file(int misc,
-		       const char *dir,
-		       const char *element,
-		       const char *name, const char *mapset)
+static const char *find_file(
+    int misc,
+    const char *dir,
+    const char *element, const char *name, const char *mapset)
 {
     char path[GPATH_MAX];
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
@@ -82,7 +82,7 @@ static char *find_file(int misc,
 		G_warning(_("Using <%s@%s>"),
 			  pname, pselmapset);
 	    
-	    return (char *)pselmapset;
+	    return pselmapset;
 	}
     }
     /*
@@ -106,13 +106,14 @@ static char *find_file(int misc,
 
 
 
-static char *find_file1(int misc,
-			const char *dir,
-			const char *element, char *name, const char *mapset)
+static const char *find_file1(
+    int misc,
+    const char *dir,
+    const char *element, char *name, const char *mapset)
 {
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     const char *pname, *pmapset;
-    char *mp;
+    const char *mp;
 
     if (G__name_is_fully_qualified(name, xname, xmapset)) {
 	pname = xname;
@@ -156,12 +157,12 @@ static char *find_file1(int misc,
  *              where file was found, or NULL if not found
  */
 
-char *G_find_file(const char *element, char *name, const char *mapset)
+const char *G_find_file(const char *element, char *name, const char *mapset)
 {
     return find_file1(0, NULL, element, name, mapset);
 }
 
-char *G_find_file_misc(const char *dir,
+const char *G_find_file_misc(const char *dir,
 		       const char *element, char *name, const char *mapset)
 {
     return find_file1(1, dir, element, name, mapset);
@@ -188,12 +189,12 @@ char *G_find_file_misc(const char *dir,
  *  \return char *  pointer to a string with name of mapset
  *              where file was found, or NULL if not found
  */
-char *G_find_file2(const char *element, const char *name, const char *mapset)
+const char *G_find_file2(const char *element, const char *name, const char *mapset)
 {
     return find_file(0, NULL, element, name, mapset);
 }
 
-char *G_find_file2_misc(const char *dir,
+const char *G_find_file2_misc(const char *dir,
 			const char *element,
 			const char *name, const char *mapset)
 {

+ 2 - 2
lib/gis/find_vect.c

@@ -52,7 +52,7 @@
  *  \return char *
  *
  */
-char *G_find_vector(char *name, const char *mapset)
+const char *G_find_vector(char *name, const char *mapset)
 {
     return G_find_file(GRASS_VECT_DIRECTORY, name, mapset);
 }
@@ -72,7 +72,7 @@ char *G_find_vector(char *name, const char *mapset)
  *  \param mapset
  *  \return char *
  */
-char *G_find_vector2(const char *name, const char *mapset)
+const char *G_find_vector2(const char *name, const char *mapset)
 {
     return G_find_file2(GRASS_VECT_DIRECTORY, name, mapset);
 }

+ 2 - 22
lib/gis/get_cellhd.c

@@ -50,7 +50,6 @@ int G_get_cellhd(const char *name, const char *mapset,
     char real_name[GNAME_MAX], real_mapset[GMAPSET_MAX];
     char buf[1024];
     char *tail;
-    char *err;
 
     /*
        is_reclass = G_is_reclass (name, mapset, real_name, real_mapset);
@@ -91,27 +90,8 @@ int G_get_cellhd(const char *name, const char *mapset,
 	}
     }
 
-    err = G__read_Cell_head(fd, cellhd, 1);
+    G__read_Cell_head(fd, cellhd, 1);
     fclose(fd);
 
-    if (err == NULL)
-	return 0;
-
-    sprintf(buf, _("Unable to read header file for raster map <%s@%s>."),
-	    name, mapset);
-    tail = buf + strlen(buf);
-    if (is_reclass) {
-	sprintf(tail,
-		_(" It is a reclass of raster map <%s@%s> whose header file is invalid."),
-		real_name, real_mapset);
-    }
-    else
-	sprintf(tail, _(" Invalid format."));
-    tail = buf + strlen(buf);
-    strcpy(tail, err);
-
-    G_free(err);
-
-    G_warning(buf);
-    return -1;
+    return 0;
 }

+ 3 - 3
lib/gis/get_ellipse.c

@@ -135,7 +135,7 @@ int G_get_ellipsoid_by_name(const char *name, double *a, double *e2)
  *  \return char * ellipsoid name
  *  \return NULL if no ellipsoid found
  */
-char *G_ellipsoid_name(int n)
+const char *G_ellipsoid_name(int n)
 {
     G_read_ellipsoid_table(0);
     return n >= 0 && n < table.count ? table.ellipses[n].name : NULL;
@@ -199,7 +199,7 @@ int G_get_spheroid_by_name(const char *name, double *a, double *e2, double *f)
  * \return NULL if no ellipsoid found
  */
 
-char *G_ellipsoid_description(int n)
+const char *G_ellipsoid_description(int n)
 {
     G_read_ellipsoid_table(0);
     return n >= 0 && n < table.count ? table.ellipses[n].descr : NULL;
@@ -338,7 +338,7 @@ int G_read_ellipsoid_table(int fatal)
 
 static int get_ellipsoid_parameters(struct Key_Value *proj_keys, double *a, double *e2)
 {
-    char *str, *str1;
+    const char *str, *str1;
 
     if (!proj_keys) {
 	return -1;

+ 2 - 2
lib/gis/get_row.c

@@ -1006,7 +1006,7 @@ int G_get_d_raster_row(int fd, DCELL * buf, int row)
 static int open_null_read(int fd)
 {
     struct fileinfo *fcb = &G__.fileinfo[fd];
-    char *name, *mapset, *dummy;
+    const char *name, *mapset, *dummy;
     int null_fd;
 
     if (fcb->null_file_exists == 0)
@@ -1021,7 +1021,7 @@ static int open_null_read(int fd)
 	mapset = fcb->mapset;
     }
 
-    dummy = G_find_file_misc("cell_misc", NULL_FILE, name, mapset);
+    dummy = G_find_file2_misc("cell_misc", NULL_FILE, name, mapset);
 
     if (!dummy) {
 	/* G_warning("unable to find [%s]",path); */

+ 1 - 1
lib/gis/gisbase.c

@@ -39,7 +39,7 @@
  *  \return char * 
  */
 
-char *G_gisbase(void)
+const char *G_gisbase(void)
 {
     return G_getenv("GISBASE");
 }

+ 1 - 1
lib/gis/gisdbase.c

@@ -26,7 +26,7 @@
  *  \return pointer to string containing the base directory
  */
 
-char *G_gisdbase(void)
+const char *G_gisdbase(void)
 {
     return G_getenv("GISDBASE");
 }

+ 3 - 2
lib/gis/gisinit.c

@@ -43,7 +43,7 @@ static int gisinit(void);
 
 void G__gisinit(const char *version, const char *pgm)
 {
-    char *mapset;
+    const char *mapset;
 
     if (initialized)
 	return;
@@ -55,7 +55,8 @@ void G__gisinit(const char *version, const char *pgm)
 
     /* Make sure location and mapset are set */
     G_location_path();
-    switch (G__mapset_permissions(mapset = G_mapset())) {
+    mapset = G_mapset();
+    switch (G__mapset_permissions(mapset)) {
     case 1:
 	break;
     case 0:

+ 4 - 4
lib/gis/home.c

@@ -29,9 +29,9 @@
  *  \return char * 
  */
 
-char *G_home(void)
+const char *G_home(void)
 {
-    char *home = G__home();
+    const char *home = G__home();
 
     if (home)
 	return home;
@@ -40,10 +40,10 @@ char *G_home(void)
     return NULL;
 }
 
-char *G__home(void)
+const char *G__home(void)
 {
     static int initialized;
-    static char *home = 0;
+    static const char *home = 0;
 
     if (G_is_initialized(&initialized))
 	return home;

+ 1 - 1
lib/gis/key_value1.c

@@ -125,7 +125,7 @@ int G_set_key_value(const char *key, const char *value, struct Key_Value *kv)
    \return poiter to value of key
    \return NULL if no key found
  */
-char *G_find_key_value(const char *key, const struct Key_Value *kv)
+const char *G_find_key_value(const char *key, const struct Key_Value *kv)
 {
     int n;
 

+ 1 - 1
lib/gis/key_value4.c

@@ -66,7 +66,7 @@ int G_lookup_key_value_from_file(const char *file,
 {
     struct Key_Value *kv;
     int stat;
-    char *v;
+    const char *v;
 
     *value = 0;
     kv = G_read_key_value_file(file, &stat);

+ 1 - 1
lib/gis/legal_name.c

@@ -68,7 +68,7 @@ int G_legal_filename(const char *s)
 int G_check_input_output_name(const char *input, const char *output,
 			      int error)
 {
-    char *mapset;
+    const char *mapset;
 
     if (output == NULL)
 	return 0;		/* don't die on undefined parameters */

+ 3 - 3
lib/gis/ll_format.c

@@ -48,7 +48,7 @@ void G_lat_format(double lat, char *buf)
     format(buf, d, m, s, h);
 }
 
-char *G_lat_format_string(void)
+const char *G_lat_format_string(void)
 {
     return "dd:mm:ss{N|S}";
 }
@@ -63,7 +63,7 @@ void G_lon_format(double lon, char *buf)
     format(buf, d, m, s, h);
 }
 
-char *G_lon_format_string(void)
+const char *G_lon_format_string(void)
 {
     return "ddd:mm:ss{E|W}";
 }
@@ -79,7 +79,7 @@ void G_llres_format(double res, char *buf)
     format(buf, d, m, s, h);
 }
 
-char *G_llres_format_string(void)
+const char *G_llres_format_string(void)
 {
     return "dd:mm:ss";
 }

+ 20 - 23
lib/gis/location.c

@@ -22,6 +22,22 @@
 
 
 /*!
+ * \brief Get current location name
+ *
+ * Returns the name of the current database location. This routine
+ * should be used by modules that need to display the current location
+ * to the user. See Locations for an explanation of locations.
+ *
+ *  \param
+ *  \return char* tolocation name
+ */
+
+const char *G_location(void)
+{
+    return G_getenv("LOCATION_NAME");
+}
+
+/*!
  * \brief Get current location directory
  *
  * Returns the full UNIX path name of the current database
@@ -39,7 +55,7 @@ char *G_location_path(void)
     char *location;
 
     location = G__location_path();
-    if (access(location, 0) != 0) {
+    if (access(location, F_OK) != 0) {
 	perror("access");
 	G_fatal_error(_("LOCATION << %s >> not available"), location);
     }
@@ -49,21 +65,6 @@ char *G_location_path(void)
 
 
 /*!
- * \brief Get current location name
- *
- * Returns the name of the current database location. This routine
- * should be used by modules that need to display the current location
- * to the user. See Locations for an explanation of locations.
- *
- *  \param
- *  \return char* tolocation name
- */
-char *G_location(void)
-{
-    return G_getenv("LOCATION_NAME");
-}
-
-/*!
  * \brief Get current location path
  *
  *  \param
@@ -71,13 +72,9 @@ char *G_location(void)
  */
 char *G__location_path(void)
 {
-    char *location = 0;
-    char *base;
-    char *name;
-
-    name = G_location();
-    base = G_gisdbase();
-    location = G_malloc(strlen(base) + strlen(name) + 2);
+    const char *name = G_location();
+    const char *base = G_gisdbase();
+    char *location = G_malloc(strlen(base) + strlen(name) + 2);
 
     sprintf(location, "%s/%s", base, name);
 

+ 1 - 1
lib/gis/mach_name.c

@@ -14,7 +14,7 @@
  *
  */
 
-char *G__machine_name(void)
+const char *G__machine_name(void)
 {
     static int initialized;
     static char name[128];

+ 2 - 2
lib/gis/make_loc.c

@@ -237,7 +237,7 @@ G_compare_projections(const struct Key_Value *proj_info1,
     /* -------------------------------------------------------------------- */
 
     {
-	char *x_0_1 = NULL, *x_0_2 = NULL;
+	const char *x_0_1 = NULL, *x_0_2 = NULL;
 
 	x_0_1 = G_find_key_value("x_0", proj_info1);
 	x_0_2 = G_find_key_value("x_0", proj_info2);
@@ -251,7 +251,7 @@ G_compare_projections(const struct Key_Value *proj_info1,
     /* -------------------------------------------------------------------- */
 
     {
-	char *y_0_1 = NULL, *y_0_2 = NULL;
+	const char *y_0_1 = NULL, *y_0_2 = NULL;
 
 	y_0_1 = G_find_key_value("y_0", proj_info1);
 	y_0_2 = G_find_key_value("y_0", proj_info2);

+ 5 - 27
lib/gis/mapset.c

@@ -28,39 +28,17 @@
  *  \return char * 
  */
 
-char *G_mapset(void)
+const char *G_mapset(void)
 {
-    static char mapset[GMAPSET_MAX];
-    static int first = 1;
-    char *m;
+    const char *m = G__mapset();
 
-    m = G__mapset();
-    if (m == NULL)
+    if (!m)
 	G_fatal_error(_("MAPSET is not set"));
 
-    if (first)
-	first = 0;
-    else if (strcmp(mapset, m) == 0)
-	return mapset;
-    strcpy(mapset, m);
-
-    switch (G__mapset_permissions(mapset)) {
-    case 0:
-    case 1:
-	return mapset;
-	/*
-	   case 0:
-	   G_fatal_error ("MAPSET %s - permission denied", mapset);
-	   break;
-	 */
-    default:
-	G_fatal_error(_("MAPSET %s not found"), mapset);
-	break;
-    }
-    exit(EXIT_FAILURE);
+    return m;
 }
 
-char *G__mapset(void)
+const char *G__mapset(void)
 {
     return G__getenv("MAPSET");
 }

+ 1 - 1
lib/gis/mapset_nme.c

@@ -39,7 +39,7 @@ static void new_mapset(const char *);
    \return mapset name
    \return NULL if mapset not found
  */
-char *G__mapset_name(int n)
+const char *G__mapset_name(int n)
 {
     G_get_list_of_mapsets();
 

+ 1 - 3
lib/gis/opencell.c

@@ -774,7 +774,7 @@ RASTER_MAP_TYPE G__check_fp_type(const char *name, const char *mapset)
     char path[GPATH_MAX];
     struct Key_Value *format_keys;
     int in_stat;
-    char *str, *str1;
+    const char *str, *str1;
     RASTER_MAP_TYPE map_type;
     const char *xmapset;
 
@@ -795,7 +795,6 @@ RASTER_MAP_TYPE G__check_fp_type(const char *name, const char *mapset)
 	return -1;
     }
     if ((str = G_find_key_value("type", format_keys)) != NULL) {
-	G_strip(str);
 	if (strcmp(str, "double") == 0)
 	    map_type = DCELL_TYPE;
 	else if (strcmp(str, "float") == 0)
@@ -813,7 +812,6 @@ RASTER_MAP_TYPE G__check_fp_type(const char *name, const char *mapset)
     }
 
     if ((str1 = G_find_key_value("byte_order", format_keys)) != NULL) {
-	G_strip(str1);
 	if (strcmp(str1, "xdr") != 0)
 	    G_warning(_("Raster map <%s> is not xdr: byte_order: %s"),
 			name, str);

+ 1 - 1
lib/gis/overwrite.c

@@ -36,7 +36,7 @@
 
 int G_check_overwrite(int argc, char **argv)
 {
-    char *overstr;
+    const char *overstr;
     int overwrite;
 
     overwrite = 0;

+ 2 - 2
lib/gis/parser.c

@@ -2013,7 +2013,7 @@ static void G_gui_wx(void)
 static void G_gui(void)
 {
     /* read environment variables first then internal GRASS variable */
-    char *gui = getenv("GRASS_GUI");
+    const char *gui = getenv("GRASS_GUI");
 
     if (!gui) {
 	gui = G_getenv("GRASS_GUI");
@@ -2510,7 +2510,7 @@ static int check_overwrite(void)
     char element[KEYLENGTH];
     char desc[KEYLENGTH];
     int error = 0;
-    char *overstr;
+    const char *overstr;
     int over;
 
     st->module_info.overwrite = 0;

+ 2 - 2
lib/gis/proj2.c

@@ -17,7 +17,7 @@ int G__projection_units(int n)
     }
 }
 
-char *G__unit_name(int unit, int plural)
+const char *G__unit_name(int unit, int plural)
 {
     switch (unit) {
     case 0:
@@ -33,7 +33,7 @@ char *G__unit_name(int unit, int plural)
     }
 }
 
-char *G__projection_name(int n)
+const char *G__projection_name(int n)
 {
     switch (n) {
     case PROJECTION_XY:

+ 1 - 1
lib/gis/put_title.c

@@ -15,7 +15,7 @@
 
 int G_put_cell_title(const char *name, const char *title)
 {
-    char *mapset;
+    const char *mapset;
     FILE *in, *out;
     char *tempfile;
     int line;

+ 1 - 1
lib/gis/put_window.c

@@ -37,7 +37,7 @@ int G_put_window(const struct Cell_head *window)
 	: G__put_window(window, "", "WIND");
 }
 
-int G__put_window(const struct Cell_head *window, char *dir, char *name)
+int G__put_window(const struct Cell_head *window, const char *dir, const char *name)
 {
     FILE *fd;
 

+ 1 - 2
lib/gis/rd_cellhd.c

@@ -85,8 +85,7 @@ char *G__read_Cell_head_array(char **array,
     char value[200];
     int i, line;
     int flags;
-    char *G_adjust_Cell_head();
-    char *err;
+    const char *err;
 
     G_debug(2, "G__read_Cell_head_array");
 

+ 1 - 1
lib/gis/remove.c

@@ -73,7 +73,7 @@ static int G__remove(int misc, const char *dir, const char *element,
 		     const char *name)
 {
     char path[GPATH_MAX];
-    char *mapset;
+    const char *mapset;
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
     /* name in mapset legal only if mapset is current mapset */

+ 1 - 1
lib/gis/set_window.c

@@ -48,7 +48,7 @@ int G_set_window(struct Cell_head *window)
 {
     int i;
     int maskfd;
-    char *err;
+    const char *err;
 
     /* adjust window, check for valid window */
     /* adjust the real one, not a copy

+ 2 - 2
lib/gis/whoami.c

@@ -37,10 +37,10 @@
  *  \retval char * Pointer to string
  */
 
-char *G_whoami(void)
+const char *G_whoami(void)
 {
     static int initialized;
-    static char *name;
+    static const char *name;
 
     if (G_is_initialized(&initialized))
 	return name;

+ 1 - 1
lib/init/clean_temp.c

@@ -119,7 +119,7 @@ void clean_dir(const char *pathname, uid_t uid, pid_t pid, time_t now,
 
 int main(int argc, char *argv[])
 {
-    char *mapset;
+    const char *mapset;
     char element[GNAME_MAX];
     char tmppath[BUF_MAX];
     pid_t ppid;

+ 3 - 5
lib/manage/add_elem.c

@@ -1,5 +1,5 @@
 #include "list.h"
-int add_element(char *elem, char *desc)
+int add_element(const char *elem, const char *desc)
 {
     int n;
     int nelem;
@@ -9,11 +9,9 @@ int add_element(char *elem, char *desc)
 
     n = nlist - 1;
     nelem = list[n].nelem++;
-    list[n].element =
-	(char **)G_realloc(list[n].element, (nelem + 1) * sizeof(char *));
+    list[n].element = G_realloc(list[n].element, (nelem + 1) * sizeof(const char *));
     list[n].element[nelem] = G_store(elem);
-    list[n].desc =
-	(char **)G_realloc(list[n].desc, (nelem + 1) * sizeof(char *));
+    list[n].desc = G_realloc(list[n].desc, (nelem + 1) * sizeof(const char *));
     list[n].desc[nelem] = G_store(desc);
 
     return 0;

+ 1 - 1
lib/manage/do_copy.c

@@ -9,7 +9,7 @@
  *  returns 0 - success
  *          1 - error
  */
-int do_copy(int n, char *old, char *mapset, char *new)
+int do_copy(int n, const char *old, const char *mapset, const char *new)
 {
     int i, ret, len;
     char path[GPATH_MAX], path2[GPATH_MAX];

+ 1 - 3
lib/manage/do_list.c

@@ -1,7 +1,5 @@
 #include "list.h"
-int do_list(int n, char *mapset)
+void do_list(int n, const char *mapset)
 {
     G_list_element(list[n].element[0], list[n].desc[0], mapset, (int (*)())0);
-
-    return 0;
 }

+ 2 - 2
lib/manage/do_remove.c

@@ -9,12 +9,12 @@
  *  returns 0 - success
  *          1 - error
  */
-int do_remove(int n, char *old)
+int do_remove(int n, const char *old)
 {
     int i, ret;
 
     /* int len; */
-    char *mapset;
+    const char *mapset;
     int result = 0;
     int removed = 0;
     char xname[GNAME_MAX], xmapset[GMAPSET_MAX];

+ 2 - 2
lib/manage/do_rename.c

@@ -9,11 +9,11 @@
  *  returns 0 - success
  *          1 - error
  */
-int do_rename(int n, char *old, char *new)
+int do_rename(int n, const char *old, const char *new)
 {
     int i, ret;
     int len;
-    char *mapset;
+    const char *mapset;
     int result = 0;
     int renamed = 0;
 

+ 3 - 3
lib/manage/find.c

@@ -1,11 +1,11 @@
 #include <string.h>
 #include "list.h"
 
-char *find(int n, char *name, char *mapsets)
+const char *find(int n, char *name, const char *mapsets)
 {
-    char *mapset;
+    const char *mapset;
 
-    mapset = G_find_file(list[n].element[0], name, mapsets);
+    mapset = G_find_file2(list[n].element[0], name, mapsets);
     if (mapset) {
 	char temp[GNAME_MAX];
 

+ 8 - 8
lib/manage/list.h

@@ -7,9 +7,9 @@
 
 struct list
 {
-    char **element;		/* list of related elements */
+    const char **element;	/* list of related elements */
     char *alias;		/* element alias */
-    char **desc;		/* description of elements */
+    const char **desc;		/* description of elements */
     char *text;			/* menu text */
     int nelem;			/* number of elements */
     char status;
@@ -26,25 +26,25 @@ extern struct list *list;
 #define LIST   4
 
 /* add_elem.c */
-int add_element(char *, char *);
+int add_element(const char *, const char *);
 
 /* do_copy.c */
-int do_copy(int, char *, char *, char *);
+int do_copy(int, const char *, const char *, const char *);
 
 /* do_list.c */
-int do_list(int, char *);
+void do_list(int, const char *);
 
 /* do_remove.c */
-int do_remove(int, char *);
+int do_remove(int, const char *);
 
 /* do_rename.c */
-int do_rename(int, char *, char *);
+int do_rename(int, const char *, const char *);
 
 /* empty.c */
 int empty(char *);
 
 /* find.c */
-char *find(int, char *, char *);
+const char *find(int, char *, const char *);
 
 /* get_len.c */
 int get_description_len(int);

+ 6 - 5
lib/proj/convert.c

@@ -93,8 +93,9 @@ OGRSpatialReferenceH GPJ_grass_to_osr(struct Key_Value * proj_info,
     struct gpj_datum dstruct;
     struct gpj_ellps estruct;
     size_t len;
-    char *ellps, *ellpslong, *datum, *params, *towgs84, *datumlongname,
-	*start, *end, *unit, *unfact, *buff;
+    const char *ellps, *unit, *unfact;
+    char *ellpslong, *datum, *params, *towgs84, *datumlongname,
+	*start, *end, *buff;
     const char *sysname, *osrunit, *osrunfact;
     double a, es, rf;
     int haveparams = 0;
@@ -138,9 +139,9 @@ OGRSpatialReferenceH GPJ_grass_to_osr(struct Key_Value * proj_info,
     haveparams = GPJ__get_datum_params(proj_info, &datum, &params);
 
     if ((datum == NULL) || (GPJ_get_datum_by_name(datum, &dstruct) < 0)) {
-	G_asprintf(&datumlongname, "unknown");
+	datumlongname = "unknown";
 	if (ellps == NULL)
-	    G_asprintf(&ellps, "unnamed");
+	    ellps = "unnamed";
     }
     else {
 	datumlongname = G_store(dstruct.longname);
@@ -204,7 +205,7 @@ OGRSpatialReferenceH GPJ_grass_to_osr(struct Key_Value * proj_info,
 	    lastpart[len] = '\0';
 
 	    if (unit == NULL)
-		G_asprintf(&unit, "unknown");
+		unit = "unknown";
 	    G_asprintf(&end, ",UNIT[\"%s\",%.16g]]", unit, unfactf);
 	}
 

+ 5 - 3
lib/proj/ellipse.c

@@ -54,7 +54,8 @@ GPJ__get_ellipsoid_params(struct Key_Value *proj_keys,
 {
     struct gpj_ellps estruct;
     struct gpj_datum dstruct;
-    char *str, *str1, *str3;
+    const char *str, *str3;
+    char *str1;
 
     str = G_find_key_value("datum", proj_keys);
 
@@ -85,7 +86,8 @@ GPJ__get_ellipsoid_params(struct Key_Value *proj_keys,
     else {
 	str3 = G_find_key_value("a", proj_keys);
 	if (str3 != NULL) {
-	    G_asprintf(&str, "a=%s", str3);
+	    char *str4;
+	    G_asprintf(&str4, "a=%s", str3);
 	    if ((str3 = G_find_key_value("es", proj_keys)) != NULL)
 		G_asprintf(&str1, "e=%s", str3);
 	    else if ((str3 = G_find_key_value("f", proj_keys)) != NULL)
@@ -98,7 +100,7 @@ GPJ__get_ellipsoid_params(struct Key_Value *proj_keys,
 		G_fatal_error(_("No secondary ellipsoid descriptor "
 				"(rf, es or b) in file"));
 
-	    if (get_a_e2_rf(str, str1, a, e2, rf) == 0)
+	    if (get_a_e2_rf(str4, str1, a, e2, rf) == 0)
 		G_fatal_error(_("Invalid ellipsoid descriptors "
 				"(a, rf, es or b) in file"));
 	    return 1;

+ 1 - 1
lib/proj/get_proj.c

@@ -59,7 +59,7 @@ static int nopt1;
 int pj_get_kv(struct pj_info *info, struct Key_Value *in_proj_keys,
 	      struct Key_Value *in_units_keys)
 {
-    char *str;
+    const char *str;
     int i;
     double a, es, rf;
     int returnval = 1;

+ 1 - 1
lib/rst/interp_float/input2d.c

@@ -29,7 +29,7 @@ struct BM *IL_create_bitmask(struct interp_params *params)
 /** Creates a bitmap mask from given raster map **/
 {
     int i, j, cfmask = 0, irev, MASKfd;
-    char *mapsetm;
+    const char *mapsetm;
     CELL *cellmask, *MASK;
     struct BM *bitmask;
 

+ 1 - 1
lib/rst/interp_float/output2d.c

@@ -46,7 +46,7 @@ int IL_output_2d(struct interp_params *params, struct Cell_head *cellhd,	/* curr
     struct Colors colors;
     struct History hist, hist1, hist2, hist3, hist4, hist5;
     char *type;
-    char *mapset = NULL;
+    const char *mapset = NULL;
     int cond1, cond2;
     FCELL dat1, dat2;
 

+ 0 - 0
lib/rst/interp_float/resout2d.c


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác