From f7e5437746241b23ddeb5393bbf49e400602cda6 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 21 Oct 2023 03:40:56 -0700 Subject: [PATCH] fix #K4019 - "can not" Report suggested that "can not" should be "cannot". Both forms are acceptable. This switches them to use contractions for various "You not subject" phrases: "You can't subject", "hadn't", and so forth. Not exhaustively tested; there may be some sentences where the informal contraction makes things worse rather than better. The goal here was compactness rather than efficiency since the code involved doesn't execute very often. --- doc/fixes3-7-0.txt | 2 ++ src/insight.c | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index cc4348a9d..b45e86c9a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2278,6 +2278,8 @@ throwing the silver bell (or other invocation item, or the Amulet) to the quest leader will identify it instead of being treated as an attack applying gold pieces will flip one and report "heads" or "tails"; with a stack of more than one, normally the flipped coin will rejoin the stack +during enlightenment and end-of-game disclosure, use contraction "n't" + for " not" Platform- and/or Interface-Specific New Features diff --git a/src/insight.c b/src/insight.c index e953c5903..0ddd235ca 100644 --- a/src/insight.c +++ b/src/insight.c @@ -127,12 +127,34 @@ enlght_out(const char *buf) } static void -enlght_line(const char *start, const char *middle, const char *end, - const char *ps) +enlght_line( + const char *start, + const char *middle, + const char *end, + const char *ps) { +#ifndef NO_ENLGHT_CONTRACTIONS + static const struct contrctn { + const char *twowords, *contrctn; + } contra[] = { + { " are not ", " aren't " }, + { " were not ", " weren't " }, + { " have not ", " haven't " }, + { " had not ", " hadn't " }, + { " can not ", " can't " }, + { " could not ", " couldn't " }, + }; + int i; +#endif char buf[BUFSZ]; Sprintf(buf, " %s%s%s%s.", start, middle, end, ps); +#ifndef NO_ENLGHT_CONTRACTIONS + if (strstri(buf, " not ")) { /* TODO: switch to libc strstr() */ + for (i = 0; i < SIZE(contra); ++i) + (void) strsubst(buf, contra[i].twowords, contra[i].contrctn); + } +#endif enlght_out(buf); }