commit d57bfc057fba151d285da5c779009408d8fec532
parent 918ce1afa3c6e9dec1bc5f17fe9bbe93a9e1ebfe
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 21 Oct 2021 11:27:29 +0200
syntax: rust: do not colorize as string the text between two strings
Strings may not contain a double quote unless it is escaped.
Reference:
https://doc.rust-lang.org/reference/tokens.html#string-literals
(This will still not colorize multi-line strings with an unescaped
newline, will still colorize "this\" as if it were a valid string,
and will still miscolor things when there is another string after
the closing quote of a two-line string. But those things can't
be helped -- line-based regexes cannot emulate a full parser.)
This fixes https://savannah.gnu.org/bugs/?61361.
Reported-by: Elias Jonsson <e@ejon.eu>
Bug existed since version 2.6.1, since the Rust syntax was introduced.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/syntax/rust.nanorc b/syntax/rust.nanorc
@@ -22,8 +22,8 @@ color magenta "[A-Z][A-Z_0-9]+"
color magenta "[A-Z][A-Za-z0-9]+"
# Strings
-color green "".*""
-color green start="".*\\$" end=".*""
+color green ""([^"]|\\")*""
+color green start=""([^"]|\\")*\\$" end=".*""
## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal.
color green start="r#+"" end=""#+"