[GRASS-SVN] r60976 - grass/trunk/general/g.rename
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 25 10:10:40 PDT 2014
Author: hcho
Date: 2014-06-25 10:10:40 -0700 (Wed, 25 Jun 2014)
New Revision: 60976
Modified:
grass/trunk/general/g.rename/main.c
Log:
g.rename: Rename basemaps only for rast= after successful renaming
Modified: grass/trunk/general/g.rename/main.c
===================================================================
--- grass/trunk/general/g.rename/main.c 2014-06-25 16:59:53 UTC (rev 60975)
+++ grass/trunk/general/g.rename/main.c 2014-06-25 17:10:40 UTC (rev 60976)
@@ -7,9 +7,10 @@
* Cedric Shock <cedricgrass shockfamily.net>,
* Glynn Clements <glynn gclements.plus.com>,
* Markus Neteler <neteler itc.it>,
- * Martin Landa <landa.martin gmail.com>
+ * Martin Landa <landa.martin gmail.com>,
+ * Huidae Cho <grass4u gmail.com>
* PURPOSE:
- * COPYRIGHT: (C) 1994-2007, 2011 by the GRASS Development Team
+ * COPYRIGHT: (C) 1994-2007, 2011-2014 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -28,7 +29,7 @@
{
int i, n;
struct GModule *module;
- struct Option **parm, *p;
+ struct Option **parm;
char *old, *new;
int nrmaps, nlist;
const char *mapset, *location_path;
@@ -50,7 +51,7 @@
parm = (struct Option **)G_calloc(nlist, sizeof(struct Option *));
for (n = 0; n < nlist; n++) {
- p = parm[n] = M_define_option(n, _("renamed"), NO);
+ parm[n] = M_define_option(n, _("renamed"), NO);
}
if (G_parser(argc, argv))
@@ -64,6 +65,8 @@
continue;
i = 0;
while (parm[n]->answers[i]) {
+ int renamed;
+
old = parm[n]->answers[i++];
new = parm[n]->answers[i++];
if (!M_find(n, old, mapset)) {
@@ -86,7 +89,12 @@
continue;
}
- if (Rast_is_reclassed_to(old, mapset, &nrmaps, &rmaps) > 0) {
+ if ((renamed = M_do_rename(n, old, new)) == 1) {
+ result = EXIT_FAILURE;
+ }
+
+ if (!renamed && strcmp(parm[n]->key, "rast") == 0 &&
+ Rast_is_reclassed_to(old, mapset, &nrmaps, &rmaps) > 0) {
int ptr, l;
char buf1[256], buf2[256], buf3[256], *str;
FILE *fp;
@@ -132,9 +140,6 @@
fclose(fp);
}
}
- if (M_do_rename(n, old, new) == 1) {
- result = EXIT_FAILURE;
- }
}
}
exit(result);
More information about the grass-commit
mailing list