[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #63202] [troff] missing delimiter diagnostics could say what they w
From: |
G. Branden Robinson |
Subject: |
[bug #63202] [troff] missing delimiter diagnostics could say what they were expecting |
Date: |
Sat, 17 Aug 2024 17:29:05 -0400 (EDT) |
Update of bug #63202 (group groff):
Status: None => In Progress
Assigned to: None => gbranden
_______________________________________________________
Follow-up Comment #1:
Almost 2 years later, this proved much less troublesome.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f49dba429..9e994be7a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5186,8 +5186,15 @@ static bool read_delimited_number(units *n,
if (start_token.is_usable_as_delimiter(true /* report error */)) {
tok.next();
if (read_measurement(n, si, prev_value)) {
- if (start_token != tok)
- warning(WARN_DELIM, "closing delimiter does not match");
+ if (start_token != tok) {
+ // token::description() writes to static, class-wide storage, so
+ // we must allocate a copy of it before issuing the next
+ // diagnostic.
+ char *delimdesc = strdup(start_token.description());
+ warning(WARN_DELIM, "closing delimiter does not match;"
+ " expected %1, got %2", delimdesc, tok.description());
+ free(delimdesc);
+ }
return true;
}
}
@@ -5201,8 +5208,15 @@ static bool read_delimited_number(units *n, unsigned
char si)
if (start_token.is_usable_as_delimiter(true /* report error */)) {
tok.next();
if (read_measurement(n, si)) {
- if (start_token != tok)
- warning(WARN_DELIM, "closing delimiter does not match");
+ if (start_token != tok) {
+ // token::description() writes to static, class-wide storage, so
+ // we must allocate a copy of it before issuing the next
+ // diagnostic.
+ char *delimdesc = strdup(start_token.description());
+ warning(WARN_DELIM, "closing delimiter does not match;"
+ " expected %1, got %2", delimdesc, tok.description());
+ free(delimdesc);
+ }
return true;
}
}
@@ -5226,8 +5240,15 @@ static bool get_line_arg(units *n, unsigned char si,
charinfo **cp)
tok.next();
}
if (!(start_token == tok
- && input_stack::get_level() == start_level))
- warning(WARN_DELIM, "closing delimiter does not match");
+ && input_stack::get_level() == start_level)) {
+ // token::description() writes to static, class-wide storage, so
+ // we must allocate a copy of it before issuing the next
+ // diagnostic.
+ char *delimdesc = strdup(start_token.description());
+ warning(WARN_DELIM, "closing delimiter does not match; expected"
+ " %1, got %2", delimdesc, tok.description());
+ free(delimdesc);
+ }
return true;
}
return false;
@@ -5439,8 +5460,13 @@ static void do_register()
int val;
if (!read_measurement(&val, 'u', prev_value))
return;
+ // token::description() writes to static, class-wide storage, so we
+ // must allocate a copy of it before issuing the next diagnostic.
+ char *delimdesc = strdup(start_token.description());
if (start_token != tok)
- warning(WARN_DELIM, "closing delimiter does not match");
+ warning(WARN_DELIM, "closing delimiter does not match; expected %1,"
+ " got %2", delimdesc, tok.description());
+ free(delimdesc);
if (r != 0 /* nullptr */)
r->set_value(val);
else
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 57f10b5a7..654b2c371 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -360,8 +360,15 @@ void inline_define_register()
if (start_token != tok) {
if (read_measurement(&v, 'u')) {
r->set_increment(v);
- if (start_token != tok)
- warning(WARN_DELIM, "closing delimiter does not match");
+ if (start_token != tok) {
+ // token::description() writes to static, class-wide storage,
+ // so we must allocate a copy of it before issuing the next
+ // diagnostic.
+ char *delimdesc = strdup(start_token.description());
+ warning(WARN_DELIM, "closing delimiter does not match;"
+ " expected %1, got %2", delimdesc, tok.description());
+ free(delimdesc);
+ }
}
}
}
(The code in "reg.cpp" is "#if 0"-ed out. FYI.)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63202>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
- [bug #63202] [troff] missing delimiter diagnostics could say what they were expecting,
G. Branden Robinson <=
- Message not available
- Message not available