diff options
author | Damien George <damien.p.george@gmail.com> | 2015-02-18 14:47:14 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-02-18 14:47:14 +0000 |
commit | 690458300b409423212ac15ab99d0891c5b702a5 (patch) | |
tree | a5352389352a19a8b026b9243c44d32311aa817e /extmod/modure.c | |
parent | 8c705233f3bb335a5531cc397b794a7537b9daf7 (diff) |
extmod/modure: Make num_matches store actual number of matches.
Diffstat (limited to 'extmod/modure.c')
-rw-r--r-- | extmod/modure.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/extmod/modure.c b/extmod/modure.c index d192585f5..62b72bd87 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -54,13 +54,13 @@ typedef struct _mp_obj_match_t { STATIC void match_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; mp_obj_match_t *self = self_in; - print(env, "<match num=%d @%p>", self->num_matches); + print(env, "<match num=%d>", self->num_matches); } STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { mp_obj_match_t *self = self_in; mp_int_t no = mp_obj_int_get_truncated(no_in); - if (no < 0 || no >= self->num_matches / 2) { + if (no < 0 || no >= self->num_matches) { nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in)); } @@ -104,7 +104,7 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { } match->base.type = &match_type; - match->num_matches = caps_num; + match->num_matches = caps_num / 2; // caps_num counts start and end pointers match->str = args[1]; return match; } |