gbranden pushed a commit to branch master
in repository groff.
commit 5004115b44a2e33ec6dfec717abfb1a606c37fba
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 28 18:53:07 2025 -0600
[troff]: Refactor.
* src/roff/troff/input.cpp (read_delimited_number, read_delimited_name):
Make logic more parallel. Make both functions check explicitly for
EOF where the starting delimiter should be (and throw error if it's
encountered). Make both call `is_usable_as_delimiter()` member
function of `start_token` object. Parallelize wording of warning
diagnostics in "delim" category.
I had experimentally added a check for a space in a delimited name, but
it turned out to be unnecessary. (They are invalid in both AT&T and GNU
troffs.)
$ printf 'foo\\C"em dash"bar\n' | dwb troff -a
foo\(em dash"bar
$ printf 'foo\\C"em dash"bar\n' | 9 troff -a
foo\(em dash"bar
$ printf 'foo\\C"em dash"bar\n' | heirloom troff -a
foo dash"bar
$ printf 'foo\\C"em dash"bar\n' | ~/groff-1.23.0/bin/troff -a
<beginning of page>
/home/branden/groff-1.23.0/bin/troff:<standard input>:1: error: missing
delimiter (got a space)
foodash"bar
$ printf 'foo\\C"em dash"bar\n' | ./build/test-groff -a
<beginning of page>
troff:<standard input>:1: error: closing delimiter does not match; expected
character '"', got a space
foodash"bar
$ printf 'foo\\C"em dash"bar\n' | ./build/test-groff -Ca
<beginning of page>
troff:<standard input>:1: error: closing delimiter does not match; expected
character '"', got a space
foodash"bar
---
ChangeLog | 10 ++++++++++
src/roff/troff/input.cpp | 17 ++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1de94c65a..703b43761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-11-28 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (read_delimited_number)
+ (read_delimited_name): Refactor. Make logic more parallel.
+ Make both functions check explicitly for EOF where the starting
+ delimiter should be (and throw error if it's encountered). Make
+ both call `is_usable_as_delimiter()` member function of
+ `start_token` object. Parallelize wording of warning
+ diagnostics in "delim" category.
+
2025-11-28 G. Branden Robinson <[email protected]>
* src/roff/groff/tests/check-delimiter-validity.sh: Add unit
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 4ba8539a5..d8f16f9ab 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5898,6 +5898,10 @@ static bool read_delimited_number(units *n,
{
token start_token;
start_token.next();
+ if (start_token.is_eof()) {
+ error("end of input at start of delimited numeric expression");
+ return false;
+ }
bool is_valid = false;
if (!want_att_compat && start_token.is_usable_as_delimiter())
is_valid = true;
@@ -6146,9 +6150,16 @@ static symbol read_delimited_name()
error("end of input at start of delimited name");
return NULL_SYMBOL;
}
- if (start_token.is_newline() || start_token.is_horizontal_space()) {
- error("%1 is not allowed to delimit a name",
- start_token.description());
+ bool is_valid = false;
+ if (!want_att_compat && start_token.is_usable_as_delimiter())
+ is_valid = true;
+ else if (want_att_compat
+ && start_token.is_usable_as_delimiter(false,
+ DELIMITER_ATT_STRING_EXPRESSION))
+ is_valid = true;
+ if (!is_valid) {
+ warning(WARN_DELIM, "cannot use %1 to delimit a name",
+ start_token.description());
return NULL_SYMBOL;
}
int start_level = input_stack::get_level();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit