[GRASS-SVN] r32123 - in grass-addons/general: g.xlist g.xremove

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 15 16:44:15 EDT 2008


Author: hcho
Date: 2008-07-15 16:44:14 -0400 (Tue, 15 Jul 2008)
New Revision: 32123

Modified:
   grass-addons/general/g.xlist/gisdefs.h
   grass-addons/general/g.xlist/join.c
   grass-addons/general/g.xlist/ls.c
   grass-addons/general/g.xlist/main.c
   grass-addons/general/g.xremove/gisdefs.h
   grass-addons/general/g.xremove/join.c
   grass-addons/general/g.xremove/ls.c
   grass-addons/general/g.xremove/main.c
Log:
Do not change options and descriptions directly

Modified: grass-addons/general/g.xlist/gisdefs.h
===================================================================
--- grass-addons/general/g.xlist/gisdefs.h	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xlist/gisdefs.h	2008-07-15 20:44:14 UTC (rev 32123)
@@ -10,6 +10,6 @@
 
 /* ls.c */
 void G_set_ls_filter(int (*)(const char *, void *), void *);
-const char **G__ls(const char *, int *);
+char **G__ls(const char *, int *);
 
 #endif

Modified: grass-addons/general/g.xlist/join.c
===================================================================
--- grass-addons/general/g.xlist/join.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xlist/join.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -85,7 +85,7 @@
     char path[GPATH_MAX], *p;
     int i, count = 0;
     int buf_len, alias_len, list_len, sep_len = strlen(separator), mapset_len;
-    const char **list;
+    char **list;
 
     /*
      * convert . to current mapset

Modified: grass-addons/general/g.xlist/ls.c
===================================================================
--- grass-addons/general/g.xlist/ls.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xlist/ls.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -76,11 +76,11 @@
  * \return          Pointer to array of strings containing the listing
  **/
 
-const char **G__ls(const char *dir, int *num_files)
+char **G__ls(const char *dir, int *num_files)
 {
     struct dirent *dp;
     DIR *dfd;
-    const char **dir_listing = NULL;
+    char **dir_listing = NULL;
     int n = 0;
 
     if ((dfd = opendir(dir)) == NULL)
@@ -92,8 +92,7 @@
 	     dp->d_name[2] == 0) || (ls_filter &&
 				     !(*ls_filter) (dp->d_name, ls_closure)))
 	    continue;
-	dir_listing = (const char **)G_realloc(dir_listing,
-					       (1 + n) * sizeof(char *));
+	dir_listing = (char **)G_realloc(dir_listing, (1 + n) * sizeof(char *));
 	dir_listing[n] = G_store(dp->d_name);
 	n++;
     }

Modified: grass-addons/general/g.xlist/main.c
===================================================================
--- grass-addons/general/g.xlist/main.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xlist/main.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -48,7 +48,7 @@
 	struct Flag *full;
     } flag;
     int i, n, all, num_types, any, flags = 0;
-    char **types, *pattern = NULL, separator[2];
+    char **types, *pattern = NULL, separator[2], *buf;
     regex_t regex;
 
     G_gisinit(argv[0]);
@@ -71,14 +71,15 @@
     opt.type->description = "Data type";
     for (i = 0, n = 0; n < nlist; n++)
 	i += strlen(list[n].alias) + 1;
-    opt.type->options = G_malloc(i + 4);
+    buf = G_malloc(i + 4);
 
-    opt.type->options[0] = 0;
+    buf[0] = 0;
     for (n = 0; n < nlist; n++) {
-	G_strcat(opt.type->options, list[n].alias);
-	G_strcat(opt.type->options, ",");
+	G_strcat(buf, list[n].alias);
+	G_strcat(buf, ",");
     }
-    G_strcat(opt.type->options, "all");
+    G_strcat(buf, "all");
+    opt.type->options = buf;
 
     opt.pattern = G_define_option();
     opt.pattern->key = "pattern";
@@ -129,6 +130,8 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    G_free(buf);
+
     if (flag.regex->answer)
 	pattern = opt.pattern->answer;
     else

Modified: grass-addons/general/g.xremove/gisdefs.h
===================================================================
--- grass-addons/general/g.xremove/gisdefs.h	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xremove/gisdefs.h	2008-07-15 20:44:14 UTC (rev 32123)
@@ -10,6 +10,6 @@
 
 /* ls.c */
 void G_set_ls_filter(int (*)(const char *, void *), void *);
-const char **G__ls(const char *, int *);
+char **G__ls(const char *, int *);
 
 #endif

Modified: grass-addons/general/g.xremove/join.c
===================================================================
--- grass-addons/general/g.xremove/join.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xremove/join.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -85,7 +85,7 @@
     char path[GPATH_MAX], *p;
     int i, count = 0;
     int buf_len, alias_len, list_len, sep_len = strlen(separator), mapset_len;
-    const char **list;
+    char **list;
 
     /*
      * convert . to current mapset

Modified: grass-addons/general/g.xremove/ls.c
===================================================================
--- grass-addons/general/g.xremove/ls.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xremove/ls.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -76,11 +76,11 @@
  * \return          Pointer to array of strings containing the listing
  **/
 
-const char **G__ls(const char *dir, int *num_files)
+char **G__ls(const char *dir, int *num_files)
 {
     struct dirent *dp;
     DIR *dfd;
-    const char **dir_listing = NULL;
+    char **dir_listing = NULL;
     int n = 0;
 
     if ((dfd = opendir(dir)) == NULL)
@@ -92,8 +92,7 @@
 	     dp->d_name[2] == 0) || (ls_filter &&
 				     !(*ls_filter) (dp->d_name, ls_closure)))
 	    continue;
-	dir_listing = (const char **)G_realloc(dir_listing,
-					       (1 + n) * sizeof(char *));
+	dir_listing = (char **)G_realloc(dir_listing, (1 + n) * sizeof(char *));
 	dir_listing[n] = G_store(dp->d_name);
 	n++;
     }

Modified: grass-addons/general/g.xremove/main.c
===================================================================
--- grass-addons/general/g.xremove/main.c	2008-07-15 11:17:41 UTC (rev 32122)
+++ grass-addons/general/g.xremove/main.c	2008-07-15 20:44:14 UTC (rev 32123)
@@ -42,8 +42,8 @@
 	struct Flag *force;
 	struct Flag *basemap;
     } flag;
-    char *name, *mapset, *location_path, path[GPATH_MAX];
-    const char **files;
+    char *name, *mapset, *location_path, path[GPATH_MAX], **files;
+    char *buf, *buf2;
     int num_files, rast, result = EXIT_SUCCESS;
     int i, j, n;
     regex_t regex;
@@ -80,16 +80,20 @@
 	o->type = TYPE_STRING;
 	o->required = NO;
 	o->multiple = YES;
-	o->gisprompt = G_malloc(64);
-	sprintf(o->gisprompt, "old,%s,%s", list[n].mainelem,
-		list[n].maindesc);
-	o->description = G_malloc(64);
-	sprintf(o->description, _("%s file(s) to be removed"), list[n].alias);
+	buf = G_malloc(64);
+	sprintf(buf, "old,%s,%s", list[n].mainelem, list[n].maindesc);
+	o->gisprompt = buf;
+	buf2 = G_malloc(64);
+	sprintf(buf2, _("%s file(s) to be removed"), list[n].alias);
+	o->description = buf2;
     }
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    G_free(buf);
+    G_free(buf2);
+
     location_path = G_location_path();
     mapset = G_mapset();
 



More information about the grass-commit mailing list