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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user