1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Catch up to latest chanage in timelocal structures exporting.

This commit is contained in:
Alexey Zelkin 2001-02-08 17:08:13 +00:00
parent 18f3e1e400
commit 930cd71107
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72168
2 changed files with 36 additions and 34 deletions

View File

@ -78,6 +78,7 @@ _fmt(format, t, pt, ptlim)
const char *const ptlim;
{
int Ealternative, Oalternative;
struct lc_time_T *tptr = __get_current_time_locale();
for ( ; *format; ++format) {
if (*format == '%') {
@ -90,24 +91,24 @@ _fmt(format, t, pt, ptlim)
break;
case 'A':
pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
"?" : Locale->weekday[t->tm_wday],
"?" : tptr->weekday[t->tm_wday],
pt, ptlim);
continue;
case 'a':
pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
"?" : Locale->wday[t->tm_wday],
"?" : tptr->wday[t->tm_wday],
pt, ptlim);
continue;
case 'B':
pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
"?" : (Oalternative ? Locale->alt_month :
Locale->month)[t->tm_mon],
"?" : (Oalternative ? tptr->alt_month :
tptr->month)[t->tm_mon],
pt, ptlim);
continue;
case 'b':
case 'h':
pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
"?" : Locale->mon[t->tm_mon],
"?" : tptr->mon[t->tm_mon],
pt, ptlim);
continue;
case 'C':
@ -161,12 +162,12 @@ _fmt(format, t, pt, ptlim)
case 'f':
if (!Ealternative)
break;
pt = _fmt(Locale->Ef_fmt, t, pt, ptlim);
pt = _fmt(tptr->Ef_fmt, t, pt, ptlim);
continue;
case 'F':
if (!Ealternative)
break;
pt = _fmt(Locale->EF_fmt, t, pt, ptlim);
pt = _fmt(tptr->EF_fmt, t, pt, ptlim);
continue;
case 'H':
pt = _conv(t->tm_hour, "%02d", pt, ptlim);
@ -225,8 +226,8 @@ _fmt(format, t, pt, ptlim)
continue;
case 'p':
pt = _add((t->tm_hour >= 12) ?
Locale->pm :
Locale->am,
tptr->pm :
tptr->am,
pt, ptlim);
continue;
case 'R':
@ -378,10 +379,10 @@ _fmt(format, t, pt, ptlim)
pt = _conv(t->tm_wday, "%d", pt, ptlim);
continue;
case 'X':
pt = _fmt(Locale->X_fmt, t, pt, ptlim);
pt = _fmt(tptr->X_fmt, t, pt, ptlim);
continue;
case 'x':
pt = _fmt(Locale->x_fmt, t, pt, ptlim);
pt = _fmt(tptr->x_fmt, t, pt, ptlim);
continue;
case 'y':
pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,
@ -417,7 +418,7 @@ _fmt(format, t, pt, ptlim)
};
continue;
case '+':
pt = _fmt(Locale->date_fmt, t, pt, ptlim);
pt = _fmt(tptr->date_fmt, t, pt, ptlim);
continue;
case '%':
/*

View File

@ -88,6 +88,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
int i,
len;
int Ealternative, Oalternative;
struct lc_time_T *tptr = __get_current_time_locale();
ptr = fmt;
while (*ptr != 0) {
@ -117,7 +118,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
break;
case '+':
buf = _strptime(buf, Locale->date_fmt, tm);
buf = _strptime(buf, tptr->date_fmt, tm);
if (buf == 0)
return 0;
break;
@ -168,7 +169,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
case 'f':
if (!Ealternative)
break;
buf = _strptime(buf, (c == 'f') ? Locale->Ef_fmt : Locale->EF_fmt, tm);
buf = _strptime(buf, (c == 'f') ? tptr->Ef_fmt : tptr->EF_fmt, tm);
if (buf == 0)
return 0;
break;
@ -192,13 +193,13 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
break;
case 'X':
buf = _strptime(buf, Locale->X_fmt, tm);
buf = _strptime(buf, tptr->X_fmt, tm);
if (buf == 0)
return 0;
break;
case 'x':
buf = _strptime(buf, Locale->x_fmt, tm);
buf = _strptime(buf, tptr->x_fmt, tm);
if (buf == 0)
return 0;
break;
@ -288,8 +289,8 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
* XXX This is bogus if parsed before hour-related
* specifiers.
*/
len = strlen(Locale->am);
if (strncasecmp(buf, Locale->am, len) == 0) {
len = strlen(tptr->am);
if (strncasecmp(buf, tptr->am, len) == 0) {
if (tm->tm_hour > 12)
return 0;
if (tm->tm_hour == 12)
@ -298,8 +299,8 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
break;
}
len = strlen(Locale->pm);
if (strncasecmp(buf, Locale->pm, len) == 0) {
len = strlen(tptr->pm);
if (strncasecmp(buf, tptr->pm, len) == 0) {
if (tm->tm_hour > 12)
return 0;
if (tm->tm_hour != 12)
@ -312,22 +313,22 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
case 'A':
case 'a':
for (i = 0; i < asizeof(Locale->weekday); i++) {
for (i = 0; i < asizeof(tptr->weekday); i++) {
if (c == 'A') {
len = strlen(Locale->weekday[i]);
len = strlen(tptr->weekday[i]);
if (strncasecmp(buf,
Locale->weekday[i],
tptr->weekday[i],
len) == 0)
break;
} else {
len = strlen(Locale->wday[i]);
len = strlen(tptr->wday[i]);
if (strncasecmp(buf,
Locale->wday[i],
tptr->wday[i],
len) == 0)
break;
}
}
if (i == asizeof(Locale->weekday))
if (i == asizeof(tptr->weekday))
return 0;
tm->tm_wday = i;
@ -406,32 +407,32 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
case 'B':
case 'b':
case 'h':
for (i = 0; i < asizeof(Locale->month); i++) {
for (i = 0; i < asizeof(tptr->month); i++) {
if (Oalternative) {
if (c == 'B') {
len = strlen(Locale->alt_month[i]);
len = strlen(tptr->alt_month[i]);
if (strncasecmp(buf,
Locale->alt_month[i],
tptr->alt_month[i],
len) == 0)
break;
}
} else {
if (c == 'B') {
len = strlen(Locale->month[i]);
len = strlen(tptr->month[i]);
if (strncasecmp(buf,
Locale->month[i],
tptr->month[i],
len) == 0)
break;
} else {
len = strlen(Locale->mon[i]);
len = strlen(tptr->mon[i]);
if (strncasecmp(buf,
Locale->mon[i],
tptr->mon[i],
len) == 0)
break;
}
}
}
if (i == asizeof(Locale->month))
if (i == asizeof(tptr->month))
return 0;
tm->tm_mon = i;