gbranden pushed a commit to branch master
in repository groff.
commit 48ab338d25fb0ac516356b6f5a0e67799085b762
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Apr 12 01:30:56 2026 -0500
[libgroff]: Diagnose font desc file open failure.
* src/libs/libgroff/font.cpp (font::load): If we're not "loading header
only" (that is, not attempting to actually mount a font, but merely
checking its availability or validity, as with `.if F ZCMI`), issue an
error diagnostic disclosing the problem and the system's reason the
file couldn't be opened.
Before:
$ echo 'hello, world' | ./build/test-groff -T utf8 -Z \
| sed 's/font 1 R/font 1 BOGUS/' | ./build/grotty -F ./build/font
./build/grotty:<standard input>:5: fatal error: cannot find font 'BOGUS'
After:
$ echo 'hello, world' | ./build/test-groff -T utf8 -Z \
| sed 's/font 1 R/font 1 BOGUS/' | ./build/grotty -F ./build/font
./build/grotty:<standard input>:5: error: cannot open font description file
'BOGUS': No such file or directory
./build/grotty:<standard input>:5: fatal error: cannot find font 'BOGUS'
While it's not great to have multiple diagnostic messages regarding one
problem, that's tough to overcome without changing libdriver's present
API or by adding logic to _every_ output driver, maybe to only "fatal
out" if the command stream tries to actually write output using a font
position that is not backed by a font description--which already doesn't
work brilliantly (and hasn't since 1.23.0): try the following.
$ echo 'hello, world' | ./build/test-groff -T utf8 -Z \
| sed 's/^f1/f 99/' | ./build/grotty -F ./build/font | head
---
ChangeLog | 8 ++++++++
src/libs/libgroff/font.cpp | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f8cb986d5..f19ca29a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-04-12 G. Branden Robinson <[email protected]>
+
+ * src/libs/libgroff/font.cpp (font::load): If we're not "loading
+ header only" (that is, not attempting to actually mount a font,
+ but merely checking its availability or validity, as with `.if F
+ ZCMI`), issue an error diagnostic disclosing the problem and the
+ system's reason the file couldn't be opened.
+
2026-04-12 G. Branden Robinson <[email protected]>
* src/libs/libdriver/printer.cpp (printer::load_font): Validate
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 907a72e1e..9f823917f 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -899,8 +899,12 @@ bool font::load(bool load_header_only)
{
char *path;
FILE *fp = open_file(filename, &path);
- if (0 /* nullptr */ == fp)
+ if (0 /* nullptr */ == fp) {
+ if (!load_header_only)
+ error("cannot open font description file '%1': %2", filename,
+ strerror(errno));
return false;
+ }
text_file t(fp, path);
t.silent = load_header_only;
char *p = 0 /* nullptr */;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit