18
18
19
19
#include "re1.5/re1.5.h"
20
20
21
+ #if CIRCUITPY_RE_DEBUG
21
22
#define FLAG_DEBUG 0x1000
23
+ #endif
22
24
23
25
typedef struct _mp_obj_re_t {
24
26
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) {
401
403
}
402
404
mp_obj_re_t * o = m_new_obj_var (mp_obj_re_t , char , size );
403
405
o -> base .type = & re_type ;
406
+ #if CIRCUITPY_RE_DEBUG
404
407
int flags = 0 ;
405
408
if (n_args > 1 ) {
406
409
flags = mp_obj_get_int (args [1 ]);
407
410
}
411
+ #else
412
+ (void )n_args ;
413
+ #endif
408
414
int error = re1_5_compilecode (& o -> re , re_str );
409
415
if (error != 0 ) {
410
416
error :
411
417
mp_raise_ValueError (translate ("Error in regex" ));
412
418
}
419
+ #if CIRCUITPY_RE_DEBUG
413
420
if (flags & FLAG_DEBUG ) {
414
421
re1_5_dumpcode (& o -> re );
415
422
}
423
+ #endif
416
424
return MP_OBJ_FROM_PTR (o );
417
425
}
418
426
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[] = {
456
464
#if MICROPY_PY_URE_SUB
457
465
{ MP_ROM_QSTR (MP_QSTR_sub ), MP_ROM_PTR (& mod_re_sub_obj ) },
458
466
#endif
467
+ #if CIRCUITPY_RE_DEBUG
459
468
{ MP_ROM_QSTR (MP_QSTR_DEBUG ), MP_ROM_INT (FLAG_DEBUG ) },
469
+ #endif
460
470
};
461
471
462
472
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 = {
471
481
472
482
#define re1_5_fatal (x ) assert(!x)
473
483
#include "re1.5/compilecode.c"
484
+ #if CIRCUITPY_RE_DEBUG
474
485
#include "re1.5/dumpcode.c"
486
+ #endif
475
487
#include "re1.5/recursiveloop.c"
476
488
#include "re1.5/charclass.c"
477
489
0 commit comments