From: nethack.rankin Date: Wed, 19 Feb 2003 08:35:51 +0000 (+0000) Subject: wizkit revisited X-Git-Tag: MOVE2GIT~2155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a1fcd008a683c5b95ccd038ef1050337615acbc;p=nethack wizkit revisited The previous changed ended up discarding the begining portion of excessively long lines and keeping the end. It's unlikely that either part is going to be valid, but reporting the ending portion as a failed wish would make tracking down and fixing the situation trickier. --- diff --git a/src/files.c b/src/files.c index 6322edf28..2c06e91e1 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)files.c 3.4 2002/08/18 */ +/* SCCS Id: @(#)files.c 3.4 2003/02/18 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2067,22 +2067,30 @@ read_wizkit() FILE *fp; char *ep, buf[BUFSZ]; struct obj *otmp; - boolean bad_items = FALSE; + boolean bad_items = FALSE, skip = FALSE; if (!wizard || !(fp = fopen_wizkit_file())) return; - while (fgets(buf, BUFSZ, fp)) { - if ((ep = index(buf, '\n'))) *ep = '\0'; - if (ep && buf[0]) { + while (fgets(buf, (int)(sizeof buf), fp)) { + ep = index(buf, '\n'); + if (skip) { /* in case previous line was too long */ + if (ep) skip = FALSE; /* found newline; next line is normal */ + } else { + if (!ep) skip = TRUE; /* newline missing; discard next fgets */ + else *ep = '\0'; /* remove newline */ + + if (buf[0]) { otmp = readobjnam(buf, (struct obj *)0, FALSE); if (otmp) { if (otmp != &zeroobj) otmp = addinv(otmp); } else { - raw_printf("Bad wizkit item: \"%.50s\"", buf); + /* .60 limits output line width to 79 chars */ + raw_printf("Bad wizkit item: \"%.60s\"", buf); bad_items = TRUE; } } + } } if (bad_items) wait_synch();