1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Don't check whether the first byte of the buffer is a null byte when

the buffer has zero length (n == 0).
This commit is contained in:
Tim J. Robbins 2002-11-10 10:49:14 +00:00
parent e8ef497c66
commit 2f5154a2c1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106725

View File

@ -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);
}