From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C0D2A1F9FD for ; Sun, 14 Mar 2021 18:33:40 +0000 (UTC) Received: from localhost ([::1]:46466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLVYZ-0006hF-DX for normalperson@yhbt.net; Sun, 14 Mar 2021 14:33:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLVYV-0006g1-Rb for bug-gnulib@gnu.org; Sun, 14 Mar 2021 14:33:35 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.217]:13294) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLVYT-0002Cf-38 for bug-gnulib@gnu.org; Sun, 14 Mar 2021 14:33:35 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1615746808; cv=none; d=strato.com; s=strato-dkim-0002; b=Wu/8QthZNiJjR+7byD6ban1TkXs0x7HTR3/0OZ7Hlv9LSzz3uvyS1X5HBDAhwg/fPm JynTyAeIp/VzVovatbz2CFY93H1ALUjrcsmCo5D5FrImXSJMqTJVz43E1VKL8g2I7wnU fTIBVO038AxHF0jzJt0geZezXPYoje71cNXsLaW2l0qsV7E9kQZrhtaMBnOWiqS/n9Et uxUUWULPfn3FYdhUBgMaOKr0wW5yZ8Cq/gAYl2f/Rbh+/VGndgDeJE9n+28zWi+i2uJ3 cTtL83VjhLtO9ZVLBb3B0EecFYIoCG/OBfRuaW4xS911r3WHjAO2xnQCxcKpQsQI2tWC uRBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1615746808; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=lvCbyPKzy5n+cctwxUASu0ShSv5HOt3EQW+No0n3Hwo=; b=eyyXg+PtfKnH/DEM8C3QgJTYY+tNeG7uyRcv06mQhO7KocZJjX93rf/avJhRc1bWSj mjgPSuRt0SNMX0yCKQrBuGXPYfzZOOSkbySTR+BfzponI6N+5dSit4PytC8tTf0Liept ZmJLmJ0rpCCaIEX6lmBVtAVj6k3QsUFrbfVfIFv+atqSE/pEmwRK1xm1zEh8DIHGTI3q vCEo3Ums3UGNWvaPz2PCUAY7v0i73lxahnURS8cOG7wGXFgzEb6MCfoaHNUdYvXht3NM 0g7n88RXXTnyRs0eOD11CI2PmEV8Q7zDEiFsB8vOycrSOLq/YPWJaXkOfA/eLNxUu1ys qWpA== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1615746808; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=lvCbyPKzy5n+cctwxUASu0ShSv5HOt3EQW+No0n3Hwo=; b=Vij8XK4bWfGo9/sG24cASAyhXASZe6F7hnC1FCpf/buzpFsURXLMdBmbT2MSkfIYM+ Z/1rAGwF85b8YjU7Se9ThybJYDHDd1SU+UhrSdaGUT44/Ze7i2bORyrRoWe1IxpplIxP JC8NJivFPKTQ7+/6mmjRkGE1Yc8JVxYO0OXv5eSse1zswRkSFEWeXA154BK0FqxZGXep sMf0D7pyKw1VLBio9dduozCA1S5gQWdhIYS2y1f6feqs653/ukwQoxZbsyovRCRxSvMq Ky1waD9jxH8nwZOywNA6u/9FuA6i7qaVvUTVf03bgNEg0Lp+ObvCJ5x+Q7mHDms3t7Ye yvTA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf0y5JW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.20.3 DYNA|AUTH) with ESMTPSA id n0b11fx2EIXRoy3 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 14 Mar 2021 19:33:27 +0100 (CET) From: Bruno Haible To: Paul Eggert Subject: Re: tzalloc (was: Re: parse-datetime test failure on NetBSD) Date: Sun, 14 Mar 2021 19:33:26 +0100 Message-ID: <4335650.5adnljZN5I@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <0fb6e643-87d6-52b0-ea86-455500d76e61@cs.ucla.edu> References: <20210314082409.m6twfv5m5a4d7i42@yt.nih.at> <3906602.FhTxbKHIuy@omega> <0fb6e643-87d6-52b0-ea86-455500d76e61@cs.ucla.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3041008.boT4JOvYm8" Content-Transfer-Encoding: 7Bit Received-SPF: none client-ip=81.169.146.217; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org, Thomas Klausner Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --nextPart3041008.boT4JOvYm8 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Paul Eggert wrote: > > On NetBSD, tzalloc() is in libc, and tzalloc("\\") returns NULL. > > On other platforms, tzalloc() comes from Gnulib, and tzalloc("\\") returns > > non-NULL. > > > > Which behaviour is correct? > > Both. The set of supported TZ values is system-dependent. OK, then we need to - conditionally disable the respective parts of the parse-datetime test (done through patch 1 below), - update the documentation of tzalloc to clarify that it may return NULL for arguments that the implementation considers as invalid. (done through patch 2 below). I also took the opportunity to move the documentation of the 'time_rz' module from the module description to the .h file. Why? - Because the usual places where people look for reference documentation are the manual and the .h files. They don't look in the module description. - Because the reference documentation refers to arguments of these functions, by name. One cannot understand the documentation if the function declarations are far away. Another thing: The module summary reads Reentrant time zone functions: localtime_rz, mktime_z, etc. What does the word "reentrant" mean here? Since the functions localtime_rz, mktime_z don't invoke themselves recursively with a different time zone argument, nor do they take function pointer parameters (callback), I think "reentrant" means nothing here. A close term is "multithread-safe". The API could be implemented in a multithread-safe way, but time_rz.c is not multithread-safe, due to the function 'change_env'. It is planned to provide a multithread-safe implementation at some point? Bruno --nextPart3041008.boT4JOvYm8 Content-Disposition: attachment; filename="0001-parse-datetime-tests-Avoid-a-test-failure-on-NetBSD.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-parse-datetime-tests-Avoid-a-test-failure-on-NetBSD.patch" >From 35f8ff2e1162bf3ee60d99b6812f2ae10f3f2898 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 14 Mar 2021 19:19:07 +0100 Subject: [PATCH 1/2] parse-datetime tests: Avoid a test failure on NetBSD. Reported by Thomas Klausner in . * tests/test-parse-datetime.c (main): Skip two tests on NetBSD. --- ChangeLog | 7 +++++++ tests/test-parse-datetime.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index a5ba848..63aaa7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-03-14 Bruno Haible + + parse-datetime tests: Avoid a test failure on NetBSD. + Reported by Thomas Klausner in + . + * tests/test-parse-datetime.c (main): Skip two tests on NetBSD. + 2021-03-10 Paul Eggert libc-config: port to DragonFlyBSD 5.9 diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c index acca47c..b972e96 100644 --- a/tests/test-parse-datetime.c +++ b/tests/test-parse-datetime.c @@ -431,8 +431,12 @@ main (int argc _GL_UNUSED, char **argv) ASSERT ( parse_datetime (&result, "TZ=\"\"", &now)); ASSERT ( parse_datetime (&result, "TZ=\"\" ", &now)); ASSERT ( parse_datetime (&result, " TZ=\"\"", &now)); + /* Exercise patterns which may be valid or invalid, depending on the + platform. */ +#if !defined __NetBSD__ ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now)); ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now)); +#endif /* Outlandishly-long time zone abbreviations should not cause problems. */ { -- 2.7.4 --nextPart3041008.boT4JOvYm8 Content-Disposition: attachment; filename="0002-time_rz-Put-reference-documentation-into-the-.h-file.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0002-time_rz-Put-reference-documentation-into-the-.h-file.patch" >From 02a474ef457f470776031b3cc38ee6e891dbff17 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 14 Mar 2021 19:22:07 +0100 Subject: [PATCH 2/2] time_rz: Put reference documentation into the .h file. * lib/time.in.h (timezone_t, tzalloc, tzfree, localtime_rz, mktime_z): Add comments, based on modules/time_rz. * modules/time_rz (Comment): Remove section. --- ChangeLog | 7 +++++++ lib/time.in.h | 42 ++++++++++++++++++++++++++++++++++++++++-- modules/time_rz | 11 ----------- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63aaa7b..b71c327 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2021-03-14 Bruno Haible + time_rz: Put reference documentation into the .h file. + * lib/time.in.h (timezone_t, tzalloc, tzfree, localtime_rz, mktime_z): + Add comments, based on modules/time_rz. + * modules/time_rz (Comment): Remove section. + +2021-03-14 Bruno Haible + parse-datetime tests: Avoid a test failure on NetBSD. Reported by Thomas Klausner in . diff --git a/lib/time.in.h b/lib/time.in.h index 4da1172..44483d0 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -340,22 +340,60 @@ _GL_CXXALIASWARN (strftime); # endif # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ +/* Functions that use a first-class time zone data type, instead of + relying on an implicit global time zone. + Inspired by NetBSD. */ + +/* Represents a time zone. + (timezone_t) NULL stands for UTC. */ typedef struct tm_zone *timezone_t; + +/* tzalloc (name) + Returns a time zone object for the given time zone NAME. This object + represents the time zone that other functions would use it the TZ + environment variable was set to NAME. + If NAME is NULL, the result represents the time zone that other functions + would use it the TZ environment variable was unset. + May return NULL if NAME is invalid (this is platform dependent) or + upon memory allocation failure. */ _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); + +/* tzfree (tz) + Frees a time zone object. + The argument must have been returned by tzalloc(). */ _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); + +/* localtime_rz (tz, &t, &result) + Converts an absolute time T to a broken-down time RESULT, assuming the + time zone TZ. + This function is like 'localtime_r', but relies on the argument TZ instead + of an implicit global time zone. */ _GL_FUNCDECL_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_SYS (localtime_rz, struct tm *, (timezone_t __tz, time_t const *restrict __timer, struct tm *restrict __result)); + +/* mktime_z (tz, &tm) + Normalizes the broken-down time TM and converts it to an absolute time, + assuming the time zone TZ. Returns the absolute time. + This function is like 'mktime', but relies on the argument TZ instead + of an implicit global time zone. */ _GL_FUNCDECL_SYS (mktime_z, time_t, - (timezone_t __tz, struct tm *restrict __result) + (timezone_t __tz, struct tm *restrict __tm) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_SYS (mktime_z, time_t, - (timezone_t __tz, struct tm *restrict __result)); + (timezone_t __tz, struct tm *restrict __tm)); + +/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' + in the 'tm_zone' member of 'struct tm') are valid as long as + - the 'struct tm' argument is not destroyed or overwritten, + and + - the 'timezone_t' argument is not freed through tzfree(). */ + # endif /* Convert TM to a time_t value, assuming UTC. */ diff --git a/modules/time_rz b/modules/time_rz index 6a2b23c..ebcef84 100644 --- a/modules/time_rz +++ b/modules/time_rz @@ -1,17 +1,6 @@ Description: Reentrant time zone functions: localtime_rz, mktime_z, etc. -Comment: -This implements the NetBSD-inspired extensions to , which -defines a type timezone_t and associated allocation functions tzalloc -and tzfree, along with two functions localtime_rz and mktime_z that -are like localtime_r and mktime except they have a new leading -timezone_t argument. Time zone abbreviation strings have lifetimes -equal to the corresponding struct tm or timezone_t object (whichever -is less). tzalloc (X) yields a time zone object equivalent to setting -the TZ environment variable to X. tzalloc (NULL) is the same as an -unset TZ environment variable. (timezone_t) 0 stands for UTC. - Files: lib/time-internal.h lib/time_rz.c -- 2.7.4 --nextPart3041008.boT4JOvYm8--