Follow-up Comment #15, bug #64155 (project groff): In my working copy of my private branch. The commit ID will almost certainly change.
commit f8e966af2985f267ed1efd9c6eeb37e41adca959 Author: G. Branden Robinson <g.branden.robin...@gmail.com> Date: Thu May 25 05:35:25 2023 -0500 [troff]: Validate a font family before using it. * src/roff/troff/env.cpp (is_family_valid): New function checks for all text styles (R, I, B, BI) and returns true only if the given family supports them all. (family_change): Call `is_family_valid()` on given argument. If invalid, throw diagnostic and ignore `fam` request. * src/roff/troff/env.h (is_family_valid): Declare; make visible. * src/roff/troff/input.cpp (main): Call `is_family_valid()` on `-f` option argument. Its invalidity is a fatal error. Fixes <https://savannah.gnu.org/bugs/?64115>. Thanks to Dave Kemper for the report. Tested with: $ echo | ./build/test-groff -fZD -z troff: fatal error: 'ZD' is not a valid font family $ echo | ./build/test-groff -fH -z $ nl ./EXPERIMENTS/validate-family.groff 1 .tm .fam=\n[.fam] 2 .fam H 3 .tm .fam=\n[.fam] 4 .fam 5 .tm .fam=\n[.fam] 6 .fam ZD 7 .fam BOGUS 8 .tm .fam=\n[.fam] 9 .fam 10 .tm .fam=\n[.fam] $ ./build/test-groff ./EXPERIMENTS/validate-family.groff .fam=T .fam=H .fam=T troff:./EXPERIMENTS/validate-family.groff:6: error: 'ZD' is not a valid font family troff:./EXPERIMENTS/validate-family.groff:7: error: 'BOGUS' is not a valid font family .fam=T .fam=H I did have to lose the bit of diagnostic about which style was missing, because the function needed to be callable from two different places and passing back that information promised to be a pain in the butt. It would have meant adding a reference or pointer argument to `is_family_valid`, or introducing C++ exceptions to groff's exception-free code base. Or something similarly grody, I expect. It didn't seem worth the trouble at this time. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?64155> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/