gbranden pushed a commit to branch master
in repository groff.
commit e4c54708f273999dd6ffee4d129cc6453ca81380
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat May 17 08:11:00 2025 -0500
[troff]: Improve warning diagnostics.
* src/roff/troff/env.cpp (space_size, hyphenate_request):
* src/roff/troff/input.cpp (set_character_flags): Phrase notice of
ignored argument(s) consistently with other GNU troff diagnostic
messages.
(hyphenate_request): Disclose valid range of argument to `hy` request
when warning of a value beyond it.
(adjust): Disclose valid range of argument (and the set of preferred
letter synonyms) to `ad` request when warning of a value beyond it.
* src/roff/troff/input.cpp (set_character_flags): Disclose value of
invalid argument encountered when warning of its out-of-range status.
---
ChangeLog | 17 +++++++++++++++++
src/roff/troff/env.cpp | 19 ++++++++++---------
src/roff/troff/input.cpp | 8 ++++----
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a60061cab..5264aec19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2025-05-17 G. Branden Robinson <[email protected]>
+
+ [troff]: Improve warning diagnostics.
+
+ * src/roff/troff/env.cpp (space_size, hyphenate_request):
+ * src/roff/troff/input.cpp (set_character_flags): Phrase notice
+ of ignored argument(s) consistently with other GNU troff
+ diagnostic messages.
+ (hyphenate_request): Disclose valid range of argument to `hy`
+ request when warning of a value beyond it.
+ (adjust): Disclose valid range of argument (and the set of
+ preferred letter synonyms) to `ad` request when warning of a
+ value beyond it.
+ * src/roff/troff/input.cpp (set_character_flags): Disclose value
+ of invalid argument encountered when warning of its out-of-range
+ status.
+
2025-05-16 G. Branden Robinson <[email protected]>
[troff]: Make reported character flags scrutable.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index dc32cd062..981994df5 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1391,12 +1391,12 @@ void space_size()
int n;
if (get_integer(&n)) {
if (n < 0)
- warning(WARN_RANGE, "negative word space size ignored: '%1'", n);
+ warning(WARN_RANGE, "ignoring negative word space size: '%1'", n);
else
curenv->space_size = n;
if (has_arg() && get_integer(&n))
if (n < 0)
- warning(WARN_RANGE, "negative sentence space size ignored: "
+ warning(WARN_RANGE, "ignoring negative sentence space size: "
"'%1'", n);
else
curenv->sentence_space_size = n;
@@ -1753,15 +1753,15 @@ void hyphenate_request()
int n;
if (has_arg() && get_integer(&n)) {
if (n < HYPHEN_NONE) {
- warning(WARN_RANGE, "negative hyphenation flags ignored: %1", n);
+ warning(WARN_RANGE, "ignoring negative hyphenation flags: %1", n);
} else if (n > HYPHEN_MAX) {
- warning(WARN_RANGE, "unknown hyphenation flags ignored (maximum "
- "%1): %2", HYPHEN_MAX, n);
+ warning(WARN_RANGE, "hyphenation flags must be in range 0..%1,"
+ " got %2", HYPHEN_MAX, n);
} else if (((n & HYPHEN_DEFAULT) && (n & ~HYPHEN_DEFAULT))
|| ((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS))
|| ((n & HYPHEN_LAST_CHAR) && (n & HYPHEN_NOT_LAST_CHARS)))
- warning(WARN_SYNTAX, "contradictory hyphenation flags ignored: "
- "%1", n);
+ warning(WARN_SYNTAX, "ignoring contradictory hyphenation flags: "
+ "%1", n);
else
curenv->hyphenation_mode = n;
}
@@ -2710,8 +2710,9 @@ void adjust()
if (n < 0)
warning(WARN_RANGE, "negative adjustment mode");
else if (n > ADJUST_MAX)
- warning(WARN_RANGE, "out-of-range adjustment mode ignored: "
- "%1", n);
+ warning(WARN_RANGE, "adjustment mode must be in range 0..%1"
+ " (or 'l', 'r', 'c', 'b', or 'n'), got %2",
+ ADJUST_MAX, n);
else
curenv->adjust_mode = n;
}
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f1d026cf1..5c2dd7868 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8074,8 +8074,8 @@ static void set_character_flags()
int flags;
if (get_integer(&flags)) {
if ((flags < 0) || (flags > charinfo::CFLAGS_MAX)) {
- warning(WARN_RANGE, "character flags must be in range 0..%1",
- charinfo::CFLAGS_MAX);
+ warning(WARN_RANGE, "character flags must be in range 0..%1,"
+ " got %2", charinfo::CFLAGS_MAX, flags);
skip_line();
return;
}
@@ -8085,8 +8085,8 @@ static void set_character_flags()
&& (flags & charinfo::PROHIBITS_BREAK_BEFORE))
|| ((flags & charinfo::ALLOWS_BREAK_AFTER)
&& (flags & charinfo::PROHIBITS_BREAK_AFTER))) {
- warning(WARN_SYNTAX, "contradictory character flags ignored: "
- "%1", flags);
+ warning(WARN_SYNTAX, "ignoring contradictory character flags: "
+ "%1", flags);
skip_line();
return;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit