gbranden pushed a commit to branch master
in repository groff.
commit baba4355f5cc6b07c48d1a56cea5c9e02c300633
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Aug 18 08:13:06 2024 -0500
[troff]: Handle bad `\D` delims as other escs do.
* src/roff/troff/input.cpp (read_drawing_command): Handle an invalid
delimiter in a drawing command escape sequence `\D` the same as every
other escape sequence that recognizes a restricted set of delimiters
(`\h`, `\H`, `\l`, `\L`, `\N`, `\R`, `\s`, `\S`, `\v`, and `\x`): stop
parsing immediately instead of consuming and discarding input until
encountering a matching invalid delimiter, newline, or EOF.
$ cat EXPERIMENTS/bad-delimiters.roff
.nf
A\D.l 1i 0.B
C\h.1i.D
E\H.12.F
G\l.1i.H
I\L.1i.J
K\N.65.L
M\R.a 1.N
O\s.10p.P
Q\S.45.R
S\v.1i.T
U\x.3p.V
Before:
$ nroff EXPERIMENTS/bad-delimiters.roff | cat -s
troff:EXPERIMENTS/bad-delimiters.roff:2: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:3: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:4: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:5: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:6: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:7: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:8: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:9: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:10: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:11: error: character '.' is not
allowed as a starting delimiter
troff:EXPERIMENTS/bad-delimiters.roff:12: error: character '.' is not
allowed as a starting delimiter
AB
C1i.D
E12.F
G1i.H
I1i.J
K65.L
Ma 1.N
O10p.P
Q45.R
S1i.T
U3p.V
Now, (only) the first line of output differs.
$ ./build/test-groff -E -T ascii -ww EXPERIMENTS/bad-delimiters.roff \
| head -n 1
Al 1i 0.B
---
ChangeLog | 10 ++++++++++
src/roff/troff/input.cpp | 7 ++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 267d303f9..8028c277c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-08-18 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (read_drawing_command): Handle
+ an invalid delimiter in a drawing command escape sequence `\D`
+ the same as every other escape sequence that recognizes a
+ restricted set of delimiters (`\h`, `\H`, `\l`, `\L`, `\N`,
+ `\R`, `\s`, `\S`, `\v`, and `\x`): stop parsing immediately
+ instead of consuming and discarding input until encountering a
+ matching invalid delimiter, newline, or EOF.
+
2024-08-18 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Trivially refactor. Rename
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index fbd7cca12..0a596fb70 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8916,11 +8916,8 @@ static node *read_drawing_command()
{
token start_token;
start_token.next();
- if (!start_token.is_usable_as_delimiter(true /* report error */)){
- do {
- tok.next();
- } while (tok != start_token && !tok.is_newline() && !tok.is_eof());
- }
+ if (!start_token.is_usable_as_delimiter(true /* report error */))
+ return 0 /* nullptr */;
else {
tok.next();
if (tok == start_token)
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit