From: Jim Meyering Date: Tue, 26 Jul 1994 04:06:18 +0000 (+0000) Subject: merge with 1.10f X-Git-Tag: textutils-1_12_1~648 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e3cc9b7b9951b2ddf32e9aac48d1594f7ab4d2a;p=thirdparty%2Fcoreutils.git merge with 1.10f --- diff --git a/lib/mktime.c b/lib/mktime.c index 07fe494f47..094380de1c 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,5 +1,6 @@ /* Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Contributed by Noel Cragg (noel@cs.oberlin.edu). + Contributed by Noel Cragg (noel@cs.oberlin.edu), with fixes + by Michael E. Calwas (calwas@ttd.teradyne.com). This file is part of the GNU C Library. @@ -226,12 +227,12 @@ _mktime_internal (timeptr, producer) while (me->foo < x) \ { \ me->bar--; \ - me->foo = (y - (x - me->foo)); \ + me->foo = (y - (x - me->foo) + 1); \ } \ while (me->foo > y) \ { \ + me->foo = (x + (me->foo - y) - 1); \ me->bar++; \ - me->foo = (x + (me->foo - y)); \ } normalize (tm_sec, 0, 59, tm_min); @@ -240,8 +241,14 @@ _mktime_internal (timeptr, producer) /* Do the month first, so day range can be found. */ normalize (tm_mon, 0, 11, tm_year); + + /* Since the day range modifies the month, we should be careful how + we reference the array of month lengths -- it is possible that + the month will go negative, hence the %... */ normalize (tm_mday, 1, - __mon_lengths[__isleap (me->tm_year)][me->tm_mon], + __mon_lengths[__isleap (me->tm_year)][((me->tm_mon < 0) + ? (12 + (me->tm_mon % 12)) + : (me->tm_mon % 12)) ], tm_mon); /* Do the month again, because the day may have pushed it out of range. */ @@ -249,7 +256,9 @@ _mktime_internal (timeptr, producer) /* Do the day again, because the month may have changed the range. */ normalize (tm_mday, 1, - __mon_lengths[__isleap (me->tm_year)][me->tm_mon], + __mon_lengths[__isleap (me->tm_year)][((me->tm_mon < 0) + ? (12 + (me->tm_mon % 12)) + : (me->tm_mon % 12)) ], tm_mon); #ifdef DEBUG diff --git a/old/sh-utils/ChangeLog b/old/sh-utils/ChangeLog index b3c8d996b5..ed4b292954 100644 --- a/old/sh-utils/ChangeLog +++ b/old/sh-utils/ChangeLog @@ -1,3 +1,7 @@ +Fri Jul 15 00:23:17 1994 Jim Meyering (meyering@comco.com) + + system.h: Remove unneeded decls of atof and atol. + Fri Jul 08 01:09:23 1994 Jim Meyering (meyering@comco.com) stty.c (main): Initialize max_col (used by wrapf) before calling