+/* mbsinit(mbstate_t *ps);\r
+\r
+ This file is part of the Public Domain C Library (PDCLib).\r
+ Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+#include <wchar.h>\r
+#ifndef REGTEST\r
+#include <_PDCLIB_encoding.h>\r
+#include <_PDCLIB_locale.h>\r
+\r
+int _PDCLIB_mbsinit_l( const mbstate_t *ps, locale_t l )\r
+{\r
+ if( ps ) {\r
+ return ps->_Surrogate == 0\r
+ && ps->_PendState == 0\r
+ && l->_Codec->__mbsinit(ps);\r
+ } else return 1;\r
+}\r
+\r
+int mbsinit( const mbstate_t * ps )\r
+{\r
+ return _PDCLIB_mbsinit_l(ps, _PDCLIB_threadlocale());\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ mbstate_t mbs;\r
+ memset(&mbs, 0, sizeof mbs);\r
+\r
+ TESTCASE(mbsinit(NULL) != 0);\r
+ TESTCASE(mbsinit(&mbs) != 0);\r
+\r
+#ifndef REGTEST\r
+ // Surrogate pending\r
+ mbs._Surrogate = 0xFEED;\r
+ TESTCASE(mbsinit(&mbs) == 0);\r
+\r
+ mbs._Surrogate = 0;\r
+ mbs._PendState = 1;\r
+ TESTCASE(mbsinit(&mbs) == 0);\r
+#endif\r
+ return TEST_RESULTS;\r
+}\r
+#endif\r
+\r
+\r
+\r