summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Skrobov <tyomitch@gmail.com>2021-03-20 09:07:36 -0400
committerArtyom Skrobov <tyomitch@gmail.com>2021-03-26 13:24:20 -0400
commitd7dc3801ab9fdeef1b1edde050f9aad35c92d73b (patch)
tree57dfefd1711850344aaa5be429159d4d20c80693
parent155b61f0275efc1eac805ed37070834e81bb32ba (diff)
[ure] to save space, disable debug dumps by default
Has to stay enabled in unix port for the sake of tests/extmod/ure_debug.py
-rw-r--r--extmod/modure.c12
-rw-r--r--ports/unix/mpconfigport.h1
-rw-r--r--py/circuitpy_mpconfig.mk3
3 files changed, 16 insertions, 0 deletions
diff --git a/extmod/modure.c b/extmod/modure.c
index e9aff9b27..0238c196b 100644
--- a/extmod/modure.c
+++ b/extmod/modure.c
@@ -18,7 +18,9 @@
#include "re1.5/re1.5.h"
+#if CIRCUITPY_RE_DEBUG
#define FLAG_DEBUG 0x1000
+#endif
typedef struct _mp_obj_re_t {
mp_obj_base_t base;
@@ -401,18 +403,24 @@ STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {
}
mp_obj_re_t *o = m_new_obj_var(mp_obj_re_t, char, size);
o->base.type = &re_type;
+ #if CIRCUITPY_RE_DEBUG
int flags = 0;
if (n_args > 1) {
flags = mp_obj_get_int(args[1]);
}
+ #else
+ (void)n_args;
+ #endif
int error = re1_5_compilecode(&o->re, re_str);
if (error != 0) {
error:
mp_raise_ValueError(translate("Error in regex"));
}
+ #if CIRCUITPY_RE_DEBUG
if (flags & FLAG_DEBUG) {
re1_5_dumpcode(&o->re);
}
+ #endif
return MP_OBJ_FROM_PTR(o);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile);
@@ -456,7 +464,9 @@ STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = {
#if MICROPY_PY_URE_SUB
{ MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&mod_re_sub_obj) },
#endif
+ #if CIRCUITPY_RE_DEBUG
{ MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) },
+ #endif
};
STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table);
@@ -471,7 +481,9 @@ const mp_obj_module_t mp_module_ure = {
#define re1_5_fatal(x) assert(!x)
#include "re1.5/compilecode.c"
+#if CIRCUITPY_RE_DEBUG
#include "re1.5/dumpcode.c"
+#endif
#include "re1.5/recursiveloop.c"
#include "re1.5/charclass.c"
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index 464c4ce11..bae0245d0 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -325,3 +325,4 @@ void mp_unix_mark_exec(void);
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
+#define CIRCUITPY_RE_DEBUG (1)
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index fea1f937e..2a4467d49 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -242,6 +242,9 @@ CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
CIRCUITPY_RE ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_RE=$(CIRCUITPY_RE)
+CIRCUITPY_RE_DEBUG ?= 0
+CFLAGS += -DCIRCUITPY_RE_DEBUG=$(CIRCUITPY_RE_DEBUG)
+
CIRCUITPY_REPL_BLE ?= 0
CFLAGS += -DCIRCUITPY_REPL_BLE=$(CIRCUITPY_REPL_BLE)