+++ /dev/null
-/** @file\r
- Wide character classification and conversion functions.\r
-\r
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials are licensed and made available under\r
- the terms and conditions of the BSD License that accompanies this distribution.\r
- The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Copyright (c) 1989 The Regents of the University of California.\r
- All rights reserved.\r
- (c) UNIX System Laboratories, Inc.\r
- All or some portions of this file are derived from material licensed\r
- to the University of California by American Telephone and Telegraph\r
- Co. or Unix System Laboratories, Inc. and are reproduced herein with\r
- the permission of UNIX System Laboratories, Inc.\r
-\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions\r
- are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
- 3. Neither the name of the University nor the names of its contributors\r
- may be used to endorse or promote products derived from this software\r
- without specific prior written permission.\r
-\r
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
-\r
- NetBSD: iswctype_sb.c,v 1.4 2004/07/21 20:27:46 tshiozak Exp\r
-**/\r
-#include <LibConfig.h>\r
-#include <sys/EfiCdefs.h>\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: iswctype_sb.c,v 1.4 2004/07/21 20:27:46 tshiozak Exp $");\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include <ctype.h>\r
-#include <string.h>\r
-#include <wchar.h>\r
-#include <wctype.h>\r
-\r
-#undef iswalnum\r
-int\r
-iswalnum(wint_t c)\r
-{\r
- return isalnum((int)c);\r
-}\r
-\r
-#undef iswalpha\r
-int\r
-iswalpha(wint_t c)\r
-{\r
- return isalpha((int)c);\r
-}\r
-\r
-#undef iswblank\r
-int\r
-iswblank(wint_t c)\r
-{\r
- return isblank((int)c);\r
-}\r
-\r
-#undef iswcntrl\r
-int\r
-iswcntrl(wint_t c)\r
-{\r
- return iscntrl((int)c);\r
-}\r
-\r
-#undef iswdigit\r
-int\r
-iswdigit(wint_t c)\r
-{\r
- return isdigit((int)c);\r
-}\r
-\r
-#undef iswgraph\r
-int\r
-iswgraph(wint_t c)\r
-{\r
- return isgraph((int)c);\r
-}\r
-\r
-#undef iswlower\r
-int\r
-iswlower(wint_t c)\r
-{\r
- return islower((int)c);\r
-}\r
-\r
-#undef iswprint\r
-int\r
-iswprint(wint_t c)\r
-{\r
- return isprint((int)c);\r
-}\r
-\r
-#undef iswpunct\r
-int\r
-iswpunct(wint_t c)\r
-{\r
- return ispunct((int)c);\r
-}\r
-\r
-#undef iswspace\r
-int\r
-iswspace(wint_t c)\r
-{\r
- return isspace((int)c);\r
-}\r
-\r
-#undef iswupper\r
-int\r
-iswupper(wint_t c)\r
-{\r
- return isupper((int)c);\r
-}\r
-\r
-#undef iswxdigit\r
-int\r
-iswxdigit(wint_t c)\r
-{\r
- return isxdigit((int)c);\r
-}\r
-\r
-#undef towupper\r
-wint_t\r
-towupper(wint_t c)\r
-{\r
- return toupper((int)c);\r
-}\r
-\r
-#undef towlower\r
-wint_t\r
-towlower(wint_t c)\r
-{\r
- return tolower((int)c);\r
-}\r
-\r
-#undef wcwidth\r
-int\r
-/*ARGSUSED*/\r
-wcwidth(wchar_t c)\r
-{\r
- return 1;\r
-}\r
-\r
-#undef iswctype\r
-int\r
-iswctype(wint_t c, wctype_t charclass)\r
-{\r
- /*\r
- * SUSv3: If charclass is 0, iswctype() shall return 0.\r
- */\r
- return (__isCClass((int)c, (unsigned int)charclass));\r
-}\r
-\r
-// Additional functions in <wctype.h> but not in NetBSD _sb code.\r
-static\r
-struct _typestrval {\r
- char *name;\r
- wctype_t value;\r
-} typestrval[] = {\r
- { "alnum", (_CD | _CU | _CL | _XA) },\r
- { "alpha", (_CU | _CL | _XA) },\r
- { "blank", (_CB) },\r
- { "cntrl", (_CC) },\r
- { "digit", (_CD) },\r
- { "graph", (_CG) },\r
- { "lower", (_CL) },\r
- { "print", (_CS | _CG) },\r
- { "punct", (_CP) },\r
- { "space", (_CW) },\r
- { "upper", (_CU) },\r
- { "xdigit", (_CD | _CX) }\r
-};\r
-\r
-#define NUM_PROPVAL (sizeof(typestrval) / sizeof(struct _typestrval))\r
-\r
-static\r
-struct _transtrval {\r
- char *name;\r
- wctrans_t function;\r
-} transtrval[] = {\r
- { "tolower", towlower },\r
- { "toupper", towupper }\r
-};\r
-\r
-#define NUM_TRANSVAL (sizeof(transtrval) / sizeof(struct _transtrval))\r
-\r
-wctype_t wctype(const char *property)\r
-{\r
- int i;\r
-\r
- for(i = 0; i < NUM_PROPVAL; ++i) {\r
- if( strcmp(typestrval[i].name, property) == 0) {\r
- return typestrval[i].value;\r
- }\r
- }\r
- return 0;\r
-}\r
-\r
-wint_t towctrans(wint_t p1, wctrans_t tranfunc)\r
-{\r
- return tranfunc(p1);\r
-}\r
-\r
-wctrans_t wctrans(const char *property)\r
-{\r
- int i;\r
-\r
- for(i = 0; i < NUM_TRANSVAL; ++i) {\r
- if( strcmp(transtrval[i].name, property) == 0) {\r
- return transtrval[i].function;\r
- }\r
- }\r
- return NULL;\r
-}\r