Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-08-17 09:19:18 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-08-17 09:19:18 +0400
commitad5527663ef5d01f531b4d4b23390c7566c93ee2 (patch)
treeeaffc628056b9323b965c0e309656b4dfb19215d /newlib/libc/locale
parent9e0f101fa9f301ceaa8c6c5152b320ce7d535eb3 (diff)
2002-08-17 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Move cmath stuff into libc/sys/linux. * Makefile.in: Regenerated. * configure.host: Default -DMB_CAPABLE for x86-linux. * libc/include/reent.h: Define _sbrk to take signed int argument. * libc/include/sys/unistd.h: Ditto for _sbrk_r and sbrk. * libc/locale/locale.c[MB_CAPABLE]: Add LC_MESSAGES support and make locale name checking more efficient. Also allow "C-ISO-8859-1" locale for LC_CTYPE and LC_MESSAGES. * libc/reent/sbrkr.c: Change prototype to take ptrdiff_t. * libc/sys/linux/brk.c: Change sbrk prototype. * libc/sys/linux/include/time.h: Remove Cygwin stuff and include <sys/features.h>. (CLOCK_THREAD_CPUTIME): Renamed to CLOCK_THREAD_CPUTIME_ID. (CLOCK_PROCESS_CPUTIME): Renamed to CLOCK_PROCESS_CPUTIME_ID. * libc/sys/linux/sys/cdefs.h: Replace with glibc sys/cdefs.h with a few local additions. * libc/sys/linux/sys/features.h: New file. * libc/sys/linux/sys/unistd.h: Change _sbrk_r and sbrk prototypes to take signed argument. * libc/syscalls/syssbrk.c: Change sbrk, _sbrk_r, and _sbrk prototypes to take signed size argument.
Diffstat (limited to 'newlib/libc/locale')
-rw-r--r--newlib/libc/locale/locale.c136
1 files changed, 115 insertions, 21 deletions
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 4487f7d47..7a4db069c 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -45,8 +45,9 @@ locale.
This is a minimal implementation, supporting only the required <<``C''>>
value for <[locale]>; strings representing other locales are not
honored unless MB_CAPABLE is defined in which case three new
-extensions are allowed for LC_CTYPE only: <<''C-JIS''>>, <<''C-EUCJP''>>,
-and <<''C-SJIS''>>. (<<``''>> is also accepted; it represents the default locale
+extensions are allowed for LC_CTYPE or LC_MESSAGES only: <<''C-JIS''>>,
+<<''C-EUCJP''>>, <<''C-SJIS''>>, or <<''C-ISO-8859-1''>>. (<<``''>> is
+also accepted; it represents the default locale
for an implementation, here equivalent to <<``C''>>.)
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
@@ -96,6 +97,10 @@ int __declspec(dllexport) __mb_cur_max = 1;
int __mb_cur_max = 1;
#endif
+int __nlocale_changed = 0;
+int __mlocale_changed = 0;
+char *_PathLocale = NULL;
+
static _CONST struct lconv lconv =
{
".", "", "", "", "", "", "", "", "", "",
@@ -104,6 +109,10 @@ static _CONST struct lconv lconv =
};
+char * _EXFUN(__locale_charset,(_VOID));
+
+static char *charset = "ISO-8859-1";
+
char *
_DEFUN(_setlocale_r, (p, category, locale),
struct _reent *p _AND
@@ -120,12 +129,14 @@ _DEFUN(_setlocale_r, (p, category, locale),
}
return "C";
#else
- static char lc_ctype[8] = "C";
- static char last_lc_ctype[8] = "C";
+ static char lc_ctype[12] = "C";
+ static char last_lc_ctype[12] = "C";
+ static char lc_messages[12] = "C";
+ static char last_lc_messages[12] = "C";
if (locale)
{
- if (category != LC_CTYPE)
+ if (category != LC_CTYPE && category != LC_MESSAGES)
{
if (strcmp (locale, "C") && strcmp (locale, ""))
return 0;
@@ -133,39 +144,117 @@ _DEFUN(_setlocale_r, (p, category, locale),
{
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, locale);
+ strcpy (last_lc_messages, lc_messages);
+ strcpy (lc_messages, locale);
__mb_cur_max = 1;
}
}
else
- {
- if (strcmp (locale, "C") && strcmp (locale, "") &&
- strcmp (locale, "C") && strcmp (locale, "C-JIS") &&
- strcmp (locale, "C-EUCJP") && strcmp (locale, "C-SJIS") &&
- strcmp (locale, "UTF-8"))
- return 0;
-
- strcpy (last_lc_ctype, lc_ctype);
- strcpy (lc_ctype, locale);
+ {
+ if (locale[0] != 'C')
+ return 0;
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ if (strcmp (locale, "C-UTF-8"))
+ return 0;
+ break;
+ case 'J':
+ if (strcmp (locale, "C-JIS"))
+ return 0;
+ break;
+ case 'E':
+ if (strcmp (locale, "C-EUCJP"))
+ return 0;
+ break;
+ case 'S':
+ if (strcmp (locale, "C-SJIS"))
+ return 0;
+ break;
+ case 'I':
+ if (strcmp (locale, "C-ISO-8859-1"))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ if (category == LC_CTYPE)
+ {
+ strcpy (last_lc_ctype, lc_ctype);
+ strcpy (lc_ctype, locale);
- if (!strcmp (locale, "UTF-8"))
- __mb_cur_max = 6;
- else if (!strcmp (locale, "C-JIS"))
- __mb_cur_max = 8;
- else if (strlen (locale) > 1)
- __mb_cur_max = 2;
+ __mb_cur_max = 1;
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ __mb_cur_max = 6;
+ break;
+ case 'J':
+ __mb_cur_max = 8;
+ break;
+ case 'E':
+ __mb_cur_max = 2;
+ break;
+ case 'S':
+ __mb_cur_max = 2;
+ break;
+ case 'I':
+ default:
+ __mb_cur_max = 1;
+ }
+ }
+ }
else
- __mb_cur_max = 1;
+ {
+ strcpy (last_lc_messages, lc_messages);
+ strcpy (lc_messages, locale);
+
+ charset = "ISO-8859-1";
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ charset = "UTF-8";
+ break;
+ case 'J':
+ charset = "JIS";
+ break;
+ case 'E':
+ charset = "EUCJP";
+ break;
+ case 'S':
+ charset = "SJIS";
+ break;
+ case 'I':
+ charset = "ISO-8859-1";
+ break;
+ default:
+ return 0;
+ }
+ }
+ }
}
p->_current_category = category;
p->_current_locale = locale;
if (category == LC_CTYPE)
return last_lc_ctype;
+ else if (category == LC_MESSAGES)
+ return last_lc_messages;
}
else
{
if (category == LC_CTYPE)
return lc_ctype;
+ else if (category == LC_MESSAGES)
+ return lc_messages;
}
return "C";
@@ -173,6 +262,11 @@ _DEFUN(_setlocale_r, (p, category, locale),
}
+char *
+_DEFUN_VOID(__locale_charset)
+{
+ return charset;
+}
struct lconv *
_DEFUN(_localeconv_r, (data),