From: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
To: linux-man@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>,
carlos@redhat.com, dj@redhat.com, eggert@cs.ucla.edu,
jens.gustedt@inria.fr, libc-alpha@sourceware.org,
rcseacord@gmail.com, vincent@vinc17.net, xry111@xry111.site
Subject: Re: [PATCH v3] ctime.3: EXAMPLES: Add example program
Date: Fri, 23 Aug 2024 12:31:01 -0600 [thread overview]
Message-ID: <e6395fed-ec28-41a2-bd48-ba6db2389a85@SystematicSW.ab.ca> (raw)
In-Reply-To: <jqdmfoxuecuevujyv66eyzg3xsvfhou4hhvvi5bachy4dujnhu@gwcgwegj7qml>
On 2024-08-23 08:25, Alejandro Colomar wrote:
> Hi Brian,
>
> On Fri, Aug 23, 2024 at 08:04:20AM GMT, Brian Inglis wrote:
>> AFAICS from 9899 1998 Draft to 2023, the *mktime* wording has been essentially:
>
> I find the above confusing. What is 9899 1998? The draft is for
> ISO/IEC 9899:2024. There's no 1998 in the name.
Sorry for the typo - from the original *1988* Draft from ANSI X3J11 88-090
1988-05-13 of ANSI/ISO/IEC 9899:1990 through 2023.
>> "The original values of the tm_wday and tm_yday components of the structure
>> are ignored, and the original values of the other components are not
>> restricted to the ranges indicated above. On successful completion, the
>> values of the tm_wday and tm_yday components of the structure are set
>> appropriately,"
>
> The text you've quoted is there since ISO C89.
> <https://port70.net/~nsz/c/c89/c89-draft.html#4.12.2.3>
>
> And that is not guarantee enough. It says that wday and yday are
> ignored (for the purposes of determining the return value). And it says
> that on success it modifies them. But that text is silent about what
> happens on error.
It states they are set on successful completion, and implied left alone if not.
> It is C23 in 7.19.2.3p3 which provides a novel guarantee, that those
^^^^^^^^^^
7.29.2.3.p3
See "WD" https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf#page=415
> fields won't be modified on a failed call.
>
>>
>> so the recommendation has been to do something like (pointless example):
>>
>> time_t tt = time(&tt);
>> struct tm *tm = localtime(&tt);
>> tm->tm_wday = tm->tm_yday = -1;
>> if ((tt = mktime(tm)) == -1 && tm->tm_wday == -1 && tm->tm_yday == -1)
>
> This conditional, just like the one in the POSIX 2024 standard, is
> redundant. Reading tm_wday is enough for determining a failure.
>
> Otherwise, what would you expect if tm_yday is 4 but tm_wday is -1? Half an error? :)
Checking both are still untouched guarantees an error!
If one is set, it's a QoI bug, not an error ;^>
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut
-- Antoine de Saint-Exupéry
next prev parent reply other threads:[~2024-08-23 18:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 23:11 [PATCH v4] ctime.3: Document how to detect invalid or ambiguous times Alejandro Colomar
[not found] ` <xned6jlywd.fsf@greed.delorie.com>
2024-08-22 23:49 ` [PATCH v3] ctime.3: EXAMPLES: Add example program Alejandro Colomar
2024-08-23 4:57 ` Paul Eggert
2024-08-23 7:02 ` Alejandro Colomar
2024-08-23 7:26 ` Xi Ruoyao
2024-08-23 7:57 ` Vincent Lefevre
2024-08-23 12:28 ` Alejandro Colomar
2024-08-23 12:28 ` Xi Ruoyao
2024-08-23 12:53 ` Vincent Lefevre
2024-08-23 13:12 ` Alejandro Colomar
2024-08-23 13:54 ` Vincent Lefevre
2024-08-23 14:18 ` Alejandro Colomar
2024-08-23 15:26 ` Vincent Lefevre
2024-08-23 17:48 ` Alejandro Colomar
2024-08-23 18:46 ` Robert Elz
2024-08-23 19:08 ` Paul Eggert
2024-08-23 20:09 ` Hans Åberg
2024-08-23 20:34 ` Alejandro Colomar
2024-08-23 14:04 ` Brian Inglis
2024-08-23 14:25 ` Alejandro Colomar
2024-08-23 18:31 ` Brian Inglis [this message]
2024-08-23 20:27 ` Alejandro Colomar
2024-08-24 8:46 ` [PATCH v5] ctime.3: Document how to detect invalid or ambiguous times Alejandro Colomar
2024-08-25 18:33 ` Alejandro Colomar
2024-08-30 11:09 ` [PATCH v6] ctime.3: EXAMPLES: " Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6395fed-ec28-41a2-bd48-ba6db2389a85@SystematicSW.ab.ca \
--to=brian.inglis@systematicsw.ab.ca \
--cc=alx@kernel.org \
--cc=carlos@redhat.com \
--cc=dj@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=jens.gustedt@inria.fr \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
--cc=rcseacord@gmail.com \
--cc=vincent@vinc17.net \
--cc=xry111@xry111.site \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox