fix #H6861 - whatis behaves weirdly with plurals

Report indicated that looking up "more info?" for "kittens" would show
the data.base entry for "kitten" and then when the display window was
dismissed, another "--More--" prompt for a empty second display window
would occur.  Looking up "2 arrows" from a closely-seen object on the
map behaved similarly.  User correctly diagnosed that the two-pass
lookup left the 'found_in_file' flag set from the first pass during
the second but that just clearing that resulted in "I have no info
about such things" on the second pass.  The code is on the convoluted
side and needed an extra flag to handle 'seen on first pass' in
addition to clearing found flag after the first pass.  I also added a
check to skip the second display if primary and secondary keys don't
match each other but both find the same entry.  To test it, I tried
"a +0 aklys named aclys".  That found the aclys entry but failed to
find "+0 aklys", so I added another change to have the key massaging
remove +/-N after removing "a", "an", or "the".

If "Want to see more info \"" + lookup string + "\"?" was too long,
the prompt buffer passed to yn() was being left uninitialized.  Also,
test for too long was based on BUFSZ but yn() complains (to paniclog)
if the prompt is longer than QBUFSZ.  Make checkfile() construct a
truncated prompt if the lookup string is too long.

I untangled some spaghetti by making all the 'goto's be forward.  It
didn't help a lot but did simplify a few early returns by having them
jump to a common exit instead of replicating the file close.
This commit is contained in:
PatR
2018-02-24 19:35:56 -08:00
parent 5dd6c05322
commit f44ff54c7f
3 changed files with 119 additions and 59 deletions

View File

@@ -54,10 +54,13 @@ suit or piece of armor
[ When Help Collides, by J. D. Berry ]
aclys
aklys
thonged club
A short studded or spiked club attached to a cord allowing
it to be drawn back to the wielder after having been thrown.
It should not be confused with the atlatl, which is a device
used to throw spears for longer distances.
(NetHack's "aklys" is just a club and won't return if thrown.)
~agate ring
agate*
Translucent, cryptocrystalline variety of quartz and a subvariety
@@ -5053,6 +5056,8 @@ tourist
Tourist, Rincewind had decided, meant "idiot".
[ The Colour of Magic, by Terry Pratchett ]
towel
wet towel
moist towel
The Hitchhiker's Guide to the Galaxy has a few things to say
on the subject of towels.
A towel, it says, is about the most massively useful thing