[PATCH] Fix mktime

Jakub Jelinek jakub@redhat.com
Fri Apr 5 04:36:00 GMT 2002


Hi!

ISO C99ism which older GCCs (< 3.0, or < 3.1?) don't cope with:

2002-04-05  Jakub Jelinek  <jakub@redhat.com>

	* time/mktime.c (__mktime_internal): Move check for year < 70 below
	all variable declarations.

--- libc/time/mktime.c.jj	Fri Apr  5 14:34:22 2002
+++ libc/time/mktime.c	Fri Apr  5 14:36:38 2002
@@ -246,10 +246,6 @@ __mktime_internal (struct tm *tp,
   int mon_years = mon / 12 - negative_mon_remainder;
   int year = year_requested + mon_years;
 
-  /* Only years after 1970 are defined.  */
-  if (year < 70)
-    return -1;
-
    /* The other values need not be in range:
      the remaining code handles minor overflows correctly,
      assuming int and time_t arithmetic wraps around.
@@ -271,6 +267,10 @@ __mktime_internal (struct tm *tp,
     sec = 59;
 #endif
 
+  /* Only years after 1970 are defined.  */
+  if (year < 70)
+    return -1;
+
   /* Invert CONVERT by probing.  First assume the same offset as last time.
      Then repeatedly use the error to improve the guess.  */
 

	Jakub



More information about the Libc-hacker mailing list