From 5c30d6429f4f5e3d187d52b6ac623d61968738a4 Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Wed, 2 Aug 2017 23:43:52 -0700 Subject: [PATCH] Simplify command word handling. --- advent.h | 7 +++++++ main.c | 8 ++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/advent.h b/advent.h index b011e96..1e7a096 100644 --- a/advent.h +++ b/advent.h @@ -230,4 +230,11 @@ extern void state_change(obj_t, int); 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 */ diff --git a/main.c b/main.c index ba2f7d7..caa328d 100644 --- a/main.c +++ b/main.c @@ -1168,12 +1168,8 @@ Lookup: continue; /* back to top of main interpreter loop */ case GO_WORD2: /* Get second word for analysis. */ - command.word[0].id = command.word[1].id; - command.word[0].type = command.word[1].type; - 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'; + command.word[0] = command.word[1]; + command.word[1] = empty_command_word; goto Lookup; case GO_UNKNOWN: /* Random intransitive verbs come here. Clear obj just in case -- 2.31.1