mktime update from libc
authorKarl Berry <karl@freefriends.org>
Fri, 30 May 2003 15:06:41 +0000 (15:06 +0000)
committerKarl Berry <karl@freefriends.org>
Fri, 30 May 2003 15:06:41 +0000 (15:06 +0000)
lib/ChangeLog
lib/mktime.c

index fa45b31f96576fbddf065d6cb8f5294237ea64e2..b3bb75a263767f14d8ac226c9eb3710ad03e842f 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-30    <karl@gnu.org>
+
+       * mktime.c: update from libc.
+
 2003-05-30  Bruno Haible  <bruno@clisp.org>
 
        * config.charset: Upgrade to gettext-0.12.1 and libiconv-1.9.1.
index 01da3e4ce3c5dc3e2d25a4a5e136ea728ceddef5..a4f4e3bfd5630100836987899ee2ebc928e9dd25 100644 (file)
@@ -1,22 +1,21 @@
 /* Convert a `struct tm' to a time_t value.
-   Copyright (C) 1993-1999, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1993-1999, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Paul Eggert (eggert@twinsun.com).
 
-   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 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 distributed in the hope that it will be useful,
+   This program 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
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* Define this to have a standalone program to test this implementation of
    mktime.  */
@@ -265,6 +264,12 @@ __mktime_internal (struct tm *tp,
 
   int sec_requested = sec;
 
+  /* Only years after 1970 are defined.
+     If year is 69, it might still be representable due to
+     timezone differences.  */
+  if (year < 69)
+    return -1;
+
 #if LEAP_SECONDS_POSSIBLE
   /* Handle out-of-range seconds specially,
      since ydhms_tm_diff assumes every minute has 60 seconds.  */
@@ -372,6 +377,14 @@ __mktime_internal (struct tm *tp,
        return -1;
     }
 
+  if (year == 69)
+    {
+      /* If year was 69, need to check whether the time was representable
+        or not.  */
+      if (t < 0 || t > 2 * 24 * 60 * 60)
+       return -1;
+    }
+
   *tp = tm;
   return t;
 }