--- old-freeciv/server/stdinhand.c Sun Mar 21 13:32:38 1999 +++ freeciv/server/stdinhand.c Tue Apr 6 22:25:00 1999 @@ -738,13 +738,27 @@ server_remove_player(pplayer); } +/************************************************************************** +Find option index by name. Return index (>=0) on success, -1 if no +suitable options were found, -2 if several matches were found. +**************************************************************************/ int lookup_cmd(char *find) { - int i; + int i, lastmatch = -1; + for (i=0;settings[i].name!=NULL;i++) - if (!strcmp(find, settings[i].name)) return i; - - return -1; + if (!strncmp(find, settings[i].name, strlen(find))) + { + /* If name is a perfect match, not partial, assume + * that this is the option the user wanted. */ + if (!strcmp(find, settings[i].name)) + return i; + if (lastmatch != -1) + return -2; + lastmatch = i; + } + + return lastmatch; } void explain_option(char *str) @@ -763,6 +777,10 @@ puts("No explanation for that yet."); return; } + else if (cmd==-2) { + puts("Ambiguous option name."); + return; + } else { struct settings_s *op = &settings[cmd]; @@ -943,6 +961,10 @@ puts("Undefined argument. Usage: set