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
8dead2a6
Commit
8dead2a6
authored
Mar 10, 2015
by
Damien George
Browse files
extmod: Pull in upstream changes to re1.5; fixes bugs with regex errors.
parent
b4c9a25e
Changes
1
Hide whitespace changes
Inline
Side-by-side
extmod/re1.5/compilecode.c
View file @
8dead2a6
...
...
@@ -129,6 +129,7 @@ const char *_compilecode(const char *re, ByteProg *prog)
prog
->
bytelen
=
pc
;
re
=
_compilecode
(
re
+
1
,
prog
);
if
(
re
==
NULL
||
*
re
!=
')'
)
return
NULL
;
// error, or no matching paren
pc
=
prog
->
bytelen
;
EMIT
(
pc
++
,
Save
);
...
...
@@ -138,12 +139,14 @@ const char *_compilecode(const char *re, ByteProg *prog)
break
;
}
case
'?'
:
if
(
pc
==
term
)
return
NULL
;
// nothing to repeat
insert_code
(
code
,
term
,
2
,
&
pc
);
EMIT
(
term
,
Split
);
EMIT
(
term
+
1
,
REL
(
term
,
pc
));
prog
->
len
++
;
break
;
case
'*'
:
if
(
pc
==
term
)
return
NULL
;
// nothing to repeat
insert_code
(
code
,
term
,
2
,
&
pc
);
EMIT
(
pc
,
Jmp
);
EMIT
(
pc
+
1
,
REL
(
pc
,
term
));
...
...
@@ -158,6 +161,7 @@ const char *_compilecode(const char *re, ByteProg *prog)
prog
->
len
+=
2
;
break
;
case
'+'
:
if
(
pc
==
term
)
return
NULL
;
// nothing to repeat
if
(
re
[
1
]
==
'?'
)
{
EMIT
(
pc
,
Split
);
re
++
;
...
...
@@ -217,7 +221,8 @@ int re1_5_compilecode(ByteProg *prog, const char *re)
prog
->
insts
[
prog
->
bytelen
++
]
=
0
;
prog
->
len
++
;
_compilecode
(
re
,
prog
);
re
=
_compilecode
(
re
,
prog
);
if
(
re
==
NULL
||
*
re
)
return
1
;
prog
->
insts
[
prog
->
bytelen
++
]
=
Save
;
prog
->
insts
[
prog
->
bytelen
++
]
=
1
;
...
...
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