X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fwchar%2Fmbsinit.c;h=0e6d7d3264ef724894a2cc36723afcada7829e75;hp=f78ae4ce4374132ebc08bb9340dee2e8a7274365;hb=abc15df6b9fae3374d24c7cf5c3ab94c605b2a6d;hpb=8894c921674bb116d0a7b8f23a55311e7a768019 diff --git a/functions/wchar/mbsinit.c b/functions/wchar/mbsinit.c index f78ae4c..0e6d7d3 100644 --- a/functions/wchar/mbsinit.c +++ b/functions/wchar/mbsinit.c @@ -1,53 +1,53 @@ -/* mbsinit( mbstate_t * ps ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -#include -#ifndef REGTEST -#include "_PDCLIB_encoding.h" -#include "_PDCLIB_locale.h" - -static int _PDCLIB_mbsinit_l( const mbstate_t *ps, locale_t l ) -{ - if( ps ) { - return ps->_Surrogate == 0 - && ps->_PendState == 0 - && l->_Codec->__mbsinit(ps); - } else return 1; -} - -int mbsinit( const mbstate_t * ps ) -{ - return _PDCLIB_mbsinit_l(ps, _PDCLIB_threadlocale()); -} - -#endif - -#ifdef TEST -#include "_PDCLIB_test.h" - -int main( void ) -{ - mbstate_t mbs; - memset(&mbs, 0, sizeof mbs); - - TESTCASE(mbsinit(NULL) != 0); - TESTCASE(mbsinit(&mbs) != 0); - -#ifndef REGTEST - // Surrogate pending - mbs._Surrogate = 0xFEED; - TESTCASE(mbsinit(&mbs) == 0); - - mbs._Surrogate = 0; - mbs._PendState = 1; - TESTCASE(mbsinit(&mbs) == 0); -#endif - return TEST_RESULTS; -} -#endif - - - +/* mbsinit( mbstate_t * ps ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include "_PDCLIB_encoding.h" +#include "_PDCLIB_locale.h" + +static int _PDCLIB_mbsinit_l( const mbstate_t *ps, locale_t l ) +{ + if( ps ) { + return ps->_Surrogate == 0 + && ps->_PendState == 0 + && l->_Codec->__mbsinit(ps); + } else return 1; +} + +int mbsinit( const mbstate_t * ps ) +{ + return _PDCLIB_mbsinit_l(ps, _PDCLIB_threadlocale()); +} + +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ + mbstate_t mbs; + memset(&mbs, 0, sizeof mbs); + + TESTCASE(mbsinit(NULL) != 0); + TESTCASE(mbsinit(&mbs) != 0); + +#ifndef REGTEST + // Surrogate pending + mbs._Surrogate = 0xFEED; + TESTCASE(mbsinit(&mbs) == 0); + + mbs._Surrogate = 0; + mbs._PendState = 1; + TESTCASE(mbsinit(&mbs) == 0); +#endif + return TEST_RESULTS; +} +#endif + + +