fix "singular of null?" warning for info lookup

Guard against the pathological cases of ", <anything>" and
" called <anything>" strings that a user could type in to indirectly
trigger impossible().  Now they'll yield "no info about such things".
This commit is contained in:
nethack.rankin
2003-08-14 02:40:24 +00:00
parent f5b1090fdc
commit 8b5d31eb01
2 changed files with 8 additions and 7 deletions
+1
View File
@@ -125,6 +125,7 @@ do not let an attached iron ball drag the hero through a location that the hero
could not move normally could not move normally
hero's appearance should change immediately after mimicing completes hero's appearance should change immediately after mimicing completes
avoid some uses of "it" in killer messages avoid some uses of "it" in killer messages
avoid "singular of null?" warning for info lookup of obscure user input
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+7 -7
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)pager.c 3.4 2003/06/29 */ /* SCCS Id: @(#)pager.c 3.4 2003/08/13 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -152,10 +152,9 @@ lookat(x, y, buf, monbuf)
/* newsym lets you know of the trap, so mention it here */ /* newsym lets you know of the trap, so mention it here */
if (tt == BEAR_TRAP || tt == PIT || if (tt == BEAR_TRAP || tt == PIT ||
tt == SPIKED_PIT ||tt == WEB) { tt == SPIKED_PIT || tt == WEB)
Strcat(buf, ", trapped in "); Sprintf(eos(buf), ", trapped in %s",
Strcat(buf, defsyms[trap_to_defsym(tt)].explanation); an(defsyms[trap_to_defsym(tt)].explanation));
}
} }
{ {
@@ -349,12 +348,13 @@ checkfile(inp, pm, user_typed_name, without_asking)
if (*dbase_str) { if (*dbase_str) {
/* adjust the input to remove "named " and convert to lower case */ /* adjust the input to remove "named " and convert to lower case */
char *alt = 0; /* alternate description */ char *alt = 0; /* alternate description */
if ((ep = strstri(dbase_str, " named ")) != 0) if ((ep = strstri(dbase_str, " named ")) != 0)
alt = ep + 7; alt = ep + 7;
else else
ep = strstri(dbase_str, " called "); ep = strstri(dbase_str, " called ");
if (ep) *ep = '\0'; if (!ep) ep = strstri(dbase_str, ", ");
else if ((ep = strstri(dbase_str, ", ")) != 0) *ep = '\0'; if (ep && ep > dbase_str) *ep = '\0';
/* /*
* If the object is named, then the name is the alternate description; * If the object is named, then the name is the alternate description;