summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-08-28 23:10:57 +0000
committerRoland McGrath <roland@gnu.org>2002-08-28 23:10:57 +0000
commit6e68eecf7b2d778e0bd488466a1798c3b3fd4dcc (patch)
tree5982b150b2d814caf0e3e7685dce9963d1a10762
parentdd4f211573cfbed669f582673e8914a1f7038cd9 (diff)
downloadglibc-6e68eecf7b2d778e0bd488466a1798c3b3fd4dcc.tar.gz
glibc-6e68eecf7b2d778e0bd488466a1798c3b3fd4dcc.tar.xz
glibc-6e68eecf7b2d778e0bd488466a1798c3b3fd4dcc.zip
2002-08-28 Roland McGrath <roland@redhat.com>
	* locale/lc-time.c (_nl_init_era_entries, _nl_get_era_entry,
	_nl_select_era_entry): Moved to ...
	* time/era.c: ... here, new file.
	(_nl_init_era_entries, _nl_get_era_entry, _nl_select_era_entry):
	Add internal_function to definitions.  Take an additional argument
	giving the `struct locale_data *' to use.
	* locale/lc-time.c (_get_alt_digit, _nl_get_walt_digit,
	_nl_parse_alt_digit): Moved to ...
	* time/alt_digit.c: ... here, new file.
	* time/lc-time-cleanup.c: New file.
	* locale/lc-time.c (_nl_postload_time, free_mem): Functions removed.
	* locale/localeinfo.h (_nl_postload_time): Remove decl.
	(_nl_cleanup_time): Declare it.
	(_nl_get_era_entry, _nl_select_era_entry): Update decls.
	(_get_alt_digit, _nl_get_walt_digit, _nl_parse_alt_digit): Likewise.
	* time/Makefile (aux): New variable: era, alt_digit, lc-time-cleanup.
	* time/strftime.c: Pass locale data to helper functions.
	* time/strptime.c: Likewise.
	* time/strptime.c [USE_IN_EXTENDED_LOCALE_MODEL] (_NL_CURRENT_WORD):
	Redefine this too.
-rw-r--r--time/strptime.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/time/strptime.c b/time/strptime.c
index bbd9e64550..61f11f488f 100644
--- a/time/strptime.c
+++ b/time/strptime.c
@@ -105,7 +105,7 @@ localtime_r (t, tp)
 									      \
      if (*decided != raw)						      \
        {								      \
-	 val = _nl_parse_alt_digit (&rp);				      \
+	 val = _nl_parse_alt_digit (&rp HELPER_LOCALE_ARG);		      \
 	 if (val == -1 && *decided != loc)				      \
 	   {								      \
 	     *decided = loc;						      \
@@ -195,15 +195,24 @@ const unsigned short int __mon_yday[2][13] =
 # undef _NL_CURRENT
 # define _NL_CURRENT(category, item) \
   (current->values[_NL_ITEM_INDEX (item)].string)
+# undef _NL_CURRENT_WORD
+# define _NL_CURRENT_WORD(category, item) \
+  (current->values[_NL_ITEM_INDEX (item)].word)
 # define LOCALE_PARAM , locale
 # define LOCALE_ARG , locale
 # define LOCALE_PARAM_PROTO , __locale_t locale
 # define LOCALE_PARAM_DECL __locale_t locale;
+# define HELPER_LOCALE_ARG , current
 #else
 # define LOCALE_PARAM
 # define LOCALE_ARG
 # define LOCALE_PARAM_DECL
 # define LOCALE_PARAM_PROTO
+# ifdef _LIBC
+#  define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME)
+# else
+#  define HELPER_LOCALE_ARG
+# endif
 #endif
 
 
@@ -731,8 +740,8 @@ strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 		{
 		  if (era_cnt >= 0)
 		    {
-		      era = _nl_select_era_entry (era_cnt);
-		      if (match_string (era->era_name, rp))
+		      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+		      if (era != NULL && match_string (era->era_name, rp))
 			{
 			  *decided = loc;
 			  break;
@@ -747,8 +756,9 @@ strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 		      for (era_cnt = 0; era_cnt < (int) num_eras;
 			   ++era_cnt, rp = rp_backup)
 			{
-			  era = _nl_select_era_entry (era_cnt);
-			  if (match_string (era->era_name, rp))
+			  era = _nl_select_era_entry (era_cnt
+						      HELPER_LOCALE_ARG);
+			  if (era != NULL && match_string (era->era_name, rp))
 			    {
 			      *decided = loc;
 			      break;
@@ -787,8 +797,8 @@ strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 		  for (era_cnt = 0; era_cnt < (int) num_eras;
 		       ++era_cnt, rp = rp_backup)
 		    {
-		      era = _nl_select_era_entry (era_cnt);
-		      if (recursive (era->era_format))
+		      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+		      if (era != NULL && recursive (era->era_format))
 			break;
 		    }
 		  if (era_cnt == (int) num_eras)
@@ -971,7 +981,9 @@ strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 
   if (era_cnt != -1)
     {
-      era = _nl_select_era_entry (era_cnt);
+      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+      if (era == NULL)
+	return NULL;
       if (want_era)
 	tm->tm_year = (era->start_date[0]
 		       + ((tm->tm_year - era->offset)