Repository navigation
Fix two input messages that failed to format - #5574
Conversation
The NEFAC warning for a standard network used placeholders unknown to the location formatter, so schedule construction failed instead of warning. Random text containing braces broke the PARSE_RANDOM_TEXT message the same way.
|
jenkins build this please |
|
This is something spotted by agent during the review of the PR #5442 . I am marking the PR as ready for review now. |
bska
left a comment
There was a problem hiding this comment.
I suppose this is mostly okay, but please check if the escape function is sufficiently robust.
| for (const auto c : text) { | ||
| escaped += c; | ||
| if ((c == '{') || (c == '}')) { | ||
| escaped += c; | ||
| } | ||
| } |
There was a problem hiding this comment.
This means that a text of the form
alpha b{{et}}a gamma
becomes
alpha b{{{{et}}}}a gamma
Is that intentional
There was a problem hiding this comment.
Yes, that's intentional. The escaped text isn't the final message: handleError() passes it through OpmInputError::format(), which formats it once more with the keyword location, and that turns each {{ back into { and each }} into }. So alpha b{{et}}a gamma in the deck shows up unchanged in the message. Braces are the only special characters in a format string, so doubling each one works for any text.
A test is added using b{{et}}a gamma.
There was a problem hiding this comment.
Yes, that's intentional. [...]
A test is added using
b{{et}}a gamma.
Very good.
|
jenkins build this please |
bska
left a comment
There was a problem hiding this comment.
Thanks a lot for the additional explanation and test. I'll merge into master.
| for (const auto c : text) { | ||
| escaped += c; | ||
| if ((c == '{') || (c == '}')) { | ||
| escaped += c; | ||
| } | ||
| } |
There was a problem hiding this comment.
Yes, that's intentional. [...]
A test is added using
b{{et}}a gamma.
Very good.
The NEFAC warning for a standard network used
{filename}and{lineno}, but the location formatter only supplies{keyword},{file}and{line}. Schedule construction therefore stopped instead of warning:It now warns
NEFAC has no effect for a standard network: file CASE.DATA line 16and ignores the keyword.Stray deck text containing braces broke the PARSE_RANDOM_TEXT message the same way. The text goes into a message that is formatted again with the location, so a stray line
{x}was read as a placeholder and parsing stopped with a bareargument not found, without a location. The braces are now doubled first: