From bf982dc2f9119b5d655e3266b70bd716cc92cf95 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Jun 2005 07:14:09 +0000 Subject: [PATCH] * mktime.c: Include even if !DEBUG. (From glibc.) (ranged_convert): Don't save conversion in a temporary struct. This causes a warning with GCC 4.0.0, and anyway in the typical case it's not worth the extra 100 bytes or so of code. (ranged_convert, __mktime_internal): When calling a function via a pointer P, use P () rather than (*P) (), as we now assume C89 or better. --- lib/ChangeLog | 10 ++++++++++ lib/mktime.c | 23 ++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 3dd4580aa2..32c5859388 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,13 @@ +2005-06-23 Paul Eggert + + * mktime.c: Include even if !DEBUG. (From glibc.) + (ranged_convert): Don't save conversion in a temporary struct. + This causes a warning with GCC 4.0.0, and anyway in the typical + case it's not worth the extra 100 bytes or so of code. + (ranged_convert, __mktime_internal): When calling a function via a + pointer P, use P () rather than (*P) (), as we now assume C89 or + better. + 2005-06-22 Paul Eggert * readutmp.c (desirable_utmp_entry): Fix bug where "who -b" and diff --git a/lib/mktime.c b/lib/mktime.c index fa65e01a09..e5f25d984e 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,5 +1,5 @@ /* Convert a `struct tm' to a time_t value. - Copyright (C) 1993-1999, 2002, 2003, 2004, 2005 Free Software Foundation, + Copyright (C) 1993-1999, 2002-2004, 2005 Free Software Foundation, Inc. Inc. This file is part of the GNU C Library. Contributed by Paul Eggert (eggert@twinsun.com). @@ -38,10 +38,11 @@ #include +#include /* For the real memcpy prototype. */ + #if DEBUG # include # include -# include /* Make it work even if the system's libc has its own mktime routine. */ # define mktime my_mktime #endif /* DEBUG */ @@ -228,13 +229,12 @@ static struct tm * ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t *t, struct tm *tp) { - struct tm *r; + struct tm *r = convert (t, tp); - if (! (r = (*convert) (t, tp)) && *t) + if (!r && *t) { time_t bad = *t; time_t ok = 0; - struct tm tm; /* BAD is a known unconvertible time_t, and OK is a known good one. Use binary search to narrow the range between BAD and OK until @@ -244,11 +244,9 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t mid = *t = (bad < 0 ? bad + ((ok - bad) >> 1) : ok + ((bad - ok) >> 1)); - if ((r = (*convert) (t, tp))) - { - tm = *r; - ok = mid; - } + r = convert (t, tp); + if (r) + ok = mid; else bad = mid; } @@ -258,8 +256,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), /* The last conversion attempt failed; revert to the most recent successful attempt. */ *t = ok; - *tp = tm; - r = tp; + r = convert (t, tp); } } @@ -488,7 +485,7 @@ __mktime_internal (struct tm *tp, t2 = t1 + sec_adjustment; if (((t1 < t) != (sec_requested < 0)) | ((t2 < t1) != (sec_adjustment < 0)) - | ! (*convert) (&t2, &tm)) + | ! convert (&t2, &tm)) return -1; t = t2; } -- 2.30.2