diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 5800fe83a0f7..aa3847368d22 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -75,10 +75,12 @@ _fmt(format, t, pt, ptlim) char *pt; const char *const ptlim; { - int alternative; + int Ealternative, Oalternative; + for ( ; *format; ++format) { if (*format == '%') { - alternative = 0; + Ealternative = 0; + Oalternative = 0; label: switch (*++format) { case '\0': @@ -96,7 +98,7 @@ _fmt(format, t, pt, ptlim) continue; case 'B': pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? - "?" : (alternative ? Locale->alt_month : + "?" : (Oalternative ? Locale->alt_month : Locale->month)[t->tm_mon], pt, ptlim); continue; @@ -127,6 +129,8 @@ _fmt(format, t, pt, ptlim) pt = _conv(t->tm_mday, "%02d", pt, ptlim); continue; case 'E': + Ealternative++; + goto label; case 'O': /* ** POSIX locale extensions, a la @@ -139,7 +143,7 @@ _fmt(format, t, pt, ptlim) ** representations. ** (ado, 5/24/93) */ - alternative = 1; + Oalternative++; goto label; case 'e': pt = _conv(t->tm_mday, "%2d", pt, ptlim); @@ -357,7 +361,7 @@ _fmt(format, t, pt, ptlim) pt = _fmt(Locale->X_fmt, t, pt, ptlim); continue; case 'x': - pt = _fmt(Locale->x_fmt, t, pt, ptlim); + pt = _fmt(Ealternative ? Locale->Ex_fmt : Locale->x_fmt, t, pt, ptlim); continue; case 'y': pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c index f58488a3bf9b..369feb7ccd97 100644 --- a/lib/libc/stdtime/timelocal.c +++ b/lib/libc/stdtime/timelocal.c @@ -46,6 +46,8 @@ int _time_using_locale; #define LCTIME_SIZE_FULL (sizeof(struct lc_time_T) / sizeof(char *)) #define LCTIME_SIZE_1 \ (offsetof(struct lc_time_T, alt_month[0]) / sizeof(char *)) +#define LCTIME_SIZE_2 \ + (offsetof(struct lc_time_T, Ex_fmt) / sizeof(char *)) const struct lc_time_T _C_time_locale = { { @@ -80,7 +82,7 @@ const struct lc_time_T _C_time_locale = { ** "%a %b %d %H:%M:%S %Y" ** is used by Solaris 2.3. */ - "%a %b %e %X %Y", + "%a %Ex %X %Y", /* am */ "AM", @@ -89,12 +91,17 @@ const struct lc_time_T _C_time_locale = { "PM", /* date_fmt */ - "%a %b %e %X %Z %Y", + "%a %Ex %X %Z %Y", { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - } + }, + + /* Ex_fmt + ** To determine months / day order + */ + "%b %e" }; @@ -173,6 +180,8 @@ __time_load_locale(const char *name) num_lines = split_lines(p, plim); if (num_lines >= LCTIME_SIZE_FULL) num_lines = LCTIME_SIZE_FULL; + else if (num_lines >= LCTIME_SIZE_2) + num_lines = LCTIME_SIZE_2; else if (num_lines >= LCTIME_SIZE_1) num_lines = LCTIME_SIZE_1; else diff --git a/lib/libc/stdtime/timelocal.h b/lib/libc/stdtime/timelocal.h index 9a19175deed7..23673ca80b19 100644 --- a/lib/libc/stdtime/timelocal.h +++ b/lib/libc/stdtime/timelocal.h @@ -42,6 +42,7 @@ struct lc_time_T { const char * pm; const char * date_fmt; const char * alt_month[12]; + const char * Ex_fmt; }; extern struct lc_time_T _time_localebuf;