mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Decremement by 1 the value taken for %j before assigning it to tm_yday,
which is zero-based. Correct the range checking for the value taken for %S. Add %w for the day of the week (0-6). Accept (but do nothing with) %U and %W. The comment for this change was taken from NetBSD. These changes were made after several failed attempts to contact the author of our strptime.c . PR: 10131 Submitted by: tadf@kt.rim.or.jp (Tadayoshi Funaba)
This commit is contained in:
parent
646e0924a1
commit
33dbb0a630
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53083
@ -171,10 +171,10 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
|
||||
i *= 10;
|
||||
i += *buf - '0';
|
||||
}
|
||||
if (i > 365)
|
||||
if (i < 1 || i > 366)
|
||||
return 0;
|
||||
|
||||
tm->tm_yday = i;
|
||||
tm->tm_yday = i - 1;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
@ -189,13 +189,16 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
|
||||
i *= 10;
|
||||
i += *buf - '0';
|
||||
}
|
||||
if (i > 59)
|
||||
return 0;
|
||||
|
||||
if (c == 'M')
|
||||
if (c == 'M') {
|
||||
if (i > 59)
|
||||
return 0;
|
||||
tm->tm_min = i;
|
||||
else
|
||||
} else {
|
||||
if (i > 60)
|
||||
return 0;
|
||||
tm->tm_sec = i;
|
||||
}
|
||||
|
||||
if (*buf != 0 && isspace((unsigned char)*buf))
|
||||
while (*ptr != 0 && !isspace((unsigned char)*ptr))
|
||||
@ -271,6 +274,47 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
|
||||
buf += len;
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
case 'W':
|
||||
/*
|
||||
* XXX This is bogus, as we can not assume any valid
|
||||
* information present in the tm structure at this
|
||||
* point to calculate a real value, so just check the
|
||||
* range for now.
|
||||
*/
|
||||
if (!isdigit((unsigned char)*buf))
|
||||
return 0;
|
||||
|
||||
for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
|
||||
i *= 10;
|
||||
i += *buf - '0';
|
||||
}
|
||||
if (i > 53)
|
||||
return 0;
|
||||
|
||||
if (*buf != 0 && isspace((unsigned char)*buf))
|
||||
while (*ptr != 0 && !isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (!isdigit((unsigned char)*buf))
|
||||
return 0;
|
||||
|
||||
for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
|
||||
i *= 10;
|
||||
i += *buf - '0';
|
||||
}
|
||||
if (i > 6)
|
||||
return 0;
|
||||
|
||||
tm->tm_wday = i;
|
||||
|
||||
if (*buf != 0 && isspace((unsigned char)*buf))
|
||||
while (*ptr != 0 && !isspace((unsigned char)*ptr))
|
||||
ptr++;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'e':
|
||||
if (!isdigit((unsigned char)*buf))
|
||||
|
Loading…
Reference in New Issue
Block a user