summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorAlex March <alex.march.dev@gmail.com>2015-09-17 18:02:53 +0100
committerDamien George <damien.p.george@gmail.com>2015-09-19 14:06:23 +0100
commitbfb272b9e09394f7594b88018d17d95eea3e18d0 (patch)
tree203d4b20fa3669d1ba76f55c4f45f24977625c5e /py
parentc0035d16941adf867b7bdb2c8e6cf2248a732be7 (diff)
downloadmicropython-bfb272b9e09394f7594b88018d17d95eea3e18d0.tar.gz
micropython-bfb272b9e09394f7594b88018d17d95eea3e18d0.zip
py/repl: Treat escaped quotes correctly in REPL continuation.
Escaped quotes are now recognised correctly in REPL when used inside normal quotes. Fixes: #1419
Diffstat (limited to 'py')
-rw-r--r--py/repl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/py/repl.c b/py/repl.c
index 962a6f72e7..4406069967 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -59,7 +59,7 @@ bool mp_repl_continue_with_input(const char *input) {
|| 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_1_SINGLE (1)
#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) {
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) {
switch (*i) {
case '(': n_paren += 1; break;