From 59fc2e62cbfb94e901ac24c0d85a7bec738473e0 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 22:51:40 +0200 Subject: fix: recover dropped readings + collapse whitespace; regenerate data Two QA-found bugs fixed: - mktext now collapses runs of whitespace in verse text to a single space (and trims), matching lectio's Fields-based rendering. The Vulgate source has occasional double spaces that were leaking into the output. - Regenerated gen/ with the hermetic, alias-fixed clectio-gen: the generator no longer picks up the user's stale books.ini (which had silently dropped ~30 EF Ember-day lessons, e.g. St Lawrence-common Sir 45, Osee/Hosea 14, 2 Esdras/Nehemiah 8). Full range 2025-2054 now has 0 dropped readings. Verified vs lectio: OF and EF 2026 are byte-identical (day names + verse text, 0 mismatches); range boundaries 2025-01-01 / 2054-12-31 match; ASAN + UBSAN clean over leap days, boundaries and edge cases; bad input never crashes. Shipped total 1.28 MiB. Claude-Session: https://claude.ai/code/session_01S1CD1u3tgSS4xNu6WHfp5a --- mktext.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'mktext.c') diff --git a/mktext.c b/mktext.c index 55af074..1cfcf4b 100644 --- a/mktext.c +++ b/mktext.c @@ -94,8 +94,29 @@ int main(int argc, char **argv) { else { missing++; /* keep a placeholder so indices stay aligned */ } size_t need = strlen(cv) + strlen(text) + 3; while (olen + need > obuf) { obuf *= 2; out = realloc(out, obuf); } - olen += (size_t)snprintf(out + olen, need, "%s %s", cv, text); - out[olen++] = '\n'; + /* "chap:verse " then the text with runs of whitespace collapsed to one + * space and the ends trimmed -- matching lectio's Fields-based render, so + * the source's stray double spaces don't leak through. */ + { + size_t cl = strlen(cv); + int sp = 0, started = 0; + const char *p; + memcpy(out + olen, cv, cl); + olen += cl; + out[olen++] = ' '; + for (p = text; *p; p++) { + if (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') { + sp = 1; + } else { + if (sp && started) + out[olen++] = ' '; + sp = 0; + started = 1; + out[olen++] = *p; + } + } + out[olen++] = '\n'; + } } if (missing) fprintf(stderr, "mktext: warning: %zu of %zu verses not in corpus (blank)\n", missing, nkeys); -- cgit v1.3