From e18cf594d388aaa014acea33b0f06178165e2f8a Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Thu, 8 Jan 2026 11:18:23 -0500 Subject: [PATCH] Avoid redundant punctuation in engraving message Change the formatting of reading an engraving to include a terminal period only if the engraving does not already include punctuation, to avoid messages like: | You feel the words: "Please don't feed the animals.". This brings the formatting of the read_engr_at() message in line with doread(). One minor concern with this is that degraded engravings can use punctuation to represent "chicken scratch" degraded text rather than as actual punctuation, and ideally it might be better to include the final period if you're reading an engraving like "Hc| ? |?". This is true of burnt T-shirts already, but it's much more common with engravings. It should be possible to identify "real punctuation" by checking whether (ep->engr_txt[pristine_text] == et[elen - 1]) -- but this doesn't actually work without more tinkering, since trimming initial whitespace in u_wipe_engr() updates the actual_text pointer so the indices stop matching. --- src/engrave.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/engrave.c b/src/engrave.c index e029e87dc..40c3f95b1 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -370,18 +370,26 @@ read_engr_at(coordxy x, coordxy y) if (sensed) { char *et, buf[BUFSZ]; + const char *endpunct; int maxelen = (int) (sizeof buf /* sizeof "literal" counts terminating \0 */ - - sizeof "You feel the words: \"\"."); + - sizeof "You feel the words: \"\"."), + elen = (int) strlen(ep->engr_txt[actual_text]); - if ((int) strlen(ep->engr_txt[actual_text]) > maxelen) { + if (elen > maxelen) { (void) strncpy(buf, ep->engr_txt[actual_text], maxelen); buf[maxelen] = '\0'; et = buf; + elen = maxelen; } else { et = ep->engr_txt[actual_text]; } - You("%s: \"%s\".", (Blind) ? "feel the words" : "read", et); + endpunct = ""; + if (elen > 0 && !strchr(".!?", et[elen - 1])) { + endpunct = "."; + } + You("%s: \"%s\"%s", (Blind) ? "feel the words" : "read", et, + endpunct); Strcpy(ep->engr_txt[remembered_text], ep->engr_txt[actual_text]); ep->eread = 1; ep->erevealed = 1;