[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #66586] [troff] be even more pernickety about input
From: |
G. Branden Robinson |
Subject: |
[bug #66586] [troff] be even more pernickety about input |
Date: |
Thu, 19 Dec 2024 13:08:12 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?66586>
Summary: [troff] be even more pernickety about input
Group: GNU roff
Submitter: gbranden
Submitted: Thu 19 Dec 2024 06:08:05 PM UTC
Category: Core
Severity: 1 - Wish
Item Group: Warning/Suspicious behaviour
Status: Postponed
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Thu 19 Dec 2024 06:08:05 PM UTC By: G. Branden Robinson <gbranden>
We warn about trailing garbage in `nr` requests but not in other contexts.
This is because request handlers tend to hurl themselves bodily into
`skip_line()` immediately upon reaching the end of any argument that satisfies
them.
Here's a patch that makes `skip_line()` gripe if it encounters anything but
syntactical nullities.
It causes warnings all over the place, because a lot of requests don't advance
the input token pointer off the last (valid) character they read before
calling `skip_line()`. So this patch also illustrates a remedy in the case of
the `af` request handler.
A similar change would have to be made lots of other places.
That sounds like a _groff_ 1.25 project.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index da9361d4d..b613fd238 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2737,11 +2737,19 @@ const char *token::description()
void skip_line()
{
+ bool was_warned = false;
while (!tok.is_newline())
if (tok.is_eof())
return;
- else
+ else {
+ if (!tok.is_space() && !tok.is_tab() && !was_warned) {
+ warning(WARN_SYNTAX,
+ "unexpected %1 in request;"
+ " ignoring rest of line", tok.description());
+ was_warned = true;
+ }
tok.next();
+ }
tok.next();
}
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index c22b088c2..b8c1ac9ae 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -438,8 +438,10 @@ void assign_register_format_request()
} while (csdigit(tok.ch()));
r->alter_format('1', n);
}
- else if (c == 'i' || c == 'I' || c == 'a' || c == 'A')
+ else if (c == 'i' || c == 'I' || c == 'a' || c == 'A') {
r->alter_format(c);
+ tok.next();
+ }
else if (!has_arg())
warning(WARN_MISSING, "register interpolation format assignment"
" request register format as second argument");
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66586>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug #66586] [troff] be even more pernickety about input,
G. Branden Robinson <=