I managed to get all gnulib's important mktime.c changes into glibc, so I resurrected the mktime.c link between glibc and gnulib in gnulib/config/srclist.txt and copied the glibc file into gnulib. Karl, you may want to check the next time that you sync gnulib sources, as you'll need up-to-date glibc sources again.
The glibc maintainers don't want to use just spaces to indent so this resurrects the tabs. I figured that it was more important to match than to be tab-free. The following listing omits the space-tab diffs as they're uninteresting. diff --git a/ChangeLog b/ChangeLog index 89ed235..5296ce5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2012-05-23 Paul Eggert <egg...@cs.ucla.edu> + + mktime: sync from glibc + * config/srclist.txt: Uncomment mktime.c. + * lib/mktime.c: Sync from glibc master. This incorporates 3 changes. + First, indent with tabs, since glibc uses tabs and doesn't want to + change and we'd rather be identical to glibc. Also, two small + coding changes: + (isdst_differ): Use &&, not &, as && is the usual style. + (__mktime_internal): Rename local var from abs_diff to approx_abs_diff + for clarity. + 2012-05-23 Akim Demaille <a...@lrde.epita.fr> announce-gen: du -h is more portable than du --human diff --git a/config/srclist.txt b/config/srclist.txt index 290f140..e69fcec 100644 --- a/config/srclist.txt +++ b/config/srclist.txt @@ -163,7 +163,7 @@ $GNUORG/disclaim.program doc/Copyright #tab changes $LIBCSRC/stdlib/strtoul.c lib gpl # (no more strtok_r.h) $LIBCSRC/string/strtok_r.c lib gpl # (gnulib needs config.h?) $LIBCSRC/string/memmem.c lib gpl -#$LIBCSRC/time/mktime.c lib gpl +$LIBCSRC/time/mktime.c lib gpl # # http://sourceware.org/bugzilla/show_bug.cgi?id=1439 diff --git a/lib/mktime.c b/lib/mktime.c index fc27adf..e1fbf9e 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,20 +1,21 @@ /* Convert a 'struct tm' to a time_t value. - Copyright (C) 1993-1999, 2002-2007, 2009-2012 Free Software Foundation, Inc. + Copyright (C) 1993-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert <egg...@twinsun.com>. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ /* Define this to have a standalone program to test this implementation of mktime. */ @@ -52,12 +53,14 @@ Define WRAPV to 1 if the assumption is valid and if #pragma GCC optimize ("wrapv") - does not trigger GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>. + does not trigger GCC bug 51793 + <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>. Otherwise, define it to 0; this forces the use of slower code that, while not guaranteed by the C Standard, works on all production platforms that we know about. */ #ifndef WRAPV -# if ((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) && defined __GLIBC__ +# if (((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) \ + && defined __GLIBC__) # pragma GCC optimize ("wrapv") # define WRAPV 1 # else @@ -179,7 +182,7 @@ const unsigned short int __mon_yday[2][13] = static int isdst_differ (int a, int b) { - return (!a != !b) & (0 <= a) & (0 <= b); + return (!a != !b) && (0 <= a) && (0 <= b); } /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - @@ -442,7 +445,7 @@ __mktime_internal (struct tm *tp, int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM); int diff = approx_biennia - approx_requested_biennia; - int abs_diff = diff < 0 ? -1 - diff : diff; + int approx_abs_diff = diff < 0 ? -1 - diff : diff; /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously gives a positive value of 715827882. Setting a variable @@ -453,15 +456,15 @@ __mktime_internal (struct tm *tp, time_t overflow_threshold = (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM; - if (overflow_threshold < abs_diff) + if (overflow_threshold < approx_abs_diff) { /* Overflow occurred. Try repairing it; this might work if the time zone offset is enough to undo the overflow. */ time_t repaired_t0 = -1 - t0; approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); diff = approx_biennia - approx_requested_biennia; - abs_diff = diff < 0 ? -1 - diff : diff; - if (overflow_threshold < abs_diff) + approx_abs_diff = diff < 0 ? -1 - diff : diff; + if (overflow_threshold < approx_abs_diff) return -1; guessed_offset += repaired_t0 - t0; t0 = repaired_t0;