summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-11-30 07:33:37 +0000
committerache <ache@FreeBSD.org>1999-11-30 07:33:37 +0000
commitf72436c9ac0e62843a4d82fa347eed75eee8bf41 (patch)
treebce4c735034e8cdcb3ae5708ef0a97dad69c9124 /lib/libc/stdtime
parent99833e1e47956499465d11f07804b5bea35fe954 (diff)
downloadFreeBSD-src-f72436c9ac0e62843a4d82fa347eed75eee8bf41.zip
FreeBSD-src-f72436c9ac0e62843a4d82fa347eed75eee8bf41.tar.gz
Add %Ex extension to determine "%e %b" or "%b %e" order
Separate alternative for O and E cases
Diffstat (limited to 'lib/libc/stdtime')
-rw-r--r--lib/libc/stdtime/strftime.c14
-rw-r--r--lib/libc/stdtime/timelocal.c15
-rw-r--r--lib/libc/stdtime/timelocal.h1
3 files changed, 22 insertions, 8 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index 5800fe8..aa38473 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 @@ label:
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 @@ label:
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 @@ label:
** representations.
** (ado, 5/24/93)
*/
- alternative = 1;
+ Oalternative++;
goto label;
case 'e':
pt = _conv(t->tm_mday, "%2d", pt, ptlim);
@@ -357,7 +361,7 @@ label:
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 f58488a..369feb7 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 9a19175..23673ca 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;
OpenPOWER on IntegriCloud