$NetBSD: patch-ci,v 1.1 2005/11/02 08:56:40 taca Exp $

--- time.c.orig	2005-01-20 18:34:36.000000000 +0900
+++ time.c
@@ -109,7 +109,7 @@ time_init(time)
 #define NDIV(x,y) (-(-((x)+1)/(y))-1)
 #define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
 
-void
+static void
 time_overflow_p(secp, usecp)
     time_t *secp, *usecp;
 {
@@ -1031,6 +1031,7 @@ time_hash(time)
     return LONG2FIX(hash);
 }
 
+/* :nodoc: */
 static VALUE
 time_init_copy(copy, time)
     VALUE copy, time;
@@ -1259,7 +1260,7 @@ typedef unsigned long unsigned_time_t;
 #elif SIZEOF_TIME_T == SIZEOF_INT
 typedef unsigned int unsigned_time_t;
 #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
-typedef unsigned long long unsigned_time_t;
+typedef unsigned LONG_LONG unsigned_time_t;
 #else
 # error cannot find integer type which size is same as time_t.
 #endif
@@ -1742,12 +1743,11 @@ time_to_a(time)
 #define SMALLBUF 100
 static int
 rb_strftime(buf, format, time)
-    char ** volatile buf;
-    char * volatile format;
-    struct tm * volatile time;
+    char **buf;
+    const char *format;
+    struct tm *time;
 {
-    volatile int size;
-    int len, flen;
+    int size, len, flen;
 
     (*buf)[0] = '\0';
     flen = strlen(format);
@@ -1819,8 +1819,8 @@ time_strftime(time, format)
     VALUE time, format;
 {
     struct time_object *tobj;
-    char buffer[SMALLBUF];
-    char *fmt, *buf = buffer;
+    char buffer[SMALLBUF], *buf = buffer;
+    const char *fmt;
     long len;
     VALUE str;
 
@@ -1837,19 +1837,19 @@ time_strftime(time, format)
     }
     else if (strlen(fmt) < len) {
 	/* Ruby string may contain \0's. */
-	char *p = fmt, *pe = fmt + len;
+	const char *p = fmt, *pe = fmt + len;
 
 	str = rb_str_new(0, 0);
 	while (p < pe) {
 	    len = rb_strftime(&buf, p, &tobj->tm);
 	    rb_str_cat(str, buf, len);
 	    p += strlen(p) + 1;
-	    if (p <= pe)
-		rb_str_cat(str, "\0", 1);
 	    if (buf != buffer) {
 		free(buf);
 		buf = buffer;
 	    }
+	    for (fmt = p; p < pe && !*p; ++p);
+	    if (p > fmt) rb_str_cat(str, fmt, p - fmt);
 	}
 	return str;
     }
