- Fix mbslwr: increment pointer in both cases (prevents infinite loops)

- Check for null character pointers, apply somewhat readable formatting
- Add some useful header information
See issue #4755 for more details.

svn path=/trunk/; revision=42363
This commit is contained in:
Gregor Schneider 2009-08-03 16:15:40 +00:00
parent 7aa73a6110
commit 9d8f60cf81

View file

@ -1,12 +1,10 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbpun.c * FILE: lib/sdk/crt/mbstring/mbslwr.c
* PURPOSE: * PURPOSE: Multibyte lowercase functions
* PROGRAMER: * PROGRAMER: Eric Kohl
* UPDATE HISTORY: * Samuel Serapion, adapted from PROJECT C Library
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/ */
#include <precomp.h> #include <precomp.h>
@ -33,14 +31,24 @@ unsigned int _mbctolower(unsigned int c)
*/ */
unsigned char * _mbslwr(unsigned char *x) unsigned char * _mbslwr(unsigned char *x)
{ {
unsigned char *y=x; unsigned char *y=x;
while (*y) { if (x == NULL)
if (!_ismbblead(*y)) { {
return NULL;
}
while (*y)
{
if (!_ismbblead(*y))
{
*y = tolower(*y); *y = tolower(*y);
} else { y++;
*y=_mbctolower(*(unsigned short *)y); }
y++; else
{
*y = _mbctolower(*(unsigned short *)y);
y++;
} }
} }
return x; return x;