From unknown Sun Jun 22 22:47:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21126: Merge gnulib time_rz changes into coreutils Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 24 Jul 2015 01:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21126 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 21126@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.143770293027076 (code B ref -1); Fri, 24 Jul 2015 01:56:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Jul 2015 01:55:30 +0000 Received: from localhost ([127.0.0.1]:57631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZISCv-00072d-BT for submit@debbugs.gnu.org; Thu, 23 Jul 2015 21:55:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56842) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZISCs-00072T-30 for submit@debbugs.gnu.org; Thu, 23 Jul 2015 21:55:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZISCq-00063V-Bk for submit@debbugs.gnu.org; Thu, 23 Jul 2015 21:55:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:58519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZISCq-00063R-8c for submit@debbugs.gnu.org; Thu, 23 Jul 2015 21:55:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZISCo-0003pv-CU for bug-coreutils@gnu.org; Thu, 23 Jul 2015 21:55:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZISCj-0005vc-8M for bug-coreutils@gnu.org; Thu, 23 Jul 2015 21:55:22 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:54727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZISCi-0005vC-VH for bug-coreutils@gnu.org; Thu, 23 Jul 2015 21:55:17 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id ED044160193 for ; Thu, 23 Jul 2015 18:55:15 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id uMcnTpQokdXi for ; Thu, 23 Jul 2015 18:55:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B7E381601B0 for ; Thu, 23 Jul 2015 18:55:14 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id udPLXj8l3wMW for ; Thu, 23 Jul 2015 18:55:14 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 8900F160193 for ; Thu, 23 Jul 2015 18:55:14 -0700 (PDT) Message-ID: <55B19B02.2020600@cs.ucla.edu> Date: Thu, 23 Jul 2015 18:55:14 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090309050903060508050100" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This is a multi-part message in MIME format. --------------090309050903060508050100 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Tags: patch I just installed some incompatible changes into gnulib for time zone handling. The attached patches (just installed into coreutils) makes coreutils work with the new API. Eventually, I hope to get this new API into glibc, but one thing at a time. --------------090309050903060508050100 Content-Type: text/x-diff; name="0001-build-update-gnulib-submodule-to-latest.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-build-update-gnulib-submodule-to-latest.patch" >From 0806daf566f36940ec71306b6c519b3038bef9e6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Jul 2015 18:33:59 -0700 Subject: [PATCH 1/2] build: update gnulib submodule to latest --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index d03962a..a89e344 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit d03962a999263ee24acbf4fe1f87eecdd2b7ba71 +Subproject commit a89e3449698f97ea0f9c5fbd73aa054009858471 -- 2.1.0 --------------090309050903060508050100 Content-Type: text/x-diff; name="0002-build-fprintftime-nstrftime-API-changes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-build-fprintftime-nstrftime-API-changes.patch" >From 74674a1fa303e3637a03ea695ffd4564f412d766 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Jul 2015 18:49:31 -0700 Subject: [PATCH 2/2] build: fprintftime/nstrftime API changes * bootstrap.conf (gnulib_modules): Add time_rz, since the main source code now uses timezone_t. * src/date.c (batch_convert, main, show_date): * src/ls.c (align_nstrftime, long_time_expected_width) (print_long_format): * src/stat.c (human_time): Use timezone_t rather than boolean to specify which time zone is wanted. * src/ls.c (localtz): New static var. (main): Initialize it. --- bootstrap.conf | 1 + src/date.c | 16 +++++++++------- src/ls.c | 15 +++++++++++---- src/stat.c | 5 ++++- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 67837b3..5c6d2bf 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -240,6 +240,7 @@ gnulib_modules=" sys_wait tempname termios + time_rz timer-time timespec tzset diff --git a/src/date.c b/src/date.c index eaee8b2..fae0256 100644 --- a/src/date.c +++ b/src/date.c @@ -38,7 +38,7 @@ #define AUTHORS proper_name ("David MacKenzie") -static bool show_date (const char *format, struct timespec when); +static bool show_date (const char *, struct timespec, timezone_t); enum Time_spec { @@ -272,7 +272,7 @@ Show the local time for 9AM next Friday on the west coast of the US\n\ Return true if successful. */ static bool -batch_convert (const char *input_filename, const char *format) +batch_convert (const char *input_filename, const char *format, timezone_t tz) { bool ok; FILE *in_stream; @@ -315,7 +315,7 @@ batch_convert (const char *input_filename, const char *format) } else { - ok &= show_date (format, when); + ok &= show_date (format, when, tz); } } @@ -485,8 +485,10 @@ main (int argc, char **argv) } } + timezone_t tz = tzalloc (getenv ("TZ")); + if (batch_file != NULL) - ok = batch_convert (batch_file, format); + ok = batch_convert (batch_file, format, tz); else { bool valid_date = true; @@ -543,7 +545,7 @@ main (int argc, char **argv) } } - ok &= show_date (format, when); + ok &= show_date (format, when, tz); } return ok ? EXIT_SUCCESS : EXIT_FAILURE; @@ -553,7 +555,7 @@ main (int argc, char **argv) in FORMAT, followed by a newline. Return true if successful. */ static bool -show_date (const char *format, struct timespec when) +show_date (const char *format, struct timespec when, timezone_t tz) { struct tm *tm; @@ -567,7 +569,7 @@ show_date (const char *format, struct timespec when) if (format == rfc_2822_format) setlocale (LC_TIME, "C"); - fprintftime (stdout, format, tm, 0, when.tv_nsec); + fprintftime (stdout, format, tm, tz, when.tv_nsec); fputc ('\n', stdout); if (format == rfc_2822_format) setlocale (LC_TIME, ""); diff --git a/src/ls.c b/src/ls.c index 6860dd4..fe95a46 100644 --- a/src/ls.c +++ b/src/ls.c @@ -699,6 +699,10 @@ static bool print_dir_name; static size_t line_length; +/* The local time zone rules, as per the TZ environment variable. */ + +static timezone_t localtz; + /* If true, the file listing format requires that stat be called on each file. */ @@ -1374,6 +1378,8 @@ main (int argc, char **argv) obstack_init (&dev_ino_obstack); } + localtz = tzalloc (getenv ("TZ")); + format_needs_stat = sort_type == sort_time || sort_type == sort_size || format == long_format || print_scontext @@ -3654,7 +3660,7 @@ print_current_files (void) static size_t align_nstrftime (char *buf, size_t size, char const *fmt, struct tm const *tm, - int __utc, int __ns) + timezone_t tz, int ns) { const char *nfmt = fmt; /* In the unlikely event that rpl_fmt below is not large enough, @@ -3674,7 +3680,7 @@ align_nstrftime (char *buf, size_t size, char const *fmt, struct tm const *tm, strcpy (pfmt, pb + 2); } } - size_t ret = nstrftime (buf, size, nfmt, tm, __utc, __ns); + size_t ret = nstrftime (buf, size, nfmt, tm, tz, ns); return ret; } @@ -3702,7 +3708,8 @@ long_time_expected_width (void) if (tm) { size_t len = - align_nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0); + align_nstrftime (buf, sizeof buf, long_time_format[0], tm, + localtz, 0); if (len != 0) width = mbsnwidth (buf, len, 0); } @@ -3987,7 +3994,7 @@ print_long_format (const struct fileinfo *f) /* We assume here that all time zones are offset from UTC by a whole number of seconds. */ s = align_nstrftime (p, TIME_STAMP_LEN_MAXIMUM + 1, fmt, - when_local, 0, when_timespec.tv_nsec); + when_local, localtz, when_timespec.tv_nsec); } if (s || !*p) diff --git a/src/stat.c b/src/stat.c index 6d23665..680a598 100644 --- a/src/stat.c +++ b/src/stat.c @@ -547,10 +547,13 @@ human_time (struct timespec t) (INT_STRLEN_BOUND (int) /* YYYY */ + 1 /* because YYYY might equal INT_MAX + 1900 */ + sizeof "-MM-DD HH:MM:SS.NNNNNNNNN +ZZZZ"))]; + static timezone_t tz; + if (!tz) + tz = tzalloc (getenv ("TZ")); struct tm const *tm = localtime (&t.tv_sec); if (tm == NULL) return timetostr (t.tv_sec, str); - nstrftime (str, sizeof str, "%Y-%m-%d %H:%M:%S.%N %z", tm, 0, t.tv_nsec); + nstrftime (str, sizeof str, "%Y-%m-%d %H:%M:%S.%N %z", tm, tz, t.tv_nsec); return str; } -- 2.1.0 --------------090309050903060508050100-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 23 22:17:31 2015 Received: (at control) by debbugs.gnu.org; 24 Jul 2015 02:17:31 +0000 Received: from localhost ([127.0.0.1]:57638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZISYF-0007ZS-2F for submit@debbugs.gnu.org; Thu, 23 Jul 2015 22:17:31 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59866) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZISYD-0007ZK-31 for control@debbugs.gnu.org; Thu, 23 Jul 2015 22:17:29 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B3C891601B0 for ; Thu, 23 Jul 2015 19:17:27 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id P-B4mZ4cSjEw for ; Thu, 23 Jul 2015 19:17:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 25161160CB7 for ; Thu, 23 Jul 2015 19:17:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YJZYcv6sdE9S for ; Thu, 23 Jul 2015 19:17:27 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 097221601B0 for ; Thu, 23 Jul 2015 19:17:27 -0700 (PDT) Message-ID: <55B1A036.6060401@cs.ucla.edu> Date: Thu, 23 Jul 2015 19:17:26 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: 21126 is already done Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) close 21126 thanks