py/repl: Treat escaped quotes correctly in REPL continuation.
Escaped quotes are now recognised correctly in REPL when used inside normal quotes. Fixes: #1419
This commit is contained in:
parent
c0035d1694
commit
bfb272b9e0
|
@ -59,7 +59,7 @@ bool mp_repl_continue_with_input(const char *input) {
|
||||||
|| str_startswith_word(input, "class")
|
|| str_startswith_word(input, "class")
|
||||||
;
|
;
|
||||||
|
|
||||||
// check for unmatched open bracket or quote
|
// check for unmatched open bracket, quote or escape quote
|
||||||
#define Q_NONE (0)
|
#define Q_NONE (0)
|
||||||
#define Q_1_SINGLE (1)
|
#define Q_1_SINGLE (1)
|
||||||
#define Q_1_DOUBLE (2)
|
#define Q_1_DOUBLE (2)
|
||||||
|
@ -85,6 +85,10 @@ bool mp_repl_continue_with_input(const char *input) {
|
||||||
} else if (in_quote == Q_NONE || in_quote == Q_1_DOUBLE) {
|
} else if (in_quote == Q_NONE || in_quote == Q_1_DOUBLE) {
|
||||||
in_quote = Q_1_DOUBLE - in_quote;
|
in_quote = Q_1_DOUBLE - in_quote;
|
||||||
}
|
}
|
||||||
|
} else if (*i == '\\' && (i[1] == '\'' || i[1] == '"')) {
|
||||||
|
if (in_quote != Q_NONE) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
} else if (in_quote == Q_NONE) {
|
} else if (in_quote == Q_NONE) {
|
||||||
switch (*i) {
|
switch (*i) {
|
||||||
case '(': n_paren += 1; break;
|
case '(': n_paren += 1; break;
|
||||||
|
|
Loading…
Reference in New Issue