Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Oct 2018 14:47:22 +0000
From:      bugzilla-noreply@freebsd.org
To:        standards@FreeBSD.org
Subject:   [Bug 232072] Parsing error with format "%d" in strptime(3)
Message-ID:  <bug-232072-99@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232072

            Bug ID: 232072
           Summary: Parsing error with format "%d" in strptime(3)
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: standards
          Assignee: standards@FreeBSD.org
          Reporter: miguel_tete17@hotmail.com

the format "%d" in the c function strptime(3) does not conform to what the
documentation says
(https://www.freebsd.org/cgi/man.cgi?query=3Dstrptime&sektion=3D3&manpath=
=3Dfreebsd-release-ports)

It is supposed to allow numbers between "01" and "31" but it also allows "0=
0".
I am not sure if it is a bug or just the FreeBSD way of doing this function.
To my knowledge GNU has the fore mentioned behaviour.

Small c++ code to reproduce the error:

########################################################
#include<iostream>
#include<ctime>

int main()
{
       struct tm tm;
       if(strptime("00", "%d", &tm))
       {
               std::cout << "WRONG" << std::endl;
       }
       else
       {
               std::cout << "OK" << std::endl;
       }
}
########################################################

just execute=20
clang++ main.cpp && ./a.out

EXPECTED:
OK

GOT:
WRONG

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-232072-99>