[GRASS-SVN] r58034 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 17 14:22:22 PDT 2013
Author: glynn
Date: 2013-10-17 14:22:22 -0700 (Thu, 17 Oct 2013)
New Revision: 58034
Modified:
grass/trunk/lib/gis/parser.c
Log:
Ignore ambiguities caused by r57999 abbreviations when option is a unique prefix
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2013-10-17 20:04:42 UTC (rev 58033)
+++ grass/trunk/lib/gis/parser.c 2013-10-17 21:22:22 UTC (rev 58034)
@@ -1143,7 +1143,9 @@
static int check_string(const char *ans, const char **opts, int *result)
{
+ int len = strlen(ans);
int found = 0;
+ int prefix = 0;
int i;
if (!opts)
@@ -1152,16 +1154,26 @@
for (i = 0; opts[i]; i++) {
if (strcmp(ans, opts[i]) == 0)
return 0;
- if (match_option(ans, opts[i])) {
+ if (strncmp(ans, opts[i], len) == 0) {
*result = i;
found++;
+ prefix++;
}
+ if (match_option(ans, opts[i])) {
+ if (!found)
+ *result = i;
+ found++;
+ }
}
switch (found) {
case 0: return OUT_OF_RANGE;
case 1: return REPLACED;
- default: return AMBIGUOUS;
+ default:
+ switch (prefix) {
+ case 1: return REPLACED;
+ default: return AMBIGUOUS;
+ }
}
}
More information about the grass-commit
mailing list