[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 22/35: [troff]: Warn if nonexistent font name selected.
From: |
G. Branden Robinson |
Subject: |
[groff] 22/35: [troff]: Warn if nonexistent font name selected. |
Date: |
Tue, 21 Jun 2022 14:26:30 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 1986da1d4bb11dc0421e004b153729b3d2a2a3ca
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jun 20 14:15:38 2022 -0500
[troff]: Warn if nonexistent font name selected.
* src/roff/troff/env.cpp (font_change):
* src/roff/troff/input.cpp (token::next): Warn upon selection of a
nonexistent font name.
Fixes <https://savannah.gnu.org/bugs/?62656>.
Also annotate a null pointer to ease any future transition to C++11,
which defines a keyword for it.
---
ChangeLog | 7 +++++++
src/roff/troff/env.cpp | 7 +++++--
src/roff/troff/input.cpp | 12 +++++++++---
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3b814ab4..8be53262 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-06-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/env.cpp (font_change): Warn upon selection of a
+ nonexistent font name.
+
+ Fixes <https://savannah.gnu.org/bugs/?62656>.
+
2022-06-20 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Revise `environment::set_font` to return Boolean value
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7aeb5bd2..c564ebc8 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1202,10 +1202,13 @@ void font_change()
break;
}
}
+ // environment::set_font warns if a bogus mounting position is
+ // requested. We must warn here if a bogus font name is selected.
if (is_number)
- curenv->set_font(atoi(s.contents()));
+ (void) curenv->set_font(atoi(s.contents()));
else
- curenv->set_font(s);
+ 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 5a299121..8aadc243 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2052,10 +2052,16 @@ void token::next()
for (p = s.contents(); *p != '\0'; p++)
if (!csdigit(*p))
break;
- if (*p || s.is_empty())
- curenv->set_font(s);
+ // environment::set_font warns if a bogus mounting position is
+ // requested. We must warn here if a bogus font name is
+ // selected.
+ if (*p != 0 /* nullptr */ || s.is_empty()) {
+ if (!curenv->set_font(s))
+ warning(WARN_FONT, "cannot select font '%1'",
+ s.contents());
+ }
else
- curenv->set_font(atoi(s.contents()));
+ (void) curenv->set_font(atoi(s.contents()));
if (!compatible_flag)
have_input = 1;
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 22/35: [troff]: Warn if nonexistent font name selected.,
G. Branden Robinson <=