]> granicus.if.org Git - nethack/commit
safe_qbuf, short_oname (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 24 Oct 2006 05:18:00 +0000 (05:18 +0000)
committernethack.rankin <nethack.rankin>
Tue, 24 Oct 2006 05:18:00 +0000 (05:18 +0000)
commit9315307df266d7b1442410376f123c208c01a3c7
tree5b4592f0959bb08c52eda74935799ee416e37470
parent3cc5a682c9618a83d11443dd763ce9084f912c26
safe_qbuf, short_oname (trunk only)

     Change safe_qbuf() so that instead of picking one of three strings
for sprintf() to plug into a prompt string, it actually constructs the
full prompt string itself.  Also pass in the unformatted object and a pair
of formatting functions instead of performing dual formatting in advance.
The actual formatting is done via new routine short_oname() which also
takes an object and a pair of formatting routines plus a target length.
It uses the first routine, typically xname() or doname(), and formats the
object, then if the result is too long it makes some transformations, and
tries again.  If truncating "called foo" and "named bar" down to 12 chars
and omitting "uncursed, rustproof, thoroughly corroded" attributes still
result in a string that's too long, it uses the other formatting routine.
The latter calls one of several jacket routines around simple_typename()
to produce a short result.

     This has been through about four incarnations now and has gotten a
bit less testing each time, but I need to get it in place before I end up
running out of gas and abandoning it.  I've got some changes to shk.c
(where safe_qbuf is needed but not currently used) that now need to be
redone and will come eventually.
include/extern.h
src/apply.c
src/do_name.c
src/eat.c
src/invent.c
src/lock.c
src/mhitu.c
src/objnam.c
src/pickup.c
src/trap.c