[GRASS-SVN] r33576 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 27 19:46:03 EDT 2008


Author: glynn
Date: 2008-09-27 19:46:03 -0400 (Sat, 27 Sep 2008)
New Revision: 33576

Modified:
   grass/trunk/lib/gis/parser.c
Log:
More restrictive test for option: [a-z0-9_]*[a-z0-9]
 i.e. must consist solely of [a-z0-9_], and the last character may not be an underscore
 [can we change 3dview= so that the first character must also be alphabetic?]


Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c	2008-09-27 23:36:15 UTC (rev 33575)
+++ grass/trunk/lib/gis/parser.c	2008-09-27 23:46:03 UTC (rev 33576)
@@ -2126,17 +2126,9 @@
 
 static int is_option(const char *string)
 {
-    const char *p = strchr(string, '=');
+    int n = strspn(string, "abcdefghijklmnopqrstuvwxyz0123456789_");
 
-    if (!p)
-	return 0;
-    if (p == string)
-	return 0;
-    p--;
-    if (!strchr("abcdefghijklmnopqrstuvwxyz0123456789", *p))
-	return 0;
-
-    return 1;
+    return n > 0 && string[n] == '=' && string[n-1] != '_';
 }
 
 static int set_option(char *string)



More information about the grass-commit mailing list