Browse Source

Ignore ambiguities caused by https://trac.osgeo.org/grass/changeset/57999 abbreviations when option is a unique prefix

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58034 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 11 years ago
parent
commit
a35a88d66e
1 changed files with 14 additions and 2 deletions
  1. 14 2
      lib/gis/parser.c

+ 14 - 2
lib/gis/parser.c

@@ -1143,7 +1143,9 @@ static int check_double(const char *ans, const char **opts)
 
 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 @@ static int check_string(const char *ans, const char **opts, int *result)
     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;
+	}
     }
 }