[前][次][番号順一覧][スレッド一覧]

ruby-changes:11617

From: nobu <ko1@a...>
Date: Wed, 22 Apr 2009 09:27:57 +0900 (JST)
Subject: [ruby-changes:11617] Ruby:r23254 (trunk): * time.c (localtime_with_gmtoff): fixed cross function jump.

nobu	2009-04-22 09:27:33 +0900 (Wed, 22 Apr 2009)

  New Revision: 23254

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23254

  Log:
    * time.c (localtime_with_gmtoff): fixed cross function jump.

  Modified files:
    trunk/ChangeLog
    trunk/strftime.c
    trunk/time.c

Index: time.c
===================================================================
--- time.c	(revision 23253)
+++ time.c	(revision 23254)
@@ -27,6 +27,13 @@
 #ifndef TYPEOF_TIMEVAL_TV_SEC
 # define TYPEOF_TIMEVAL_TV_SEC time_t
 #endif
+#ifndef TYPEOF_TIMEVAL_TV_USEC
+# if INT_MAX >= 1000000
+# define TYPEOF_TIMEVAL_TV_USEC int
+# else
+# define TYPEOF_TIMEVAL_TV_USEC long
+# endif
+#endif
 
 #if SIZEOF_TIME_T == SIZEOF_LONG
 typedef unsigned long unsigned_time_t;
@@ -503,7 +510,7 @@
     result->tm_isdst = 0;
     result->tm_gmtoff = 0;
 #if defined(HAVE_TM_ZONE)
-    result->tm_zone = "UTC";
+    result->tm_zone = (char *)"UTC";
 #endif
     return result;
 #else
@@ -746,12 +753,12 @@
 # if defined(NEGATIVE_TIME_T)
     /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
     if (localtime_with_gmtoff((t = (time_t)0x80000000, &t), &tm, &gmtoff))
-         off = LONG2FIX(gmtoff);
+	off = LONG2FIX(gmtoff);
     else
 # endif
     /* 1970-01-01 00:00:00 UTC : The Unix epoch - the oldest time in portable time_t. */
     if (localtime_with_gmtoff((t = 0, &t), &tm, &gmtoff))
-         off = LONG2FIX(gmtoff);
+	off = LONG2FIX(gmtoff);
 
     /* The first DST is at 1916 in German.
      * So we don't need to care DST before that. */
@@ -903,9 +910,9 @@
 	long off;
 	IF_HAVE_GMTIME_R(struct tm tmbuf);
 	l = &tm;
-	u = GMTIME(&t, tmbuf);
+	u = GMTIME(t, tmbuf);
 	if (!u)
-	    goto no_localtime;
+	    return NULL;
 	if (l->tm_year != u->tm_year)
 	    off = l->tm_year < u->tm_year ? -1 : 1;
 	else if (l->tm_mon != u->tm_mon)
@@ -966,9 +973,6 @@
             return result;
         }
     }
-#if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
-  no_localtime:
-#endif
 
     if (!gmtimev(timev, result))
         return NULL;
@@ -1256,7 +1260,7 @@
 
     ts = time_timespec(num, interval);
     tv.tv_sec = (TYPEOF_TIMEVAL_TV_SEC)ts.tv_sec;
-    tv.tv_usec = ts.tv_nsec / 1000;
+    tv.tv_usec = (TYPEOF_TIMEVAL_TV_USEC)(ts.tv_nsec / 1000);
 
     return tv;
 }
@@ -1278,7 +1282,7 @@
 	GetTimeval(time, tobj);
         ts = timev2timespec(tobj->timev);
         t.tv_sec = (TYPEOF_TIMEVAL_TV_SEC)ts.tv_sec;
-        t.tv_usec = ts.tv_nsec / 1000;
+        t.tv_usec = (TYPEOF_TIMEVAL_TV_USEC)(ts.tv_nsec / 1000);
 	return t;
     }
     return time_timeval(time, Qfalse);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23253)
+++ ChangeLog	(revision 23254)
@@ -1,3 +1,7 @@
+Wed Apr 22 09:27:31 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* time.c (localtime_with_gmtoff): fixed cross function jump.
+
 Wed Apr 22 03:06:56 2009  Tanaka Akira  <akr@f...>
 
 	* lib/time.rb (Time#rfc2822): pad leading zeros for year.
Index: strftime.c
===================================================================
--- strftime.c	(revision 23253)
+++ strftime.c	(revision 23254)
@@ -202,7 +202,7 @@
 	static short first = 1;
 #ifdef POSIX_SEMANTICS
 	static char *savetz = NULL;
-	static int savetzlen = 0;
+	static size_t savetzlen = 0;
 	char *tz;
 #endif /* POSIX_SEMANTICS */
 #ifndef HAVE_TM_ZONE
@@ -250,7 +250,7 @@
 	tz = getenv("TZ");
 	if (first) {
 		if (tz != NULL) {
-			int tzlen = strlen(tz);
+			size_t tzlen = strlen(tz);
 
 			savetz = (char *) malloc(tzlen + 1);
 			if (savetz != NULL) {
@@ -263,7 +263,7 @@
 	}
 	/* if we have a saved TZ, and it is different, recapture and reset */
 	if (tz && savetz && (tz[0] != savetz[0] || strcmp(tz, savetz) != 0)) {
-		i = strlen(tz) + 1;
+		size_t i = strlen(tz) + 1;
 		if (i > savetzlen) {
 			savetz = (char *) realloc(savetz, i);
 			if (savetz) {
@@ -892,7 +892,7 @@
     tm.tm_gmtoff = NUM2LONG(vtm->utc_offset);
 #endif
 #if defined(HAVE_TM_ZONE)
-    tm.tm_zone = vtm->zone;
+    tm.tm_zone = (char *)vtm->zone;
 #endif
     *result = tm;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]