This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Add missing fields to struct lc_time_T


Hi,

the current struct lc_time_T in libc/locale/timelocal.h is missing the
ERA related LC_TIME members required by POSIX-1.2008(*).  Only with
these fields we can correctly implement the %E and %O format modifiers
in the strftime and strptime functions at one point.

The below patch adds these fields and the required changes to
timeformat.c and nl_langinfo.c.

Ok to apply?


Thanks,
Corinna

(*)
http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07


	* libc/locale/timelocal.h (struct lc_time_T): Add missing ERA-related
	members.
	* libc/locale/timelocal.c (_C_time_local): Set new members to empty
	strings.
	* libc/locale/nl_langinfo.c (nl_langinfo): Return values from
	__get_current_time_locale() for ERA related requests.


Index: libc/locale/timelocal.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/timelocal.h,v
retrieving revision 1.2
diff -u -p -r1.2 timelocal.h
--- libc/locale/timelocal.h	22 Jan 2010 13:03:42 -0000	1.2
+++ libc/locale/timelocal.h	18 Feb 2010 16:05:12 -0000
@@ -50,6 +50,11 @@ struct lc_time_T {
 	const char	*alt_month[12];
 	const char	*md_order;
 	const char	*ampm_fmt;
+	const char	*era;
+	const char	*era_d_fmt;
+	const char	*era_d_t_fmt;
+	const char	*era_t_fmt;
+	const char	*alt_digits;
 };
 
 struct lc_time_T *__get_current_time_locale(void);
Index: libc/locale/timelocal.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/timelocal.c,v
retrieving revision 1.3
diff -u -p -r1.3 timelocal.c
--- libc/locale/timelocal.c	9 Feb 2010 08:58:38 -0000	1.3
+++ libc/locale/timelocal.c	18 Feb 2010 16:05:12 -0000
@@ -92,7 +92,24 @@ static const struct lc_time_T	_C_time_lo
 	/* ampm_fmt
 	 * To determine 12-hour clock format time (empty, if N/A)
 	 */
-	"%I:%M:%S %p"
+	"%I:%M:%S %p",
+
+	/* Era.  This and the following entries are used if the alternative
+	 * date format is specified in strftime
+	 */
+	"",
+
+	/* Era date format used with the %Ex */
+	"",
+
+	/* Era date/time format (%Ec) */
+	"",
+
+	/* Era time format (%EX) */
+	"",
+
+	/* Alternate digits used if %O format prefix is specified */
+	""
 };
 
 struct lc_time_T *
Index: libc/locale/nl_langinfo.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/nl_langinfo.c,v
retrieving revision 1.8
diff -u -p -r1.8 nl_langinfo.c
--- libc/locale/nl_langinfo.c	6 Feb 2010 18:28:33 -0000	1.8
+++ libc/locale/nl_langinfo.c	18 Feb 2010 16:05:12 -0000
@@ -175,24 +175,19 @@ _DEFUN(nl_langinfo, (item), 
 		ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)];
 		break;
 	case ERA:
-		/* XXX: need to be implemented  */
-		ret = "";
+		ret = (char*) __get_current_time_locale()->era;
 		break;
 	case ERA_D_FMT:
-		/* XXX: need to be implemented  */
-		ret = "";
+		ret = (char*) __get_current_time_locale()->era_d_fmt;
 		break;
 	case ERA_D_T_FMT:
-		/* XXX: need to be implemented  */
-		ret = "";
+		ret = (char*) __get_current_time_locale()->era_d_t_fmt;
 		break;
 	case ERA_T_FMT:
-		/* XXX: need to be implemented  */
-		ret = "";
+		ret = (char*) __get_current_time_locale()->era_t_fmt;
 		break;
 	case ALT_DIGITS:
-		/* XXX: need to be implemented  */
-		ret = "";
+		ret = (char*) __get_current_time_locale()->alt_digits;
 		break;
 	case RADIXCHAR:
 		ret = (char*) __get_current_numeric_locale()->decimal_point;


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]