stdtime: style(9) fixes.
Obtained from: illumos MFC after: 5 days
This commit is contained in:
parent
b95e9c279b
commit
269d4e1e64
@ -24,9 +24,9 @@
|
||||
#ifndef NOID
|
||||
static const char elsieid[] = "@(#)strftime.3 8.3";
|
||||
/*
|
||||
** Based on the UCB version with the ID appearing below.
|
||||
** This is ANSIish only when "multibyte character == plain character".
|
||||
*/
|
||||
* Based on the UCB version with the ID appearing below.
|
||||
* This is ANSIish only when "multibyte character == plain character".
|
||||
*/
|
||||
#endif /* !defined NOID */
|
||||
#endif /* !defined lint */
|
||||
|
||||
@ -57,32 +57,32 @@ extern char * tzname[];
|
||||
#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
|
||||
#endif /* !defined YEAR_2000_NAME */
|
||||
|
||||
#define IN_NONE 0
|
||||
#define IN_SOME 1
|
||||
#define IN_THIS 2
|
||||
#define IN_ALL 3
|
||||
#define IN_NONE 0
|
||||
#define IN_SOME 1
|
||||
#define IN_THIS 2
|
||||
#define IN_ALL 3
|
||||
|
||||
#define PAD_DEFAULT 0
|
||||
#define PAD_LESS 1
|
||||
#define PAD_SPACE 2
|
||||
#define PAD_ZERO 3
|
||||
#define PAD_DEFAULT 0
|
||||
#define PAD_LESS 1
|
||||
#define PAD_SPACE 2
|
||||
#define PAD_ZERO 3
|
||||
|
||||
static const char fmt_padding[][4][5] = {
|
||||
/* DEFAULT, LESS, SPACE, ZERO */
|
||||
#define PAD_FMT_MONTHDAY 0
|
||||
#define PAD_FMT_HMS 0
|
||||
#define PAD_FMT_CENTURY 0
|
||||
#define PAD_FMT_SHORTYEAR 0
|
||||
#define PAD_FMT_MONTH 0
|
||||
#define PAD_FMT_WEEKOFYEAR 0
|
||||
#define PAD_FMT_DAYOFMONTH 0
|
||||
#define PAD_FMT_MONTHDAY 0
|
||||
#define PAD_FMT_HMS 0
|
||||
#define PAD_FMT_CENTURY 0
|
||||
#define PAD_FMT_SHORTYEAR 0
|
||||
#define PAD_FMT_MONTH 0
|
||||
#define PAD_FMT_WEEKOFYEAR 0
|
||||
#define PAD_FMT_DAYOFMONTH 0
|
||||
{ "%02d", "%d", "%2d", "%02d" },
|
||||
#define PAD_FMT_SDAYOFMONTH 1
|
||||
#define PAD_FMT_SHMS 1
|
||||
#define PAD_FMT_SDAYOFMONTH 1
|
||||
#define PAD_FMT_SHMS 1
|
||||
{ "%2d", "%d", "%2d", "%02d" },
|
||||
#define PAD_FMT_DAYOFYEAR 2
|
||||
{ "%03d", "%d", "%3d", "%03d" },
|
||||
#define PAD_FMT_YEAR 3
|
||||
#define PAD_FMT_YEAR 3
|
||||
{ "%04d", "%d", "%4d", "%04d" }
|
||||
};
|
||||
|
||||
@ -114,7 +114,7 @@ strftime_l(char * __restrict s, size_t maxsize, const char * __restrict format,
|
||||
}
|
||||
#endif /* !defined NO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU */
|
||||
if (p == s + maxsize)
|
||||
return 0;
|
||||
return (0);
|
||||
*p = '\0';
|
||||
return p - s;
|
||||
}
|
||||
@ -176,12 +176,12 @@ label:
|
||||
continue;
|
||||
case 'C':
|
||||
/*
|
||||
** %C used to do a...
|
||||
** _fmt("%a %b %e %X %Y", t);
|
||||
** ...whereas now POSIX 1003.2 calls for
|
||||
** something completely different.
|
||||
** (ado, 1993-05-24)
|
||||
*/
|
||||
* %C used to do a...
|
||||
* _fmt("%a %b %e %X %Y", t);
|
||||
* ...whereas now POSIX 1003.2 calls for
|
||||
* something completely different.
|
||||
* (ado, 1993-05-24)
|
||||
*/
|
||||
pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 0,
|
||||
pt, ptlim);
|
||||
continue;
|
||||
@ -210,17 +210,17 @@ label:
|
||||
goto label;
|
||||
case 'O':
|
||||
/*
|
||||
** C99 locale modifiers.
|
||||
** The sequences
|
||||
** %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.
|
||||
**
|
||||
** FreeBSD extension
|
||||
** %OB
|
||||
*/
|
||||
* C99 locale modifiers.
|
||||
* The sequences
|
||||
* %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.
|
||||
*
|
||||
* FreeBSD extension
|
||||
* %OB
|
||||
*/
|
||||
if (Ealternative || Oalternative)
|
||||
break;
|
||||
Oalternative++;
|
||||
@ -239,7 +239,8 @@ label:
|
||||
case 'I':
|
||||
pt = _conv((t->tm_hour % 12) ?
|
||||
(t->tm_hour % 12) : 12,
|
||||
fmt_padding[PAD_FMT_HMS][PadIndex], pt, ptlim);
|
||||
fmt_padding[PAD_FMT_HMS][PadIndex],
|
||||
pt, ptlim);
|
||||
continue;
|
||||
case 'j':
|
||||
pt = _conv(t->tm_yday + 1,
|
||||
@ -247,15 +248,15 @@ label:
|
||||
continue;
|
||||
case 'k':
|
||||
/*
|
||||
** This used to be...
|
||||
** _conv(t->tm_hour % 12 ?
|
||||
** t->tm_hour % 12 : 12, 2, ' ');
|
||||
** ...and has been changed to the below to
|
||||
** match SunOS 4.1.1 and Arnold Robbins'
|
||||
** strftime version 3.0. That is, "%k" and
|
||||
** "%l" have been swapped.
|
||||
** (ado, 1993-05-24)
|
||||
*/
|
||||
* This used to be...
|
||||
* _conv(t->tm_hour % 12 ?
|
||||
* t->tm_hour % 12 : 12, 2, ' ');
|
||||
* ...and has been changed to the below to
|
||||
* match SunOS 4.1.1 and Arnold Robbins'
|
||||
* strftime version 3.0. That is, "%k" and
|
||||
* "%l" have been swapped.
|
||||
* (ado, 1993-05-24)
|
||||
*/
|
||||
pt = _conv(t->tm_hour, fmt_padding[PAD_FMT_SHMS][PadIndex],
|
||||
pt, ptlim);
|
||||
continue;
|
||||
@ -269,17 +270,18 @@ label:
|
||||
#endif /* defined KITCHEN_SINK */
|
||||
case 'l':
|
||||
/*
|
||||
** This used to be...
|
||||
** _conv(t->tm_hour, 2, ' ');
|
||||
** ...and has been changed to the below to
|
||||
** match SunOS 4.1.1 and Arnold Robbin's
|
||||
** strftime version 3.0. That is, "%k" and
|
||||
** "%l" have been swapped.
|
||||
** (ado, 1993-05-24)
|
||||
*/
|
||||
* This used to be...
|
||||
* _conv(t->tm_hour, 2, ' ');
|
||||
* ...and has been changed to the below to
|
||||
* match SunOS 4.1.1 and Arnold Robbin's
|
||||
* strftime version 3.0. That is, "%k" and
|
||||
* "%l" have been swapped.
|
||||
* (ado, 1993-05-24)
|
||||
*/
|
||||
pt = _conv((t->tm_hour % 12) ?
|
||||
(t->tm_hour % 12) : 12,
|
||||
fmt_padding[PAD_FMT_SHMS][PadIndex], pt, ptlim);
|
||||
fmt_padding[PAD_FMT_SHMS][PadIndex],
|
||||
pt, ptlim);
|
||||
continue;
|
||||
case 'M':
|
||||
pt = _conv(t->tm_min, fmt_padding[PAD_FMT_HMS][PadIndex],
|
||||
@ -287,15 +289,15 @@ label:
|
||||
continue;
|
||||
case 'm':
|
||||
pt = _conv(t->tm_mon + 1,
|
||||
fmt_padding[PAD_FMT_MONTH][PadIndex], pt, ptlim);
|
||||
fmt_padding[PAD_FMT_MONTH][PadIndex],
|
||||
pt, ptlim);
|
||||
continue;
|
||||
case 'n':
|
||||
pt = _add("\n", pt, ptlim);
|
||||
continue;
|
||||
case 'p':
|
||||
pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ?
|
||||
tptr->pm :
|
||||
tptr->am,
|
||||
tptr->pm : tptr->am,
|
||||
pt, ptlim);
|
||||
continue;
|
||||
case 'R':
|
||||
@ -339,11 +341,11 @@ label:
|
||||
continue;
|
||||
case 'u':
|
||||
/*
|
||||
** From Arnold Robbins' strftime version 3.0:
|
||||
** "ISO 8601: Weekday as a decimal number
|
||||
** [1 (Monday) - 7]"
|
||||
** (ado, 1993-05-24)
|
||||
*/
|
||||
* From Arnold Robbins' strftime version 3.0:
|
||||
* "ISO 8601: Weekday as a decimal number
|
||||
* [1 (Monday) - 7]"
|
||||
* (ado, 1993-05-24)
|
||||
*/
|
||||
pt = _conv((t->tm_wday == 0) ?
|
||||
DAYSPERWEEK : t->tm_wday,
|
||||
"%d", pt, ptlim);
|
||||
@ -352,23 +354,23 @@ label:
|
||||
case 'G': /* ISO 8601 year (four digits) */
|
||||
case 'g': /* ISO 8601 year (two digits) */
|
||||
/*
|
||||
** From Arnold Robbins' strftime version 3.0: "the week number of the
|
||||
** year (the first Monday as the first day of week 1) as a decimal number
|
||||
** (01-53)."
|
||||
** (ado, 1993-05-24)
|
||||
**
|
||||
** From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn:
|
||||
** "Week 01 of a year is per definition the first week which has the
|
||||
** Thursday in this year, which is equivalent to the week which contains
|
||||
** the fourth day of January. In other words, the first week of a new year
|
||||
** is the week which has the majority of its days in the new year. Week 01
|
||||
** might also contain days from the previous year and the week before week
|
||||
** 01 of a year is the last week (52 or 53) of the previous year even if
|
||||
** it contains days from the new year. A week starts with Monday (day 1)
|
||||
** and ends with Sunday (day 7). For example, the first week of the year
|
||||
** 1997 lasts from 1996-12-30 to 1997-01-05..."
|
||||
** (ado, 1996-01-02)
|
||||
*/
|
||||
* From Arnold Robbins' strftime version 3.0: "the week number of the
|
||||
* year (the first Monday as the first day of week 1) as a decimal number
|
||||
* (01-53)."
|
||||
* (ado, 1993-05-24)
|
||||
*
|
||||
* From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn:
|
||||
* "Week 01 of a year is per definition the first week which has the
|
||||
* Thursday in this year, which is equivalent to the week which contains
|
||||
* the fourth day of January. In other words, the first week of a new year
|
||||
* is the week which has the majority of its days in the new year. Week 01
|
||||
* might also contain days from the previous year and the week before week
|
||||
* 01 of a year is the last week (52 or 53) of the previous year even if
|
||||
* it contains days from the new year. A week starts with Monday (day 1)
|
||||
* and ends with Sunday (day 7). For example, the first week of the year
|
||||
* 1997 lasts from 1996-12-30 to 1997-01-05..."
|
||||
* (ado, 1996-01-02)
|
||||
*/
|
||||
{
|
||||
int year;
|
||||
int base;
|
||||
@ -389,15 +391,15 @@ label:
|
||||
DAYSPERLYEAR :
|
||||
DAYSPERNYEAR;
|
||||
/*
|
||||
** What yday (-3 ... 3) does
|
||||
** the ISO year begin on?
|
||||
*/
|
||||
* What yday (-3 ... 3) does
|
||||
* the ISO year begin on?
|
||||
*/
|
||||
bot = ((yday + 11 - wday) %
|
||||
DAYSPERWEEK) - 3;
|
||||
/*
|
||||
** What yday does the NEXT
|
||||
** ISO year begin on?
|
||||
*/
|
||||
* What yday does the NEXT
|
||||
* ISO year begin on?
|
||||
*/
|
||||
top = bot -
|
||||
(len % DAYSPERWEEK);
|
||||
if (top < -3)
|
||||
@ -438,10 +440,10 @@ label:
|
||||
continue;
|
||||
case 'v':
|
||||
/*
|
||||
** From Arnold Robbins' strftime version 3.0:
|
||||
** "date as dd-bbb-YYYY"
|
||||
** (ado, 1993-05-24)
|
||||
*/
|
||||
* From Arnold Robbins' strftime version 3.0:
|
||||
* "date as dd-bbb-YYYY"
|
||||
* (ado, 1993-05-24)
|
||||
*/
|
||||
pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp, loc);
|
||||
continue;
|
||||
case 'W':
|
||||
@ -487,10 +489,10 @@ label:
|
||||
pt = _add(tzname[t->tm_isdst != 0],
|
||||
pt, ptlim);
|
||||
/*
|
||||
** C99 says that %Z must be replaced by the
|
||||
** empty string if the time zone is not
|
||||
** determinable.
|
||||
*/
|
||||
* C99 says that %Z must be replaced by the
|
||||
* empty string if the time zone is not
|
||||
* determinable.
|
||||
*/
|
||||
continue;
|
||||
case 'z':
|
||||
{
|
||||
@ -503,24 +505,24 @@ label:
|
||||
diff = t->TM_GMTOFF;
|
||||
#else /* !defined TM_GMTOFF */
|
||||
/*
|
||||
** C99 says that the UTC offset must
|
||||
** be computed by looking only at
|
||||
** tm_isdst. This requirement is
|
||||
** incorrect, since it means the code
|
||||
** must rely on magic (in this case
|
||||
** altzone and timezone), and the
|
||||
** magic might not have the correct
|
||||
** offset. Doing things correctly is
|
||||
** tricky and requires disobeying C99;
|
||||
** see GNU C strftime for details.
|
||||
** For now, punt and conform to the
|
||||
** standard, even though it's incorrect.
|
||||
**
|
||||
** C99 says that %z must be replaced by the
|
||||
** empty string if the time zone is not
|
||||
** determinable, so output nothing if the
|
||||
** appropriate variables are not available.
|
||||
*/
|
||||
* C99 says that the UTC offset must
|
||||
* be computed by looking only at
|
||||
* tm_isdst. This requirement is
|
||||
* incorrect, since it means the code
|
||||
* must rely on magic (in this case
|
||||
* altzone and timezone), and the
|
||||
* magic might not have the correct
|
||||
* offset. Doing things correctly is
|
||||
* tricky and requires disobeying C99;
|
||||
* see GNU C strftime for details.
|
||||
* For now, punt and conform to the
|
||||
* standard, even though it's incorrect.
|
||||
*
|
||||
* C99 says that %z must be replaced by the
|
||||
* empty string if the time zone is not
|
||||
* determinable, so output nothing if the
|
||||
* appropriate variables are not available.
|
||||
*/
|
||||
if (t->tm_isdst == 0)
|
||||
#ifdef USG_COMPAT
|
||||
diff = -timezone;
|
||||
@ -537,7 +539,8 @@ label:
|
||||
if (diff < 0) {
|
||||
sign = "-";
|
||||
diff = -diff;
|
||||
} else sign = "+";
|
||||
} else
|
||||
sign = "+";
|
||||
pt = _add(sign, pt, ptlim);
|
||||
diff /= SECSPERMIN;
|
||||
diff = (diff / MINSPERHOUR) * 100 +
|
||||
@ -567,10 +570,10 @@ label:
|
||||
goto label;
|
||||
case '%':
|
||||
/*
|
||||
** X311J/88-090 (4.12.3.5): if conversion char is
|
||||
** undefined, behavior is undefined. Print out the
|
||||
** character itself as printf(3) also does.
|
||||
*/
|
||||
* X311J/88-090 (4.12.3.5): if conversion char is
|
||||
* undefined, behavior is undefined. Print out the
|
||||
* character itself as printf(3) also does.
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -579,7 +582,7 @@ label:
|
||||
break;
|
||||
*pt++ = *format;
|
||||
}
|
||||
return pt;
|
||||
return (pt);
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -603,16 +606,16 @@ const char * const ptlim;
|
||||
{
|
||||
while (pt < ptlim && (*pt = *str++) != '\0')
|
||||
++pt;
|
||||
return pt;
|
||||
return (pt);
|
||||
}
|
||||
|
||||
/*
|
||||
** POSIX and the C Standard are unclear or inconsistent about
|
||||
** what %C and %y do if the year is negative or exceeds 9999.
|
||||
** Use the convention that %C concatenated with %y yields the
|
||||
** same output as %Y, and that %Y contains at least 4 bytes,
|
||||
** with more only if necessary.
|
||||
*/
|
||||
* POSIX and the C Standard are unclear or inconsistent about
|
||||
* what %C and %y do if the year is negative or exceeds 9999.
|
||||
* Use the convention that %C concatenated with %y yields the
|
||||
* same output as %Y, and that %Y contains at least 4 bytes,
|
||||
* with more only if necessary.
|
||||
*/
|
||||
|
||||
static char *
|
||||
_yconv(a, b, convert_top, convert_yy, pt, ptlim)
|
||||
@ -626,7 +629,7 @@ const char * const ptlim;
|
||||
register int lead;
|
||||
register int trail;
|
||||
|
||||
#define DIVISOR 100
|
||||
#define DIVISOR 100
|
||||
trail = a % DIVISOR + b % DIVISOR;
|
||||
lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
|
||||
trail %= DIVISOR;
|
||||
@ -644,5 +647,5 @@ const char * const ptlim;
|
||||
}
|
||||
if (convert_yy)
|
||||
pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
|
||||
return pt;
|
||||
return (pt);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static char * _strptime(const char *, const char *, struct tm *, int *, locale_t);
|
||||
|
||||
#define asizeof(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
#define asizeof(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
static char *
|
||||
_strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
|
||||
@ -64,8 +64,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
|
||||
{
|
||||
char c;
|
||||
const char *ptr;
|
||||
int i,
|
||||
len;
|
||||
int i, len;
|
||||
int Ealternative, Oalternative;
|
||||
struct lc_time_T *tptr = __get_current_time_locale(locale);
|
||||
|
||||
@ -82,7 +81,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
|
||||
isspace_l((unsigned char)*buf, locale))
|
||||
buf++;
|
||||
else if (c != *buf++)
|
||||
return 0;
|
||||
return (NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -94,18 +93,18 @@ label:
|
||||
case 0:
|
||||
case '%':
|
||||
if (*buf++ != '%')
|
||||
return 0;
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case '+':
|
||||
buf = _strptime(buf, tptr->date_fmt, tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
/* XXX This will break for 3-digit centuries. */
|
||||
len = 2;
|
||||
@ -116,21 +115,21 @@ label:
|
||||
len--;
|
||||
}
|
||||
if (i < 19)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_year = i * 100 - 1900;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
buf = _strptime(buf, tptr->c_fmt, tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
buf = _strptime(buf, "%m/%d/%y", tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
@ -147,43 +146,43 @@ label:
|
||||
|
||||
case 'F':
|
||||
buf = _strptime(buf, "%Y-%m-%d", tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
buf = _strptime(buf, "%H:%M", tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
buf = _strptime(buf, tptr->ampm_fmt, tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
buf = _strptime(buf, "%H:%M:%S", tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
buf = _strptime(buf, tptr->X_fmt, tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
buf = _strptime(buf, tptr->x_fmt, tm, GMTp, locale);
|
||||
if (buf == 0)
|
||||
return 0;
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 3;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -193,7 +192,7 @@ label:
|
||||
len--;
|
||||
}
|
||||
if (i < 1 || i > 366)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_yday = i - 1;
|
||||
break;
|
||||
@ -205,7 +204,7 @@ label:
|
||||
break;
|
||||
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -217,11 +216,11 @@ label:
|
||||
|
||||
if (c == 'M') {
|
||||
if (i > 59)
|
||||
return 0;
|
||||
return (NULL);
|
||||
tm->tm_min = i;
|
||||
} else {
|
||||
if (i > 60)
|
||||
return 0;
|
||||
return (NULL);
|
||||
tm->tm_sec = i;
|
||||
}
|
||||
|
||||
@ -245,7 +244,7 @@ label:
|
||||
* digits if used incorrectly.
|
||||
*/
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -256,9 +255,9 @@ label:
|
||||
}
|
||||
if (c == 'H' || c == 'k') {
|
||||
if (i > 23)
|
||||
return 0;
|
||||
return (NULL);
|
||||
} else if (i > 12)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_hour = i;
|
||||
|
||||
@ -277,7 +276,7 @@ label:
|
||||
len = strlen(tptr->am);
|
||||
if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
|
||||
if (tm->tm_hour > 12)
|
||||
return 0;
|
||||
return (NULL);
|
||||
if (tm->tm_hour == 12)
|
||||
tm->tm_hour = 0;
|
||||
buf += len;
|
||||
@ -287,14 +286,14 @@ label:
|
||||
len = strlen(tptr->pm);
|
||||
if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
|
||||
if (tm->tm_hour > 12)
|
||||
return 0;
|
||||
return (NULL);
|
||||
if (tm->tm_hour != 12)
|
||||
tm->tm_hour += 12;
|
||||
buf += len;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
case 'A':
|
||||
case 'a':
|
||||
@ -309,7 +308,7 @@ label:
|
||||
break;
|
||||
}
|
||||
if (i == asizeof(tptr->weekday))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_wday = i;
|
||||
buf += len;
|
||||
@ -324,7 +323,7 @@ label:
|
||||
* range for now.
|
||||
*/
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -334,7 +333,7 @@ label:
|
||||
len--;
|
||||
}
|
||||
if (i > 53)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
if (*buf != 0 &&
|
||||
isspace_l((unsigned char)*buf, locale))
|
||||
@ -345,11 +344,11 @@ label:
|
||||
|
||||
case 'w':
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
i = *buf - '0';
|
||||
if (i > 6)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_wday = i;
|
||||
|
||||
@ -371,7 +370,7 @@ label:
|
||||
* digits if used incorrectly.
|
||||
*/
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -381,7 +380,7 @@ label:
|
||||
len--;
|
||||
}
|
||||
if (i > 31)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_mday = i;
|
||||
|
||||
@ -424,7 +423,7 @@ label:
|
||||
}
|
||||
}
|
||||
if (i == asizeof(tptr->month))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_mon = i;
|
||||
buf += len;
|
||||
@ -432,7 +431,7 @@ label:
|
||||
|
||||
case 'm':
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -442,7 +441,7 @@ label:
|
||||
len--;
|
||||
}
|
||||
if (i < 1 || i > 12)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_mon = i - 1;
|
||||
|
||||
@ -465,7 +464,7 @@ label:
|
||||
n = strtol_l(buf, &cp, 10, locale);
|
||||
if (errno == ERANGE || (long)(t = n) != n) {
|
||||
errno = sverrno;
|
||||
return 0;
|
||||
return (NULL);
|
||||
}
|
||||
errno = sverrno;
|
||||
buf = cp;
|
||||
@ -481,7 +480,7 @@ label:
|
||||
break;
|
||||
|
||||
if (!isdigit_l((unsigned char)*buf, locale))
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
len = (c == 'Y') ? 4 : 2;
|
||||
for (i = 0; len && *buf != 0 &&
|
||||
@ -495,7 +494,7 @@ label:
|
||||
if (c == 'y' && i < 69)
|
||||
i += 100;
|
||||
if (i < 0)
|
||||
return 0;
|
||||
return (NULL);
|
||||
|
||||
tm->tm_year = i;
|
||||
|
||||
@ -526,7 +525,7 @@ label:
|
||||
} else if (0 == strcmp(zonestr, tzname[1])) {
|
||||
tm->tm_isdst = 1;
|
||||
} else {
|
||||
return 0;
|
||||
return (NULL);
|
||||
}
|
||||
buf += cp - buf;
|
||||
}
|
||||
@ -541,7 +540,7 @@ label:
|
||||
if (*buf == '-')
|
||||
sign = -1;
|
||||
else
|
||||
return 0;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
buf++;
|
||||
@ -552,7 +551,7 @@ label:
|
||||
i += *buf - '0';
|
||||
buf++;
|
||||
} else
|
||||
return 0;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
tm->tm_hour -= sign * (i / 100);
|
||||
@ -562,7 +561,7 @@ label:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (char *)buf;
|
||||
return ((char *)buf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ struct xlocale_time {
|
||||
|
||||
struct xlocale_time __xlocale_global_time;
|
||||
|
||||
#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
|
||||
#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
|
||||
|
||||
static const struct lc_time_T _C_time_locale = {
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user