aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-18 18:08:20 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-18 18:08:20 +0200
commitfd3eda0da228d2417b8b7f9007533e214d7a5e80 (patch)
tree58e0db94748e4dce663c2ecdc78a9faeb8d9b659 /cmd
parente713da2d796eabc55d407ad2f8488861e7598798 (diff)
downloadlectio-fd3eda0da228d2417b8b7f9007533e214d7a5e80.tar.gz
lectio-fd3eda0da228d2417b8b7f9007533e214d7a5e80.zip
fix(clectio-gen): write the verse keys gzipped as well as plain
clectio's Makefile unpacks gen/verses_<form>.keys from the COMMITTED .gz, and its clean target deletes the plain file. clectio-gen wrote only the plain one, so regenerating the tables without separately re-gzipping the keys left gen/liturgy_<form>.h indexing verses the packed text did not hold. clectio then dereferenced a NULL verse pointer. That shipped: 1246 of the 10957 EF dates in the 2025-2054 range segfaulted, 11% of the calendar. OF was unaffected -- its tables had not been regenerated since the keys were last packed. The two artefacts are generated together, so they are now written together and cannot drift. OF's keys are byte-different after this (Go's gzip, not gzip(1)) but content-identical, verified.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/clectio-gen/main.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/cmd/clectio-gen/main.go b/cmd/clectio-gen/main.go
index 422cd34..9897642 100644
--- a/cmd/clectio-gen/main.go
+++ b/cmd/clectio-gen/main.go
@@ -23,6 +23,7 @@ package main
import (
"bufio"
+ "compress/gzip"
"flag"
"fmt"
"os"
@@ -256,18 +257,41 @@ func resolveRef(sec liturgy.Section, form string) string {
return bible.OFRef(cit, "vulgate")
}
+// writeKeys writes the verse keys BOTH plain and gzipped, because clectio's
+// Makefile unpacks gen/verses_<form>.keys from the COMMITTED .gz -- and its
+// clean target deletes the plain file. Emitting only the plain one therefore
+// left a regenerated gen/liturgy_<form>.h indexing verses the packed text did
+// not hold, and clectio dereferenced a NULL verse: 1246 of the 10957 EF dates
+// segfaulted in the version that shipped that way. The two artefacts are
+// generated together, so they are now written together.
func writeKeys(path string, keys []string) {
+ writeKeysTo(path, keys, false)
+ writeKeysTo(path+".gz", keys, true)
+}
+
+func writeKeysTo(path string, keys []string, compress bool) {
f, err := os.Create(path)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer f.Close()
- w := bufio.NewWriter(f)
+ var w *bufio.Writer
+ var gz *gzip.Writer
+ if compress {
+ gz, _ = gzip.NewWriterLevel(f, gzip.BestCompression)
+ defer gz.Close()
+ w = bufio.NewWriter(gz)
+ } else {
+ w = bufio.NewWriter(f)
+ }
for _, k := range keys {
w.WriteString(k + "\n")
}
w.Flush()
+ if gz != nil {
+ gz.Flush()
+ }
}
func cstr(s string) string {