Commit 90ab191b authored by Damien George's avatar Damien George
Browse files

py/objstr: Convert some instances of mp_uint_t to size_t.

parent 50a9dd59
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "py/stackctrl.h" #include "py/stackctrl.h"
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict); STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str); STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str);
STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in); STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in);
...@@ -654,7 +654,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { ...@@ -654,7 +654,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
return MP_OBJ_FROM_PTR(res); return MP_OBJ_FROM_PTR(res);
} }
STATIC mp_obj_t str_finder(mp_uint_t n_args, const mp_obj_t *args, mp_int_t direction, bool is_index) { STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, mp_int_t direction, bool is_index) {
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0]));
...@@ -740,7 +740,7 @@ STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { ...@@ -740,7 +740,7 @@ STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
enum { LSTRIP, RSTRIP, STRIP }; enum { LSTRIP, RSTRIP, STRIP };
STATIC mp_obj_t str_uni_strip(int type, mp_uint_t n_args, const mp_obj_t *args) { STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0]));
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
...@@ -892,7 +892,7 @@ STATIC NORETURN void terse_str_format_value_error(void) { ...@@ -892,7 +892,7 @@ STATIC NORETURN void terse_str_format_value_error(void) {
#define terse_str_format_value_error() #define terse_str_format_value_error()
#endif #endif
STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
vstr_t vstr; vstr_t vstr;
mp_print_t print; mp_print_t print;
vstr_init_print(&vstr, 16, &print); vstr_init_print(&vstr, 16, &print);
...@@ -1344,13 +1344,13 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs ...@@ -1344,13 +1344,13 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
} }
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict) { STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
mp_check_self(MP_OBJ_IS_STR_OR_BYTES(pattern)); mp_check_self(MP_OBJ_IS_STR_OR_BYTES(pattern));
GET_STR_DATA_LEN(pattern, str, len); GET_STR_DATA_LEN(pattern, str, len);
const byte *start_str = str; const byte *start_str = str;
bool is_bytes = MP_OBJ_IS_TYPE(pattern, &mp_type_bytes); bool is_bytes = MP_OBJ_IS_TYPE(pattern, &mp_type_bytes);
int arg_i = 0; size_t arg_i = 0;
vstr_t vstr; vstr_t vstr;
mp_print_t print; mp_print_t print;
vstr_init_print(&vstr, 16, &print); vstr_init_print(&vstr, 16, &print);
...@@ -1409,7 +1409,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o ...@@ -1409,7 +1409,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
int width = 0; int width = 0;
if (str < top) { if (str < top) {
if (*str == '*') { if (*str == '*') {
if ((uint)arg_i >= n_args) { if (arg_i >= n_args) {
goto not_enough_args; goto not_enough_args;
} }
width = mp_obj_get_int(args[arg_i++]); width = mp_obj_get_int(args[arg_i++]);
...@@ -1422,7 +1422,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o ...@@ -1422,7 +1422,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_o
if (str < top && *str == '.') { if (str < top && *str == '.') {
if (++str < top) { if (++str < top) {
if (*str == '*') { if (*str == '*') {
if ((uint)arg_i >= n_args) { if (arg_i >= n_args) {
goto not_enough_args; goto not_enough_args;
} }
prec = mp_obj_get_int(args[arg_i++]); prec = mp_obj_get_int(args[arg_i++]);
...@@ -1445,7 +1445,7 @@ incomplete_format: ...@@ -1445,7 +1445,7 @@ incomplete_format:
// Tuple value lookup // Tuple value lookup
if (arg == MP_OBJ_NULL) { if (arg == MP_OBJ_NULL) {
if ((uint)arg_i >= n_args) { if (arg_i >= n_args) {
not_enough_args: not_enough_args:
mp_raise_TypeError("not enough arguments for format string"); mp_raise_TypeError("not enough arguments for format string");
} }
...@@ -1533,7 +1533,7 @@ not_enough_args: ...@@ -1533,7 +1533,7 @@ not_enough_args:
} }
} }
if ((uint)arg_i != n_args) { if (arg_i != n_args) {
mp_raise_TypeError("not all arguments converted during string formatting"); mp_raise_TypeError("not all arguments converted during string formatting");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment