Standard Libraries for EDK II.

This set of three packages: AppPkg, StdLib, StdLibPrivateInternalFiles; contains the implementation of libraries based upon non-UEFI standards such as ISO/IEC-9899, the library portion of the C Language Standard, POSIX, etc.

AppPkg contains applications that make use of the standard libraries defined in the StdLib Package.

StdLib contains header (include) files and the implementations of the standard libraries.

StdLibPrivateInternalFiles contains files for the exclusive use of the library implementations in StdLib.  These files should never be directly referenced from applications or other code.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11600 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503
2011-04-27 21:42:16 +00:00
parent 98790d8148
commit 2aa62f2bc9
503 changed files with 67344 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
## @file
# Standard C library: Locale implementation.
#
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = LibLocale
FILE_GUID = 9205cde5-5ae5-4a4b-bfbf-f6211967eef9
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = LibLocale
#
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources]
__mb_cur_max.c #
_def_messages.c #
_def_monetary.c #
_def_numeric.c #
_def_time.c #
aliasname.c #
ctypeio.c #
localeconv.c #
nl_langinfo.c #
setlocale1.c #
setlocale32.c #
setlocale.c #
wcscoll.c #
wcsftime.c #
wcstoimax.c #
wcstol.c #
wcstoll.c #
wcstoul.c #
wcstoull.c #
wcstoumax.c #
wcstod.c #
wcstof.c #
wcstold.c #
wcsxfrm.c #
# Single-byte locale to avoid bringing in citrus
iswctype_sb.c #
multibyte_sb.c #
[Packages]
StdLib/StdLib.dec
StdLibPrivateInternalFiles/DoNotUse.dec
MdePkg/MdePkg.dec
[LibraryClasses]
LibC
LibCType
################################################################
#
# The Build Options, below, are only used when building the C library.
# DO NOT use them when building your application!
# Nasty things could happen if you do.
#
[BuildOptions]
GCC:*_*_*_CC_FLAGS = -fno-builtin

View File

@@ -0,0 +1,39 @@
/* $NetBSD: __mb_cur_max.c,v 1.2 2001/01/25 01:25:06 itojun Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: __mb_cur_max.c,v 1.2 2001/01/25 01:25:06 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <limits.h>
size_t __mb_cur_max = 1;
size_t __mb_len_max_runtime = MB_LEN_MAX;

View File

@@ -0,0 +1,79 @@
/* $NetBSD: __wctoint.h,v 1.1 2001/09/28 11:25:37 yamt Exp $ */
/*-
* Copyright (c)2001 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Citrus: xpg4dl/FreeBSD/lib/libc/locale/__wctoint.h,v 1.1 2001/09/21 13:52:32 yamt Exp $
*/
__inline static int
__wctoint(wchar_t wc)
{
int n;
/* XXX I expect compiler to optimize this. :D */
switch (wc) {
case L'0': n = 0; break;
case L'1': n = 1; break;
case L'2': n = 2; break;
case L'3': n = 3; break;
case L'4': n = 4; break;
case L'5': n = 5; break;
case L'6': n = 6; break;
case L'7': n = 7; break;
case L'8': n = 8; break;
case L'9': n = 9; break;
case L'A': case L'a': n = 10; break;
case L'B': case L'b': n = 11; break;
case L'C': case L'c': n = 12; break;
case L'D': case L'd': n = 13; break;
case L'E': case L'e': n = 14; break;
case L'F': case L'f': n = 15; break;
case L'G': case L'g': n = 16; break;
case L'H': case L'h': n = 17; break;
case L'I': case L'i': n = 18; break;
case L'J': case L'j': n = 19; break;
case L'K': case L'k': n = 20; break;
case L'L': case L'l': n = 21; break;
case L'M': case L'm': n = 22; break;
case L'N': case L'n': n = 23; break;
case L'O': case L'o': n = 24; break;
case L'P': case L'p': n = 25; break;
case L'Q': case L'q': n = 26; break;
case L'R': case L'r': n = 27; break;
case L'S': case L's': n = 28; break;
case L'T': case L't': n = 29; break;
case L'U': case L'u': n = 30; break;
case L'V': case L'v': n = 31; break;
case L'W': case L'w': n = 32; break;
case L'X': case L'x': n = 33; break;
case L'Y': case L'y': n = 34; break;
case L'Z': case L'z': n = 35; break;
default: n = -1; break; /* error */
}
return n;
}

View File

@@ -0,0 +1,24 @@
/* $NetBSD: _def_messages.c,v 1.6 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_messages.c,v 1.6 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _MessagesLocale _DefaultMessagesLocale =
{
"^[Yy]",
"^[Nn]",
"yes",
"no"
} ;
const _MessagesLocale *_CurrentMessagesLocale = &_DefaultMessagesLocale;

View File

@@ -0,0 +1,42 @@
/* $NetBSD: _def_monetary.c,v 1.8 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_monetary.c,v 1.8 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <limits.h>
#include <locale.h>
const _MonetaryLocale _DefaultMonetaryLocale =
{
"",
"",
"",
"",
"",
"",
"",
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX
};
const _MonetaryLocale *_CurrentMonetaryLocale = &_DefaultMonetaryLocale;

View File

@@ -0,0 +1,23 @@
/* $NetBSD: _def_numeric.c,v 1.6 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_numeric.c,v 1.6 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _NumericLocale _DefaultNumericLocale =
{
".",
"",
""
};
const _NumericLocale *_CurrentNumericLocale = &_DefaultNumericLocale;

View File

@@ -0,0 +1,42 @@
/* $NetBSD: _def_time.c,v 1.8 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_time.c,v 1.8 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _TimeLocale _DefaultTimeLocale =
{
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
},
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
},
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
},
{
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
},
{
"AM", "PM"
},
"%a %b %e %H:%M:%S %Y",
"%m/%d/%y",
"%H:%M:%S",
"%I:%M:%S %p"
};
const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;

View File

@@ -0,0 +1,126 @@
/* $NetBSD: _wcstod.h,v 1.1 2006/04/15 12:17:23 tnozaki Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Original version ID:
* FreeBSD: /repoman/r/ncvs/src/lib/libc/locale/wcstod.c,v 1.4 2004/04/07 09:47:56 tjr Exp
* NetBSD: wcstod.c,v 1.8 2006/04/13 01:25:13 tnozaki Exp
*/
/*
* function template for wcstof, wcstod, wcstold.
*
* parameters:
* _FUNCNAME : function name
* _RETURN_TYPE : return type
* _STRTOD_FUNC : real conversion function
*/
#ifndef __WCSTOD_H_
#define __WCSTOD_H_
/*
* Convert a string to a double-precision number.
*
* This is the wide-character counterpart of strto{f,d,ld}(). So that
* we do not have to duplicate the code of strto{f,d,ld}() here,
* we convert the supplied wide character string to multibyte and
* call strto{f,d,ld}() on the result.
* This assumes that the multibyte encoding is compatible with ASCII
* for at least the digits, radix character and letters.
*/
_RETURN_TYPE
_FUNCNAME(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
{
const wchar_t *src, *start;
_RETURN_TYPE val;
char *buf, *end;
size_t bufsiz, len;
_DIAGASSERT(nptr != NULL);
/* endptr may be null */
src = nptr;
while (iswspace((wint_t)*src) != 0)
++src;
if (*src == L'\0')
goto no_convert;
/*
* Convert the supplied numeric wide char. string to multibyte.
*
* We could attempt to find the end of the numeric portion of the
* wide char. string to avoid converting unneeded characters but
* choose not to bother; optimising the uncommon case where
* the input string contains a lot of text after the number
* duplicates a lot of strto{f,d,ld}()'s functionality and
* slows down the most common cases.
*/
start = src;
len = wcstombs(NULL, src, 0);
if (len == (size_t)-1)
/* errno = EILSEQ */
goto no_convert;
_DIAGASSERT(len > 0);
bufsiz = len;
buf = (void *)malloc(bufsiz + 1);
if (buf == NULL)
/* errno = ENOMEM */
goto no_convert;
len = wcstombs(buf, src, bufsiz + 1);
_DIAGASSERT(len == bufsiz);
_DIAGASSERT(buf[len] == '\0');
/* Let strto{f,d,ld}() do most of the work for us. */
val = _STRTOD_FUNC(buf, &end);
if (buf == end) {
free(buf);
goto no_convert;
}
/*
* We only know where the number ended in the _multibyte_
* representation of the string. If the caller wants to know
* where it ended, count multibyte characters to find the
* corresponding position in the wide char string.
*/
if (endptr != NULL)
/* XXX Assume each wide char is one byte. */
*endptr = __UNCONST(start + (size_t)(end - buf));
free(buf);
return val;
no_convert:
if (endptr != NULL)
*endptr = __UNCONST(nptr);
return 0;
}
#endif /*__WCSTOD_H_*/

View File

@@ -0,0 +1,153 @@
/** @file
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Original version ID:
@(#)strtol.c 8.1 (Berkeley) 6/4/93
NetBSD: wcstol.c,v 1.1 2001/09/27 16:30:36 yamt Exp
Citrus: xpg4dl/FreeBSD/lib/libc/locale/wcstol.c,v 1.2 2001/09/21 16:11:41 yamt Exp
NetBSD: _wcstol.h,v 1.3 2005/11/29 03:11:59 christos Exp
*/
/*
* function template for wcstol, wcstoll and wcstoimax.
*
* parameters:
* _FUNCNAME : function name
* __wINT : return type
* __wINT_MIN : lower limit of the return type
* __wINT_MAX : upper limit of the return type
*/
__wINT
_FUNCNAME(
const wchar_t *nptr,
wchar_t **endptr,
int base
)
{
const wchar_t *s;
__wINT acc, cutoff;
wint_t wc;
int i;
int neg, any, cutlim;
_DIAGASSERT(nptr != NULL);
/* endptr may be NULL */
#ifdef __GNUC__
(void)&acc; (void)&cutoff;
#endif
/* check base value */
if (base && (base < 2 || base > 36)) {
errno = EINVAL;
return 0;
}
/*
* Skip white space and pick up leading +/- sign if any.
* If base is 0, allow 0x for hex and 0 for octal, else
* assume decimal; if base is already 16, allow 0x.
*/
s = nptr;
do {
wc = (wchar_t) *s++;
} while (iswspace(wc));
if (wc == L'-') {
neg = 1;
wc = *s++;
} else {
neg = 0;
if (wc == L'+')
wc = *s++;
}
if ((base == 0 || base == 16) &&
wc == L'0' && (*s == L'x' || *s == L'X')) {
wc = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = ((wc == L'0') ? 8 : 10);
/*
* See strtol for comments as to the logic used.
*/
cutoff = neg ? __wINT_MIN : __wINT_MAX;
cutlim = (int)(cutoff % base);
cutoff /= base;
if (neg) {
if (cutlim > 0) {
cutlim -= base;
cutoff += 1;
}
cutlim = -cutlim;
}
for (acc = 0, any = 0;; wc = (wchar_t) *s++) {
i = __wctoint((wchar_t)wc);
if (i == -1)
break;
if (i >= base)
break;
if (any < 0)
continue;
if (neg) {
if (acc < cutoff || (acc == cutoff && i > cutlim)) {
any = -1;
acc = __wINT_MIN;
errno = ERANGE;
} else {
any = 1;
acc *= base;
acc -= i;
}
} else {
if (acc > cutoff || (acc == cutoff && i > cutlim)) {
any = -1;
acc = __wINT_MAX;
errno = ERANGE;
} else {
any = 1;
acc *= base;
acc += i;
}
}
}
if (endptr != 0)
*endptr = __UNCONST(any ? s - 1 : nptr);
return (acc);
}

View File

@@ -0,0 +1,131 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Original version ID:
@(#)strtoul.c 8.1 (Berkeley) 6/4/93
Citrus: xpg4dl/FreeBSD/lib/libc/locale/wcstoul.c,v 1.2 2001/09/21 16:11:41 yamt Exp
NetBSD: wcstoul.c,v 1.1 2001/09/27 16:30:37 yamt Exp
NetBSD: _wcstoul.h,v 1.3 2005/11/29 03:11:59 christos Exp
*/
/*
* function template for wcstoul, wcstoull and wcstoumax.
*
* parameters:
* _FUNCNAME : function name
* __wUINT : return type
* __wINT : signed version of __wUINT
* __wUINT_MAX : upper limit of the return type
*/
__wUINT
_FUNCNAME(
const wchar_t *nptr,
wchar_t **endptr,
int base
)
{
const wchar_t *s;
__wUINT acc, cutoff;
wint_t wc;
int i;
int neg, any, cutlim;
_DIAGASSERT(nptr != NULL);
/* endptr may be NULL */
if (base && (base < 2 || base > 36)) {
errno = EINVAL;
return 0;
}
/*
* Skip white space and pick up leading +/- sign if any.
* If base is 0, allow 0x for hex and 0 for octal, else
* assume decimal; if base is already 16, allow 0x.
*/
s = nptr;
do {
wc = (wchar_t) *s++;
} while (iswspace(wc));
if (wc == L'-') {
neg = 1;
wc = *s++;
} else {
neg = 0;
if (wc == L'+')
wc = *s++;
}
if ((base == 0 || base == 16) &&
wc == L'0' && (*s == L'x' || *s == L'X')) {
wc = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = wc == L'0' ? 8 : 10;
/*
* See strtoul for comments as to the logic used.
*/
cutoff = __wUINT_MAX / (__wUINT)base;
cutlim = (int)(__wUINT_MAX % (__wUINT)base);
for (acc = 0, any = 0;; wc = (wint_t) *s++) {
i = __wctoint((wchar_t)wc);
if (i == -1) {
break;
}
if (i >= base)
break;
if (any < 0)
continue;
if (acc > cutoff || (acc == cutoff && i > cutlim)) {
any = -1;
acc = __wUINT_MAX;
errno = ERANGE;
} else {
any = 1;
acc *= (__wUINT)base;
acc += i;
}
}
if (neg && any > 0)
acc = (__wUINT)(-((__wINT)acc));
if (endptr != 0)
*endptr = __UNCONST(any ? s - 1 : nptr);
return (acc);
}

View File

@@ -0,0 +1,129 @@
/* $NetBSD: aliasname.c,v 1.2 2005/02/09 21:35:46 kleink Exp $ */
/*-
* Copyright (c)2002 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: aliasname.c,v 1.2 2005/02/09 21:35:46 kleink Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "aliasname_local.h"
__inline int __is_ws(char);
__inline int __is_ws(char ch)
{
return (ch == ' ' || ch == '\t');
}
const char *
__unaliasname(const char *dbname, const char *alias, void *buf, size_t bufsize)
{
FILE *fp = NULL;
const char *result = alias;
size_t resultlen;
size_t aliaslen;
const char *p;
size_t len;
_DIAGASSERT(dbname != NULL);
_DIAGASSERT(alias != NULL);
_DIAGASSERT(buf != NULL);
fp = fopen(dbname, "r");
if (fp == NULL)
goto quit;
aliaslen = strlen(alias);
while (/*CONSTCOND*/ 1) {
p = fgetln(fp, &len);
if (p == NULL)
goto quit; /* eof or error */
_DIAGASSERT(len != 0);
/* ignore terminating NL */
if (p[len - 1] == '\n')
len--;
/* ignore null line and comment */
if (len == 0 || p[0] == '#')
continue;
if (aliaslen > len)
continue;
if (memcmp(alias, p, aliaslen))
continue;
p += aliaslen;
len -= aliaslen;
if (len == 0 || !__is_ws(*p))
continue;
/* entry was found here */
break;
/* NOTREACHED */
}
/* skip white spaces */
do {
p++;
len--;
} while (len != 0 && __is_ws(*p));
if (len == 0)
goto quit;
/* count length of result */
resultlen = 0;
while (resultlen < len && !__is_ws(*p))
resultlen++;
/* check if space is enough */
if (bufsize < resultlen + 1)
goto quit;
memcpy(buf, p, resultlen);
((char *)buf)[resultlen] = 0;
result = buf;
quit:
if (fp)
fclose(fp);
return result;
}

View File

@@ -0,0 +1,29 @@
/* $NetBSD: aliasname_local.h,v 1.1 2002/02/13 07:45:52 yamt Exp $ */
/*-
* Copyright (c)2002 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
const char *__unaliasname(const char *, const char *, void *, size_t);

View File

@@ -0,0 +1,186 @@
/** @file
Internal C-type locale functions.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c) 1997 Christos Zoulas. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Christos Zoulas.
4. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NetBSD: ctypeio.c,v 1.7 2005/11/29 03:11:59 christos Exp
**/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: ctypeio.c,v 1.7 2005/11/29 03:11:59 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _CTYPE_PRIVATE
#include <ctype.h>
#include "ctypeio.h"
int
__loadctype(const char *name)
{
FILE *fp;
char id[sizeof(_CTYPE_ID) - 1];
u_int32_t i, len;
unsigned short *new_ctype = NULL;
unsigned char *new_toupper = NULL, *new_tolower = NULL;
_DIAGASSERT(name != NULL);
if ((fp = fopen(name, "r")) == NULL)
return 0;
if (fread(id, sizeof(id), 1, fp) != 1)
goto bad;
if (memcmp(id, _CTYPE_ID, sizeof(id)) != 0)
goto bad;
if (fread(&i, sizeof(u_int32_t), 1, fp) != 1)
goto bad;
if ((i = ntohl(i)) != _CTYPE_REV)
goto bad;
if (fread(&len, sizeof(u_int32_t), 1, fp) != 1)
goto bad;
if ((len = ntohl(len)) != _CTYPE_NUM_CHARS)
goto bad;
if ((new_ctype = malloc(sizeof(UINT16) * (1 + len))) == NULL)
goto bad;
new_ctype[0] = 0;
if (fread(&new_ctype[1], sizeof(UINT16), len, fp) != len)
goto bad;
if ((new_toupper = malloc(sizeof(UINT8) * (1 + len))) == NULL)
goto bad;
new_toupper[0] = (UINT8)EOF;
if (fread(&new_toupper[1], sizeof(UINT8), len, fp) != len)
goto bad;
if ((new_tolower = malloc(sizeof(UINT8) * (1 + len))) == NULL)
goto bad;
new_tolower[0] = (UINT8)EOF;
if (fread(&new_tolower[1], sizeof(UINT8), len, fp) != len)
goto bad;
#if BYTE_ORDER == LITTLE_ENDIAN
for (i = 1; i <= len; i++) {
new_ctype[i] = ntohs(new_ctype[i]);
}
#endif
(void) fclose(fp);
if (_cClass != _C_CharClassTable)
free(__UNCONST(_cClass));
_cClass = new_ctype;
if (_uConvT != _C_ToUpperTable)
free(__UNCONST(_uConvT));
_uConvT = new_toupper;
if (_lConvT != _C_ToLowerTable)
free(__UNCONST(_lConvT));
_lConvT = new_tolower;
return 1;
bad:
free(new_tolower);
free(new_toupper);
free(new_ctype);
(void) fclose(fp);
return 0;
}
int
__savectype(
const char *name,
unsigned short *new_ctype,
unsigned char *new_toupper,
unsigned char *new_tolower
)
{
FILE *fp;
u_int32_t i, len = _CTYPE_NUM_CHARS;
_DIAGASSERT(name != NULL);
_DIAGASSERT(new_ctype != NULL);
_DIAGASSERT(new_toupper != NULL);
_DIAGASSERT(new_tolower != NULL);
if ((fp = fopen(name, "w")) == NULL)
return 0;
if (fwrite(_CTYPE_ID, sizeof(_CTYPE_ID) - 1, 1, fp) != 1)
goto bad;
i = htonl(_CTYPE_REV);
if (fwrite(&i, sizeof(u_int32_t), 1, fp) != 1)
goto bad;
i = htonl(len);
if (fwrite(&i, sizeof(u_int32_t), 1, fp) != 1)
goto bad;
#if BYTE_ORDER == LITTLE_ENDIAN
for (i = 1; i <= len; i++) {
new_ctype[i] = htons(new_ctype[i]);
}
#endif
if (fwrite(&new_ctype[1], sizeof(UINT16), len, fp) != len)
goto bad;
if (fwrite(&new_toupper[1], sizeof(UINT8), len, fp) != len)
goto bad;
if (fwrite(&new_tolower[1], sizeof(UINT8), len, fp) != len)
goto bad;
(void) fclose(fp);
return 1;
bad:
(void) fclose(fp);
return 0;
}

View File

@@ -0,0 +1,35 @@
/* $NetBSD: ctypeio.h,v 1.1 1997/06/02 09:52:48 kleink Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christos Zoulas.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
__BEGIN_DECLS
int __loadctype (const char *);
int __savectype (const char *, unsigned short *, unsigned char *, unsigned char *);
__END_DECLS

View File

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

View File

@@ -0,0 +1,85 @@
/* $NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeconv.c,v 1.13 2005/11/29 03:11:59 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
/*
* The localeconv() function constructs a struct lconv from the current
* monetary and numeric locales.
*
* Because localeconv() may be called many times (especially by library
* routines like printf() & strtod()), the approprate members of the
* lconv structure are computed only when the monetary or numeric
* locale has been changed.
*/
int __mlocale_changed = 1;
int __nlocale_changed = 1;
/*
* Return the current locale conversion.
*/
struct lconv *
localeconv()
{
static struct lconv ret;
if (__mlocale_changed) {
/* LC_MONETARY */
ret.int_curr_symbol =
__UNCONST(_CurrentMonetaryLocale->int_curr_symbol);
ret.currency_symbol =
__UNCONST(_CurrentMonetaryLocale->currency_symbol);
ret.mon_decimal_point =
__UNCONST(_CurrentMonetaryLocale->mon_decimal_point);
ret.mon_thousands_sep =
__UNCONST(_CurrentMonetaryLocale->mon_thousands_sep);
ret.mon_grouping =
__UNCONST(_CurrentMonetaryLocale->mon_grouping);
ret.positive_sign =
__UNCONST(_CurrentMonetaryLocale->positive_sign);
ret.negative_sign =
__UNCONST(_CurrentMonetaryLocale->negative_sign);
ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
ret.int_p_cs_precedes =
_CurrentMonetaryLocale->int_p_cs_precedes;
ret.int_n_cs_precedes =
_CurrentMonetaryLocale->int_n_cs_precedes;
ret.int_p_sep_by_space =
_CurrentMonetaryLocale->int_p_sep_by_space;
ret.int_n_sep_by_space =
_CurrentMonetaryLocale->int_n_sep_by_space;
ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn;
ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn;
__mlocale_changed = 0;
}
if (__nlocale_changed) {
/* LC_NUMERIC */
ret.decimal_point =
__UNCONST(_CurrentNumericLocale->decimal_point);
ret.thousands_sep =
__UNCONST(_CurrentNumericLocale->thousands_sep);
ret.grouping =
__UNCONST(_CurrentNumericLocale->grouping);
__nlocale_changed = 0;
}
return (&ret);
}

View File

@@ -0,0 +1,272 @@
/* $NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $ */
/*
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char *sccsid = "from: @(#)multibyte.c 5.1 (Berkeley) 2/18/91";
#else
__RCSID("$NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <wchar.h>
/*
* Stub multibyte character functions.
* This cheezy implementation is fixed to the native single-byte
* character set.
*/
/*ARGSUSED*/
int
mbsinit(const mbstate_t *ps)
{
return 1;
}
/*ARGSUSED*/
size_t
mbrlen(
const char *s,
size_t n,
mbstate_t *ps
)
{
/* ps appears to be unused */
if (s == NULL || *s == '\0')
return 0;
if (n == 0)
return (size_t)-1;
return 1;
}
int
mblen(
const char *s,
size_t n
)
{
/* s may be NULL */
return (int)mbrlen(s, n, NULL);
}
/*ARGSUSED*/
size_t
mbrtowc(
wchar_t *pwc,
const char *s,
size_t n,
mbstate_t *ps
)
{
/* pwc may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
if (n == 0)
return (size_t)-1;
if (pwc)
*pwc = (wchar_t) *s;
return (*s != '\0');
}
int
mbtowc(
wchar_t *pwc,
const char *s,
size_t n
)
{
/* pwc may be NULL */
/* s may be NULL */
return (int)mbrtowc(pwc, s, n, NULL);
}
/*ARGSUSED*/
size_t
wcrtomb(
char *s,
wchar_t wchar,
mbstate_t *ps
)
{
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
*s = (char) wchar;
return 1;
}
int
wctomb(
char *s,
wchar_t wchar
)
{
/* s may be NULL */
return (int)wcrtomb(s, wchar, NULL);
}
/*ARGSUSED*/
size_t
mbsrtowcs(
wchar_t *pwcs,
const char **s,
size_t n,
mbstate_t *ps
)
{
int count = 0;
/* pwcs may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (!s || !*s)
return 0;
if (n != 0) {
if (pwcs != NULL) {
do {
if ((*pwcs++ = (wchar_t) *(*s)++) == 0)
break;
count++;
} while (--n != 0);
} else {
do {
if (((wchar_t)*(*s)++) == 0)
break;
count++;
} while (--n != 0);
}
}
return count;
}
size_t
mbstowcs(
wchar_t *pwcs,
const char *s,
size_t n
)
{
/* pwcs may be NULL */
/* s may be NULL */
return mbsrtowcs(pwcs, &s, n, NULL);
}
/*ARGSUSED*/
size_t
wcsrtombs(
char *s,
const wchar_t **pwcs,
size_t n,
mbstate_t *ps
)
{
int count = 0;
/* s may be NULL */
/* pwcs may be NULL */
/* ps appears to be unused */
if (pwcs == NULL || *pwcs == NULL)
return (0);
if (s == NULL) {
while (*(*pwcs)++ != 0)
count++;
return(count);
}
if (n != 0) {
do {
if ((*s++ = (char) *(*pwcs)++) == 0)
break;
count++;
} while (--n != 0);
}
return count;
}
size_t
wcstombs(
char *s,
const wchar_t *pwcs,
size_t n
)
{
/* s may be NULL */
/* pwcs may be NULL */
return wcsrtombs(s, &pwcs, n, NULL);
}
wint_t
btowc(int c)
{
if (c == EOF || c & ~0xFF)
return WEOF;
return (wint_t)c;
}
int
wctob(wint_t c)
{
if (c == WEOF || c & ~0xFF)
return EOF;
return (int)c;
}

View File

@@ -0,0 +1,125 @@
/* $NetBSD: nl_langinfo.c,v 1.11 2005/11/29 03:11:59 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: nl_langinfo.c,v 1.11 2005/11/29 03:11:59 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
#include <nl_types.h>
#include <langinfo.h>
#include "rune.h"
#include "runetype.h"
char *
nl_langinfo(nl_item item)
{
const char *s;
switch (item) {
case D_T_FMT:
s = _CurrentTimeLocale->d_t_fmt;
break;
case D_FMT:
s = _CurrentTimeLocale->d_fmt;
break;
case T_FMT:
s = _CurrentTimeLocale->t_fmt;
break;
case T_FMT_AMPM:
s = _CurrentTimeLocale->t_fmt_ampm;
break;
case AM_STR:
case PM_STR:
s = _CurrentTimeLocale->am_pm[(size_t)(item - AM_STR)];
break;
case DAY_1:
case DAY_2:
case DAY_3:
case DAY_4:
case DAY_5:
case DAY_6:
case DAY_7:
s = _CurrentTimeLocale->day[(size_t)(item - DAY_1)];
break;
case ABDAY_1:
case ABDAY_2:
case ABDAY_3:
case ABDAY_4:
case ABDAY_5:
case ABDAY_6:
case ABDAY_7:
s = _CurrentTimeLocale->abday[(size_t)(item - ABDAY_1)];
break;
case MON_1:
case MON_2:
case MON_3:
case MON_4:
case MON_5:
case MON_6:
case MON_7:
case MON_8:
case MON_9:
case MON_10:
case MON_11:
case MON_12:
s = _CurrentTimeLocale->mon[(size_t)(item - MON_1)];
break;
case ABMON_1:
case ABMON_2:
case ABMON_3:
case ABMON_4:
case ABMON_5:
case ABMON_6:
case ABMON_7:
case ABMON_8:
case ABMON_9:
case ABMON_10:
case ABMON_11:
case ABMON_12:
s = _CurrentTimeLocale->abmon[(size_t)(item - ABMON_1)];
break;
case RADIXCHAR:
s = _CurrentNumericLocale->decimal_point;
break;
case THOUSEP:
s = _CurrentNumericLocale->thousands_sep;
break;
case YESSTR:
s = _CurrentMessagesLocale->yesstr;
break;
case YESEXPR:
s = _CurrentMessagesLocale->yesexpr;
break;
case NOSTR:
s = _CurrentMessagesLocale->nostr;
break;
case NOEXPR:
s = _CurrentMessagesLocale->noexpr;
break;
case CRNCYSTR: /* XXX */
s = "";
break;
case CODESET:
#ifdef WITH_RUNE
s = _CurrentRuneLocale->rl_codeset;
#else
s = NULL;
#endif
if (!s)
s = "";
break;
default:
s = "";
break;
}
/* The return value should be really const, but the interface says OW */
return __UNCONST(s);
}

100
StdLib/LibC/Locale/rune.h Normal file
View File

@@ -0,0 +1,100 @@
/* $NetBSD: rune.h,v 1.11 2006/02/16 19:19:49 tnozaki Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)rune.h 8.1 (Berkeley) 6/27/93
*/
#ifndef _RUNE_H_
#define _RUNE_H_
#include <LibConfig.h>
#include <stdio.h>
#include <wchar.h>
#include "runetype.h"
/*
* map _RTYPE_x to _CTYPE_x
*
* XXX: these should be defined in ctype.h and used in isxxx macros.
* (note: current isxxx macros use "old" NetBSD masks and
* _CTYPE_x are not public.)
*/
#define _CTYPE_A _RUNETYPE_A
#define _CTYPE_C _RUNETYPE_C
#define _CTYPE_D _RUNETYPE_D
#define _CTYPE_G _RUNETYPE_G
#define _CTYPE_L _RUNETYPE_L
#define _CTYPE_P _RUNETYPE_P
#define _CTYPE_S _RUNETYPE_S
#define _CTYPE_U _RUNETYPE_U
#define _CTYPE_X _RUNETYPE_X
#define _CTYPE_B _RUNETYPE_B
#define _CTYPE_R _RUNETYPE_R
#define _CTYPE_I _RUNETYPE_I
#define _CTYPE_T _RUNETYPE_T
#define _CTYPE_Q _RUNETYPE_Q
#define _CTYPE_SWM _RUNETYPE_SWM
#define _CTYPE_SWS _RUNETYPE_SWS
#define _CTYPE_SW0 _RUNETYPE_SW0
#define _CTYPE_SW1 _RUNETYPE_SW1
#define _CTYPE_SW2 _RUNETYPE_SW2
#define _CTYPE_SW3 _RUNETYPE_SW3
/*
* Other namespace conversion.
*/
#define rune_t __nbrune_t
#define _RUNE_ISCACHED _NB_RUNE_ISCACHED
#define _CACHED_RUNES _NB_CACHED_RUNES
#define _DEFAULT_INVALID_RUNE _NB_DEFAULT_INVALID_RUNE
#define _RuneEntry _NBRuneEntry
#define _RuneRange _NBRuneRange
#define _RuneLocale _NBRuneLocale
#define _RUNE_MAGIC_1 _NB_RUNE_MAGIC_1
#define _RUNE_MODULE_1 _NB_RUNE_MODULE_1
#define _RUNE_CODESET _NB_RUNE_CODESET
/*
* global variables
*/
extern size_t __mb_len_max_runtime;
#define __MB_LEN_MAX_RUNTIME __mb_len_max_runtime
extern _RuneLocale _DefaultRuneLocale;
extern _RuneLocale *_CurrentRuneLocale;
extern const char *_PathLocale;
#define _LOCALE_ALIAS_NAME "locale.alias"
#endif /*! _RUNE_H_ */

View File

@@ -0,0 +1,221 @@
/* $NetBSD: runetype.h,v 1.19 2005/11/29 03:11:59 christos Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)runetype.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _NB_RUNETYPE_H_
#define _NB_RUNETYPE_H_
#include <sys/EfiCdefs.h>
#include <sys/types.h>
/* for cross host tools on older systems */
#ifndef UINT32_C
/* assumes sizeof(unsigned int)>=4 */
#define UINT32_C(c) ((uint32_t)(c##U))
#endif
typedef uint32_t __nbrune_t;
typedef uint64_t __runepad_t;
#define _NB_CACHED_RUNES (1 << 8) /* Must be a power of 2 */
#define _NB_RUNE_ISCACHED(c) ((c)>=0 && (c)<_CACHED_RUNES)
#define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
/*
* The lower 8 bits of runetype[] contain the digit value of the rune.
*/
typedef uint32_t _RuneType;
#define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */
#define _RUNETYPE_C UINT32_C(0x00000200) /* Control */
#define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */
#define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */
#define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */
#define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */
#define _RUNETYPE_S UINT32_C(0x00004000) /* Space */
#define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */
#define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */
#define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */
#define _RUNETYPE_R UINT32_C(0x00040000) /* Print */
#define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */
#define _RUNETYPE_T UINT32_C(0x00100000) /* Special */
#define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */
#define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */
#define _RUNETYPE_SWS 30 /* Bits to shift to get width */
#define _RUNETYPE_SW0 UINT32_C(0x00000000) /* 0 width character */
#define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */
#define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */
#define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */
/*
* rune file format. network endian.
*/
typedef struct {
int32_t fre_min; /* First rune of the range */
int32_t fre_max; /* Last rune (inclusive) of the range */
int32_t fre_map; /* What first maps to in maps */
uint32_t fre_pad1; /* backward compatibility */
__runepad_t fre_pad2; /* backward compatibility */
} __attribute__((__packed__)) _FileRuneEntry;
typedef struct {
uint32_t frr_nranges; /* Number of ranges stored */
uint32_t frr_pad1; /* backward compatibility */
__runepad_t frr_pad2; /* backward compatibility */
} __attribute__((__packed__)) _FileRuneRange;
typedef struct {
char frl_magic[8]; /* Magic saying what version we are */
char frl_encoding[32];/* ASCII name of this encoding */
__runepad_t frl_pad1; /* backward compatibility */
__runepad_t frl_pad2; /* backward compatibility */
int32_t frl_invalid_rune;
uint32_t frl_pad3; /* backward compatibility */
_RuneType frl_runetype[_NB_CACHED_RUNES];
int32_t frl_maplower[_NB_CACHED_RUNES];
int32_t frl_mapupper[_NB_CACHED_RUNES];
/*
* The following are to deal with Runes larger than _CACHED_RUNES - 1.
* Their data is actually contiguous with this structure so as to make
* it easier to read/write from/to disk.
*/
_FileRuneRange frl_runetype_ext;
_FileRuneRange frl_maplower_ext;
_FileRuneRange frl_mapupper_ext;
__runepad_t frl_pad4; /* backward compatibility */
int32_t frl_variable_len;/* how long that data is */
uint32_t frl_pad5; /* backward compatibility */
/* variable size data follows */
} __attribute__((__packed__)) _FileRuneLocale;
/*
* expanded rune locale declaration. local to the host. host endian.
*/
typedef struct {
__nbrune_t re_min; /* First rune of the range */
__nbrune_t re_max; /* Last rune (inclusive) of the range */
__nbrune_t re_map; /* What first maps to in maps */
_RuneType *re_rune_types; /* Array of types in range */
} _NBRuneEntry;
typedef struct {
uint32_t rr_nranges; /* Number of ranges stored */
_NBRuneEntry *rr_rune_ranges;
} _NBRuneRange;
/*
* wctrans stuffs.
*/
typedef struct _WCTransEntry {
const char *te_name;
__nbrune_t *te_cached;
_NBRuneRange *te_extmap;
} _WCTransEntry;
#define _WCTRANS_INDEX_LOWER 0
#define _WCTRANS_INDEX_UPPER 1
#define _WCTRANS_NINDEXES 2
/*
* wctype stuffs.
*/
typedef struct _WCTypeEntry {
const char *te_name;
_RuneType te_mask;
} _WCTypeEntry;
#define _WCTYPE_INDEX_ALNUM 0
#define _WCTYPE_INDEX_ALPHA 1
#define _WCTYPE_INDEX_BLANK 2
#define _WCTYPE_INDEX_CNTRL 3
#define _WCTYPE_INDEX_DIGIT 4
#define _WCTYPE_INDEX_GRAPH 5
#define _WCTYPE_INDEX_LOWER 6
#define _WCTYPE_INDEX_PRINT 7
#define _WCTYPE_INDEX_PUNCT 8
#define _WCTYPE_INDEX_SPACE 9
#define _WCTYPE_INDEX_UPPER 10
#define _WCTYPE_INDEX_XDIGIT 11
#define _WCTYPE_NINDEXES 12
/*
* ctype stuffs
*/
typedef struct _NBRuneLocale {
/*
* copied from _FileRuneLocale
*/
char rl_magic[8]; /* Magic saying what version we are */
char rl_encoding[32];/* ASCII name of this encoding */
__nbrune_t rl_invalid_rune;
_RuneType rl_runetype[_NB_CACHED_RUNES];
__nbrune_t rl_maplower[_NB_CACHED_RUNES];
__nbrune_t rl_mapupper[_NB_CACHED_RUNES];
_NBRuneRange rl_runetype_ext;
_NBRuneRange rl_maplower_ext;
_NBRuneRange rl_mapupper_ext;
void *rl_variable;
size_t rl_variable_len;
/*
* the following portion is generated on the fly
*/
const char *rl_codeset;
struct _citrus_ctype_rec *rl_citrus_ctype;
_WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];
_WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];
} _NBRuneLocale;
/* magic number for LC_CTYPE (rune)locale declaration */
#define _NB_RUNE_MAGIC_1 "RuneCT10" /* Indicates version 0 of RuneLocale */
/* magic string for dynamic link module - type should be like "LC_CTYPE" */
#define _NB_RUNE_MODULE_1(type) "RuneModule10." type
/* codeset tag */
#define _NB_RUNE_CODESET "CODESET="
#endif /* !_NB_RUNETYPE_H_ */

View File

@@ -0,0 +1,423 @@
/* $NetBSD: setlocale.c,v 1.50 2006/02/16 19:19:49 tnozaki Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93";
#else
__RCSID("$NetBSD: setlocale.c,v 1.50 2006/02/16 19:19:49 tnozaki Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if defined(_MSC_VER)
// Disable warnings about assignment within conditional expressions.
#pragma warning ( disable : 4706 )
#endif
#define _CTYPE_PRIVATE
#include "namespace.h"
#include <sys/localedef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/EfiSysCall.h>
#include "rune.h"
#ifdef WITH_RUNE
#include "rune_local.h"
#else
#include "ctypeio.h"
#endif
#ifdef CITRUS
#include <citrus/citrus_namespace.h>
#include <citrus/citrus_region.h>
#include <citrus/citrus_lookup.h>
#include <citrus/citrus_bcs.h>
#else
#include "aliasname_local.h"
#define _lookup_alias(p, a, b, s, c) __unaliasname((p), (a), (b), (s))
#define _bcs_strcasecmp(a, b) strcasecmp((a), (b))
#endif
#define _LOCALE_SYM_FORCE "/force"
#ifndef WITH_RUNE
const char *_PathLocale = NULL;
#endif
/*
* Category names for getenv()
*/
static const char *const categories[_LC_LAST] = {
"LC_ALL",
"LC_COLLATE",
"LC_CTYPE",
"LC_MONETARY",
"LC_NUMERIC",
"LC_TIME",
"LC_MESSAGES"
};
/*
* Current locales for each category
*/
static char current_categories[_LC_LAST][32] = {
"C",
"C",
"C",
"C",
"C",
"C",
"C"
};
/*
* The locales we are going to try and load
*/
static char new_categories[_LC_LAST][32];
static char current_locale_string[_LC_LAST * 33];
static char *currentlocale(void);
static void revert_to_default(int);
static int force_locale_enable(int);
static int load_locale_sub(int, const char *, int);
static char *loadlocale(int);
static const char *__get_locale_env(int);
char *
__setlocale(int category, const char *locale)
{
int i, loadlocale_success;
size_t len;
const char *env, *r;
//if (issetugid() ||
// (!_PathLocale && !(_PathLocale = getenv("PATH_LOCALE"))))
// _PathLocale = _PATH_LOCALE;
if (category < 0 || category >= _LC_LAST)
return (NULL);
if (!locale)
return (category ?
current_categories[category] : currentlocale());
/*
* Default to the current locale for everything.
*/
for (i = 1; i < _LC_LAST; ++i)
(void)strncpyX(new_categories[i], current_categories[i],
sizeof(new_categories[i]));
/*
* Now go fill up new_categories from the locale argument
*/
if (!*locale) {
if (category == LC_ALL) {
for (i = 1; i < _LC_LAST; ++i) {
env = __get_locale_env(i);
(void)strncpyX(new_categories[i], env,
sizeof(new_categories[i]));
}
}
else {
env = __get_locale_env(category);
(void)strncpyX(new_categories[category], env,
sizeof(new_categories[category]));
}
} else if (category) {
(void)strncpyX(new_categories[category], locale,
sizeof(new_categories[category]));
} else {
if ((r = strchr(locale, '/')) == 0) {
for (i = 1; i < _LC_LAST; ++i) {
(void)strncpyX(new_categories[i], locale,
sizeof(new_categories[i]));
}
} else {
for (i = 1;;) {
_DIAGASSERT(*r == '/' || *r == 0);
_DIAGASSERT(*locale != 0);
if (*locale == '/')
return (NULL); /* invalid format. */
len = r - locale;
if (len + 1 > sizeof(new_categories[i]))
return (NULL); /* too long */
(void)memcpy(new_categories[i], locale, len);
new_categories[i][len] = '\0';
if (*r == 0)
break;
_DIAGASSERT(*r == '/');
if (*(locale = ++r) == 0)
/* slash followed by NUL */
return (NULL);
/* skip until NUL or '/' */
while (*r && *r != '/')
r++;
if (++i == _LC_LAST)
return (NULL); /* too many slashes. */
}
if (i + 1 != _LC_LAST)
return (NULL); /* too few slashes. */
}
}
if (category)
return (loadlocale(category));
loadlocale_success = 0;
for (i = 1; i < _LC_LAST; ++i) {
if (loadlocale(i) != NULL)
loadlocale_success = 1;
}
/*
* If all categories failed, return NULL; we don't need to back
* changes off, since none happened.
*/
if (!loadlocale_success)
return NULL;
return (currentlocale());
}
static char *
currentlocale()
{
int i;
(void)strncpyX(current_locale_string, current_categories[1],
sizeof(current_locale_string));
for (i = 2; i < _LC_LAST; ++i)
if (strcmp(current_categories[1], current_categories[i])) {
(void)snprintf(current_locale_string,
sizeof(current_locale_string), "%s/%s/%s/%s/%s/%s",
current_categories[1], current_categories[2],
current_categories[3], current_categories[4],
current_categories[5], current_categories[6]);
break;
}
return (current_locale_string);
}
static void
revert_to_default(int category)
{
switch (category) {
case LC_CTYPE:
#ifdef WITH_RUNE
(void)_xpg4_setrunelocale("C");
(void)__runetable_to_netbsd_ctype("C");
#else
if (_cClass != _C_CharClassTable) {
/* LINTED const castaway */
free((void *)_cClass);
_cClass = _C_CharClassTable;
}
if (_uConvT != _C_ToUpperTable) {
/* LINTED const castaway */
free((void *)_uConvT);
_uConvT = _C_ToUpperTable;
}
if (_lConvT != _C_ToLowerTable) {
/* LINTED const castaway */
free((void *)_lConvT);
_lConvT = _C_ToLowerTable;
}
#endif
break;
case LC_MESSAGES:
case LC_COLLATE:
case LC_MONETARY:
case LC_NUMERIC:
case LC_TIME:
break;
}
}
static int
force_locale_enable(int category)
{
revert_to_default(category);
return 0;
}
static int
load_locale_sub(
int category,
const char *locname,
int isspecial
)
{
char name[PATH_MAX];
/* check for the default locales */
if (!strcmp(new_categories[category], "C") ||
!strcmp(new_categories[category], "POSIX")) {
revert_to_default(category);
return 0;
}
/* check whether special symbol */
if (isspecial && _bcs_strcasecmp(locname, _LOCALE_SYM_FORCE) == 0)
return force_locale_enable(category);
/* sanity check */
if (strchr(locname, '/') != NULL)
return -1;
(void)snprintf(name, sizeof(name), "%s/%s/%s",
_PathLocale, locname, categories[category]);
switch (category) {
case LC_CTYPE:
#ifdef WITH_RUNE
if (_xpg4_setrunelocale(__UNCONST(locname)))
return -1;
if (__runetable_to_netbsd_ctype(locname)) {
/* very unfortunate, but need to go to "C" locale */
revert_to_default(category);
return -1;
}
#else
if (!__loadctype(name))
return -1;
#endif
break;
case LC_MESSAGES:
/*
* XXX we don't have LC_MESSAGES support yet,
* but catopen may use the value of LC_MESSAGES category.
* so return successfully if locale directory is present.
*/
(void)snprintf(name, sizeof(name), "%s/%s",
_PathLocale, locname);
/* local */
{
struct stat st;
if (stat(name, &st) < 0)
return -1;
if (!S_ISDIR(st.st_mode))
return -1;
}
break;
case LC_COLLATE:
case LC_MONETARY:
case LC_NUMERIC:
case LC_TIME:
return -1;
}
return 0;
}
static char *
loadlocale(int category)
{
//char aliaspath[PATH_MAX], loccat[PATH_MAX], buf[PATH_MAX];
//const char *alias;
_DIAGASSERT(0 < category && category < _LC_LAST);
if (strcmp(new_categories[category], current_categories[category]) == 0)
return (current_categories[category]);
/* (1) non-aliased file */
if (!load_locale_sub(category, new_categories[category], 0))
goto success;
///* (2) lookup locname/catname type alias */
//(void)snprintf(aliaspath, sizeof(aliaspath),
// "%s/" _LOCALE_ALIAS_NAME, _PathLocale);
//(void)snprintf(loccat, sizeof(loccat), "%s/%s",
// new_categories[category], categories[category]);
//alias = _lookup_alias(aliaspath, loccat, buf, sizeof(buf),
// _LOOKUP_CASE_SENSITIVE);
//if (!load_locale_sub(category, alias, 1))
// goto success;
///* (3) lookup locname type alias */
//alias = _lookup_alias(aliaspath, new_categories[category],
// buf, sizeof(buf), _LOOKUP_CASE_SENSITIVE);
//if (!load_locale_sub(category, alias, 1))
// goto success;
return NULL;
success:
(void)strncpyX(current_categories[category],
new_categories[category],
sizeof(current_categories[category]));
return current_categories[category];
}
static const char *
__get_locale_env(int category)
{
const char *env;
//_DIAGASSERT(category != LC_ALL);
///* 1. check LC_ALL. */
//env = getenv(categories[0]);
///* 2. check LC_* */
//if (!env || !*env)
// env = getenv(categories[category]);
///* 3. check LANG */
//if (!env || !*env)
// env = getenv("LANG");
///* 4. if none is set, fall to "C" */
//if (!env || !*env || strchr(env, '/'))
env = "C";
return env;
}

View File

@@ -0,0 +1,53 @@
/* $NetBSD: setlocale1.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: setlocale1.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include "rune.h"
__warn_references(setlocale,
"warning: reference to compatibility setlocale(); include <locale.h> for correct reference")
/*
* Preparation for the future import of multibyte locale.
* This function will ensure binary compatibility for old executables.
*/
char *
setlocale(int category, const char *locale)
{
/* locale may be NULL */
__mb_len_max_runtime = 1;
return __setlocale(category, locale);
}

View File

@@ -0,0 +1,46 @@
/* $NetBSD: setlocale32.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: setlocale32.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include "rune.h"
char *
__setlocale_mb_len_max_32(int category, const char *locale)
{
/* locale may be NULL */
__mb_len_max_runtime = 32;
return __setlocale(category, locale);
}

View File

@@ -0,0 +1,47 @@
/* $NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <wchar.h>
/*
* Compare strings with using collating information.
*/
int
wcscoll(const wchar_t *s1, const wchar_t *s2)
{
/* XXX: LC_COLLATE should be implemented. */
return (wcscmp(s1, s2));
}

View File

@@ -0,0 +1,109 @@
/* $NetBSD: wcsftime.c,v 1.2 2006/10/04 14:19:16 tnozaki Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
__FBSDID("$FreeBSD: src/lib/libc/locale/wcsftime.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
#else
__RCSID("$NetBSD: wcsftime.c,v 1.2 2006/10/04 14:19:16 tnozaki Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>
#include <wchar.h>
#include <machine/int_limits.h>
/*
* Convert date and time to a wide-character string.
*
* This is the wide-character counterpart of strftime(). So that we do not
* have to duplicate the code of strftime(), we convert the format string to
* multibyte, call strftime(), then convert the result back into wide
* characters.
*
* This technique loses in the presence of stateful multibyte encoding if any
* of the conversions in the format string change conversion state. When
* stateful encoding is implemented, we will need to reset the state between
* format specifications in the format string.
*/
size_t
wcsftime(wchar_t *wcs, size_t maxsize,
const wchar_t *format, const struct tm *timeptr)
{
char *dst, *dstp, *sformat;
size_t n, sflen;
int sverrno;
sformat = dst = NULL;
/*
* Convert the supplied format string to a multibyte representation
* for strftime(), which only handles single-byte characters.
*/
sflen = wcstombs(NULL, format, 0);
if (sflen == (size_t)-1)
goto error;
if ((sformat = malloc(sflen + 1)) == NULL)
goto error;
wcstombs(sformat, format, sflen + 1);
/*
* Allocate memory for longest multibyte sequence that will fit
* into the caller's buffer and call strftime() to fill it.
* Then, copy and convert the result back into wide characters in
* the caller's buffer.
*/
if (SIZE_T_MAX / MB_CUR_MAX <= maxsize) {
/* maxsize is preposturously large - avoid int. overflow. */
errno = EINVAL;
goto error;
}
dst = malloc(maxsize * MB_CUR_MAX);
if (dst == NULL)
goto error;
if (strftime(dst, maxsize, sformat, timeptr) == 0)
goto error;
dstp = dst;
n = mbstowcs(wcs, dstp, maxsize);
if (n == (size_t)-2 || n == (size_t)-1)
goto error;
free(sformat);
free(dst);
return n;
error:
sverrno = errno;
free(sformat);
free(dst);
errno = sverrno;
return 0;
}

View File

@@ -0,0 +1,51 @@
/* $NetBSD: wcstod.c,v 1.12 2006/04/16 17:03:32 christos Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstod.c,v 1.12 2006/04/16 17:03:32 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
//#ifdef __weak_alias
//__strong_alias(_wcstod,wcstod)
//__weak_alias(wcstod,_wcstod)
//#endif
#define _FUNCNAME wcstod
#define _RETURN_TYPE double
#define _STRTOD_FUNC strtod
#include "_wcstod.h"

View File

@@ -0,0 +1,53 @@
/* $NetBSD: wcstof.c,v 1.2 2006/04/16 17:03:32 christos Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstof.c,v 1.2 2006/04/16 17:03:32 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#ifdef __weak_alias
__strong_alias(_wcstof,wcstof)
__weak_alias(wcstof,_wcstof)
#endif
#define _FUNCNAME wcstof
#define _RETURN_TYPE float
#define _STRTOD_FUNC strtof
#include "_wcstod.h"

View File

@@ -0,0 +1,59 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstoimax.c,v 1.2 2004/06/21 21:20:43 itojun Exp
**/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstoimax.c,v 1.2 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstoimax
#define __wINT intmax_t
#define __wINT_MIN INTMAX_MIN
#define __wINT_MAX INTMAX_MAX
#include "_wcstol.h"

View File

@@ -0,0 +1,58 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstol.c,v 1.3 2004/06/21 21:20:43 itojun Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstol.c,v 1.3 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstol
#define __wINT long int
#define __wINT_MIN LONG_MIN
#define __wINT_MAX LONG_MAX
#include "_wcstol.h"

View File

@@ -0,0 +1,53 @@
/* $NetBSD: wcstold.c,v 1.2 2006/04/16 17:03:32 christos Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstold.c,v 1.2 2006/04/16 17:03:32 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#ifdef __weak_alias
__strong_alias(_wcstold,wcstold)
__weak_alias(wcstold,_wcstold)
#endif
#define _FUNCNAME wcstold
#define _RETURN_TYPE long double
#define _STRTOD_FUNC strtold
#include "_wcstod.h"

View File

@@ -0,0 +1,58 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstoll.c,v 1.2 2004/06/21 21:20:43 itojun Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstoll.c,v 1.2 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstoll
#define __wINT /* LONGLONG */ long long int
#define __wINT_MIN LLONG_MIN
#define __wINT_MAX LLONG_MAX
#include "_wcstol.h"

View File

@@ -0,0 +1,58 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstoul.c,v 1.3 2004/06/21 21:20:43 itojun Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstoul.c,v 1.3 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstoul
#define __wINT long int
#define __wUINT unsigned long int
#define __wUINT_MAX ULONG_MAX
#include "_wcstoul.h"

View File

@@ -0,0 +1,58 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstoull.c,v 1.2 2004/06/21 21:20:43 itojun Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstoull.c,v 1.2 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstoull
#define __wINT long long int
#define __wUINT /* LONGLONG */ unsigned long long int
#define __wUINT_MAX ULLONG_MAX
#include "_wcstoul.h"

View File

@@ -0,0 +1,59 @@
/** @file
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Copyright (c)2003 Citrus Project,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
NetBSD: wcstoumax.c,v 1.2 2004/06/21 21:20:43 itojun Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcstoumax.c,v 1.2 2004/06/21 21:20:43 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include "__wctoint.h"
#define _FUNCNAME wcstoumax
#define __wINT intmax_t
#define __wUINT uintmax_t
#define __wUINT_MAX UINTMAX_MAX
#include "_wcstoul.h"

View File

@@ -0,0 +1,66 @@
/* $NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <wchar.h>
/*
* Compare strings with using collating information.
*/
size_t
wcsxfrm(
wchar_t *s1,
const wchar_t *s2,
size_t n
)
{
size_t len;
/* XXX: LC_COLLATE should be implemented. */
len = wcslen(s2);
if (len<n)
wcscpy(s1, s2);
else {
/*
* SUSv3 says:
* If the value returned is n or more, the contents
* of the array pointed to by ws1 are unspecified.
*/
/* thus, do nothing */
}
return (len);
}