diff options
author | tjr <tjr@FreeBSD.org> | 2002-11-10 10:49:14 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-11-10 10:49:14 +0000 |
commit | 68886a9d65d5d21bdfe3d23f50770ce071fc5d86 (patch) | |
tree | 7b2d62e0e43e77c4fa885217598c32f9b1b66df7 /lib/libc/locale/mbrtowc.c | |
parent | 7b1fbe5e362dd09ff33aeed1e5b459887faf4218 (diff) | |
download | FreeBSD-src-68886a9d65d5d21bdfe3d23f50770ce071fc5d86.zip FreeBSD-src-68886a9d65d5d21bdfe3d23f50770ce071fc5d86.tar.gz |
Don't check whether the first byte of the buffer is a null byte when
the buffer has zero length (n == 0).
Diffstat (limited to 'lib/libc/locale/mbrtowc.c')
-rw-r--r-- | lib/libc/locale/mbrtowc.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/libc/locale/mbrtowc.c b/lib/libc/locale/mbrtowc.c index 2a61115..7e4d90e 100644 --- a/lib/libc/locale/mbrtowc.c +++ b/lib/libc/locale/mbrtowc.c @@ -45,12 +45,6 @@ mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, n = 1; } - if (*s == '\0') { - if (pwc != NULL) - *pwc = L'\0'; - return (0); - } - if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) { /* * The design of sgetrune() doesn't give us any way to tell @@ -77,5 +71,5 @@ mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, if (pwc != NULL) *pwc = (wchar_t)r; - return ((size_t)(e - s)); + return (r != 0 ? (size_t)(e - s) : 0); } |