summaryrefslogtreecommitdiff
path: root/lib/libc/stdtime/strptime.c
Commit message (Collapse)AuthorAgeFilesLines
* strptime: make %k and %l specifiers match their description inYuri Pankov2018-11-031-5/+12
| | | | | | | | | | | | strftime(3), and allow them to process space-padded input. PR: 230720 Submitted by: rlittle@inetco.com (original version) Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17761 Notes: svn path=/head/; revision=340106
* strptime: fix parsing of tm_year when both %C and %y appear in theYuri Pankov2018-10-171-9/+17
| | | | | | | | | | | | | | | | | | format string in arbitrary order. This makes the related test cases in lib/libc/tests/time (not yet connected to the build) pass. While here, don't error on negative tm_year value based on the APPLICATION USAGE in http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html (glibc does the same): tm_year is a signed value; therefore, years before 1900 may be represented. Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17550 Notes: svn path=/head/; revision=339408
* strptime: disallow zero hour for %I (defined by POSIX as [01,12]) and %lYuri Pankov2018-10-131-1/+1
| | | | | | | | | | (extension, defined in strftime(3) as 1-12). Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17543 Notes: svn path=/head/; revision=339346
* Disallow zero day of month from strptime("%d").Konstantin Belousov2018-10-081-1/+1
| | | | | | | | | | | | | | It is required by POSIX, specified in our man page, and followed by Linux. PR: 232072 Reported by: miguel_tete17@hotmail.com Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after: 1 week Notes: svn path=/head/; revision=339241
* libc: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-251-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326193
* 1) For already non-standard %z extension implement GNU compatible formats:Andrey A. Chernov2016-09-211-0/+6
| | | | | | | | | | +hh and -hh. 2) Check for incorrect values for %z. MFC after: 7 days Notes: svn path=/head/; revision=306109
* 1) Microoptimize %p case.Andrey A. Chernov2016-09-211-14/+26
| | | | | | | | | | | | | | | | | 2) Implememt %u for GNU compatibility. 3) Don't forget to advance buf for %w/%u. 4) Fail with incomplete week (week 0) request and no such week in the year. 5) Fix yday formula when Sunday requested and the week started from Monday. 6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u request. 7) Shift yday/wday to the first day of the year, if incomplete week (week 0) requested and no %w/%u used. MFC after: 7 days Notes: svn path=/head/; revision=306075
* 1) Fix the case we have less arguments for format string than we expected.Andrey A. Chernov2014-10-071-4/+3
| | | | | | | | | | 2) Return error on unsupported format specs. (both according to POSIX) PR: 93197 Notes: svn path=/head/; revision=272679
* Back out timegm error check from r272562.Andrey A. Chernov2014-10-071-2/+0
| | | | | | | | | | POSIX treats negative time_t as undefined (i.e. may be valid too, depends on system's policy we don't have) and we don't set EOVERFLOW in mktime/timegm as POSIX requires to surely distinguish -1 return as valid negative time from -1 as error return. Notes: svn path=/head/; revision=272678
* 1) For %Z format, understand "UTC" name too.Andrey A. Chernov2014-10-051-1/+5
| | | | | | | | 2) Return NULL if timegm() fails, because it means we can convert what we have in GMT to local time needed. Notes: svn path=/head/; revision=272562
* strptime: %s format fix.Pedro F. Giffuni2014-10-021-1/+4
| | | | | | | | | | | | | Almost never needed in real life because %s is tends to be only one format spec. 1) Return code of gmtime_r() is checked. 2) All flags are set. Submitted by: ache MFC after: 3 weeks Notes: svn path=/head/; revision=272441
* strptime: fix bug introduced in r272273.Pedro F. Giffuni2014-10-011-1/+2
| | | | | | | | | Reported by: portmgr (antoine) Fix by: Andrey Chernov, David Carlier PR: 137307 (follow up) Notes: svn path=/head/; revision=272387
* Add strptime(3) support for %U and %W (take 2)Pedro F. Giffuni2014-09-281-7/+119
| | | | | | | | | | | | | | | | | | | | | | | Add support for the missing POSIX-2001 %U and %W features: the existing FreeBSD strptime code recognizes both directives and validates that the week number lies in the permitted range, but then simply discards the value. Initial support for the feature was written by Paul Green. David Carlier added the initial handling of tm_wday/tm_yday. Major credit goes to Andrey Chernov for detecting much of the brokenness, and rewriting/cleaning most of the code, making it much more robust. Tested independently with the strptime test from the GNU C library. PR: 137307 MFC after: 1 month Relnotes: yes Notes: svn path=/head/; revision=272273
* Revert r272122Pedro F. Giffuni2014-09-251-126/+5
| | | | | | | | | | | | The patch still needs to be more robust and it broke the build on MIPS so revert it for now while all the issues are fixed. Reported by: ache, davide PR: 137307 Notes: svn path=/head/; revision=272146
* Add strptime(3) support for %U and %WPedro F. Giffuni2014-09-251-5/+126
| | | | | | | | | | | | | | | | | Add support for the missing POSIX-2001 %U and %W features: the existing FreeBSD strptime code recognizes both directives and validates that the week number lies in the permitted range, but then simply discards the value. Initial support for the feature was written by Paul Green with important fixes by Andrey Chernov. Additional support for handling tm_wday/tm_yday was written by David Carlier. PR: 137307 MFC after: 1 month Notes: svn path=/head/; revision=272122
* strptime: add support for %t and %nPedro F. Giffuni2014-06-181-38/+20
| | | | | | | | | | | | | | | | | | Posix strptime() requires support for %t and %n, which were added to the illumos port. Curiously we were skipping white spaces by default in most other cases making %t meaningless. We now skip spaces in the case of the %e specifier as strftime(3) explicitly adds a space for the single digit case. Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html Obtained from: Illumos (Rev. a11c1571b6942161b0186d0588609448066892c2) MFC after: 3 weeks Notes: svn path=/head/; revision=267627
* stdtime: style(9) fixes.Pedro F. Giffuni2014-06-181-53/+52
| | | | | | | | Obtained from: illumos MFC after: 5 days Notes: svn path=/head/; revision=267601
* Update license to strptime(3) implementation.Pedro F. Giffuni2014-06-161-28/+5
| | | | | | | | | | | | | | | | | | | | | | | Our strptime(3) implementation was the base for the illumos implementation and after contacting the author, Kevin Rudy stated the code is under a 2-Clause BSD License [1] After reviewing our local changes to the file in question, the FreeBSD Foundation has agreed that their contributions to this file are not required to carry clause 3 or 4 so the file can be relicensed as in Illumos [2]. References: [1] https://www.illumos.org/issues/357 [2] Illumos Revision: 13222:02526851ba75 Approved: core (jhb) Approved: FreeBSD Foundation (emaste) MFC after: 4 days Notes: svn path=/head/; revision=267544
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-201-65/+105
| | | | | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) Notes: svn path=/head/; revision=227753
* strptime(3) confused July with June with the fr_FR locale.Edwin Groothuis2010-05-091-0/+8
| | | | | | | | | | | | | | | | When parsing the month "juillet" (abbr "jul"), %B recognized it as "juin" (abbr "jui") because the full name of the month names is checked at the same time as the abbrevation. The new behaviour checks the full names first before checking the abbrevation names. PR: kern/141939 Submitted by: Denis Chatelain <denis@tikuts.com> MFC after: 1 week Notes: svn path=/head/; revision=207830
* Use (unsigned char) cast for ctype macroAndrey A. Chernov2009-09-021-1/+1
| | | | Notes: svn path=/head/; revision=196752
* Implement %z for strptime.Xin LI2009-06-251-0/+28
| | | | | | | | | PR: kern/63064 Submitted by: Stefan `Sec` Zehl <sec 42 org> (with some small changes) MFC after: 1 month Notes: svn path=/head/; revision=195015
* Detect range errors when using the %s specifier. Previously, LONG_MAXJacques Vidrine2003-11-171-3/+10
| | | | | | | | | | was rejected as a range error, while any values less than LONG_MIN were silently substituted with LONG_MIN. Furthermore, on some platforms `time_t' has less range than `long' (e.g. alpha), which may give incorrect results when parsing some strings. Notes: svn path=/head/; revision=122830
* Backout my changes in rev. 1.32 and 1.33. There is some code that dependsMike Makonnen2003-04-301-4/+2
| | | | | | | | | | on the previous behaviour. This also brings strptime(3) behaviour back in line with the other BSDs. Approved by: markm (mentor) Notes: svn path=/head/; revision=114285
* Zero out the struct tm supplied by the caller. Otherwise,Mike Makonnen2003-04-051-0/+1
| | | | | | | | | | | strange things might happen when garbage values in the struct get passed in to localtime_r() and family. Noticed by: marcus Approved by: markm (mentor)(implicit) Notes: svn path=/head/; revision=113104
* Fill in the rest of the fields in the resulting struct tmMike Makonnen2003-03-291-2/+3
| | | | | | | | | | | | | from strptime(3). Previously, they would get filled only for the %s specifier and as a side effect of using the the %Z specifier with a GMT time zone. PR: misc/48993 Approved by: markm (mentor) Silence on: -standards Notes: svn path=/head/; revision=112787
* Ditch a static global and the mutex that protected it. Achieve theMike Makonnen2003-03-121-27/+18
| | | | | | | | | | | desired strptime(3) reentrancy by adding an extra argument to _strptime() instead. Approved by: markm (mentor) MFC: 4 weeks Notes: svn path=/head/; revision=112156
* Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).Jacques Vidrine2003-02-161-3/+3
| | | | | | | | | | Only warnings that could be fixed without changing the generated object code and without restructuring the source code have been handled. Reviewed by: /sbin/md5 Notes: svn path=/head/; revision=111010
* Style: One space between "restrict" qualifier and "*".Tim J. Robbins2002-09-061-2/+2
| | | | Notes: svn path=/head/; revision=103012
* - Add the C99 'restrict' qualifier using the '__restrict' macro toRobert Drehmel2002-08-141-1/+2
| | | | | | | | function prototype and definition of strptime(3). - Update the manual page. Notes: svn path=/head/; revision=101886
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-5/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Recognize the %s format.Dima Dorfman2001-07-131-0/+16
| | | | | | | | | Submitted by: Thomas Zenker <thz@lennartz-electronic.de> and Maxim Konovalov <maxim@macomnet.ru>, respectively Reviewed by: -audit Notes: svn path=/head/; revision=79664
* Get rid of non-standard %E[Ff] formats, userland apps already fixedAndrey A. Chernov2001-03-211-16/+1
| | | | Notes: svn path=/head/; revision=74578
* Relax local FreeBSD restrictions on 3 chars abbrev. name length and %c formatAndrey A. Chernov2001-03-181-2/+13
| | | | | | | | | | | | | | | since they not allows POSIXly legal locale data. Currently, if relaxed form POSIXly legal locale data will be used right now, some programs will be broken, but it means that either locale data or programs must be fixed, not the library. Introduce non-standard md_order (month/day order) locale field to be used later via nl_langinfo(). Currently %EF and %Ef emulated using this field, but they planned for remove in future in favour of nl_langinfo() test field. Implement %F per POSIX Notes: svn path=/head/; revision=74412
* Make 'A' and 'a', 'B' and 'b' the same, per POSIXAndrey A. Chernov2001-03-181-26/+16
| | | | Notes: svn path=/head/; revision=74409
* Implement ampm_fmt (%r) per POSIXAndrey A. Chernov2001-03-021-1/+1
| | | | Notes: svn path=/head/; revision=73359
* Hardcode c_fmt in a different way since used in nl_langinfo nowAndrey A. Chernov2001-02-081-2/+2
| | | | Notes: svn path=/head/; revision=72183
* Catch up to latest chanage in timelocal structures exporting.Alexey Zelkin2001-02-081-22/+23
| | | | Notes: svn path=/head/; revision=72168
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch Notes: svn path=/head/; revision=71579
* Force "%c" to be ctime-compatibleAndrey A. Chernov2000-10-261-1/+2
| | | | | | | Submitted by: ru Notes: svn path=/head/; revision=67632
* Prevent digit-gobbling for all but %l and %e, which can't be fixed.Sheldon Hearn1999-12-081-12/+46
| | | | | | | | | | | Discuss in the BUGS section of the manpage, problems involved with the use of %C, %e, %l, %p, %U and %W. PR: 13901 Reported by: scott@chronis.pobox.com Notes: svn path=/head/; revision=54316
* Accept 12 for %l, because it's logical to expect "%l:%M" to work forSheldon Hearn1999-12-081-1/+1
| | | | | | | "12:00" and because strftime(3) does the same. Notes: svn path=/head/; revision=54301
* %Ex -> %Ef to not conflict with POSIXAndrey A. Chernov1999-11-301-1/+14
| | | | | | | | | Add %EF (long months name / day order) Check that O and E not intermixed Add missing POSIX extension to example Notes: svn path=/head/; revision=53960
* Stricter checking %A vs %aAndrey A. Chernov1999-11-301-11/+13
| | | | Notes: svn path=/head/; revision=53942
* Fix %C handlingAndrey A. Chernov1999-11-301-14/+52
| | | | | | | | | Use locale for %c Add %+ Add %Ex and %OB Notes: svn path=/head/; revision=53941
* Decremement by 1 the value taken for %j before assigning it to tm_yday,Sheldon Hearn1999-11-101-6/+50
| | | | | | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=53083
* Add unsigned char cast to isupperAndrey A. Chernov1999-11-041-1/+1
| | | | Notes: svn path=/head/; revision=52860
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Make the new %Z addition thread-safe.David E. O'Brien1999-07-061-19/+49
| | | | Notes: svn path=/head/; revision=48614
* Actually impliment the documented %Z specifier.David E. O'Brien1999-07-041-1/+32
| | | | Notes: svn path=/head/; revision=48550