[GRASS-SVN] r62401 - grass/trunk/general/g.remove
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 26 18:33:49 PDT 2014
Author: hcho
Date: 2014-10-26 18:33:49 -0700 (Sun, 26 Oct 2014)
New Revision: 62401
Modified:
grass/trunk/general/g.remove/construct_pattern.c
Log:
g.remove: Escape special characters in names= and ignore=
Modified: grass/trunk/general/g.remove/construct_pattern.c
===================================================================
--- grass/trunk/general/g.remove/construct_pattern.c 2014-10-27 01:14:40 UTC (rev 62400)
+++ grass/trunk/general/g.remove/construct_pattern.c 2014-10-27 01:33:49 UTC (rev 62401)
@@ -5,7 +5,7 @@
char *construct_pattern(char **names)
{
char *pattern, *p;
- int i, len, found_illegal_names;
+ int i, j, len, found_illegal_names;
const char *mapset;
char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
@@ -15,6 +15,10 @@
len += p - names[i];
else
len += strlen(names[i]);
+
+ /* make room for escaping special characters */
+ for (j = 0; names[i][j]; j++)
+ len += !isalnum(names[i][j]);
}
len += i; /* # names - 1 commas + \0 */
@@ -39,9 +43,14 @@
if (i)
*p++ = ',';
- strcpy(p, name);
- p += strlen(name);
+
+ for (j = 0; name[j]; j++) {
+ if (!isalnum(name[j]))
+ *p++ = '\\';
+ *p++ = name[j];
+ }
}
+ *p = '\0';
if (found_illegal_names)
G_fatal_error(_("Illegal filenames not allowed in the names or ignore "
More information about the grass-commit
mailing list