Simplify command word handling.
This commit is contained in:
parent
23ae7edb10
commit
5c30d6429f
2 changed files with 9 additions and 6 deletions
7
advent.h
7
advent.h
|
@ -230,4 +230,11 @@ extern void state_change(obj_t, int);
|
||||||
|
|
||||||
void bug(enum bugtype, const char *) __attribute__((__noreturn__));
|
void bug(enum bugtype, const char *) __attribute__((__noreturn__));
|
||||||
|
|
||||||
|
/* represent an empty command word */
|
||||||
|
static const command_word_t empty_command_word = {
|
||||||
|
.raw = "",
|
||||||
|
.id = WORD_EMPTY,
|
||||||
|
.type = NO_WORD_TYPE,
|
||||||
|
};
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
|
|
8
main.c
8
main.c
|
@ -1168,12 +1168,8 @@ Lookup:
|
||||||
continue; /* back to top of main interpreter loop */
|
continue; /* back to top of main interpreter loop */
|
||||||
case GO_WORD2:
|
case GO_WORD2:
|
||||||
/* Get second word for analysis. */
|
/* Get second word for analysis. */
|
||||||
command.word[0].id = command.word[1].id;
|
command.word[0] = command.word[1];
|
||||||
command.word[0].type = command.word[1].type;
|
command.word[1] = empty_command_word;
|
||||||
strncpy(command.word[0].raw, command.word[1].raw, LINESIZE - 1);
|
|
||||||
command.word[1].id = WORD_EMPTY;
|
|
||||||
command.word[1].type = NO_WORD_TYPE;
|
|
||||||
command.word[1].raw[0] = '\0';
|
|
||||||
goto Lookup;
|
goto Lookup;
|
||||||
case GO_UNKNOWN:
|
case GO_UNKNOWN:
|
||||||
/* Random intransitive verbs come here. Clear obj just in case
|
/* Random intransitive verbs come here. Clear obj just in case
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue