diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2019-10-16 16:56:29 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-10-18 12:20:32 +1100 |
commit | ebf8332104c1c6fbd01b521a713e49d040c62920 (patch) | |
tree | 3be7d8c0f5ab02e7797775b33fe99f08eadb5d00 /extmod/re1.5/compilecode.c | |
parent | 7a7ee16ccf51d4218c17628e745228316f0151f0 (diff) | |
download | micropython-ebf8332104c1c6fbd01b521a713e49d040c62920.tar.gz micropython-ebf8332104c1c6fbd01b521a713e49d040c62920.zip |
extmod/re1.5: Support escaping within RE classes.
Fixes issues #3178 and #5220.
Tests are added, including all the cases mentioned in both bugs.
Diffstat (limited to 'extmod/re1.5/compilecode.c')
-rw-r--r-- | extmod/re1.5/compilecode.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/re1.5/compilecode.c b/extmod/re1.5/compilecode.c index a685a508a0..3f54b3993f 100644 --- a/extmod/re1.5/compilecode.c +++ b/extmod/re1.5/compilecode.c @@ -53,6 +53,9 @@ static const char *_compilecode(const char *re, ByteProg *prog, int sizecode) PC++; // Skip # of pair byte prog->len++; for (cnt = 0; *re != ']'; re++, cnt++) { + if (*re == '\\') { + ++re; + } if (!*re) return NULL; EMIT(PC++, *re); if (re[1] == '-' && re[2] != ']') { |