[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23035: date: regression in timezone printing (+%Z)

From: Assaf Gordon
Subject: bug#23035: date: regression in timezone printing (+%Z)
Date: Wed, 16 Mar 2016 23:51:42 -0400


I think there's a small regression in coreutils 8.25 date command with
regards to timezone printing on a machine without native 'timezone_t'.

  $ uname -a
  SunOS unstable10x 5.10 Generic_147441-19 i86pc i386 i86pc
  $ export TZ=Asia/Tokyo
  $ ./coreutils-8.24/src/date +%Z
  $ ./coreutils-8.25/src/date +%Z
  [[[empty line]]]

I suspect it has something to do with this commit:
  commit    037e3b9847feb46cf6b58d99ce960d3987faaf52
  date:     2015-07-24 01:49:31 (GMT)
  subject:  build: fprintftime/nstrftime API changes

configuration values on this machine:
    $ ggrep -E 'TZ|ZONE' lib/config.h
    #define HAVE_DECL_TZNAME 1
    #define HAVE_RUN_TZSET_TEST 1
    /* #undef HAVE_STRUCT_TM_TM_ZONE */
    /* #undef HAVE_TIMEZONE_T */
       `HAVE_STRUCT_TM_TM_ZONE' instead. */
    /* #undef HAVE_TM_ZONE */
    #define HAVE_TZNAME 1
    #define HAVE_TZSET 1

Trying to debug, I see the following:

1. in 'date.c', show_date() calls fprintftime (in ./lib/strftime.c).
The values upon entry are:

    fprintftime (s=0x8079c10 <_iob+16>, format=0x8047ccd "%Z",
tp=0xfef30200, tz=0x807b028,
        ns=446195784) at lib/strftime.c:1465
    (gdb) p *tz
    $6 = {next = 0x0, tzname_copy = {0x0, 0x0}, tz_is_set = 1 '\001',
          abbrs = 0x807b035 "Asia/Tokyo"}

2. stepping through ./lib/strftime.c:445 has this:

    445       char **tzname_vec = tzname;
    (gdb) p tzname
    $10 = {0xfef302c4 "JST", 0xfef30304 "JDT"}

3. ./lib/strftime.c:484 has this, which sets tzname_vec to nulls (from 'tz',
   originating from 'tzalloc'):

    (gdb) n
    484           tzname_vec = tz->tzname_copy;
    (gdb) n
    493       if (!(zone && *zone) && tp->tm_isdst >= 0) {
    (gdb) p tzname_vec
    $3 = (char **) 0x807b02c
    (gdb) p *tzname_vec
    $4 = 0x0
    (gdb) p zone
    $5 = 0x0
    (gdb) n
    494         zone = tzname_vec[tp->tm_isdst != 0];
    (gdb) n
    496       if (! zone)
    (gdb) p zone
    $6 = 0x0
    (gdb) n
    497         zone = "";

>From this point on, 'zone' is an empty string, and that's what is printed
by 'date'.

Not sure where to start at fixing it, but I hope the attached patch can be
used to test it.

Happy to test things further if needed.
 - assaf

Attachment: 0001-tests-test-date-Z-behaviour.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]