From: PatR Date: Sat, 5 Dec 2015 02:52:51 +0000 (-0800) Subject: "Bad option line" formatting X-Git-Tag: NetHack-3.6.0_RC02~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=841662ff3200402fa3cae0b940b33daa885fa2a4;p=nethack "Bad option line" formatting Change |Bad option line: "foo |" to |Bad option line: "foo" by stripping away the input line's newline before processing it. (This doesn't address the PANICTRACE options processing issue.) --- diff --git a/src/files.c b/src/files.c index 1ce0c872e..6a74de52c 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1448323244 2015/11/24 00:00:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.190 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1449283964 2015/12/05 02:52:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.191 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2559,7 +2559,7 @@ read_config_file(filename, src) const char *filename; int src; { - char buf[4 * BUFSZ]; + char buf[4 * BUFSZ], *p; FILE *fp; boolean rv = TRUE; /* assume successful parse */ @@ -2577,8 +2577,16 @@ line at this level. OR: Forbid multiline stuff for alternate config sources. */ #endif + if ((p = index(buf, '\n')) != 0) + *p = '\0'; if (!parse_config_line(fp, buf, src)) { - raw_printf("Bad option line: \"%.50s\"", buf); + static const char badoptionline[] = "Bad option line: \"%s\""; + + /* truncate buffer if it's long; this is actually conservative */ + if (strlen(buf) > BUFSZ - sizeof badoptionline) + buf[BUFSZ - sizeof badoptionline] = '\0'; + + raw_printf(badoptionline, buf); wait_synch(); rv = FALSE; }