summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-11-30 19:24:07 +0000
committerache <ache@FreeBSD.org>1999-11-30 19:24:07 +0000
commit220fa3568085fd0ad052a65bf3f7f6065248e490 (patch)
tree27b3b9d8ce2ca7a51c9f4d37493d0eb5c0e61589
parent764544f79db5c70e43cf95469521d403163cab31 (diff)
downloadFreeBSD-src-220fa3568085fd0ad052a65bf3f7f6065248e490.zip
FreeBSD-src-220fa3568085fd0ad052a65bf3f7f6065248e490.tar.gz
%Ex -> %Ef to not conflict with POSIX
Add %EF (long months name / day order) Check that O and E not intermixed Add missing POSIX extension to example
-rw-r--r--lib/libc/stdtime/strftime.310
-rw-r--r--lib/libc/stdtime/strftime.c21
-rw-r--r--lib/libc/stdtime/strptime.c15
-rw-r--r--lib/libc/stdtime/timelocal.c17
-rw-r--r--lib/libc/stdtime/timelocal.h3
5 files changed, 53 insertions, 13 deletions
diff --git a/lib/libc/stdtime/strftime.3 b/lib/libc/stdtime/strftime.3
index 76a2e4e..c4d2d8c 100644
--- a/lib/libc/stdtime/strftime.3
+++ b/lib/libc/stdtime/strftime.3
@@ -106,12 +106,16 @@ is replaced by the day of the month as a decimal number (01-31).
.It Cm \&%E* Cm \&%O*
POSIX locale extensions.
The sequences
-%Ec %EC %Ex %Ey %EY
+%Ec %EC %Ex %EX %Ey %EY
%Od %Oe %OH %OI %Om %OM
%OS %Ou %OU %OV %Ow %OW %Oy
are supposed to provide alternate
-representations. Currently %Ex implemented to represent short month name / day
-order of the date and %OB to represent alternative months names
+representations.
+.Pp
+Additionly %Ef implemented to represent short month name / day
+order of the date, %EF to represent long month name / day
+order
+and %OB to represent alternative months names
(used standalone, without day mentioned).
.It Cm %e
is replaced by the day of month as a decimal number (1-31); single
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index aa38473..9aa891f 100644
--- a/lib/libc/stdtime/strftime.c
+++ b/lib/libc/stdtime/strftime.c
@@ -129,6 +129,8 @@ label:
pt = _conv(t->tm_mday, "%02d", pt, ptlim);
continue;
case 'E':
+ if (Ealternative || Oalternative)
+ break;
Ealternative++;
goto label;
case 'O':
@@ -136,18 +138,33 @@ label:
** POSIX locale extensions, a la
** Arnold Robbins' strftime version 3.0.
** The sequences
- ** %Ec %EC %Ex %Ey %EY
+ ** %Ec %EC %Ex %EX %Ey %EY
** %Od %oe %OH %OI %Om %OM
** %OS %Ou %OU %OV %Ow %OW %Oy
** are supposed to provide alternate
** representations.
** (ado, 5/24/93)
+ **
+ ** FreeBSD extensions
+ ** %OB %Ef %EF
*/
+ if (Ealternative || Oalternative)
+ break;
Oalternative++;
goto label;
case 'e':
pt = _conv(t->tm_mday, "%2d", pt, ptlim);
continue;
+ case 'f':
+ if (!Ealternative)
+ break;
+ pt = _fmt(Locale->Ef_fmt, t, pt, ptlim);
+ continue;
+ case 'F':
+ if (!Ealternative)
+ break;
+ pt = _fmt(Locale->EF_fmt, t, pt, ptlim);
+ continue;
case 'H':
pt = _conv(t->tm_hour, "%02d", pt, ptlim);
continue;
@@ -361,7 +378,7 @@ label:
pt = _fmt(Locale->X_fmt, t, pt, ptlim);
continue;
case 'x':
- pt = _fmt(Ealternative ? Locale->Ex_fmt : Locale->x_fmt, t, pt, ptlim);
+ pt = _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/strptime.c b/lib/libc/stdtime/strptime.c
index 687cafa..40ce9d9 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -152,13 +152,26 @@ label:
break;
case 'E':
+ if (Ealternative || Oalternative)
+ break;
Ealternative++;
goto label;
case 'O':
+ if (Ealternative || Oalternative)
+ break;
Oalternative++;
goto label;
+ case 'F':
+ case 'f':
+ if (!Ealternative)
+ break;
+ buf = _strptime(buf, (c == 'f') ? Locale->Ef_fmt : Locale->EF_fmt, tm);
+ if (buf == 0)
+ return 0;
+ break;
+
case 'R':
buf = _strptime(buf, "%H:%M", tm);
if (buf == 0)
@@ -184,7 +197,7 @@ label:
break;
case 'x':
- buf = _strptime(buf, Ealternative ? Locale->Ex_fmt : Locale->x_fmt, tm);
+ buf = _strptime(buf, Locale->x_fmt, tm);
if (buf == 0)
return 0;
break;
diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c
index 369feb7..a7d91e5 100644
--- a/lib/libc/stdtime/timelocal.c
+++ b/lib/libc/stdtime/timelocal.c
@@ -47,7 +47,7 @@ int _time_using_locale;
#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 *))
+ (offsetof(struct lc_time_T, Ef_fmt) / sizeof(char *))
const struct lc_time_T _C_time_locale = {
{
@@ -82,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 %Ex %X %Y",
+ "%a %Ef %X %Y",
/* am */
"AM",
@@ -91,17 +91,22 @@ const struct lc_time_T _C_time_locale = {
"PM",
/* date_fmt */
- "%a %Ex %X %Z %Y",
+ "%a %Ef %X %Z %Y",
{
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
},
- /* Ex_fmt
- ** To determine months / day order
+ /* Ef_fmt
+ ** To determine short months / day order
*/
- "%b %e"
+ "%b %e",
+
+ /* EF_fmt
+ ** To determine long months / day order
+ */
+ "%B %e"
};
diff --git a/lib/libc/stdtime/timelocal.h b/lib/libc/stdtime/timelocal.h
index 23673ca..19b9d21 100644
--- a/lib/libc/stdtime/timelocal.h
+++ b/lib/libc/stdtime/timelocal.h
@@ -42,7 +42,8 @@ struct lc_time_T {
const char * pm;
const char * date_fmt;
const char * alt_month[12];
- const char * Ex_fmt;
+ const char * Ef_fmt;
+ const char * EF_fmt;
};
extern struct lc_time_T _time_localebuf;
OpenPOWER on IntegriCloud