Skip to content

Commit 8705171

Browse files
committed
objstr: Expose mp_obj_str_split() for reuse in other modules.
1 parent 4a8556c commit 8705171

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

py/objstr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
456456

457457
#define is_ws(c) ((c) == ' ' || (c) == '\t')
458458

459-
STATIC mp_obj_t str_split(mp_uint_t n_args, const mp_obj_t *args) {
459+
mp_obj_t mp_obj_str_split(mp_uint_t n_args, const mp_obj_t *args) {
460460
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
461461
mp_int_t splits = -1;
462462
mp_obj_t sep = mp_const_none;
@@ -535,7 +535,7 @@ STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) {
535535
if (n_args < 3) {
536536
// If we don't have split limit, it doesn't matter from which side
537537
// we split.
538-
return str_split(n_args, args);
538+
return mp_obj_str_split(n_args, args);
539539
}
540540
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
541541
mp_obj_t sep = args[1];
@@ -1762,7 +1762,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind);
17621762
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index);
17631763
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex);
17641764
MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join);
1765-
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, str_split);
1765+
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split);
17661766
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit);
17671767
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith);
17681768
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith);

py/objstr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ typedef struct _mp_obj_str_t {
5757
mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
5858
void mp_str_print_json(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, mp_uint_t str_len);
5959
mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
60+
mp_obj_t mp_obj_str_split(mp_uint_t n_args, const mp_obj_t *args);
6061
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, mp_uint_t len);
6162

6263
mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);

0 commit comments

Comments
 (0)