summaryrefslogtreecommitdiff
path: root/libbb/unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/unicode.c')
-rw-r--r--libbb/unicode.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/unicode.c b/libbb/unicode.c
index 844c154..39b173e 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -203,11 +203,13 @@ size_t FAST_FUNC mbstowcs(wchar_t *dest, const char *src, size_t n)
while (n) {
wchar_t wc;
- const char *rc = mbstowc_internal(dest ? dest : &wc, src);
- if (rc == NULL) /* error */
+ src = mbstowc_internal(&wc, src);
+ if (src == NULL) /* error */
return (size_t) -1L;
if (dest)
- dest++;
+ *dest++ = wc;
+ if (wc == 0) /* end-of-string */
+ break;
n--;
}