diff options
author | Damien George <damien.p.george@gmail.com> | 2016-01-13 15:47:56 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-01-13 15:47:56 +0000 |
commit | 22d85ec5be77e7ee6b703221d51113f7f21a995b (patch) | |
tree | 52741900f09b57b78c568188b3d7f38f0200eaf0 /py/objstr.c | |
parent | 8bb4931fec1d3661487e126ff541479948d50d2e (diff) | |
download | micropython-22d85ec5be77e7ee6b703221d51113f7f21a995b.tar.gz micropython-22d85ec5be77e7ee6b703221d51113f7f21a995b.zip |
py: Use new code pattern for parsing kw args with mp_arg_parse_all.
Makes code easier to read and more maintainable.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/py/objstr.c b/py/objstr.c index 8a0a19de15..73de7b5da2 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -557,11 +557,14 @@ STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t }; // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + struct { + mp_arg_val_t keepends; + } args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); mp_obj_t new_args[2] = {pos_args[0], MP_OBJ_NEW_QSTR(MP_QSTR__backslash_n)}; - return str_split_internal(2, new_args, SPLITLINES | (args[0].u_bool ? KEEP : 0)); + return str_split_internal(2, new_args, SPLITLINES | (args.keepends.u_bool ? KEEP : 0)); } #endif |