* logfiles for testing purposes.
*/
/* Normal case - no script arguments */
- if (settings.argc == 0)
- return readline(prompt);
+ if (settings.argc == 0) {
+ char *ln = readline(prompt);
+ if (ln == NULL) {
+ fputs(prompt, stdout);
+ }
+ return ln;
+ }
char *buf = malloc(LINESIZE + 1);
for (;;) {
} else {
char *ln = fgets(buf, LINESIZE, settings.scriptfp);
if (ln != NULL) {
- fputs(PROMPT, stdout);
+ fputs(prompt, stdout);
fputs(ln, stdout);
- return ln;
+ return ln;
}
}
}
return true;
}
-static bool do_command()
+static bool do_command(void)
/* Get and execute a command */
{
static command_t command;
if (!get_command_input(&command))
return false;
+ /* Every input, check "foobar" flag. If zero, nothing's going
+ * on. If pos, make neg. If neg, he skipped a word, so make it
+ * zero.
+ */
+ game.foobar = (game.foobar > WORD_EMPTY) ? -game.foobar : WORD_EMPTY;
+
++game.turns;
preprocess_command(&command);
}
/* Options. */
#if defined ADVENT_AUTOSAVE
- const char* opts = "l:oa:";
+ const char* opts = "dl:oa:";
const char* usage = "Usage: %s [-l logfilename] [-o] [-a filename] [script...]\n";
FILE *rfp = NULL;
const char* autosave_filename = NULL;
#elif !defined ADVENT_NOSAVE
- const char* opts = "l:or:";
+ const char* opts = "dl:or:";
const char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename] [script...]\n";
FILE *rfp = NULL;
#else
- const char* opts = "l:o";
+ const char* opts = "dl:o";
const char* usage = "Usage: %s [-l logfilename] [-o] [script...]\n";
#endif
while ((ch = getopt(argc, argv, opts)) != EOF) {
switch (ch) {
+ case 'd': // LCOV_EXCL_LINE
+ settings.debug +=1; // LCOV_EXCL_LINE
+ break; // LCOV_EXCL_LINE
case 'l':
settings.logfp = fopen(optarg, "w");
if (settings.logfp == NULL)