aboutsummaryrefslogtreecommitdiff
path: root/locale
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-10 02:09:02 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-10 02:09:02 +0000
commit2b15132f986df6e8dcc2355f6e3e618550d1922b (patch)
tree353dc8f7cb396266db622345f1e02ec19764f612 /locale
parent5b643faffc5f43402854fdfc2bdd807ce719bbfb (diff)
downloadglibc-2b15132f986df6e8dcc2355f6e3e618550d1922b.tar
glibc-2b15132f986df6e8dcc2355f6e3e618550d1922b.tar.gz
glibc-2b15132f986df6e8dcc2355f6e3e618550d1922b.tar.bz2
glibc-2b15132f986df6e8dcc2355f6e3e618550d1922b.zip
Update.
* locale/lc-time.c (_nl_parse_alt_digit): New function. * locale/localeinfo.h: Add prototype for it. * time/strptime.c (get_alt_number): Use _nl_parse_alt_digit to get the value. Correct computation of hour for %OI. If no %EC given but %Ey use numeric formular.
Diffstat (limited to 'locale')
-rw-r--r--locale/lc-time.c59
-rw-r--r--locale/localeinfo.h3
2 files changed, 61 insertions, 1 deletions
diff --git a/locale/lc-time.c b/locale/lc-time.c
index 545f83d123..efa56b8f82 100644
--- a/locale/lc-time.c
+++ b/locale/lc-time.c
@@ -1,5 +1,5 @@
/* Define current locale data for LC_TIME category.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -250,6 +250,63 @@ _nl_get_walt_digit (unsigned int number)
}
+int
+_nl_parse_alt_digit (const char **strp)
+{
+ const char *str = *strp;
+ int result = -1;
+ size_t cnt;
+ size_t maxlen = 0;
+
+ __libc_lock_lock (__libc_setlocale_lock);
+
+ if (alt_digits_initialized == 0)
+ {
+ alt_digits_initialized = 1;
+
+ if (alt_digits == NULL)
+ alt_digits = malloc (100 * sizeof (const char *));
+
+ if (alt_digits != NULL)
+ {
+ const char *ptr = _NL_CURRENT (LC_TIME, ALT_DIGITS);
+
+ if (alt_digits != NULL)
+ for (cnt = 0; cnt < 100; ++cnt)
+ {
+ alt_digits[cnt] = ptr;
+
+ /* Skip digit format. */
+ ptr = strchr (ptr, '\0') + 1;
+ }
+ }
+ }
+
+ /* Matching is not unambiguos. The alternative digits could be like
+ I, II, III, ... and the first one is a substring of the second
+ and third. Therefore we must keep on searching until we found
+ the longest possible match. Note that this is not specified in
+ the standard. */
+ for (cnt = 0; cnt < 100; ++cnt)
+ {
+ size_t len = strlen (alt_digits[cnt]);
+
+ if (len > maxlen && strncmp (alt_digits[cnt], str, len) == 0)
+ {
+ maxlen = len;
+ result = (int) cnt;
+ }
+ }
+
+ __libc_lock_unlock (__libc_setlocale_lock);
+
+ if (result != -1)
+ *strp += maxlen;
+
+ return result;
+}
+
+
static void
free_mem (void)
{
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index 24ddabed71..e7528e9edb 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -205,6 +205,9 @@ extern const char *_nl_get_alt_digit (unsigned int number);
/* Similar, but now for wide characters. */
extern const wchar_t *_nl_get_walt_digit (unsigned int number);
+/* Parse string as alternative digit and return numeric value. */
+extern int _nl_parse_alt_digit (const char **strp);
+
/* Postload processing. */
extern void _nl_postload_ctype (void);
extern void _nl_postload_time (void);