From ffe196d6aa086bf248951d20fe56a1f7d02f8d3f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 1 May 2025 09:39:46 +0200 Subject: [PATCH] Fix "must contain" with too many of a letter If the "must contain" (rs) set had too many uses of a character, the initial letter counts (ww) could be nonsense. Now, if you do a bogus search like `munmunii -- iii` (commandline) or `munmun =iii` (web), you'll get 0 results. (it'll somewhat confusingly report that it reached a max of 0 searches, but so be it) Closes #1 --- run.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/run.cc b/run.cc index baa6229..a0129ed 100644 --- a/run.cc +++ b/run.cc @@ -350,7 +350,14 @@ struct ana_cfg { : apos(apos), just_candidates(just_candidates), minlen(minlen), maxlen(maxlen), total_matches(0), max_matches(max_matches), total_searches(0), - max_searches(max_searches), lengths(lengths), rs(rs), ww(wordholder(ws).value() - wordholder(rs).value()) { + max_searches(max_searches), lengths(lengths), rs(rs), ww() { + auto wsv = wordholder(ws).value(); + auto rsv = wordholder(rs).value(); + if (candidate(wsv, rsv)) { + ww = wsv - rsv; + } else { + this->max_searches = 0; + } } bool apos, just_candidates;