summaryrefslogtreecommitdiff
path: root/lib/re1.5/compilecode.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-10-22 22:23:47 +1100
committerDamien George <damien@micropython.org>2023-01-18 09:15:32 +1100
commit64193c7de9f53e01dca447a4a902398fe85b9c06 (patch)
tree1db9fbe0f3a774f643270f4e17de87ca5c925ea3 /lib/re1.5/compilecode.c
parentbd86ce5f8213398a196019ad517df42e27fc173d (diff)
lib/re1.5: Add support for named classes in class sets.
Total code size change of this and previous commit: bare-arm: +0 +0.000% minimal x86: +0 +0.000% unix x64: +32 +0.004% standard stm32: +24 +0.006% PYBV10 cc3200: +16 +0.009% esp8266: +20 +0.003% GENERIC esp32: +44 +0.003% GENERIC[incl +8(data)] mimxrt: +32 +0.009% TEENSY40 renesas-ra: +24 +0.004% RA6M2_EK nrf: +0 +0.000% pca10040 rp2: +24 +0.005% PICO samd: +32 +0.012% ADAFRUIT_ITSYBITSY_M4_EXPRESS Addresses issue #7920. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'lib/re1.5/compilecode.c')
-rw-r--r--lib/re1.5/compilecode.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/re1.5/compilecode.c b/lib/re1.5/compilecode.c
index d4fc2a289..513a15597 100644
--- a/lib/re1.5/compilecode.c
+++ b/lib/re1.5/compilecode.c
@@ -66,14 +66,21 @@ 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 == '\\') {
+ char c = *re;
+ if (c == '\\') {
++re;
+ c = *re;
+ if (MATCH_NAMED_CLASS_CHAR(c)) {
+ c = RE15_CLASS_NAMED_CLASS_INDICATOR;
+ goto emit_char_pair;
+ }
}
- if (!*re) return NULL;
- EMIT(PC++, *re);
+ if (!c) return NULL;
if (re[1] == '-' && re[2] != ']') {
re += 2;
}
+ emit_char_pair:
+ EMIT(PC++, c);
EMIT(PC++, *re);
}
EMIT_CHECKED(term + 1, cnt);