From 381618269a9eb3e49d0e42d389d2dec312907577 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 3 Jul 2014 14:13:33 +0100 Subject: parser: Convert (u)int to mp_(u)int_t. --- py/parsenum.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'py/parsenum.c') diff --git a/py/parsenum.c b/py/parsenum.c index 9f84bfc5ad..f7f43ac9b5 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -41,7 +41,7 @@ #include #endif -mp_obj_t mp_parse_num_integer(const char *restrict str_, uint len, int base) { +mp_obj_t mp_parse_num_integer(const char *restrict str_, mp_uint_t len, mp_uint_t base) { const byte *restrict str = (const byte *)str_; const byte *restrict top = str + len; bool neg = false; @@ -74,7 +74,7 @@ mp_obj_t mp_parse_num_integer(const char *restrict str_, uint len, int base) { const byte *restrict str_val_start = str; for (; str < top; str++) { // get next digit as a value - int dig = *str; + mp_uint_t dig = *str; if (unichar_isdigit(dig) && dig - '0' < base) { // 0-9 digit dig = dig - '0'; @@ -141,11 +141,13 @@ value_error: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid syntax for integer with base %d: '%s'", base, str)); } -#define PARSE_DEC_IN_INTG (1) -#define PARSE_DEC_IN_FRAC (2) -#define PARSE_DEC_IN_EXP (3) +typedef enum { + PARSE_DEC_IN_INTG, + PARSE_DEC_IN_FRAC, + PARSE_DEC_IN_EXP, +} parse_dec_in_t; -mp_obj_t mp_parse_num_decimal(const char *str, uint len, bool allow_imag, bool force_complex) { +mp_obj_t mp_parse_num_decimal(const char *str, mp_uint_t len, bool allow_imag, bool force_complex) { #if MICROPY_PY_BUILTINS_FLOAT const char *top = str + len; mp_float_t dec_val = 0; @@ -187,12 +189,12 @@ mp_obj_t mp_parse_num_decimal(const char *str, uint len, bool allow_imag, bool f } } else { // string should be a decimal number - int in = PARSE_DEC_IN_INTG; + parse_dec_in_t in = PARSE_DEC_IN_INTG; bool exp_neg = false; - int exp_val = 0; - int exp_extra = 0; + mp_int_t exp_val = 0; + mp_int_t exp_extra = 0; for (; str < top; str++) { - int dig = *str; + mp_uint_t dig = *str; if ('0' <= dig && dig <= '9') { dig -= '0'; if (in == PARSE_DEC_IN_EXP) { -- cgit v1.2.3