14887Schin /***********************************************************************
24887Schin * *
34887Schin * This software is part of the ast package *
4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property *
54887Schin * and is licensed under the *
64887Schin * Common Public License, Version 1.0 *
78462SApril.Chin@Sun.COM * by AT&T Intellectual Property *
84887Schin * *
94887Schin * A copy of the License is available at *
104887Schin * http://www.opensource.org/licenses/cpl1.0.txt *
114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
124887Schin * *
134887Schin * Information and Software Systems Research *
144887Schin * AT&T Research *
154887Schin * Florham Park NJ *
164887Schin * *
174887Schin * Glenn Fowler <gsf@research.att.com> *
184887Schin * David Korn <dgk@research.att.com> *
194887Schin * Phong Vo <kpv@research.att.com> *
204887Schin * *
214887Schin ***********************************************************************/
224887Schin #pragma prototyped
234887Schin
244887Schin /*
254887Schin * NOTE: mbs* and wcs* are provided to avoid link errors only
264887Schin */
274887Schin
284887Schin #include <ast.h>
294887Schin #include <wchar.h>
304887Schin
314887Schin #define STUB 1
324887Schin
334887Schin #if !_lib_mbtowc
344887Schin #undef STUB
354887Schin size_t
mbtowc(wchar_t * t,const char * s,size_t n)364887Schin mbtowc(wchar_t* t, const char* s, size_t n)
374887Schin {
384887Schin if (t && n > 0)
394887Schin *t = *s;
404887Schin return 1;
414887Schin }
424887Schin #endif
434887Schin
444887Schin #if !_lib_mbrtowc
454887Schin #undef STUB
464887Schin size_t
mbrtowc(wchar_t * t,const char * s,size_t n,mbstate_t * q)474887Schin mbrtowc(wchar_t* t, const char* s, size_t n, mbstate_t* q)
484887Schin {
494887Schin #if _lib_mbtowc
504887Schin #undef STUB
514887Schin memset(q, 0, sizeof(*q));
524887Schin return mbtowc(t, s, n);
534887Schin #else
544887Schin *q = 0;
554887Schin if (t && n > 0)
564887Schin *t = *s;
574887Schin return 1;
584887Schin #endif
594887Schin }
604887Schin #endif
614887Schin
624887Schin #if !_lib_mbstowcs
634887Schin #undef STUB
644887Schin size_t
mbstowcs(wchar_t * t,const char * s,size_t n)654887Schin mbstowcs(wchar_t* t, const char* s, size_t n)
664887Schin {
674887Schin register wchar_t* p = t;
684887Schin register wchar_t* e = t + n;
694887Schin register unsigned char* u = (unsigned char*)s;
704887Schin
714887Schin if (t)
724887Schin while (p < e && (*p++ = *u++));
734887Schin else
744887Schin while (p++, *u++);
754887Schin return p - t;
764887Schin }
774887Schin #endif
784887Schin
794887Schin #if !_lib_wctomb
804887Schin #undef STUB
814887Schin int
wctomb(char * s,wchar_t c)824887Schin wctomb(char* s, wchar_t c)
834887Schin {
844887Schin if (s)
854887Schin *s = c;
864887Schin return 1;
874887Schin }
884887Schin #endif
894887Schin
904887Schin #if !_lib_wcrtomb
914887Schin #undef STUB
924887Schin size_t
wcrtomb(char * s,wchar_t c,mbstate_t * q)934887Schin wcrtomb(char* s, wchar_t c, mbstate_t* q)
944887Schin {
954887Schin #if _lib_wctomb
964887Schin #undef STUB
974887Schin memset(q, 0, sizeof(*q));
984887Schin return wctomb(s, c);
994887Schin #else
1004887Schin if (s)
1014887Schin *s = c;
1024887Schin *q = 0;
1034887Schin return 1;
1044887Schin #endif
1054887Schin }
1064887Schin #endif
1074887Schin
1084887Schin #if !_lib_wcslen
1094887Schin #undef STUB
1104887Schin size_t
wcslen(const wchar_t * s)1114887Schin wcslen(const wchar_t* s)
1124887Schin {
1134887Schin register const wchar_t* p = s;
1144887Schin
1154887Schin while (*p)
1164887Schin p++;
1174887Schin return p - s;
1184887Schin }
1194887Schin #endif
1204887Schin
1214887Schin #if !_lib_wcstombs
1224887Schin #undef STUB
1234887Schin size_t
wcstombs(char * t,register const wchar_t * s,size_t n)1244887Schin wcstombs(char* t, register const wchar_t* s, size_t n)
1254887Schin {
1264887Schin register char* p = t;
1274887Schin register char* e = t + n;
1284887Schin
1294887Schin if (t)
1304887Schin while (p < e && (*p++ = *s++));
1314887Schin else
1324887Schin while (p++, *s++);
1334887Schin return p - t;
1344887Schin }
1354887Schin #endif
1364887Schin
1374887Schin #if STUB
1384887Schin NoN(wc)
1394887Schin #endif
140