handle the "special" wc NULL case.

This commit is contained in:
christos 2014-11-15 17:49:19 +00:00
parent 017bd8df74
commit c94539ae6b
1 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte.c,v 1.5 2013/04/19 18:45:03 joerg Exp $ */
/* $NetBSD: multibyte.c,v 1.6 2014/11/15 17:49:19 christos Exp $ */
/*
* Ignore all multibyte sequences, removes all the citrus code.
@ -12,7 +12,15 @@
size_t
mbrtowc(wchar_t *wc, const char *str, size_t max_sz, mbstate_t *ps)
{
return str == NULL || (*wc = (unsigned char)*str) == 0 ? 0 : 1;
wchar_t c;
if (str == NULL)
return 0;
if (wc != NULL)
*wc = (unsigned char)*str;
return *str == '\0' ? 0 : 1;
}
size_t