edit: Accept interactive empty key argument again

Empty key arguments work fine when passed as command arguments, but
not interactively.  For example, 'edit s 42 R ""' clears the retreat
path, but in an interactive 'edit s 43', 'R ""' sets it to "".

In Empire 1, omitting the argument made it empty.  Empire 2 turned
that into an error without providing an alternative.

Switch to the common command parser, so that quoting works, and "" is
parsed as empty argument.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2013-01-20 23:39:03 +01:00
parent 33456b3371
commit c0f3a1e5e5
3 changed files with 40 additions and 10 deletions

View file

@ -399,22 +399,22 @@ print_ship(struct shpstr *ship)
static int
getin(char *buf, char **valp)
{
char line[1024];
char *argp[128];
char *p;
unsigned char thing;
p = getstarg(NULL, "%c xxxxx -- thing value : ", buf);
p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
if (!p)
return -1;
for (; isspace(*p); p++) ;
if (!*p)
switch (parse(p, buf, argp, NULL, NULL, NULL)) {
case 0:
return 0;
thing = *p;
for (; *p && !isspace(*p); p++) ;
for (; isspace(*p); p++) ;
if (!*p)
case 1:
return -1;
*valp = p;
return thing;
default:
*valp = argp[1];
return argp[0][0];
}
}
#if 0 /* not needed right now */