aboutsummaryrefslogtreecommitdiff
path: root/mktext.c
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 22:51:40 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 22:51:40 +0200
commit59fc2e62cbfb94e901ac24c0d85a7bec738473e0 (patch)
tree5173739bd831b33aa4c9ec3f9a81f17c8ec3b69b /mktext.c
parent42fd9a69fa2bc9ef11c65c169a58ff40c9cb0fa1 (diff)
downloadclectio-59fc2e62cbfb94e901ac24c0d85a7bec738473e0.tar.gz
clectio-59fc2e62cbfb94e901ac24c0d85a7bec738473e0.zip
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
Diffstat (limited to 'mktext.c')
-rw-r--r--mktext.c25
1 files changed, 23 insertions, 2 deletions
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);