OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/newlib-1.18.0/newlib-1.18.0-or32-1.0rc2/newlib/libc/locale
    from Rev 207 to Rev 520
    Reverse comparison

Rev 207 → Rev 520

/locale.c
0,0 → 1,797
/*
FUNCTION
<<setlocale>>, <<localeconv>>---select or query locale
 
INDEX
setlocale
INDEX
localeconv
INDEX
_setlocale_r
INDEX
_localeconv_r
 
ANSI_SYNOPSIS
#include <locale.h>
char *setlocale(int <[category]>, const char *<[locale]>);
lconv *localeconv(void);
 
char *_setlocale_r(void *<[reent]>,
int <[category]>, const char *<[locale]>);
lconv *_localeconv_r(void *<[reent]>);
 
TRAD_SYNOPSIS
#include <locale.h>
char *setlocale(<[category]>, <[locale]>)
int <[category]>;
char *<[locale]>;
 
lconv *localeconv();
 
char *_setlocale_r(<[reent]>, <[category]>, <[locale]>)
char *<[reent]>;
int <[category]>;
char *<[locale]>;
 
lconv *_localeconv_r(<[reent]>);
char *<[reent]>;
 
DESCRIPTION
<<setlocale>> is the facility defined by ANSI C to condition the
execution environment for international collating and formatting
information; <<localeconv>> reports on the settings of the current
locale.
 
This is a minimal implementation, supporting only the required <<"POSIX">>
and <<"C">> values for <[locale]>; strings representing other locales are not
honored unless _MB_CAPABLE is defined.
 
If _MB_CAPABLE is defined, POSIX locale strings are allowed, following
the form
 
language[_TERRITORY][.charset][@@modifier]
 
<<"language">> is a two character string per ISO 639. <<"TERRITORY">> is a
country code per ISO 3166. For <<"charset">> and <<"modifier">> see below.
 
Additionally to the POSIX specifier, seven extensions are supported for
backward compatibility with older implementations using newlib:
<<"C-UTF-8">>, <<"C-JIS">>, <<"C-eucJP">>, <<"C-SJIS">>, <<C-KOI8-R>>,
<<C-KOI8-U>>, <<"C-ISO-8859-x">> with 1 <= x <= 15, or <<"C-CPxxx">> with
xxx in [437, 720, 737, 775, 850, 852, 855, 857, 858, 862, 866, 874, 1125,
1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258].
 
Instead of <<"C-">>, you can specify also <<"C.">>. Both variations allow
to specify language neutral locales while using other charsets than ASCII,
for instance <<"C.UTF-8">>, which keeps all settings as in the C locale,
but uses the UTF-8 charset.
 
Even when using POSIX locale strings, the only charsets allowed are
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>, <<"SJIS">>, <<KOI8-R>>, <<KOI8-U>>,
<<"ISO-8859-x">> with 1 <= x <= 15, or <<"CPxxx">> with xxx in
[437, 720, 737, 775, 850, 852, 855, 857, 858, 862, 866, 874, 1125, 1250,
1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258].
Charsets are case insensitive. For instance, <<"EUCJP">> and <<"eucJP">>
are equivalent. <<"UTF-8">> can also be written without dash, as in
<<"UTF8">> or <<"utf8">>.
 
(<<"">> is also accepted; if given, the settings are read from the
corresponding LC_* environment variables and $LANG according to POSIX rules.
 
Under Cygwin, this implementation additionally supports the charsets
<<"GBK">>, <<"eucKR">>, and <<"Big5">>.
 
This implementation also supports a single modifier, <<"cjknarrow">>.
Any other modifier is ignored. <<"cjknarrow">>, in conjunction with one
of the language specifiers <<"ja">>, <<"ko">>, and <<"zh">> specifies
how the functions <<wcwidth>> and <<wcswidth>> handle characters from
the "CJK Ambiguous Width" character class described in
http://www.unicode.org/unicode/reports/tr11/. Usually these characters
have a width of 1, unless you specify one of the aforementioned
languages, in which case these characters have a width of 2. By
specifying the <<"cjknarrow">> modifier, these characters will have a
width of one in the languages <<"ja">>, <<"ko">>, and <<"zh">> as well.
 
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a
pointer to the string representing the current locale. The acceptable
values for <[category]> are defined in `<<locale.h>>' as macros
beginning with <<"LC_">>.
 
<<localeconv>> returns a pointer to a structure (also defined in
`<<locale.h>>') describing the locale-specific conventions currently
in effect.
 
<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
<<localeconv>> and <<setlocale>> respectively. The extra argument
<[reent]> is a pointer to a reentrancy structure.
 
RETURNS
A successful call to <<setlocale>> returns a pointer to a string
associated with the specified category for the new locale. The string
returned by <<setlocale>> is such that a subsequent call using that
string will restore that category (or all categories in case of LC_ALL),
to that state. The application shall not modify the string returned
which may be overwritten by a subsequent call to <<setlocale>>.
On error, <<setlocale>> returns <<NULL>>.
 
<<localeconv>> returns a pointer to a structure of type <<lconv>>,
which describes the formatting and collating conventions in effect (in
this implementation, always those of the C locale).
 
PORTABILITY
ANSI C requires <<setlocale>>, but the only locale required across all
implementations is the C locale.
 
NOTES
There is no ISO-8859-12 codepage. It's also refused by this implementation.
 
No supporting OS subroutines are required.
*/
 
/* Parts of this code are originally taken from FreeBSD. */
/*
* Copyright (c) 1996 - 2002 FreeBSD Project
* 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.
* 4. 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 <newlib.h>
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <limits.h>
#include <reent.h>
#include <stdlib.h>
#include <wchar.h>
#include "../stdlib/local.h"
 
#define _LC_LAST 7
#define ENCODING_LEN 31
 
int __EXPORT __mb_cur_max = 1;
 
int __nlocale_changed = 0;
int __mlocale_changed = 0;
char *_PathLocale = NULL;
 
static _CONST struct lconv lconv =
{
".", "", "", "", "", "", "", "", "", "",
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
CHAR_MAX, CHAR_MAX
};
 
#ifdef _MB_CAPABLE
/*
* Category names for getenv()
*/
static char *categories[_LC_LAST] = {
"LC_ALL",
"LC_COLLATE",
"LC_CTYPE",
"LC_MONETARY",
"LC_NUMERIC",
"LC_TIME",
"LC_MESSAGES",
};
 
/*
* Default locale per POSIX. Can be overridden on a per-target base.
*/
#ifndef DEFAULT_LOCALE
#define DEFAULT_LOCALE "C"
#endif
/*
* This variable can be changed by any outside mechanism. This allows,
* for instance, to load the default locale from a file.
*/
char __default_locale[ENCODING_LEN + 1] = DEFAULT_LOCALE;
 
/*
* Current locales for each category
*/
static char current_categories[_LC_LAST][ENCODING_LEN + 1] = {
"C",
"C",
"C",
"C",
"C",
"C",
"C",
};
 
/*
* The locales we are going to try and load
*/
static char new_categories[_LC_LAST][ENCODING_LEN + 1];
static char saved_categories[_LC_LAST][ENCODING_LEN + 1];
 
static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)];
static char *currentlocale(void);
static char *loadlocale(struct _reent *, int);
static const char *__get_locale_env(struct _reent *, int);
 
#endif
 
#ifdef __CYGWIN__
static char lc_ctype_charset[ENCODING_LEN + 1] = "UTF-8";
static char lc_message_charset[ENCODING_LEN + 1] = "UTF-8";
#else
static char lc_ctype_charset[ENCODING_LEN + 1] = "ASCII";
static char lc_message_charset[ENCODING_LEN + 1] = "ASCII";
#endif
static int lc_ctype_cjk_lang = 0;
 
char *
_DEFUN(_setlocale_r, (p, category, locale),
struct _reent *p _AND
int category _AND
_CONST char *locale)
{
#ifndef _MB_CAPABLE
if (locale)
{
if (strcmp (locale, "POSIX") && strcmp (locale, "C")
&& strcmp (locale, ""))
return NULL;
}
return "C";
#else
int i, j, len, saverr;
const char *env, *r;
 
if (category < LC_ALL || category >= _LC_LAST)
{
p->_errno = EINVAL;
return NULL;
}
 
if (locale == NULL)
return category != LC_ALL ? current_categories[category] : currentlocale();
 
/*
* Default to the current locale for everything.
*/
for (i = 1; i < _LC_LAST; ++i)
strcpy (new_categories[i], current_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 (p, i);
if (strlen (env) > ENCODING_LEN)
{
p->_errno = EINVAL;
return NULL;
}
strcpy (new_categories[i], env);
}
}
else
{
env = __get_locale_env (p, category);
if (strlen (env) > ENCODING_LEN)
{
p->_errno = EINVAL;
return NULL;
}
strcpy (new_categories[category], env);
}
}
else if (category != LC_ALL)
{
if (strlen (locale) > ENCODING_LEN)
{
p->_errno = EINVAL;
return NULL;
}
strcpy (new_categories[category], locale);
}
else
{
if ((r = strchr (locale, '/')) == NULL)
{
if (strlen (locale) > ENCODING_LEN)
{
p->_errno = EINVAL;
return NULL;
}
for (i = 1; i < _LC_LAST; ++i)
strcpy (new_categories[i], locale);
}
else
{
for (i = 1; r[1] == '/'; ++r)
;
if (!r[1])
{
p->_errno = EINVAL;
return NULL; /* Hmm, just slashes... */
}
do
{
if (i == _LC_LAST)
break; /* Too many slashes... */
if ((len = r - locale) > ENCODING_LEN)
{
p->_errno = EINVAL;
return NULL;
}
strlcpy (new_categories[i], locale, len + 1);
i++;
while (*r == '/')
r++;
locale = r;
while (*r && *r != '/')
r++;
}
while (*locale);
while (i < _LC_LAST)
{
strcpy (new_categories[i], new_categories[i-1]);
i++;
}
}
}
 
if (category != LC_ALL)
return loadlocale (p, category);
 
for (i = 1; i < _LC_LAST; ++i)
{
strcpy (saved_categories[i], current_categories[i]);
if (loadlocale (p, i) == NULL)
{
saverr = p->_errno;
for (j = 1; j < i; j++)
{
strcpy (new_categories[j], saved_categories[j]);
if (loadlocale (p, j) == NULL)
{
strcpy (new_categories[j], "C");
loadlocale (p, j);
}
}
p->_errno = saverr;
return NULL;
}
}
return currentlocale ();
#endif
}
 
#ifdef _MB_CAPABLE
static char *
currentlocale()
{
int i;
 
(void)strcpy(current_locale_string, current_categories[1]);
 
for (i = 2; i < _LC_LAST; ++i)
if (strcmp(current_categories[1], current_categories[i])) {
for (i = 2; i < _LC_LAST; ++i) {
(void)strcat(current_locale_string, "/");
(void)strcat(current_locale_string,
current_categories[i]);
}
break;
}
return (current_locale_string);
}
#endif
 
#ifdef _MB_CAPABLE
#ifdef __CYGWIN__
extern void *__set_charset_from_codepage (unsigned int, char *charset);
#endif /* __CYGWIN__ */
 
extern void __set_ctype (const char *charset);
 
static char *
loadlocale(struct _reent *p, int category)
{
/* At this point a full-featured system would just load the locale
specific data from the locale files.
What we do here for now is to check the incoming string for correctness.
The string must be in one of the allowed locale strings, either
one in POSIX-style, or one in the old newlib style to maintain
backward compatibility. If the local string is correct, the charset
is extracted and stored in lc_ctype_charset or lc_message_charset
dependent on the cateogry. */
char *locale = new_categories[category];
char charset[ENCODING_LEN + 1];
unsigned long val;
char *end;
int mbc_max;
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
const char *, mbstate_t *);
#ifdef _MB_CAPABLE
int cjknarrow = 0;
#endif
/* "POSIX" is translated to "C", as on Linux. */
if (!strcmp (locale, "POSIX"))
strcpy (locale, "C");
if (!strcmp (locale, "C")) /* Default "C" locale */
#ifdef __CYGWIN__
strcpy (charset, "UTF-8");
#else
strcpy (charset, "ASCII");
#endif
else if (locale[0] == 'C'
&& (locale[1] == '-' /* Old newlib style */
|| locale[1] == '.')) /* Extension for the C locale to allow
specifying different charsets while
sticking to the C locale in terms
of sort order, etc. Proposed in
the Debian project. */
strcpy (charset, locale + 2);
else /* POSIX style */
{
char *c = locale;
 
/* Don't use ctype macros here, they might be localized. */
/* Language */
if (c[0] < 'a' || c[0] > 'z'
|| c[1] < 'a' || c[1] > 'z')
return NULL;
c += 2;
if (c[0] == '_')
{
/* Territory */
++c;
if (c[0] < 'A' || c[0] > 'Z'
|| c[1] < 'A' || c[1] > 'Z')
return NULL;
c += 2;
}
if (c[0] == '.')
{
/* Charset */
char *chp;
 
++c;
strcpy (charset, c);
if ((chp = strchr (charset, '@')))
/* Strip off modifier */
*chp = '\0';
c += strlen (charset);
}
else if (c[0] == '\0' || c[0] == '@')
/* End of string or just a modifier */
#ifdef __CYGWIN__
__set_charset_from_codepage (0, charset);
#else
strcpy (charset, "ISO-8859-1");
#endif
else
/* Invalid string */
return NULL;
#ifdef _MB_CAPABLE
if (c[0] == '@')
{
/* Modifier */
/* Only one modifier is recognized right now. "cjknarrow" is used
to modify the behaviour of wcwidth() for East Asian languages.
For details see the comment at the end of this function. */
if (!strcmp (c + 1, "cjknarrow"))
cjknarrow = 1;
}
#endif
}
/* We only support this subset of charsets. */
switch (charset[0])
{
case 'U':
case 'u':
if (strcasecmp (charset, "UTF-8") && strcasecmp (charset, "UTF8"))
return NULL;
strcpy (charset, "UTF-8");
mbc_max = 6;
#ifdef _MB_CAPABLE
l_wctomb = __utf8_wctomb;
l_mbtowc = __utf8_mbtowc;
#endif
break;
case 'J':
case 'j':
if (strcasecmp (charset, "JIS"))
return NULL;
strcpy (charset, "JIS");
mbc_max = 8;
#ifdef _MB_CAPABLE
l_wctomb = __jis_wctomb;
l_mbtowc = __jis_mbtowc;
#endif
break;
case 'E':
case 'e':
if (!strcasecmp (charset, "EUCJP"))
{
strcpy (charset, "EUCJP");
mbc_max = 3;
#ifdef _MB_CAPABLE
l_wctomb = __eucjp_wctomb;
l_mbtowc = __eucjp_mbtowc;
#endif
}
#ifdef __CYGWIN__
else if (!strcasecmp (charset, "EUCKR"))
{
strcpy (charset, "EUCKR");
mbc_max = 2;
#ifdef _MB_CAPABLE
l_wctomb = __kr_wctomb;
l_mbtowc = __kr_mbtowc;
#endif
}
#endif
else
return NULL;
break;
case 'S':
case 's':
if (strcasecmp (charset, "SJIS"))
return NULL;
strcpy (charset, "SJIS");
mbc_max = 2;
#ifdef _MB_CAPABLE
l_wctomb = __sjis_wctomb;
l_mbtowc = __sjis_mbtowc;
#endif
break;
case 'I':
case 'i':
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for
ISO-8859-12. */
if (strncasecmp (charset, "ISO-8859-", 9))
return NULL;
strncpy (charset, "ISO", 3);
val = _strtol_r (p, charset + 9, &end, 10);
if (val < 1 || val > 16 || val == 12 || *end)
return NULL;
mbc_max = 1;
#ifdef _MB_CAPABLE
#ifdef _MB_EXTENDED_CHARSETS_ISO
l_wctomb = __iso_wctomb;
l_mbtowc = __iso_mbtowc;
#else /* !_MB_EXTENDED_CHARSETS_ISO */
l_wctomb = __ascii_wctomb;
l_mbtowc = __ascii_mbtowc;
#endif /* _MB_EXTENDED_CHARSETS_ISO */
#endif
break;
case 'C':
case 'c':
if (charset[1] != 'P' && charset[1] != 'p')
return NULL;
strncpy (charset, "CP", 2);
val = _strtol_r (p, charset + 2, &end, 10);
if (*end)
return NULL;
switch (val)
{
case 437:
case 720:
case 737:
case 775:
case 850:
case 852:
case 855:
case 857:
case 858:
case 862:
case 866:
case 874:
case 1125:
case 1250:
case 1251:
case 1252:
case 1253:
case 1254:
case 1255:
case 1256:
case 1257:
case 1258:
mbc_max = 1;
#ifdef _MB_CAPABLE
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
l_wctomb = __cp_wctomb;
l_mbtowc = __cp_mbtowc;
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
l_wctomb = __ascii_wctomb;
l_mbtowc = __ascii_mbtowc;
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
#endif
break;
default:
return NULL;
}
break;
case 'K':
case 'k':
if (!strcasecmp (charset, "KOI8-R"))
strcpy (charset, "CP20866");
else if (!strcasecmp (charset, "KOI8-U"))
strcpy (charset, "CP21866");
else
return NULL;
mbc_max = 1;
#ifdef _MB_CAPABLE
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
l_wctomb = __cp_wctomb;
l_mbtowc = __cp_mbtowc;
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
l_wctomb = __ascii_wctomb;
l_mbtowc = __ascii_mbtowc;
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
#endif
break;
case 'A':
case 'a':
if (strcasecmp (charset, "ASCII"))
return NULL;
strcpy (charset, "ASCII");
mbc_max = 1;
#ifdef _MB_CAPABLE
l_wctomb = __ascii_wctomb;
l_mbtowc = __ascii_mbtowc;
#endif
break;
#ifdef __CYGWIN__
case 'G':
case 'g':
if (strcasecmp (charset, "GBK"))
return NULL;
strcpy (charset, "GBK");
mbc_max = 2;
#ifdef _MB_CAPABLE
l_wctomb = __gbk_wctomb;
l_mbtowc = __gbk_mbtowc;
#endif
break;
case 'B':
case 'b':
if (strcasecmp (charset, "BIG5"))
return NULL;
strcpy (charset, "BIG5");
mbc_max = 2;
#ifdef _MB_CAPABLE
l_wctomb = __big5_wctomb;
l_mbtowc = __big5_mbtowc;
#endif
break;
#endif /* __CYGWIN__ */
default:
return NULL;
}
if (category == LC_CTYPE)
{
strcpy (lc_ctype_charset, charset);
__mb_cur_max = mbc_max;
#ifdef _MB_CAPABLE
__wctomb = l_wctomb;
__mbtowc = l_mbtowc;
__set_ctype (charset);
/* Check for the language part of the locale specifier. In case
of "ja", "ko", or "zh", assume the use of CJK fonts, unless the
"@cjknarrow" modifier has been specifed.
The result is stored in lc_ctype_cjk_lang and tested in wcwidth()
to figure out the width to return (1 or 2) for the "CJK Ambiguous
Width" category of characters. */
lc_ctype_cjk_lang = !cjknarrow
&& ((strncmp (locale, "ja", 2) == 0
|| strncmp (locale, "ko", 2) == 0
|| strncmp (locale, "zh", 2) == 0));
#endif
}
else if (category == LC_MESSAGES)
strcpy (lc_message_charset, charset);
return strcpy(current_categories[category], new_categories[category]);
}
 
static const char *
__get_locale_env(struct _reent *p, int category)
{
const char *env;
 
/* 1. check LC_ALL. */
env = _getenv_r (p, categories[0]);
 
/* 2. check LC_* */
if (env == NULL || !*env)
env = _getenv_r (p, categories[category]);
 
/* 3. check LANG */
if (env == NULL || !*env)
env = _getenv_r (p, "LANG");
 
/* 4. if none is set, fall to default locale */
if (env == NULL || !*env)
env = __default_locale;
 
return env;
}
#endif
 
char *
_DEFUN_VOID(__locale_charset)
{
return lc_ctype_charset;
}
 
char *
_DEFUN_VOID(__locale_msgcharset)
{
return lc_message_charset;
}
 
int
_DEFUN_VOID(__locale_cjk_lang)
{
return lc_ctype_cjk_lang;
}
 
struct lconv *
_DEFUN(_localeconv_r, (data),
struct _reent *data)
{
return (struct lconv *) &lconv;
}
 
#ifndef _REENT_ONLY
 
#ifndef __CYGWIN__
char *
_DEFUN(setlocale, (category, locale),
int category _AND
_CONST char *locale)
{
return _setlocale_r (_REENT, category, locale);
}
#endif
 
struct lconv *
_DEFUN_VOID(localeconv)
{
return _localeconv_r (_REENT);
}
 
#endif
locale.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fix_grouping.c =================================================================== --- fix_grouping.c (nonexistent) +++ fix_grouping.c (revision 520) @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2001 Alexey Zelkin + * 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 + +#include +#include +#include + +static const char nogrouping[] = { CHAR_MAX, '\0' }; + +/* + * "3;3;-1" -> "\003\003\177" + */ + +const char * +__fix_locale_grouping_str(const char *str) { + + char *src, *dst; + char n; + + if (str == NULL || *str == '\0') { + return nogrouping; + } + + for (src = (char*)str, dst = (char*)str; *src != '\0'; src++) { + + /* input string examples: "3;3", "3;2;-1" */ + if (*src == ';') + continue; + + if (*src == '-' && *(src+1) == '1') { + *dst++ = CHAR_MAX; + src++; + continue; + } + + if (!isdigit((unsigned char)*src)) { + /* broken grouping string */ + return nogrouping; + } + + /* assume all numbers <= 99 */ + n = *src - '0'; + if (isdigit((unsigned char)*(src+1))) { + src++; + n *= 10; + n += *src - '0'; + } + + *dst = n; + /* NOTE: assume all input started with "0" as 'no grouping' */ + if (*dst == '\0') + return (dst == (char*)str) ? nogrouping : str; + dst++; + } + *dst = '\0'; + return str; +}
fix_grouping.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 520) @@ -0,0 +1,568 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am +subdir = locale +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \ + $(top_srcdir)/../../ltoptions.m4 \ + $(top_srcdir)/../../ltsugar.m4 \ + $(top_srcdir)/../../ltversion.m4 \ + $(top_srcdir)/../../lt~obsolete.m4 \ + $(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +lib_a_AR = $(AR) $(ARFLAGS) +lib_a_LIBADD = +am__objects_1 = lib_a-locale.$(OBJEXT) +@ELIX_LEVEL_1_FALSE@am__objects_2 = lib_a-fix_grouping.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-ldpart.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-lmessages.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-lnumeric.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-lmonetary.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-nl_langinfo.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@ lib_a-timelocal.$(OBJEXT) +@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ +@USE_LIBTOOL_FALSE@ $(am__objects_2) +lib_a_OBJECTS = $(am_lib_a_OBJECTS) +LTLIBRARIES = $(noinst_LTLIBRARIES) +liblocale_la_LIBADD = +am__objects_3 = locale.lo +@ELIX_LEVEL_1_FALSE@am__objects_4 = fix_grouping.lo ldpart.lo \ +@ELIX_LEVEL_1_FALSE@ lmessages.lo lnumeric.lo lmonetary.lo \ +@ELIX_LEVEL_1_FALSE@ nl_langinfo.lo timelocal.lo +@USE_LIBTOOL_TRUE@am_liblocale_la_OBJECTS = $(am__objects_3) \ +@USE_LIBTOOL_TRUE@ $(am__objects_4) +liblocale_la_OBJECTS = $(am_liblocale_la_OBJECTS) +liblocale_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(liblocale_la_LDFLAGS) $(LDFLAGS) -o $@ +@USE_LIBTOOL_TRUE@am_liblocale_la_rpath = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(lib_a_SOURCES) $(liblocale_la_SOURCES) +DATA = $(noinst_DATA) +ETAGS = etags +CTAGS = ctags +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRT0 = @CRT0@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ +LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ +LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ +LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ +LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ +LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ +LIBC_STDIO_DEF = @LIBC_STDIO_DEF@ +LIBC_STDIO_LIB = @LIBC_STDIO_LIB@ +LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ +LIBC_SYS_LIB = @LIBC_SYS_LIB@ +LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +READELF = @READELF@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +aext = @aext@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extra_dir = @extra_dir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libm_machine_dir = @libm_machine_dir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lpfx = @lpfx@ +lt_ECHO = @lt_ECHO@ +machine_dir = @machine_dir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +newlib_basedir = @newlib_basedir@ +oext = @oext@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +subdirs = @subdirs@ +sys_dir = @sys_dir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = cygnus +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h +@ELIX_LEVEL_1_FALSE@ELIX_SOURCES = \ +@ELIX_LEVEL_1_FALSE@ fix_grouping.c \ +@ELIX_LEVEL_1_FALSE@ ldpart.c \ +@ELIX_LEVEL_1_FALSE@ lmessages.c \ +@ELIX_LEVEL_1_FALSE@ lnumeric.c \ +@ELIX_LEVEL_1_FALSE@ lmonetary.c \ +@ELIX_LEVEL_1_FALSE@ nl_langinfo.c \ +@ELIX_LEVEL_1_FALSE@ timelocal.c + +@ELIX_LEVEL_1_TRUE@ELIX_SOURCES = +liblocale_la_LDFLAGS = -Xcompiler -nostdlib +@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = liblocale.la +@USE_LIBTOOL_TRUE@liblocale_la_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) +@USE_LIBTOOL_FALSE@noinst_DATA = +@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in +@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a +@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) +@USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS) +CHEWOUT_FILES = locale.def +SUFFIXES = .def +CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str +TARGETDOC = ../tmp.texi +CLEANFILES = $(CHEWOUT_FILES) *.ref +all: all-am + +.SUFFIXES: +.SUFFIXES: .def .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../Makefile.shared $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus locale/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --cygnus locale/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) + -rm -f lib.a + $(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD) + $(RANLIB) lib.a + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +liblocale.la: $(liblocale_la_OBJECTS) $(liblocale_la_DEPENDENCIES) + $(liblocale_la_LINK) $(am_liblocale_la_rpath) $(liblocale_la_OBJECTS) $(liblocale_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +lib_a-locale.o: locale.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-locale.o `test -f 'locale.c' || echo '$(srcdir)/'`locale.c + +lib_a-locale.obj: locale.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-locale.obj `if test -f 'locale.c'; then $(CYGPATH_W) 'locale.c'; else $(CYGPATH_W) '$(srcdir)/locale.c'; fi` + +lib_a-fix_grouping.o: fix_grouping.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fix_grouping.o `test -f 'fix_grouping.c' || echo '$(srcdir)/'`fix_grouping.c + +lib_a-fix_grouping.obj: fix_grouping.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fix_grouping.obj `if test -f 'fix_grouping.c'; then $(CYGPATH_W) 'fix_grouping.c'; else $(CYGPATH_W) '$(srcdir)/fix_grouping.c'; fi` + +lib_a-ldpart.o: ldpart.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldpart.o `test -f 'ldpart.c' || echo '$(srcdir)/'`ldpart.c + +lib_a-ldpart.obj: ldpart.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldpart.obj `if test -f 'ldpart.c'; then $(CYGPATH_W) 'ldpart.c'; else $(CYGPATH_W) '$(srcdir)/ldpart.c'; fi` + +lib_a-lmessages.o: lmessages.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lmessages.o `test -f 'lmessages.c' || echo '$(srcdir)/'`lmessages.c + +lib_a-lmessages.obj: lmessages.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lmessages.obj `if test -f 'lmessages.c'; then $(CYGPATH_W) 'lmessages.c'; else $(CYGPATH_W) '$(srcdir)/lmessages.c'; fi` + +lib_a-lnumeric.o: lnumeric.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lnumeric.o `test -f 'lnumeric.c' || echo '$(srcdir)/'`lnumeric.c + +lib_a-lnumeric.obj: lnumeric.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lnumeric.obj `if test -f 'lnumeric.c'; then $(CYGPATH_W) 'lnumeric.c'; else $(CYGPATH_W) '$(srcdir)/lnumeric.c'; fi` + +lib_a-lmonetary.o: lmonetary.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lmonetary.o `test -f 'lmonetary.c' || echo '$(srcdir)/'`lmonetary.c + +lib_a-lmonetary.obj: lmonetary.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lmonetary.obj `if test -f 'lmonetary.c'; then $(CYGPATH_W) 'lmonetary.c'; else $(CYGPATH_W) '$(srcdir)/lmonetary.c'; fi` + +lib_a-nl_langinfo.o: nl_langinfo.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nl_langinfo.o `test -f 'nl_langinfo.c' || echo '$(srcdir)/'`nl_langinfo.c + +lib_a-nl_langinfo.obj: nl_langinfo.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nl_langinfo.obj `if test -f 'nl_langinfo.c'; then $(CYGPATH_W) 'nl_langinfo.c'; else $(CYGPATH_W) '$(srcdir)/nl_langinfo.c'; fi` + +lib_a-timelocal.o: timelocal.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-timelocal.o `test -f 'timelocal.c' || echo '$(srcdir)/'`timelocal.c + +lib_a-timelocal.obj: timelocal.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-timelocal.obj `if test -f 'timelocal.c'; then $(CYGPATH_W) 'timelocal.c'; else $(CYGPATH_W) '$(srcdir)/timelocal.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-am: +check: check-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am + +objectlist.awk.in: $(noinst_LTLIBRARIES) + -rm -f objectlist.awk.in + for i in `ls *.lo` ; \ + do \ + echo $$i `pwd`/$$i >> objectlist.awk.in ; \ + done + +.c.def: + $(CHEW) < $< > $*.def 2> $*.ref + touch stmp-def + +doc: $(CHEWOUT_FILES) + cat $(srcdir)/locale.tex >> $(TARGETDOC) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Index: nl_langinfo.3 =================================================================== --- nl_langinfo.3 (nonexistent) +++ nl_langinfo.3 (revision 520) @@ -0,0 +1,90 @@ +.\" Copyright (c) 2001 Alexey Zelkin +.\" 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 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. +.\" +.\" $FreeBSD: src/lib/libc/locale/nl_langinfo.3,v 1.4 2002/04/13 04:25:56 dd Exp $ +.\" +.Dd May 3, 2001 +.Dt NL_LANGINFO 3 +.Os +.Sh NAME +.Nm nl_langinfo +.Nd language information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In langinfo.h +.Ft char * +.Fn nl_langinfo "nl_item item" +.Sh DESCRIPTION +The +.Fn nl_langinfo +function returns a pointer to a string containing information relevant to +the particular language or cultural area defined in the program's locale. +The manifest constant names and values of +.Fa item +are defined in +.Aq Pa langinfo.h . +.Pp +Calls to +.Fn setlocale +with a category corresponding to the category of +.Fa item , +or to the +category +.Dv LC_ALL , +may overwrite buffer pointed by the return value. +.Sh EXAMPLES +For example: +.Pp +.Dl nl_langinfo(ABDAY_1) +.Pp +would return a pointer to the string +.Qq Li Dom +if the identified language was +Portuguese, and +.Qq Li Sun +if the identified language was English. +.Sh RETURN VALUES +In a locale where langinfo data is not defined, +.Fn nl_langinfo +returns a pointer to the corresponding string in the +.Tn POSIX +locale. +In all locales, +.Fn nl_langinfo +returns a pointer to an empty string if +.Fa item +contains an invalid setting. +.Sh SEE ALSO +.Xr setlocale 3 +.Sh STANDARDS +The +.Fn nl_langinfo +function conforms to +.St -susv2 . +.Sh HISTORY +The +.Fn nl_langinfo +function first appeared in +.Fx 4.6 . Index: timelocal.c =================================================================== --- timelocal.c (nonexistent) +++ timelocal.c (revision 520) @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 2001 Alexey Zelkin + * Copyright (c) 1997 FreeBSD Inc. + * 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 + +#include + +#include "ldpart.h" +#include "timelocal.h" + +static struct lc_time_T _time_locale; +static int _time_using_locale; +static char *time_locale_buf; + +#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *)) + +static const struct lc_time_T _C_time_locale = { + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }, { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }, { + "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat" + }, { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }, + + /* X_fmt */ + "%H:%M:%S", + + /* + * x_fmt + * Since the C language standard calls for + * "date, using locale's date format," anything goes. + * Using just numbers (as here) makes Quakers happier; + * it's also compatible with SVR4. + */ + "%m/%d/%y", + + /* + * c_fmt + */ + "%a %b %e %H:%M:%S %Y", + + /* am */ + "AM", + + /* pm */ + "PM", + + /* date_fmt */ + "%a %b %e %H:%M:%S %Z %Y", + + /* alt_month + * Standalone months forms for %OB + */ + { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }, + + /* md_order + * Month / day order in dates + */ + "md", + + /* ampm_fmt + * To determine 12-hour clock format time (empty, if N/A) + */ + "%I:%M:%S %p" +}; + +struct lc_time_T * +__get_current_time_locale(void) { + return (_time_using_locale + ? &_time_locale + : (struct lc_time_T *)&_C_time_locale); +} + +int +__time_load_locale(const char *name) { + + int ret; + + ret = __part_load_locale(name, &_time_using_locale, + time_locale_buf, "LC_TIME", + LCTIME_SIZE, LCTIME_SIZE, + (const char **)&_time_locale); + + return (ret); +}
timelocal.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lmonetary.c =================================================================== --- lmonetary.c (nonexistent) +++ lmonetary.c (revision 520) @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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 + +#include +#include +#include "lmonetary.h" +#include "ldpart.h" + +extern int __mlocale_changed; +extern const char * __fix_locale_grouping_str(const char *); + +#define LCMONETARY_SIZE (sizeof(struct lc_monetary_T) / sizeof(char *)) + +static char empty[] = ""; +static char numempty[] = { CHAR_MAX, '\0'}; + +static const struct lc_monetary_T _C_monetary_locale = { + empty, /* int_curr_symbol */ + empty, /* currency_symbol */ + empty, /* mon_decimal_point */ + empty, /* mon_thousands_sep */ + numempty, /* mon_grouping */ + empty, /* positive_sign */ + empty, /* negative_sign */ + numempty, /* int_frac_digits */ + numempty, /* frac_digits */ + numempty, /* p_cs_precedes */ + numempty, /* p_sep_by_space */ + numempty, /* n_cs_precedes */ + numempty, /* n_sep_by_space */ + numempty, /* p_sign_posn */ + numempty /* n_sign_posn */ +}; + +static struct lc_monetary_T _monetary_locale; +static int _monetary_using_locale; +static char *_monetary_locale_buf; + +static char +cnv(const char *str) { + int i = strtol(str, NULL, 10); + if (i == -1) + i = CHAR_MAX; + return (char)i; +} + +int +__monetary_load_locale(const char *name) { + + int ret; + __mlocale_changed = 1; + ret = __part_load_locale(name, &_monetary_using_locale, + _monetary_locale_buf, "LC_MONETARY", + LCMONETARY_SIZE, LCMONETARY_SIZE, + (const char **)&_monetary_locale); + if (ret == 0 && _monetary_using_locale) { + _monetary_locale.mon_grouping = + __fix_locale_grouping_str(_monetary_locale.mon_grouping); + +#define M_ASSIGN_CHAR(NAME) (((char *)_monetary_locale.NAME)[0] = \ + cnv(_monetary_locale.NAME)) + + M_ASSIGN_CHAR(int_frac_digits); + M_ASSIGN_CHAR(frac_digits); + M_ASSIGN_CHAR(p_cs_precedes); + M_ASSIGN_CHAR(p_sep_by_space); + M_ASSIGN_CHAR(n_cs_precedes); + M_ASSIGN_CHAR(n_sep_by_space); + M_ASSIGN_CHAR(p_sign_posn); + M_ASSIGN_CHAR(n_sign_posn); + } + return ret; +} + +struct lc_monetary_T * +__get_current_monetary_locale(void) { + + return (_monetary_using_locale + ? &_monetary_locale + : (struct lc_monetary_T *)&_C_monetary_locale); +} + +#ifdef LOCALE_DEBUG +void +monetdebug() { +printf( "int_curr_symbol = %s\n" + "currency_symbol = %s\n" + "mon_decimal_point = %s\n" + "mon_thousands_sep = %s\n" + "mon_grouping = %s\n" + "positive_sign = %s\n" + "negative_sign = %s\n" + "int_frac_digits = %d\n" + "frac_digits = %d\n" + "p_cs_precedes = %d\n" + "p_sep_by_space = %d\n" + "n_cs_precedes = %d\n" + "n_sep_by_space = %d\n" + "p_sign_posn = %d\n" + "n_sign_posn = %d\n", + _monetary_locale.int_curr_symbol, + _monetary_locale.currency_symbol, + _monetary_locale.mon_decimal_point, + _monetary_locale.mon_thousands_sep, + _monetary_locale.mon_grouping, + _monetary_locale.positive_sign, + _monetary_locale.negative_sign, + _monetary_locale.int_frac_digits[0], + _monetary_locale.frac_digits[0], + _monetary_locale.p_cs_precedes[0], + _monetary_locale.p_sep_by_space[0], + _monetary_locale.n_cs_precedes[0], + _monetary_locale.n_sep_by_space[0], + _monetary_locale.p_sign_posn[0], + _monetary_locale.n_sign_posn[0] +); +} +#endif /* LOCALE_DEBUG */
lmonetary.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: locale.tex =================================================================== --- locale.tex (nonexistent) +++ locale.tex (revision 520) @@ -0,0 +1,123 @@ +@node Locale +@chapter Locale (@file{locale.h}) + +A @dfn{locale} is the name for a collection of parameters (affecting +collating sequences and formatting conventions) that may be different +depending on location or culture. The @code{"C"} locale is the only +one defined in the ANSI C standard. + +This is a minimal implementation, supporting only the required @code{"C"} +value for locale; strings representing other locales are not +honored. (@code{""} is also accepted; it represents the default locale +for an implementation, here equivalent to @code{"C"}. + + +@file{locale.h} defines the structure @code{lconv} to collect the +information on a locale, with the following fields: + +@table @code +@item char *decimal_point +The decimal point character used to format ``ordinary'' numbers (all +numbers except those referring to amounts of money). @code{"."} in the +C locale. + +@item char *thousands_sep +The character (if any) used to separate groups of digits, when +formatting ordinary numbers. +@code{""} in the C locale. + +@item char *grouping +Specifications for how many digits to group (if any grouping is done at +all) when formatting ordinary numbers. The @emph{numeric value} of each +character in the string represents the number of digits for the next +group, and a value of @code{0} (that is, the string's trailing +@code{NULL}) means to continue grouping digits using the last value +specified. Use @code{CHAR_MAX} to indicate that no further grouping is +desired. @code{""} in the C locale. + +@item char *int_curr_symbol +The international currency symbol (first three characters), if any, and +the character used to separate it from numbers. +@code{""} in the C locale. + +@item char *currency_symbol +The local currency symbol, if any. +@code{""} in the C locale. + +@item char *mon_decimal_point +The symbol used to delimit fractions in amounts of money. +@code{""} in the C locale. + +@item char *mon_thousands_sep +Similar to @code{thousands_sep}, but used for amounts of money. +@code{""} in the C locale. + +@item char *mon_grouping +Similar to @code{grouping}, but used for amounts of money. +@code{""} in the C locale. + +@item char *positive_sign +A string to flag positive amounts of money when formatting. +@code{""} in the C locale. + +@item char *negative_sign +A string to flag negative amounts of money when formatting. +@code{""} in the C locale. + +@item char int_frac_digits +The number of digits to display when formatting amounts of money to +international conventions. +@code{CHAR_MAX} (the largest number representable as a @code{char}) in +the C locale. + +@item char frac_digits +The number of digits to display when formatting amounts of money to +local conventions. +@code{CHAR_MAX} in the C locale. + +@item char p_cs_precedes +@code{1} indicates the local currency symbol is used before a +@emph{positive or zero} formatted amount of money; @code{0} indicates +the currency symbol is placed after the formatted number. +@code{CHAR_MAX} in the C locale. + +@item char p_sep_by_space +@code{1} indicates the local currency symbol must be separated from +@emph{positive or zero} numbers by a space; @code{0} indicates that it +is immediately adjacent to numbers. +@code{CHAR_MAX} in the C locale. + +@item char n_cs_precedes +@code{1} indicates the local currency symbol is used before a +@emph{negative} formatted amount of money; @code{0} indicates +the currency symbol is placed after the formatted number. +@code{CHAR_MAX} in the C locale. + +@item char n_sep_by_space +@code{1} indicates the local currency symbol must be separated from +@emph{negative} numbers by a space; @code{0} indicates that it +is immediately adjacent to numbers. +@code{CHAR_MAX} in the C locale. + +@item char p_sign_posn +Controls the position of the @emph{positive} sign for +numbers representing money. @code{0} means parentheses surround the +number; @code{1} means the sign is placed before both the number and the +currency symbol; @code{2} means the sign is placed after both the number +and the currency symbol; @code{3} means the sign is placed just before +the currency symbol; and @code{4} means the sign is placed just after +the currency symbol. +@code{CHAR_MAX} in the C locale. + +@item char n_sign_posn +Controls the position of the @emph{negative} sign for numbers +representing money, using the same rules as @code{p_sign_posn}. +@code{CHAR_MAX} in the C locale. +@end table + +@menu +* setlocale:: Select or query locale +@end menu + +@page +@include locale/locale.def Index: timelocal.h =================================================================== --- timelocal.h (nonexistent) +++ timelocal.h (revision 520) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1997-2002 FreeBSD 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. + * + * $FreeBSD: src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $ + */ + +#ifndef _TIMELOCAL_H_ +#define _TIMELOCAL_H_ + +/* + * Private header file for the strftime and strptime localization + * stuff. + */ +struct lc_time_T { + const char *mon[12]; + const char *month[12]; + const char *wday[7]; + const char *weekday[7]; + const char *X_fmt; + const char *x_fmt; + const char *c_fmt; + const char *am; + const char *pm; + const char *date_fmt; + const char *alt_month[12]; + const char *md_order; + const char *ampm_fmt; +}; + +struct lc_time_T *__get_current_time_locale(void); +int __time_load_locale(const char *); + +#endif /* !_TIMELOCAL_H_ */
timelocal.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lnumeric.c =================================================================== --- lnumeric.c (nonexistent) +++ lnumeric.c (revision 520) @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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 + +#include +#include "lnumeric.h" +#include "ldpart.h" + +extern int __nlocale_changed; +extern const char *__fix_locale_grouping_str(const char *); + +#define LCNUMERIC_SIZE (sizeof(struct lc_numeric_T) / sizeof(char *)) + +static char numempty[] = { CHAR_MAX, '\0' }; + +static const struct lc_numeric_T _C_numeric_locale = { + ".", /* decimal_point */ + "", /* thousands_sep */ + numempty /* grouping */ +}; + +static struct lc_numeric_T _numeric_locale; +static int _numeric_using_locale; +static char *_numeric_locale_buf; + +int +__numeric_load_locale(const char *name) { + + int ret; + + __nlocale_changed = 1; + ret = __part_load_locale(name, &_numeric_using_locale, + _numeric_locale_buf, "LC_NUMERIC", + LCNUMERIC_SIZE, LCNUMERIC_SIZE, + (const char **)&_numeric_locale); + if (ret == 0 && _numeric_using_locale) + _numeric_locale.grouping = + __fix_locale_grouping_str(_numeric_locale.grouping); + return ret; +} + +struct lc_numeric_T * +__get_current_numeric_locale(void) { + + return (_numeric_using_locale + ? &_numeric_locale + : (struct lc_numeric_T *)&_C_numeric_locale); +} + +#ifdef LOCALE_DEBUG +void +numericdebug(void) { +printf( "decimal_point = %s\n" + "thousands_sep = %s\n" + "grouping = %s\n", + _numeric_locale.decimal_point, + _numeric_locale.thousands_sep, + _numeric_locale.grouping +); +} +#endif /* LOCALE_DEBUG */
lnumeric.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lmonetary.h =================================================================== --- lmonetary.h (nonexistent) +++ lmonetary.h (revision 520) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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. + * + * $FreeBSD: src/lib/libc/locale/lmonetary.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ + */ + +#ifndef _LMONETARY_H_ +#define _LMONETARY_H_ + +struct lc_monetary_T { + const char *int_curr_symbol; + const char *currency_symbol; + const char *mon_decimal_point; + const char *mon_thousands_sep; + const char *mon_grouping; + const char *positive_sign; + const char *negative_sign; + const char *int_frac_digits; + const char *frac_digits; + const char *p_cs_precedes; + const char *p_sep_by_space; + const char *n_cs_precedes; + const char *n_sep_by_space; + const char *p_sign_posn; + const char *n_sign_posn; +}; + +struct lc_monetary_T *__get_current_monetary_locale(void); +int __monetary_load_locale(const char *); + +#endif /* !_LMONETARY_H_ */
lmonetary.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: setlocale.h =================================================================== --- setlocale.h (nonexistent) +++ setlocale.h (revision 520) @@ -0,0 +1,37 @@ +/*- + * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. + * 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 ``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. + * + * $FreeBSD: src/lib/libc/locale/setlocale.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ + */ + +#ifndef _SETLOCALE_H_ +#define _SETLOCALE_H_ + +#define ENCODING_LEN 31 +#define CATEGORY_LEN 11 + +extern char *_PathLocale; + +#endif /* !_SETLOCALE_H_ */
setlocale.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lmessages.c =================================================================== --- lmessages.c (nonexistent) +++ lmessages.c (revision 520) @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2001 Alexey Zelkin + * 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 + +#include + +#include "lmessages.h" +#include "ldpart.h" + +#define LCMESSAGES_SIZE_FULL (sizeof(struct lc_messages_T) / sizeof(char *)) +#define LCMESSAGES_SIZE_MIN \ + (offsetof(struct lc_messages_T, yesstr) / sizeof(char *)) + +static char empty[] = ""; + +static const struct lc_messages_T _C_messages_locale = { + "^[yY]" , /* yesexpr */ + "^[nN]" , /* noexpr */ + "yes" , /* yesstr */ + "no" /* nostr */ +}; + +static struct lc_messages_T _messages_locale; +static int _messages_using_locale; +static char *_messages_locale_buf; + +int +__messages_load_locale(const char *name) { + + /* + * Propose that we can have incomplete locale file (w/o "{yes,no}str"). + * Initialize them before loading. In case of complete locale, they'll + * be initialized to loaded value, otherwise they'll not be touched. + */ + _messages_locale.yesstr = empty; + _messages_locale.nostr = empty; + + return __part_load_locale(name, &_messages_using_locale, + _messages_locale_buf, "LC_MESSAGES", + LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN, + (const char **)&_messages_locale); +} + +struct lc_messages_T * +__get_current_messages_locale(void) { + + return (_messages_using_locale + ? &_messages_locale + : (struct lc_messages_T *)&_C_messages_locale); +} + +#ifdef LOCALE_DEBUG +void +msgdebug() { +printf( "yesexpr = %s\n" + "noexpr = %s\n" + "yesstr = %s\n" + "nostr = %s\n", + _messages_locale.yesexpr, + _messages_locale.noexpr, + _messages_locale.yesstr, + _messages_locale.nostr +); +} +#endif /* LOCALE_DEBUG */
lmessages.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lnumeric.h =================================================================== --- lnumeric.h (nonexistent) +++ lnumeric.h (revision 520) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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. + * + * $FreeBSD: src/lib/libc/locale/lnumeric.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ + */ + +#ifndef _LNUMERIC_H_ +#define _LNUMERIC_H_ + +struct lc_numeric_T { + const char *decimal_point; + const char *thousands_sep; + const char *grouping; +}; + +struct lc_numeric_T *__get_current_numeric_locale(void); +int __numeric_load_locale(const char *); + +#endif /* !_LNUMERIC_H_ */
lnumeric.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ldpart.c =================================================================== --- ldpart.c (nonexistent) +++ ldpart.c (revision 520) @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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 + +#include +#include +#include +#include +#include +#include +#include + +#include "setlocale.h" +#include "ldpart.h" + +static int split_lines(char *, const char *); +static void set_from_buf(const char *, int, const char **); + +int +__part_load_locale(const char *name, + int *using_locale, + char *locale_buf, + const char *category_filename, + int locale_buf_size_max, + int locale_buf_size_min, + const char **dst_localebuf) { + + static char locale_buf_C[] = "C"; + static int num_lines; + + int fd; + char *lbuf; + char *p; + const char *plim; + char filename[PATH_MAX]; +#ifdef __USE_INTERNAL_STAT64 + struct stat64 st; +#else + struct stat st; +#endif + size_t namesize; + size_t bufsize; + int save_using_locale; + char *nptr; + + save_using_locale = *using_locale; + *using_locale = 0; + + if (name == NULL) + goto no_locale; + + if (!strcmp(name, "C") || !strcmp(name, "POSIX")) + return 0; + + /* + * If the locale name is the same as our cache, use the cache. + */ + lbuf = locale_buf; + if (lbuf != NULL && strcmp(name, lbuf) == 0) { + set_from_buf(lbuf, num_lines, dst_localebuf); + *using_locale = 1; + return 0; + } + + /* + * Slurp the locale file into the cache. + */ + namesize = strlen(name) + 1; + + if (!_PathLocale) + goto no_locale; + /* Range checking not needed, 'name' size is limited */ + strcpy(filename, _PathLocale); + strcat(filename, "/"); + strcat(filename, name); + strcat(filename, "/"); + strcat(filename, category_filename); + fd = open(filename, O_RDONLY); + if (fd < 0) + goto no_locale; +#ifdef __USE_INTERNAL_STAT64 + if (fstat64(fd, &st) != 0) +#else + if (fstat(fd, &st) != 0) +#endif + goto bad_locale; + if (st.st_size <= 0) + goto bad_locale; + bufsize = namesize + st.st_size; + locale_buf = NULL; + + if (lbuf == NULL || lbuf == locale_buf_C) + { + lbuf = malloc(bufsize); + } + else + { + nptr = realloc(lbuf, bufsize); + if (!nptr && lbuf) + free (lbuf); + lbuf = nptr; + } + + if (lbuf == NULL) + goto bad_locale; + (void) strcpy(lbuf, name); + p = lbuf + namesize; + plim = p + st.st_size; + if (read(fd, p, (size_t) st.st_size) != st.st_size) + goto bad_lbuf; + if (close(fd) != 0) + goto bad_lbuf; + /* + * Parse the locale file into localebuf. + */ + if (plim[-1] != '\n') + goto bad_lbuf; + num_lines = split_lines(p, plim); + if (num_lines >= locale_buf_size_max) + num_lines = locale_buf_size_max; + else if (num_lines >= locale_buf_size_min) + num_lines = locale_buf_size_min; + else + goto reset_locale; + set_from_buf(lbuf, num_lines, dst_localebuf); + /* + * Record the successful parse in the cache. + */ + locale_buf = lbuf; + + *using_locale = 1; + return 0; + +reset_locale: + locale_buf = locale_buf_C; + save_using_locale = 0; +bad_lbuf: + free(lbuf); +bad_locale: + (void)close(fd); +no_locale: + *using_locale = save_using_locale; + return -1; +} + +static int +split_lines(char *p, const char *plim) { + + int i; + + for (i = 0; p < plim; i++) { + p = strchr(p, '\n'); + *p++ = '\0'; + } + return i; +} + +static void +set_from_buf(const char *p, int num_lines, const char **dst_localebuf) { + + const char **ap; + int i; + + for (ap = dst_localebuf, i = 0; i < num_lines; ++ap, ++i) + *ap = p += strlen(p) + 1; +} +
ldpart.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: nl_langinfo.c =================================================================== --- nl_langinfo.c (nonexistent) +++ nl_langinfo.c (revision 520) @@ -0,0 +1,228 @@ +/*- + * Copyright (c) 2001 Alexey Zelkin + * 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 + +#include +#include +#include +#include +#include + +#include "timelocal.h" +#include "lnumeric.h" +#include "lmonetary.h" +#include "lmessages.h" + +#ifndef __CYGWIN__ +#define TRANSITION_PERIOD_HACK +#endif + +#define _REL(BASE) ((int)item-BASE) + +extern char *__locale_charset (); + +char * +_DEFUN(nl_langinfo, (item), + nl_item item) { + + char *ret, *s, *cs; + static char *csym = NULL; +#ifdef TRANSITION_PERIOD_HACK + static char *cset = NULL; +#endif /* TRANSITION_PERIOD_HACK */ + char *nptr; + + switch (item) { + case CODESET: +#ifdef __CYGWIN__ + ret = __locale_charset (); + /* Temporary exception for KOI8 charsets which are + incorrectly treated by calling applications otherwise. */ + if (strcmp (ret, "CP20866") == 0) + ret = "KOI8-R"; + else if (strcmp (ret, "CP21866") == 0) + ret = "KOI8-U"; +#else + ret = ""; + if ((s = setlocale(LC_CTYPE, NULL)) != NULL) { + if ((cs = strchr(s, '.')) != NULL) { + ret = cs + 1; +#ifdef TRANSITION_PERIOD_HACK + if (strncmp(ret, "ISO_", 4) == 0) { + int slen = strlen(ret); + + nptr = realloc(cset, slen); + + if (!nptr && cset) + free (cset); + + cset = nptr; + if (cset != NULL) { + strcpy(cset, "ISO"); + strcat(cset, ret + 4); + ret = cset; + } else + ret = ""; + } else if (strcmp(ret, "EUC") == 0) { + if (strncmp(s, "ja_JP", 5) == 0) + ret = "eucJP"; + else if (strncmp(s, "ko_KR", 5) == 0) + ret = "eucKR"; + else if (strncmp(s, "zh_CN", 5) == 0) + ret = "eucCN"; + } else if (strcmp(ret, "ASCII") == 0) + ret = "US-ASCII"; +#endif /* TRANSITION_PERIOD_HACK */ + } else if (strcmp(s, "C") == 0 || + strcmp(s, "POSIX") == 0 +#ifdef TRANSITION_PERIOD_HACK + || strstr(s, "ASCII") != NULL +#endif /* TRANSITION_PERIOD_HACK */ + ) + ret = "US-ASCII"; + } +#endif /* __CYGWIN__ */ + break; + case D_T_FMT: + ret = (char *) __get_current_time_locale()->c_fmt; + break; + case D_FMT: + ret = (char *) __get_current_time_locale()->x_fmt; + break; + case T_FMT: + ret = (char *) __get_current_time_locale()->X_fmt; + break; + case T_FMT_AMPM: + ret = (char *) __get_current_time_locale()->ampm_fmt; + break; + case AM_STR: + ret = (char *) __get_current_time_locale()->am; + break; + case PM_STR: + ret = (char *) __get_current_time_locale()->pm; + break; + case DAY_1: case DAY_2: case DAY_3: + case DAY_4: case DAY_5: case DAY_6: case DAY_7: + ret = (char*) __get_current_time_locale()->weekday[_REL(DAY_1)]; + break; + case ABDAY_1: case ABDAY_2: case ABDAY_3: + case ABDAY_4: case ABDAY_5: case ABDAY_6: case ABDAY_7: + ret = (char*) __get_current_time_locale()->wday[_REL(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: + ret = (char*) __get_current_time_locale()->month[_REL(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: + ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)]; + break; + case ERA: + /* XXX: need to be implemented */ + ret = ""; + break; + case ERA_D_FMT: + /* XXX: need to be implemented */ + ret = ""; + break; + case ERA_D_T_FMT: + /* XXX: need to be implemented */ + ret = ""; + break; + case ERA_T_FMT: + /* XXX: need to be implemented */ + ret = ""; + break; + case ALT_DIGITS: + /* XXX: need to be implemented */ + ret = ""; + break; + case RADIXCHAR: + ret = (char*) __get_current_numeric_locale()->decimal_point; + break; + case THOUSEP: + ret = (char*) __get_current_numeric_locale()->thousands_sep; + break; + case YESEXPR: + ret = (char*) __get_current_messages_locale()->yesexpr; + break; + case NOEXPR: + ret = (char*) __get_current_messages_locale()->noexpr; + break; + /* + * All items marked with LEGACY are available, but not recomended + * by SUSv2 to be used in portable applications since they're subject + * to remove in future specification editions + */ + case YESSTR: /* LEGACY */ + ret = (char*) __get_current_messages_locale()->yesstr; + break; + case NOSTR: /* LEGACY */ + ret = (char*) __get_current_messages_locale()->nostr; + break; + case CRNCYSTR: + ret = ""; + cs = (char*) __get_current_monetary_locale()->currency_symbol; + if (*cs != '\0') { + char pos = localeconv()->p_cs_precedes; + + if (pos == localeconv()->n_cs_precedes) { + char psn = '\0'; + + if (pos == CHAR_MAX) { + if (strcmp(cs, __get_current_monetary_locale()->mon_decimal_point) == 0) + psn = '.'; + } else + psn = pos ? '-' : '+'; + if (psn != '\0') { + int clen = strlen(cs); + + nptr = realloc(csym, clen + 2); + if (!nptr && csym) + free (csym); + + csym = nptr; + + if (csym != NULL) { + *csym = psn; + strcpy(csym + 1, cs); + ret = csym; + } + } + } + } + break; + case D_MD_ORDER: /* local extension */ + ret = (char *) __get_current_time_locale()->md_order; + break; + default: + ret = ""; + } + return (ret); +}
nl_langinfo.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: lmessages.h =================================================================== --- lmessages.h (nonexistent) +++ lmessages.h (revision 520) @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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. + * + * $FreeBSD: src/lib/libc/locale/lmessages.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ + */ + +#ifndef _LMESSAGES_H_ +#define _LMESSAGES_H_ + +struct lc_messages_T { + const char *yesexpr; + const char *noexpr; + const char *yesstr; + const char *nostr; +}; + +struct lc_messages_T *__get_current_messages_locale(void); +int __messages_load_locale(const char *); + +#endif /* !_LMESSAGES_H_ */
lmessages.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: Makefile.am =================================================================== --- Makefile.am (nonexistent) +++ Makefile.am (revision 520) @@ -0,0 +1,54 @@ +## Process this file with automake to generate Makefile.in + +AUTOMAKE_OPTIONS = cygnus + +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) + +GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h + +## The following interfaces are EL/IX level 2 +if ELIX_LEVEL_1 +ELIX_SOURCES = +else +ELIX_SOURCES = \ + fix_grouping.c \ + ldpart.c \ + lmessages.c \ + lnumeric.c \ + lmonetary.c \ + nl_langinfo.c \ + timelocal.c +endif + +liblocale_la_LDFLAGS = -Xcompiler -nostdlib + +if USE_LIBTOOL +noinst_LTLIBRARIES = liblocale.la +liblocale_la_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) +noinst_DATA = objectlist.awk.in +else +noinst_LIBRARIES = lib.a +lib_a_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) +lib_a_CFLAGS = $(AM_CFLAGS) +noinst_DATA = +endif # USE_LIBTOOL + +include $(srcdir)/../../Makefile.shared + +CHEWOUT_FILES = locale.def + +SUFFIXES = .def + +CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str + +.c.def: + $(CHEW) < $< > $*.def 2> $*.ref + touch stmp-def + +TARGETDOC = ../tmp.texi + +doc: $(CHEWOUT_FILES) + cat $(srcdir)/locale.tex >> $(TARGETDOC) + +CLEANFILES = $(CHEWOUT_FILES) *.ref +
Makefile.am Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ldpart.h =================================================================== --- ldpart.h (nonexistent) +++ ldpart.h (revision 520) @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2000, 2001 Alexey Zelkin + * 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. + * + * $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ + */ + +#ifndef _LDPART_H_ +#define _LDPART_H_ + +int __part_load_locale(const char *, int*, char *, const char *, + int, int, const char **); + +#endif /* !_LDPART_H_ */
ldpart.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.