Skip to content

Commit bfb272b

Browse files
Alex Marchdpgeorge
authored andcommitted
py/repl: Treat escaped quotes correctly in REPL continuation.
Escaped quotes are now recognised correctly in REPL when used inside normal quotes. Fixes: adafruit#1419
1 parent c0035d1 commit bfb272b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

py/repl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool mp_repl_continue_with_input(const char *input) {
5959
|| str_startswith_word(input, "class")
6060
;
6161

62-
// check for unmatched open bracket or quote
62+
// check for unmatched open bracket, quote or escape quote
6363
#define Q_NONE (0)
6464
#define Q_1_SINGLE (1)
6565
#define Q_1_DOUBLE (2)
@@ -85,6 +85,10 @@ bool mp_repl_continue_with_input(const char *input) {
8585
} else if (in_quote == Q_NONE || in_quote == Q_1_DOUBLE) {
8686
in_quote = Q_1_DOUBLE - in_quote;
8787
}
88+
} else if (*i == '\\' && (i[1] == '\'' || i[1] == '"')) {
89+
if (in_quote != Q_NONE) {
90+
i++;
91+
}
8892
} else if (in_quote == Q_NONE) {
8993
switch (*i) {
9094
case '(': n_paren += 1; break;

0 commit comments

Comments
 (0)