#include "dungeon.h"
+#define LINESIZE 1024
#define NDWARVES 6 // number of dwarves
#define PIRATE NDWARVES // must be NDWARVES-1 when zero-origin
#define DALTLC LOC_NUGGET // alternate dwarf location
/* This is where we get a new command from the user */
char* input;
+ char inputbuf[LINESIZE];
+
for (;;) {
input = get_input();
if (input == NULL)
if (strcmp(input, "") != 0)
break;
}
+
+ strncpy(inputbuf, input, LINESIZE - 1);
+ linenoiseFree(input);
+
long tokens[4];
- tokenize(input, tokens);
+ tokenize(inputbuf, tokens);
command.wd1 = tokens[0];
command.wd1x = tokens[1];
command.wd2 = tokens[2];
defn = get_vocab_id(word1);
if (defn == -1) {
/* Gee, I don't understand. */
- if (fallback_handler(input))
+ if (fallback_handler(inputbuf))
continue;
rspeak(DONT_KNOW, command.wd1, command.wd1x);
goto L2600;
}
}
- /* Version specifier */
+ /* Version specifier */
if (msg[i] == 'V') {
- strcpy(renderp, VERSION);
+ strcpy(renderp, VERSION);
size_t len = strlen(VERSION);
renderp += len;
size -= len;
- }
-
+ }
+
// All-lowercase specifier.
if (msg[i] == 'L' || msg[i] == 'C') {
packed_to_token(arg, renderp); /* unpack directly to destination */
printf("%s", input_prompt);
// LCOV_EXCL_STOP
ssize_t numread = getline(&input, &n, stdin);
- if (numread == -1) // Got EOF; return with it.
+ if (numread == -1) { // Got EOF; return with it.
+ free(input);
return (NULL);
+ }
}
if (input == NULL) // Got EOF; return with it.