summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime/strftime.c
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/strftime.c
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/strftime.c')
-rw-r--r--lib/libc/stdtime/strftime.c14
1 files changed, 9 insertions, 5 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,
OpenPOWER on IntegriCloud