projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
23ae7ed
)
Simplify command word handling.
author
Jason S. Ninneman
<jsn@mbar.us>
Thu, 3 Aug 2017 06:43:52 +0000
(23:43 -0700)
committer
Jason S. Ninneman
<jsn@mbar.us>
Thu, 3 Aug 2017 15:24:18 +0000
(08:24 -0700)
advent.h
patch
|
blob
|
history
main.c
patch
|
blob
|
history
diff --git
a/advent.h
b/advent.h
index b011e96f9e7429fd623ba3d7e825ce582968d485..1e7a0962f65d7684f1df8cd1f193d4512af7da49 100644
(file)
--- 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__));
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 */
diff --git
a/main.c
b/main.c
index ba2f7d7597668f7c2eeb84292c76d6f41a405650..caa328d28e49767757e046f916293aec792ab126 100644
(file)
--- 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. */
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
goto Lookup;
case GO_UNKNOWN:
/* Random intransitive verbs come here. Clear obj just in case