3232#if MICROPY_HELPER_REPL
3333
3434STATIC bool str_startswith_word (const char * str , const char * head ) {
35- mp_uint_t i ;
35+ size_t i ;
3636 for (i = 0 ; str [i ] && head [i ]; i ++ ) {
3737 if (str [i ] != head [i ]) {
3838 return false;
@@ -124,7 +124,7 @@ bool mp_repl_continue_with_input(const char *input) {
124124 return false;
125125}
126126
127- mp_uint_t mp_repl_autocomplete (const char * str , mp_uint_t len , const mp_print_t * print , const char * * compl_str ) {
127+ size_t mp_repl_autocomplete (const char * str , size_t len , const mp_print_t * print , const char * * compl_str ) {
128128 // scan backwards to find start of "a.b.c" chain
129129 const char * org_str = str ;
130130 const char * top = str + len ;
@@ -145,13 +145,13 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
145145 while (str < top && * str != '.' ) {
146146 ++ str ;
147147 }
148- mp_uint_t s_len = str - s_start ;
148+ size_t s_len = str - s_start ;
149149
150150 if (str < top ) {
151151 // a complete word, lookup in current dict
152152
153153 mp_obj_t obj = MP_OBJ_NULL ;
154- for (mp_uint_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
154+ for (size_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
155155 if (MP_MAP_SLOT_IS_FILLED (& dict -> map , i )) {
156156 size_t d_len ;
157157 const char * d_str = mp_obj_str_get_data (dict -> map .table [i ].key , & d_len );
@@ -194,8 +194,8 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
194194 // look for matches
195195 int n_found = 0 ;
196196 const char * match_str = NULL ;
197- mp_uint_t match_len = 0 ;
198- for (mp_uint_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
197+ size_t match_len = 0 ;
198+ for (size_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
199199 if (MP_MAP_SLOT_IS_FILLED (& dict -> map , i )) {
200200 size_t d_len ;
201201 const char * d_str = mp_obj_str_get_data (dict -> map .table [i ].key , & d_len );
@@ -206,7 +206,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
206206 } else {
207207 // search for longest common prefix of match_str and d_str
208208 // (assumes these strings are null-terminated)
209- for (mp_uint_t j = s_len ; j <= match_len && j <= d_len ; ++ j ) {
209+ for (size_t j = s_len ; j <= match_len && j <= d_len ; ++ j ) {
210210 if (match_str [j ] != d_str [j ]) {
211211 match_len = j ;
212212 break ;
@@ -245,7 +245,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
245245 #define MAX_LINE_LEN (4 * WORD_SLOT_LEN)
246246
247247 int line_len = MAX_LINE_LEN ; // force a newline for first word
248- for (mp_uint_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
248+ for (size_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
249249 if (MP_MAP_SLOT_IS_FILLED (& dict -> map , i )) {
250250 size_t d_len ;
251251 const char * d_str = mp_obj_str_get_data (dict -> map .table [i ].key , & d_len );
@@ -270,7 +270,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
270270 }
271271 mp_print_str (print , "\n" );
272272
273- return (mp_uint_t )(-1 ); // indicate many matches
273+ return (size_t )(-1 ); // indicate many matches
274274 }
275275 }
276276}
0 commit comments