summaryrefslogtreecommitdiff
path: root/src/time/strptime.c
AgeCommit message (Collapse)AuthorLines
2026-03-30fix incorrect access to tzname[] by strptime %Z conversion specifierRich Felker-10/+3
there are three issues here: 1. if tzset has not been called (explicitly or implicitly), the tzname[] array will contain null pointers, and the dereference to compare against them has undefined behavior (and will fault). 2. access to tzname[] was performed without the timezone lock held. this resulted in a data race if the timezone is concurrently changed from another thread. 3. due to unintended signedness of the types, the open-coded isalpha in the non-matching case was wrong and would continue past null termination. to fix the first two issues, the body of the %Z conversion is moved to __tz.c where it has access to locking, and null checks are added. there is probably an argument to be made that the equivalent of tzset should happen here, but POSIX does not specify that to happen, so in the absence of an interpretation adding such an allowance or requirement, it is not done. the third issue is fixed just by using the existing isalpha macro.
2024-05-06strptime: implement conversion specifiers adopted for next POSIX issueRich Felker-1/+65
the %s conversion is added as the outcome of Austin Group tracker issue 169 and its unspecified behavior is clarified as the outcome of issue 1727. the %F, %g, %G, %u, %V, %z, and %Z conversions are added as the outcome of Austin Group tracker issue 879 for alignment with strftime and the behaviors of %u, %z, and %Z are defined as the outcome of issue 1727. at this time, the conversions with unspecified effects on struct tm are all left as parse-only no-ops. this may be changed at a later time, particularly for %s, if there is reasonable cross-implementation consensus outside the standards process on what the behavior should be.
2017-03-21fix strptime output for %C without %yJulien Ramseier-2/+3
in this case, a potentially-uninitialized or unrelated existing value in tm_year was being used. instead use 0 if %y was not present.
2017-03-21fix processing of strptime %p formatJulien Ramseier-0/+2
string pointer was not advanced after matching.
2017-03-21fix off-by-one in strptime %jJulien Ramseier-0/+1
tm_yday range is 0-365 while %j is 1-366
2016-10-20fix gratuitous undefined behavior in strptimeRich Felker-2/+7
accessing an object of type const char *restrict as if it had type char * is not defined.
2014-06-06implement %y and %C specifiers in strptimeTimo Teräs-4/+10
2014-05-19fix unhandled cases in strptimeRich Felker-5/+16
%C, %U, %W, and %y handling were completely missing; %C wrongly fell-through to unrelated cases, and the rest returned failure. for now, they all parse numbers in the proper forms and range-check the values, but they do not store the value anywhere. it's not clear to me whether, as "derived" fields, %U and %W should produce any result. they certainly cannot produce a result unless the year and weekday are also converted, but in this case it might be desirable for them to do so. clarification is needed on the intended behavior of strptime in cases like this. %C and %y have well-defined behavior as long as they are used together (and %y is defined by itself but may change in the future). implementing them (including their correct interaction) is left as a later change to be made. finally, strptime now rejects unknown/invalid format characters instead of ignoring them.
2013-12-12include cleanups: remove unused headers and add feature test macrosSzabolcs Nagy-1/+0
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker-1/+1
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2012-03-02fix bugs in strptime handling of string day/month names, literalsRich Felker-0/+2
2011-09-05strptime: fix use of uninitialized dest field in converting integerRich Felker-1/+1
2011-08-16partially working strptimeRich Felker-148/+149
it's missing at least: - derived fields - week numbers - short year (without century) support - locale modifiers
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+178