gbranden pushed a commit to branch master
in repository groff.
commit fd1d4770331d6be31e5aacdd7ccac8f391b9f4e8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 7 17:19:10 2023 -0500
[troff]: Throw error on font selection "DESC".
Throw error diagnostic on attempt to select a font named "DESC". That
will never work.
* src/roff/troff/env.cpp (font_change):
* src/roff/troff/input.cpp (token::next): Do it.
Tested as follows.
$ printf '.ft DESC\n\\f[DESC]\n' | ./build/test-groff -z
troff:<standard input>:1: error: 'DESC' is not a valid font name
troff:<standard input>:2: error: 'DESC' is not a valid font name
---
ChangeLog | 8 ++++++++
src/roff/troff/env.cpp | 7 +++++--
src/roff/troff/input.cpp | 4 +++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b4afd794f..224236c0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-10-07 G. Branden Robinson <[email protected]>
+
+ [troff]: Throw error diagnostic on attempt to select a font
+ named "DESC". That will never work.
+
+ * src/roff/troff/env.cpp (font_change):
+ * src/roff/troff/input.cpp (token::next): Do it.
+
2023-09-25 G. Branden Robinson <[email protected]>
[man]: Add bespoke handling of `lbp` device.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index bed574b3c..c0d47fcfa 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1250,9 +1250,12 @@ void font_change()
// requested. We must warn here if a bogus font name is selected.
if (is_number)
(void) curenv->set_font(atoi(s.contents()));
- else
- if (!curenv->set_font(s))
+ else {
+ if (s == "DESC")
+ error("'%1' is not a valid font name", s.contents());
+ else if (!curenv->set_font(s))
warning(WARN_FONT, "cannot select font '%1'", s.contents());
+ }
skip_line();
}
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 77c5e3133..693a01386 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2178,7 +2178,9 @@ void token::next()
// requested. We must warn here if a bogus font name is
// selected.
if (*p != '\0' || s.is_empty()) {
- if (!curenv->set_font(s))
+ if (s == "DESC")
+ error("'%1' is not a valid font name", s.contents());
+ else if (!curenv->set_font(s))
warning(WARN_FONT, "cannot select font '%1'",
s.contents());
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit