Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
a28507ab
Commit
a28507ab
authored
Apr 07, 2014
by
Damien George
Browse files
py: Detect unmatched tripple quote in repl helper.
parent
34ba06b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/repl.c
View file @
a28507ab
...
...
@@ -29,10 +29,11 @@ bool mp_repl_is_compound_stmt(const char *line) {
return
true
;
}
// also "compound" if unmatched open bracket
// also "compound" if unmatched open bracket
or triple quote
int
n_paren
=
0
;
int
n_brack
=
0
;
int
n_brace
=
0
;
int
in_triple_quote
=
0
;
for
(
const
char
*
l
=
line
;
*
l
;
l
++
)
{
switch
(
*
l
)
{
case
'('
:
n_paren
+=
1
;
break
;
...
...
@@ -41,9 +42,15 @@ bool mp_repl_is_compound_stmt(const char *line) {
case
']'
:
n_brack
-=
1
;
break
;
case
'{'
:
n_brace
+=
1
;
break
;
case
'}'
:
n_brace
-=
1
;
break
;
case
'"'
:
if
(
l
[
1
]
==
'"'
&&
l
[
2
]
==
'"'
)
{
l
+=
2
;
in_triple_quote
=
1
-
in_triple_quote
;
}
break
;
}
}
return
n_paren
>
0
||
n_brack
>
0
||
n_brace
>
0
;
return
n_paren
>
0
||
n_brack
>
0
||
n_brace
>
0
||
in_triple_quote
!=
0
;
}
#endif // MICROPY_ENABLE_REPL_HELPERS
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment