Clean up warning and deprecation issues.

This commit is contained in:
Eric S. Raymond 2022-04-12 10:53:37 -04:00
parent 49e2479efa
commit c5250b5f3f
2 changed files with 7 additions and 3 deletions

8
main.c
View file

@ -147,9 +147,11 @@ char *myreadline(const char *prompt)
if (settings.argc == 0) if (settings.argc == 0)
return readline(prompt); return readline(prompt);
char *buf = malloc(BUFSIZ);
for (;;) { for (;;) {
if (settings.scriptfp == NULL || feof(settings.scriptfp)) { if (settings.scriptfp == NULL || feof(settings.scriptfp)) {
if (settings.optind >= settings.argc) { if (settings.optind >= settings.argc) {
free(buf);
return NULL; return NULL;
} }
@ -164,9 +166,10 @@ char *myreadline(const char *prompt)
} }
if (isatty(fileno(settings.scriptfp))) { if (isatty(fileno(settings.scriptfp))) {
free(buf);
return readline(prompt); return readline(prompt);
} else { } else {
char *ln = fgets(malloc(BUFSIZ), BUFSIZ-1, settings.scriptfp); char *ln = fgets(buf, BUFSIZ-1, settings.scriptfp);
if (ln != NULL) { if (ln != NULL) {
fputs(PROMPT, stdout); fputs(PROMPT, stdout);
fputs(ln, stdout); fputs(ln, stdout);
@ -1041,7 +1044,7 @@ static void listobjects(void)
} }
} }
bool preprocess_command(command_t *command) static bool preprocess_command(command_t *command)
/* Pre-processes a command input to see if we need to tease out a few specific cases: /* Pre-processes a command input to see if we need to tease out a few specific cases:
* - "enter water" or "enter stream": * - "enter water" or "enter stream":
* wierd specific case that gets the user wet, and then kicks us back to get another command * wierd specific case that gets the user wet, and then kicks us back to get another command
@ -1263,6 +1266,7 @@ static bool do_command()
} }
break;// LCOV_EXCL_LINE break;// LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
case NO_WORD_TYPE: // LCOV_EXCL_LINE
BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
} }

View file

@ -197,7 +197,7 @@ if __name__ == "__main__":
# load DB # load DB
try: try:
with open(YAML_PATH, "r") as f: with open(YAML_PATH, "r") as f:
db = yaml.load(f) db = yaml.safe_load(f)
except IOError as e: except IOError as e:
print('ERROR: could not load {} ({}})'.format(YAML_PATH, e.strerror)) print('ERROR: could not load {} ({}})'.format(YAML_PATH, e.strerror))
exit(-1) exit(-1)