diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-09 19:04:23 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-09 19:04:23 +0000 |
commit | 1cfb14aa972ccf3235ac67f07b7db1175b7c5384 (patch) | |
tree | b746eda548993b9e0987d7c9c0c543ddddc5758f /src/charset.c | |
parent | 765d82a657c5e42d5d7c88ae410e53f398c34c43 (diff) |
patch 9.0.1166: code is indented more than necessaryv9.0.1166
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11792)
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/charset.c b/src/charset.c index 8d7b61a4a6..0bad471e45 100644 --- a/src/charset.c +++ b/src/charset.c @@ -345,24 +345,25 @@ transstr(char_u *s) } else res = alloc(vim_strsize(s) + 1); - if (res != NULL) + + if (res == NULL) + return NULL; + + *res = NUL; + p = s; + while (*p != NUL) { - *res = NUL; - p = s; - while (*p != NUL) + if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { - if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) - { - c = (*mb_ptr2char)(p); - if (vim_isprintc(c)) - STRNCAT(res, p, l); // append printable multi-byte char - else - transchar_hex(res + STRLEN(res), c); - p += l; - } + c = (*mb_ptr2char)(p); + if (vim_isprintc(c)) + STRNCAT(res, p, l); // append printable multi-byte char else - STRCAT(res, transchar_byte(*p++)); + transchar_hex(res + STRLEN(res), c); + p += l; } + else + STRCAT(res, transchar_byte(*p++)); } return res; } |