diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-30 03:07:05 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-30 03:15:17 +0300 |
commit | bcdffe53c641ad5832f06cd544f29e3cdd522829 (patch) | |
tree | 53c6662e3bbf5aeb1895d3a9002f7c20611ecd2e /py | |
parent | 059f95b2cb11f39e7a46c56e3de250f3c739f3ac (diff) | |
download | micropython-bcdffe53c641ad5832f06cd544f29e3cdd522829.tar.gz micropython-bcdffe53c641ad5832f06cd544f29e3cdd522829.zip |
objstr: *strip(): Fix handling of one-char subject strings.
Diffstat (limited to 'py')
-rw-r--r-- | py/objstr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objstr.c b/py/objstr.c index 83fd002d1e..42a246429c 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -667,6 +667,7 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) { for (machine_uint_t len = orig_str_len; len > 0; len--) { if (find_subbytes(chars_to_del, chars_to_del_len, &orig_str[i], 1, 1) == NULL) { if (!first_good_char_pos_set) { + first_good_char_pos_set = true; first_good_char_pos = i; if (type == LSTRIP) { last_good_char_pos = orig_str_len - 1; @@ -676,14 +677,13 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) { last_good_char_pos = i; break; } - first_good_char_pos_set = true; } last_good_char_pos = i; } i += delta; } - if (first_good_char_pos == 0 && last_good_char_pos == 0) { + if (!first_good_char_pos_set) { // string is all whitespace, return '' return MP_OBJ_NEW_QSTR(MP_QSTR_); } |