diff -NrU2 ruby-1.8.7/ChangeLog ruby-1.8.7-p17/ChangeLog
--- ruby-1.8.7/ChangeLog	2008-05-31 23:57:11.000000000 +0900
+++ ruby-1.8.7-p17/ChangeLog	2008-06-09 18:20:43.000000000 +0900
@@ -1,2 +1,144 @@
+Mon Jun  9 17:56:30 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* lib/set.rb (Set#delete_if): Call to_a.
+	  (SortedSet#delete_if, TC_SortedSet#test_sortedset): Use super to
+	  yield elements in sorted order; [ruby-core:17144] by Arthur
+	  Schreiber.
+	  (SortedSet#each, SortedSet#each, TC_Set#test_each)
+	  (TC_SortedSet#test_sortedset): Return self; [ruby-dev:35002] by
+	  Arthur Schreiber.
+
+Mon Jun  9 03:28:05 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* ext/zlib/zlib.c (rb_deflate_initialize, Init_zlib): Fix up
+	  initialize_copy; [ruby-list:45016], [ruby-list:45018].
+
+Mon Jun  9 03:26:03 2008  Kazuhiro NISHIYAMA  <zn@mbf.nifty.com>
+
+	* NEWS: Mention new constants.
+
+Mon Jun  9 03:24:18 2008  Tanaka Akira  <akr@fsij.org>
+
+	* hash.c (hash_i): make Hash#hash order insensitive.
+
+Mon Jun  9 03:22:43 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
+
+	* configure.in (VENDOR_DIR): use LIBDIR instead of PREFIX as well as
+	  SITE_DIR.  a patch from Richard Brown <rbrown AT exherbo.org> in
+	  [ruby-core:17129].
+
+Mon Jun  9 03:21:20 2008  Tanaka Akira  <akr@fsij.org>
+
+	* gc.c (os_obj_of): assure to not free the scanning heap.
+
+Mon Jun  9 03:20:12 2008  NAKAMURA Usaku  <usa@ruby-lang.org>
+
+	* io.c (rb_open_file, rb_io_s_sysopen): fmode should be unsigned int.
+	  fixed [ruby-dev:34979]
+
+Fri Jun  6 21:16:55 2008  NAKAMURA Usaku  <usa@ruby-lang.org>
+
+	* win32/Makefile.sub (COMMON_HEADERS): include ws2tcpip.h.
+
+	* ext/socket/addrinfo.h (addrinfo, getaddrinfo, getnameinfo,
+	  freehostent, freeaddrinfo): undef before define because these are
+	  macros in some versions of Windows SDK.
+
+	* win32/setup.mak: maybe commit miss.
+
+Fri Jun  6 19:34:22 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* mkconfig.rb: hide build path from rbconfig.rb.
+
+	* util.c (ruby_strtod, dtoa): initialize more variables for error
+	  handling.
+
+	* io.c (rscheck), marshal.c (w_nbyte, w_bytes, w_unique),
+	  (path2class, path2module): constified.
+
+	* pack.c (pack_unpack), process.c (rb_syswait): suppress warnings.
+
+	* suppress warnings on cygwin, mingw and mswin.
+
+Fri Jun  6 19:23:53 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
+
+	* file.c (file_expand_path): fix for non-existent files and SFN of
+	  symlinks.  [ruby-talk:303736]
+
+Fri Jun  6 18:25:43 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
+
+	* test/iconv: Tests fixed.
+
+Fri Jun  6 17:04:56 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* win32/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528]
+
+	* lib/time.rb (Time.xmlschema): don't use float.  fix
+	  http://rubyforge.org/tracker/index.php?func=detail&group_id=426&atid=1698&aid=20504
+
+	* object.c (rb_obj_alloc): RDoc updated.  a patch from Gaston
+	  Ramos <ramos.gaston at gmail.com> in [ruby-core:17073].
+
+	* lib/rdoc.rb: massive spelling correction patch from Evan Farrar
+	  <evanfarrar at gmail.com> in [ruby-doc:1382] applied.
+
+	* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_initialize):
+	  Add a null check for ssl; submitted by akira yamada
+	  in [ruby-dev:34950].
+
+	* ext/openssl/ossl_ssl.c (Init_ossl_ssl): Define OP_NO_TICKET if
+	  SSL_OP_NO_TICKET is present; submitted by akira yamada
+	  in [ruby-dev:34944].
+
+	* test/openssl/test_ssl.rb (OpenSSL#test_server_session): Add a
+	  workaround for the case where OpenSSL is configured with
+	  --enable-tlsext; submitted by akira yamada in [ruby-dev:34944].
+
+Fri Jun  6 16:58:23 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
+
+	* ext/iconv/iconv.c (iconv_iconv): fix for length argument and now
+	  allows range.  [ruby-core:17092] [ruby-core:17115]
+
+Wed Jun  4 17:22:30 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* NEWS: Fix typos and move misplaced entries.
+	  NEWS: Somehow optflags and warnflags were not actually included
+	  in this release.
+
+Tue Jun  3 19:33:22 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* enumerator.c (enumerator_init_copy): Take care of
+	  initialize_copy as well as initialize.
+
+	* test/ruby/test_enumerator.rb: Pull in the test suite for
+	  enumerator from trunk.
+
+Tue Jun  3 12:51:57 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* enumerator.c (enumerator_allocate, enumerator_ptr): Properly
+	  detect if the object is initialized and raise error when
+	  appropriate.
+	  (enumerator_initialize): Fix a typo in rdoc. [ruby-core:17052]
+
+Tue Jun  3 10:16:40 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug
+	  where tokens are not yilelded one by one.
+	  (ERB::Compiler::TrimScanner#explicit_trim_line): Fix without-
+	  strscan problems. [ruby_core:17028].
+
+	* test/erb/test_erb.rb (TestERBCore#_test_01)
+	  (TestERBCore#test_02_safe_04): The expected value should come
+	  first for assert_equal().
+	  (TestERBCoreWOStrScan): Add test class for without-strscan.
+
+Mon Jun  2 19:47:16 2008  Akinori MUSHA  <knu@iDaemons.org>
+
+	* lib/delegate.rb (DelegateClass, Delegator#respond_to?):
+	  respond_to? must take optional second argument.  This was a
+	  latent bug exposed by a recent internal change of marshal.c to
+	  call respond_to? with a second argument; submitted by Jeremy
+	  Kemper <jeremy at bitsweat.net> in [ruby-core:17045].
+
 Sat May 31 23:53:35 2008  Akinori MUSHA  <knu@iDaemons.org>
 
diff -NrU2 ruby-1.8.7/NEWS ruby-1.8.7-p17/NEWS
--- ruby-1.8.7/NEWS	2008-05-31 23:40:44.000000000 +0900
+++ ruby-1.8.7-p17/NEWS	2008-06-09 03:27:15.000000000 +0900
@@ -12,10 +12,4 @@
 === Configuration changes
 
-* default C flags
-
-  Some C compiler flags may be added by default depending on your
-  environment.  Specify optflags=.. and warnflags=.. as necessary to
-  override them.
-
 * vendor_ruby directory
 
@@ -35,4 +29,11 @@
   as `--with-sitedir=DIR' and `--with-vendordir=DIR'.
 
+=== Global constants
+
+* new constants
+
+  * RUBY_COPYRIGHT
+  * RUBY_DESCRIPTION
+
 === Library updates (outstanding ones only)
 
@@ -219,6 +220,4 @@
     New methods. 
 
-  * Method#class_exec
-  * Method#module_exec
   * Method#name
   * Method#owner
@@ -229,4 +228,9 @@
     New methods.
 
+  * Module#class_exec
+  * Module#module_exec
+
+    New methods.
+
   * Numeric#step
 
@@ -383,4 +387,10 @@
       Tempfile.open(['image', 'jpg']) { |tempfile| ... }
 
+* tmpdir
+
+  * New method:
+
+    * Dir.mktmpdir
+
 * uri
 
@@ -497,9 +507,4 @@
     suffix.
 
-* tmpdir
-
-  * New method:
-    * Dir.mktmpdir
-
 * uri
 
@@ -516,4 +521,10 @@
 * autoconf 2.6x
 
+=== Global constants
+
+* RUBY_PATCHLEVEL
+
+  New constant since 1.8.5-p1.
+
 === Library updates (outstanding ones only)
 
diff -NrU2 ruby-1.8.7/configure ruby-1.8.7-p17/configure
--- ruby-1.8.7/configure	2008-06-01 00:18:42.000000000 +0900
+++ ruby-1.8.7-p17/configure	2008-06-09 18:38:04.000000000 +0900
@@ -1366,6 +1366,6 @@
   --with-dln-a-out        use dln_a_out if possible
   --with-static-linked-ext link external modules statically
-  --with-sitedir=DIR      site libraries in DIR PREFIX/lib/ruby/site_ruby
-  --with-vendordir=DIR    vendor libraries in DIR PREFIX/lib/ruby/vendor_ruby
+  --with-sitedir=DIR      site libraries in DIR [LIBDIR/ruby/site_ruby]
+  --with-vendordir=DIR    vendor libraries in DIR [LIBDIR/ruby/vendor_ruby]
   --with-search-path=DIR specify the additional search path
   --with-mantype=TYPE specify man page type; TYPE is one of man and doc
@@ -17558,5 +17558,5 @@
   withval=$with_vendordir; vendordir=$withval
 else
-  vendordir='${prefix}/lib/ruby/vendor_ruby'
+  vendordir='${libdir}/ruby/vendor_ruby'
 fi
 
diff -NrU2 ruby-1.8.7/configure.in ruby-1.8.7-p17/configure.in
--- ruby-1.8.7/configure.in	2008-05-31 23:57:11.000000000 +0900
+++ ruby-1.8.7-p17/configure.in	2008-06-09 03:23:46.000000000 +0900
@@ -1689,5 +1689,5 @@
 
 AC_ARG_WITH(sitedir,
-	    [  --with-sitedir=DIR      site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+	    [  --with-sitedir=DIR      site libraries in DIR [[LIBDIR/ruby/site_ruby]]],
             [sitedir=$withval],
             [sitedir='${libdir}/ruby/site_ruby'])
@@ -1712,7 +1712,7 @@
 
 AC_ARG_WITH(vendordir,
-	    [  --with-vendordir=DIR    vendor libraries in DIR [PREFIX/lib/ruby/vendor_ruby]],
+	    [  --with-vendordir=DIR    vendor libraries in DIR [[LIBDIR/ruby/vendor_ruby]]],
             [vendordir=$withval],
-            [vendordir='${prefix}/lib/ruby/vendor_ruby'])
+            [vendordir='${libdir}/ruby/vendor_ruby'])
 VENDOR_DIR=`eval echo \\"${vendordir}\\"`
 case "$target_os" in
diff -NrU2 ruby-1.8.7/dln.c ruby-1.8.7-p17/dln.c
--- ruby-1.8.7/dln.c	2008-04-25 15:51:21.000000000 +0900
+++ ruby-1.8.7-p17/dln.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-04-25 15:51:21 +0900 (Fri, 25 Apr 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Tue Jan 18 17:05:06 JST 1994
 
@@ -1690,10 +1690,10 @@
 static char *
 dln_find_1(fname, path, exe_flag)
-    char *fname;
-    char *path;
+    const char *fname;
+    const char *path;
     int exe_flag;		/* non 0 if looking for executable. */
 {
-    register char *dp;
-    register char *ep;
+    register const char *dp;
+    register const char *ep;
     register char *bp;
     struct stat st;
@@ -1702,17 +1702,17 @@
 #endif
 
-    if (!fname) return fname;
-    if (fname[0] == '/') return fname;
+    if (!fname) return (char *)fname;
+    if (fname[0] == '/') return (char *)fname;
     if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
-      return fname;
-    if (exe_flag && strchr(fname, '/')) return fname;
+      return (char *)fname;
+    if (exe_flag && strchr(fname, '/')) return (char *)fname;
 #ifdef DOSISH
-    if (fname[0] == '\\') return fname;
+    if (fname[0] == '\\') return (char *)fname;
 # ifdef DOSISH_DRIVE_LETTER
-    if (strlen(fname) > 2 && fname[1] == ':') return fname;
+    if (strlen(fname) > 2 && fname[1] == ':') return (char *)fname;
 # endif
     if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
-      return fname;
-    if (exe_flag && strchr(fname, '\\')) return fname;
+      return (char *)fname;
+    if (exe_flag && strchr(fname, '\\')) return (char *)fname;
 #endif
 
diff -NrU2 ruby-1.8.7/enumerator.c ruby-1.8.7-p17/enumerator.c
--- ruby-1.8.7/enumerator.c	2008-05-25 05:21:59.000000000 +0900
+++ ruby-1.8.7-p17/enumerator.c	2008-06-03 20:06:38.000000000 +0900
@@ -9,5 +9,5 @@
   $Idaemons: /home/cvs/rb/enumerator/enumerator.c,v 1.1.1.1 2001/07/15 10:12:48 knu Exp $
   $RoughId: enumerator.c,v 1.6 2003/07/27 11:03:24 nobu Exp $
-  $Id: enumerator.c 16583 2008-05-24 20:21:59Z knu $
+  $Id: enumerator.c 16794 2008-06-03 11:06:38Z knu $
 
 ************************************************/
@@ -56,5 +56,5 @@
 		 rb_obj_classname(obj));
     }
-    if (!ptr) {
+    if (!ptr || ptr->obj == Qundef) {
 	rb_raise(rb_eArgError, "uninitialized enumerator");
     }
@@ -215,6 +215,11 @@
 {
     struct enumerator *ptr;
-    return Data_Make_Struct(klass, struct enumerator,
-			    enumerator_mark, -1, ptr);
+    VALUE enum_obj;
+
+    enum_obj = Data_Make_Struct(klass, struct enumerator,
+				enumerator_mark, -1, ptr);
+    ptr->obj = Qundef;
+
+    return enum_obj;
 }
 
@@ -236,5 +241,11 @@
     VALUE *argv;
 {
-    struct enumerator *ptr = enumerator_ptr(enum_obj);
+    struct enumerator *ptr;
+
+    Data_Get_Struct(enum_obj, struct enumerator, ptr);
+
+    if (!ptr) {
+	rb_raise(rb_eArgError, "unallocated enumerator");
+    }
 
     ptr->obj  = obj;
@@ -254,6 +265,5 @@
  *  method with the given arguments.
  *
- *  Use of this method is not discouraged.  Use Kernel#enum_for()
- *  instead.
+ *  Use of this method is discouraged.  Use Kernel#enum_for() instead.
  */
 static VALUE
@@ -284,5 +294,10 @@
 
     ptr0 = enumerator_ptr(orig);
-    ptr1 = enumerator_ptr(obj);
+
+    Data_Get_Struct(obj, struct enumerator, ptr1);
+
+    if (!ptr1) {
+	rb_raise(rb_eArgError, "unallocated enumerator");
+    }
 
     ptr1->obj  = ptr0->obj;
diff -NrU2 ruby-1.8.7/ext/iconv/iconv.c ruby-1.8.7-p17/ext/iconv/iconv.c
--- ruby-1.8.7/ext/iconv/iconv.c	2008-02-15 15:23:14.000000000 +0900
+++ ruby-1.8.7-p17/ext/iconv/iconv.c	2008-06-06 17:03:49.000000000 +0900
@@ -4,6 +4,6 @@
   iconv.c -
 
-  $Author: nobu $
-  $Date: 2008-02-15 15:23:14 +0900 (Fri, 15 Feb 2008) $
+  $Author: knu $
+  $Date: 2008-06-06 17:03:49 +0900 (Fri, 06 Jun 2008) $
   created at: Wed Dec  1 20:28:09 JST 1999
 
@@ -102,5 +102,5 @@
 static VALUE iconv_try _((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen));
 static VALUE rb_str_derive _((VALUE str, const char* ptr, int len));
-static VALUE iconv_convert _((iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env));
+static VALUE iconv_convert _((iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env));
 static VALUE iconv_s_allocate _((VALUE klass));
 static VALUE iconv_initialize _((VALUE self, VALUE to, VALUE from));
@@ -171,5 +171,5 @@
 	if (cd == (iconv_t)-1) {
 	    int inval = errno == EINVAL;
-	    char *s = inval ? "invalid encoding " : "iconv";
+	    const char *s = inval ? "invalid encoding " : "iconv";
 	    volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
 					    RSTRING(from)->len + 8);
@@ -363,11 +363,11 @@
 iconv_convert
 #ifdef HAVE_PROTOTYPES
-    (iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env)
+    (iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env)
 #else /* HAVE_PROTOTYPES */
     (cd, str, start, length, env)
     iconv_t cd;
     VALUE str;
-    int start;
-    int length;
+    long start;
+    long length;
     struct iconv_env_t *env;
 #endif /* HAVE_PROTOTYPES */
@@ -418,15 +418,7 @@
 	inptr = RSTRING(str)->ptr;
 
-	if (start < 0 ? (start += slen) < 0 : start >= slen)
-	    length = 0;
-	else if (length < 0 && (length += slen + 1) < 0)
-	    length = 0;
-	else if ((length -= start) < 0)
-	    length = 0;
-	else {
-	    inptr += start;
-	    if (length > slen)
-		length = slen;
-	}
+	inptr += start;
+	if (length < 0 || length > start + slen)
+	    length = slen - start;
     }
     instart = inptr;
@@ -758,12 +750,20 @@
     VALUE str, n1, n2;
     VALUE cd = check_iconv(self);
+    long start = 0, length = 0, slen = 0;
 
-    n1 = n2 = Qnil;
     rb_scan_args(argc, argv, "12", &str, &n1, &n2);
+    if (!NIL_P(str)) slen = RSTRING_LEN(StringValue(str));
+    if (argc != 2 || !RTEST(rb_range_beg_len(n1, &start, &length, slen, 0))) {
+	if (NIL_P(n1) || ((start = NUM2LONG(n1)) < 0 ? (start += slen) >= 0 : start < slen)) {
+	    if (NIL_P(n2)) {
+		length = -1;
+	    }
+	    else if ((length = NUM2LONG(n2)) >= slen - start) {
+		length = slen - start;
+	    }
+	}
+    }
 
-    return iconv_convert(VALUE2ICONV(cd), str,
-			 NIL_P(n1) ? 0 : NUM2INT(n1),
-			 NIL_P(n2) ? -1 : NUM2INT(n2),
-			 NULL);
+    return iconv_convert(VALUE2ICONV(cd), str, start, length, NULL);
 }
 
@@ -829,5 +829,5 @@
 #endif /* HAVE_PROTOTYPES */
 {
-    char *cname = rb_class2name(CLASS_OF(self));
+    const char *cname = rb_class2name(CLASS_OF(self));
     VALUE success = rb_attr_get(self, rb_success);
     VALUE failed = rb_attr_get(self, rb_failed);
diff -NrU2 ruby-1.8.7/ext/openssl/ossl_ssl.c ruby-1.8.7-p17/ext/openssl/ossl_ssl.c
--- ruby-1.8.7/ext/openssl/ossl_ssl.c	2008-04-25 15:51:21.000000000 +0900
+++ ruby-1.8.7-p17/ext/openssl/ossl_ssl.c	2008-06-06 17:05:24.000000000 +0900
@@ -1,4 +1,4 @@
 /*
- * $Id: ossl_ssl.c 16193 2008-04-25 06:51:21Z knu $
+ * $Id: ossl_ssl.c 16857 2008-06-06 08:05:24Z knu $
  * 'OpenSSL for Ruby' project
  * Copyright (C) 2000-2002  GOTOU Yuuzou <gotoyuzo@notwork.org>
@@ -1467,4 +1467,7 @@
     ossl_ssl_def_const(OP_NO_SSLv3);
     ossl_ssl_def_const(OP_NO_TLSv1);
+#if defined(SSL_OP_NO_TICKET)
+    ossl_ssl_def_const(OP_NO_TICKET);
+#endif
     ossl_ssl_def_const(OP_PKCS1_CHECK_1);
     ossl_ssl_def_const(OP_PKCS1_CHECK_2);
diff -NrU2 ruby-1.8.7/ext/openssl/ossl_ssl_session.c ruby-1.8.7-p17/ext/openssl/ossl_ssl_session.c
--- ruby-1.8.7/ext/openssl/ossl_ssl_session.c	2008-02-26 16:11:23.000000000 +0900
+++ ruby-1.8.7-p17/ext/openssl/ossl_ssl_session.c	2008-06-06 17:05:24.000000000 +0900
@@ -48,5 +48,5 @@
 		Data_Get_Struct(arg1, SSL, ssl);
 
-		if ((ctx = SSL_get1_session(ssl)) == NULL)
+		if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
 			ossl_raise(eSSLSession, "no session available");
 	} else {
diff -NrU2 ruby-1.8.7/ext/socket/addrinfo.h ruby-1.8.7-p17/ext/socket/addrinfo.h
--- ruby-1.8.7/ext/socket/addrinfo.h	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/ext/socket/addrinfo.h	2008-06-06 21:19:21.000000000 +0900
@@ -62,8 +62,13 @@
 #undef NI_DGRAM
 
+#undef addrinfo
 #define addrinfo addrinfo__compat
+#undef getaddrinfo
 #define getaddrinfo getaddrinfo__compat
+#undef getnameinfo
 #define getnameinfo getnameinfo__compat
+#undef freehostent
 #define freehostent freehostent__compat
+#undef freeaddrinfo
 #define freeaddrinfo freeaddrinfo__compat
 
diff -NrU2 ruby-1.8.7/ext/zlib/zlib.c ruby-1.8.7-p17/ext/zlib/zlib.c
--- ruby-1.8.7/ext/zlib/zlib.c	2008-05-19 00:02:36.000000000 +0900
+++ ruby-1.8.7-p17/ext/zlib/zlib.c	2008-06-09 03:28:37.000000000 +0900
@@ -4,5 +4,5 @@
  *   Copyright (C) UENO Katsuhiro 2000-2003
  *
- * $Id: zlib.c 16458 2008-05-18 15:02:36Z knu $
+ * $Id: zlib.c 17033 2008-06-08 18:28:37Z knu $
  */
 
@@ -1183,12 +1183,17 @@
     VALUE self, orig;
 {
-    struct zstream *z1 = get_zstream(self);
-    struct zstream *z2 = get_zstream(orig);
+    struct zstream *z1, *z2;
     int err;
 
+    Data_Get_Struct(self, struct zstream, z1);
+    z2 = get_zstream(orig);
+
     err = deflateCopy(&z1->stream, &z2->stream);
     if (err != Z_OK) {
 	raise_zlib_error(err, 0);
     }
+    z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input);
+    z1->buf   = NIL_P(z2->buf)   ? Qnil : rb_str_dup(z2->buf);
+    z1->buf_filled = z2->buf_filled;
     z1->flags = z2->flags;
 
@@ -3372,5 +3377,5 @@
     rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
     rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
-    rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 0);
+    rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 1);
     rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
     rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);
diff -NrU2 ruby-1.8.7/file.c ruby-1.8.7-p17/file.c
--- ruby-1.8.7/file.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/file.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Mon Nov 15 12:24:34 JST 1993
 
@@ -2321,4 +2321,8 @@
 #endif
 
+#ifdef DOSISH_DRIVE_LETTER
+#include <ctype.h>
+#endif
+
 #if USE_NTFS
 #define istrailinggabage(x) ((x) == '.' || (x) == ' ')
@@ -2533,5 +2537,5 @@
     if (s[0] == '~') {
 	if (isdirsep(s[1]) || s[1] == '\0') {
-	    char *dir = getenv("HOME");
+	    const char *dir = getenv("HOME");
 
 	    if (!dir) {
@@ -2743,9 +2747,5 @@
 #if USE_NTFS
     *p = '\0';
-    if (1 &&
-#ifdef __CYGWIN__
-	!(buf[0] == '/' && !buf[1]) &&
-#endif
-	!strpbrk(b = buf, "*?")) {
+    if (*(s = skipprefix(b = buf)) && !strpbrk(s, "*?")) {
 	size_t len;
 	WIN32_FIND_DATA wfd;
@@ -2753,21 +2753,16 @@
 	int lnk_added = 0, is_symlink = 0;
 	struct stat st;
-	char w32buf[MAXPATHLEN], sep = 0;
-	p = 0;
+	char w32buf[MAXPATHLEN];
+	p = strrdirsep(s);
 	if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
 	    is_symlink = 1;
-	    p = strrdirsep(buf);
-	    if (!p) p = skipprefix(buf);
-	    if (p) {
-		sep = *p;
-		*p = '\0';
-	    }
+	    *p = '\0';
 	}
-	if (cygwin_conv_to_win32_path(buf, w32buf) == 0) {
+	if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
 	    b = w32buf;
 	}
-	if (p) *p = sep;
-	else p = buf;
 	if (is_symlink && b == w32buf) {
+	    *p = '\\';
+	    strlcat(w32buf, p, sizeof(w32buf));
 	    len = strlen(p);
 	    if (len > 4 && strcasecmp(p + len - 4, ".lnk") != 0) {
@@ -2776,9 +2771,9 @@
 	    }
 	}
+	*p = '/';
 #endif
 	HANDLE h = FindFirstFile(b, &wfd);
 	if (h != INVALID_HANDLE_VALUE) {
 	    FindClose(h);
-	    p = strrdirsep(buf);
 	    len = strlen(wfd.cFileName);
 #ifdef __CYGWIN__
@@ -2787,6 +2782,7 @@
 		wfd.cFileName[len -= 4] = '\0';
 	    }
+#else
+	    p = strrdirsep(s);
 #endif
-	    if (!p) p = buf;
 	    ++p;
 	    BUFCHECK(bdiff + len >= buflen);
@@ -2794,4 +2790,9 @@
 	    p += len;
 	}
+#ifdef __CYGWIN__
+	else {
+	    p += strlen(p);
+	}
+#endif
     }
 #endif
@@ -2892,7 +2893,7 @@
 {
     VALUE fname, fext, basename;
-    char *name, *p;
+    const char *name, *p;
 #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
-    char *root;
+    const char *root;
 #endif
     int f, n;
@@ -3104,5 +3105,5 @@
     int taint = 0;
     VALUE result, tmp;
-    char *name, *tail;
+    const char *name, *tail;
 
     if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
@@ -4289,5 +4290,5 @@
 {
     struct stat st;
-    char *p0 = StringValueCStr(fpath);
+    const char *p0 = StringValueCStr(fpath);
     char *p = 0, *s;
 
@@ -4328,5 +4329,5 @@
 static int
 fpath_check(path)
-    char *path;
+    const char *path;
 {
 #if ENABLE_PATH_CHECK
@@ -4339,8 +4340,8 @@
 int
 rb_path_check(path)
-    char *path;
+    const char *path;
 {
 #if ENABLE_PATH_CHECK
-    char *p0, *p, *pend;
+    const char *p0, *p, *pend;
     const char sep = PATH_SEP_CHAR;
 
@@ -4377,5 +4378,5 @@
 static int
 file_load_ok(file)
-    char *file;
+    const char *file;
 {
     FILE *f;
@@ -4395,6 +4396,6 @@
     const char * const *ext;
 {
-    char *path, *found;
-    char *f = RSTRING(*filep)->ptr;
+    const char *path, *found;
+    const char *f = RSTRING(*filep)->ptr;
     VALUE fname;
     long i, j;
@@ -4451,6 +4452,6 @@
 {
     VALUE tmp;
-    char *f = StringValueCStr(path);
-    char *lpath;
+    const char *f = StringValueCStr(path);
+    const char *lpath;
 
     if (f[0] == '~') {
diff -NrU2 ruby-1.8.7/gc.c ruby-1.8.7-p17/gc.c
--- ruby-1.8.7/gc.c	2008-05-22 02:27:56.000000000 +0900
+++ ruby-1.8.7-p17/gc.c	2008-06-09 03:21:56.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-22 02:27:56 +0900 (Thu, 22 May 2008) $
+  $Date: 2008-06-09 03:21:56 +0900 (Mon, 09 Jun 2008) $
   created at: Tue Oct  5 09:44:46 JST 1993
 
@@ -1645,4 +1645,5 @@
     int i;
     int n = 0;
+    volatile VALUE v;
 
     for (i = 0; i < heaps_used; i++) {
@@ -1663,6 +1664,7 @@
 		  default:
 		    if (!p->as.basic.klass) continue;
-		    if (!of || rb_obj_is_kind_of((VALUE)p, of)) {
-			rb_yield((VALUE)p);
+                    v = (VALUE)p;
+		    if (!of || rb_obj_is_kind_of(v, of)) {
+			rb_yield(v);
 			n++;
 		    }
diff -NrU2 ruby-1.8.7/hash.c ruby-1.8.7-p17/hash.c
--- ruby-1.8.7/hash.c	2008-05-26 03:33:05.000000000 +0900
+++ ruby-1.8.7-p17/hash.c	2008-06-09 03:25:01.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-26 03:33:05 +0900 (Mon, 26 May 2008) $
+  $Date: 2008-06-09 03:25:01 +0900 (Mon, 09 Jun 2008) $
   created at: Mon Nov 22 18:51:18 JST 1993
 
@@ -1603,5 +1603,4 @@
     if (key == Qundef) return ST_CONTINUE;
     *hval ^= rb_hash(key);
-    *hval *= 137;
     *hval ^= rb_hash(val);
     return ST_CONTINUE;
diff -NrU2 ruby-1.8.7/intern.h ruby-1.8.7-p17/intern.h
--- ruby-1.8.7/intern.h	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/intern.h	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Thu Jun 10 14:22:17 JST 1993
 
@@ -278,5 +278,5 @@
 VALUE rb_hash_delete_if _((VALUE));
 VALUE rb_hash_delete _((VALUE,VALUE));
-int rb_path_check _((char*));
+int rb_path_check _((const char*));
 int rb_env_path_tainted _((void));
 /* io.c */
diff -NrU2 ruby-1.8.7/io.c ruby-1.8.7-p17/io.c
--- ruby-1.8.7/io.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/io.c	2008-06-09 03:20:37.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-09 03:20:37 +0900 (Mon, 09 Jun 2008) $
   created at: Fri Oct 15 18:08:59 JST 1993
 
@@ -51,4 +51,7 @@
 #include <sys/fcntl.h>
 #endif
+#ifdef __CYGWIN__
+#include <io.h>
+#endif
 
 #if !HAVE_OFF_T && !defined(off_t)
@@ -430,5 +433,8 @@
 {
     FILE *f = GetWriteFile(fptr);
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
     int r;
+#endif
+
     if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
         struct stat buf;
@@ -1676,5 +1682,5 @@
 static int
 rscheck(rsptr, rslen, rs)
-    char *rsptr;
+    const char *rsptr;
     long rslen;
     VALUE rs;
@@ -3391,5 +3397,6 @@
     VALUE fname, vmode, perm;
     const char *path, *mode;
-    int flags, fmode;
+    int flags;
+    unsigned int fmode;
 
     rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
@@ -3405,5 +3412,5 @@
 	    flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
 	}
-	fmode = NIL_P(perm) ? 0666 :  NUM2INT(perm);
+	fmode = NIL_P(perm) ? 0666 :  NUM2UINT(perm);
 
 	rb_file_sysopen_internal(io, path, flags, fmode);
@@ -3461,5 +3468,6 @@
 {
     VALUE fname, vmode, perm;
-    int flags, fmode, fd;
+    int flags, fd;
+    unsigned int fmode;
     char *path;
 
@@ -3474,5 +3482,5 @@
     }
     if (NIL_P(perm)) fmode = 0666;
-    else             fmode = NUM2INT(perm);
+    else             fmode = NUM2UINT(perm);
 
     path = ALLOCA_N(char, strlen(RSTRING(fname)->ptr)+1);
@@ -4523,5 +4531,8 @@
 
 		if (ruby_inplace_mode) {
-		    struct stat st, st2;
+		    struct stat st;
+#ifndef NO_SAFE_RENAME
+		    struct stat st2;
+#endif
 		    VALUE str;
 		    FILE *fw;
diff -NrU2 ruby-1.8.7/lib/cgi/session/pstore.rb ruby-1.8.7-p17/lib/cgi/session/pstore.rb
--- ruby-1.8.7/lib/cgi/session/pstore.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/cgi/session/pstore.rb	2008-06-06 17:05:24.000000000 +0900
@@ -31,5 +31,5 @@
       # this requirement.
       # 
-      # +option+ is a hash of options for the initialiser.  The
+      # +option+ is a hash of options for the initializer.  The
       # following options are recognised:
       #
diff -NrU2 ruby-1.8.7/lib/cgi/session.rb ruby-1.8.7-p17/lib/cgi/session.rb
--- ruby-1.8.7/lib/cgi/session.rb	2007-11-15 18:17:58.000000000 +0900
+++ ruby-1.8.7-p17/lib/cgi/session.rb	2008-06-06 17:05:24.000000000 +0900
@@ -231,5 +231,5 @@
     #                to the directory of the CGI script.
     #
-    # +option+ is also passed on to the session storage class initialiser; see
+    # +option+ is also passed on to the session storage class initializer; see
     # the documentation for each session storage class for the options
     # they support.
@@ -358,5 +358,5 @@
       # this requirement.
       # 
-      # +option+ is a hash of options for the initialiser.  The
+      # +option+ is a hash of options for the initializer.  The
       # following options are recognised:
       #
diff -NrU2 ruby-1.8.7/lib/delegate.rb ruby-1.8.7-p17/lib/delegate.rb
--- ruby-1.8.7/lib/delegate.rb	2008-05-19 00:02:36.000000000 +0900
+++ ruby-1.8.7-p17/lib/delegate.rb	2008-06-06 17:05:24.000000000 +0900
@@ -164,7 +164,7 @@
   # call through \_\_getobj\_\_.
   # 
-  def respond_to?(m)
+  def respond_to?(m, include_private = false)
     return true if super
-    return self.__getobj__.respond_to?(m)
+    return self.__getobj__.respond_to?(m, include_private)
   end
 
@@ -251,5 +251,5 @@
 #
 #   class MyClass < DelegateClass( ClassToDelegateTo )    # Step 1
-#     def initiaize
+#     def initialize
 #       super(obj_of_ClassToDelegateTo)                   # Step 2
 #     end
@@ -271,7 +271,7 @@
       @_dc_obj.__send__(m, *args)
     end
-    def respond_to?(m)  # :nodoc:
+    def respond_to?(m, include_private = false)  # :nodoc:
       return true if super
-      return @_dc_obj.respond_to?(m)
+      return @_dc_obj.respond_to?(m, include_private)
     end
     def __getobj__  # :nodoc:
diff -NrU2 ruby-1.8.7/lib/erb.rb ruby-1.8.7-p17/lib/erb.rb
--- ruby-1.8.7/lib/erb.rb	2008-03-24 01:27:20.000000000 +0900
+++ ruby-1.8.7-p17/lib/erb.rb	2008-06-06 17:05:24.000000000 +0900
@@ -237,5 +237,5 @@
 #
 class ERB
-  Revision = '$Date: 2008-03-24 01:27:20 +0900 (Mon, 24 Mar 2008) $' 	#'
+  Revision = '$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $' 	#'
 
   # Returns revision information for the erb.rb module.
@@ -328,7 +328,9 @@
 
       def scan_line(line)
-        line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |token|
-	  next if token.empty?
-	  yield(token)
+        line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
+          tokens.each do |token|
+            next if token.empty?
+            yield(token)
+          end
 	end
       end
@@ -337,5 +339,5 @@
         line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
           tokens.each do |token|
-	  next if token.empty?
+            next if token.empty?
             if token == "%>\n"
               yield('%>')
@@ -356,5 +358,5 @@
             if token == "%>\n"
               yield('%>')
-              if  is_erb_stag?(head)
+              if is_erb_stag?(head)
                 yield(:cr)
               else
@@ -370,19 +372,20 @@
       end
 
-      ExplicitTrimRegexp = /(^[ \t]*<%-)|(-%>\n?\z)|(<%-)|(-%>)|(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
       def explicit_trim_line(line)
-	line.split(ExplicitTrimRegexp).each do |token|
-	  next if token.empty?
-	  if @stag.nil? && /[ \t]*<%-/ =~ token
-	    yield('<%')
-	  elsif @stag && /-%>\n/ =~ token
-	    yield('%>')
-	    yield(:cr)
-	  elsif @stag && token == '-%>'
-	    yield('%>')
-	  else
-	    yield(token)
-	  end
-	end
+        line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens|
+          tokens.each do |token|
+            next if token.empty?
+            if @stag.nil? && /[ \t]*<%-/ =~ token
+              yield('<%')
+            elsif @stag && token == "-%>\n"
+              yield('%>')
+              yield(:cr)
+            elsif @stag && token == '-%>'
+              yield('%>')
+            else
+              yield(token)
+            end
+          end
+        end
       end
 
@@ -654,5 +657,5 @@
   #    def build
   #      b = binding
-  #      # create and run templates, filling member data variebles
+  #      # create and run templates, filling member data variables
   #      ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").result b
   #        <%= PRODUCT[:name] %>
diff -NrU2 ruby-1.8.7/lib/forwardable.rb ruby-1.8.7-p17/lib/forwardable.rb
--- ruby-1.8.7/lib/forwardable.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/forwardable.rb	2008-06-06 17:05:24.000000000 +0900
@@ -2,6 +2,6 @@
 #
 #    $Release Version: 1.1$
-#    $Revision: 11708 $
-#    $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#    $Revision: 16857 $
+#    $Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #    by Keiju ISHITSUKA(keiju@ishitsuka.com)
 #
@@ -39,5 +39,5 @@
 #     end
 #     
-#     # setup prefered interface, enq() and deq()...
+#     # setup preferred interface, enq() and deq()...
 #     def_delegator :@q, :push, :enq
 #     def_delegator :@q, :shift, :deq
diff -NrU2 ruby-1.8.7/lib/irb/extend-command.rb ruby-1.8.7-p17/lib/irb/extend-command.rb
--- ruby-1.8.7/lib/irb/extend-command.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/irb/extend-command.rb	2008-06-06 17:05:24.000000000 +0900
@@ -2,6 +2,6 @@
 #   irb/extend-command.rb - irb extend command 
 #   	$Release Version: 0.9.5$
-#   	$Revision: 11708 $
-#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#   	$Revision: 16857 $
+#   	$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 #
@@ -113,5 +113,5 @@
     end
 
-    # aliases = [commans_alias, flag], ...
+    # aliases = [commands_alias, flag], ...
     def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
       case cmd_class
diff -NrU2 ruby-1.8.7/lib/irb/help.rb ruby-1.8.7-p17/lib/irb/help.rb
--- ruby-1.8.7/lib/irb/help.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/irb/help.rb	2008-06-06 17:05:24.000000000 +0900
@@ -1,7 +1,7 @@
 #
-#   irb/help.rb - print usase module
+#   irb/help.rb - print usage module
 #   	$Release Version: 0.9.5$
-#   	$Revision: 11708 $
-#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#   	$Revision: 16857 $
+#   	$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 #
diff -NrU2 ruby-1.8.7/lib/irb/notifier.rb ruby-1.8.7-p17/lib/irb/notifier.rb
--- ruby-1.8.7/lib/irb/notifier.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/irb/notifier.rb	2008-06-06 17:05:24.000000000 +0900
@@ -1,7 +1,7 @@
 #
-#   notifier.rb - optput methods used by irb 
+#   notifier.rb - output methods used by irb 
 #   	$Release Version: 0.9.5$
-#   	$Revision: 11708 $
-#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#   	$Revision: 16857 $
+#   	$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 #
diff -NrU2 ruby-1.8.7/lib/irb/ruby-lex.rb ruby-1.8.7-p17/lib/irb/ruby-lex.rb
--- ruby-1.8.7/lib/irb/ruby-lex.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/irb/ruby-lex.rb	2008-06-06 17:05:24.000000000 +0900
@@ -1,7 +1,7 @@
 #
-#   irb/ruby-lex.rb - ruby lexcal analizer
+#   irb/ruby-lex.rb - ruby lexcal analyzer
 #   	$Release Version: 0.9.5$
-#   	$Revision: 11708 $
-#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#   	$Revision: 16857 $
+#   	$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 #
@@ -16,5 +16,5 @@
 
 class RubyLex
-  @RCS_ID='-$Id: ruby-lex.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
+  @RCS_ID='-$Id: ruby-lex.rb 16857 2008-06-06 08:05:24Z knu $-'
 
   extend Exception2MessageMapper
diff -NrU2 ruby-1.8.7/lib/irb/slex.rb ruby-1.8.7-p17/lib/irb/slex.rb
--- ruby-1.8.7/lib/irb/slex.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/irb/slex.rb	2008-06-06 17:05:24.000000000 +0900
@@ -1,7 +1,7 @@
 #
-#   irb/slex.rb - symple lex analizer
+#   irb/slex.rb - simple lex analyzer
 #   	$Release Version: 0.9.5$
-#   	$Revision: 11708 $
-#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+#   	$Revision: 16857 $
+#   	$Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
 #   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 #
@@ -16,5 +16,5 @@
 module IRB
   class SLex
-    @RCS_ID='-$Id: slex.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
+    @RCS_ID='-$Id: slex.rb 16857 2008-06-06 08:05:24Z knu $-'
 
     extend Exception2MessageMapper
diff -NrU2 ruby-1.8.7/lib/logger.rb ruby-1.8.7-p17/lib/logger.rb
--- ruby-1.8.7/lib/logger.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/logger.rb	2008-06-06 17:05:24.000000000 +0900
@@ -1,3 +1,3 @@
-# logger.rb - saimple logging utility
+# logger.rb - simple logging utility
 # Copyright (C) 2000-2003, 2005  NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
 
@@ -11,5 +11,5 @@
 #   You can redistribute it and/or modify it under the same terms of Ruby's
 #   license; either the dual license version in 2003, or any later version.
-# Revision:: $Id: logger.rb 11708 2007-02-12 23:01:19Z shyouhei $
+# Revision:: $Id: logger.rb 16857 2008-06-06 08:05:24Z knu $
 #
 # == Description
@@ -171,5 +171,5 @@
 class Logger
   VERSION = "1.2.6"
-  /: (\S+),v (\S+)/ =~ %q$Id: logger.rb 11708 2007-02-12 23:01:19Z shyouhei $
+  /: (\S+),v (\S+)/ =~ %q$Id: logger.rb 16857 2008-06-06 08:05:24Z knu $
   ProgName = "#{$1}/#{$2}"
 
diff -NrU2 ruby-1.8.7/lib/net/https.rb ruby-1.8.7-p17/lib/net/https.rb
--- ruby-1.8.7/lib/net/https.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/net/https.rb	2008-06-06 17:05:24.000000000 +0900
@@ -17,5 +17,5 @@
 
 == Version
-  $Id: https.rb 11708 2007-02-12 23:01:19Z shyouhei $
+  $Id: https.rb 16857 2008-06-06 08:05:24Z knu $
   
   2001-11-06: Contiributed to Ruby/OpenSSL project.
@@ -66,9 +66,9 @@
 : key, key=((|key|))
     Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
-    (This method is appeared in Michal Rokos's OpenSSL extention.)
+    (This method is appeared in Michal Rokos's OpenSSL extension.)
 
 : cert, cert=((|cert|))
     Sets an OpenSSL::X509::Certificate object as client certificate
-    (This method is appeared in Michal Rokos's OpenSSL extention).
+    (This method is appeared in Michal Rokos's OpenSSL extension).
 
 : ca_file, ca_file=((|path|))
diff -NrU2 ruby-1.8.7/lib/optparse.rb ruby-1.8.7-p17/lib/optparse.rb
--- ruby-1.8.7/lib/optparse.rb	2007-11-05 05:17:06.000000000 +0900
+++ ruby-1.8.7-p17/lib/optparse.rb	2008-06-06 17:05:24.000000000 +0900
@@ -204,5 +204,5 @@
 class OptionParser
   # :stopdoc:
-  RCSID = %w$Id: optparse.rb 13823 2007-11-04 20:17:06Z nobu $[1..-1].each {|s| s.freeze}.freeze
+  RCSID = %w$Id: optparse.rb 16857 2008-06-06 08:05:24Z knu $[1..-1].each {|s| s.freeze}.freeze
   Version = (RCSID[1].split('.').collect {|s| s.to_i}.extend(Comparable).freeze if RCSID[1])
   LastModified = (Time.gm(*RCSID[2, 2].join('-').scan(/\d+/).collect {|s| s.to_i}) if RCSID[2])
@@ -827,5 +827,5 @@
   # Directs to reject specified class argument.
   #
-  # +t+:: Argument class speficier, any object including Class.
+  # +t+:: Argument class specifier, any object including Class.
   #
   #   reject(t)
@@ -1038,5 +1038,5 @@
   #     "-x"
   #   There is also a special form which matches character range (not full
-  #   set of regural expression):
+  #   set of regular expression):
   #     "-[a-z]MANDATORY"
   #     "-[a-z][OPTIONAL]" 
@@ -1044,5 +1044,5 @@
   #
   # [Argument style and description:]
-  #   Instead of specifying mandatory or optional orguments directly in the
+  #   Instead of specifying mandatory or optional arguments directly in the
   #   switch parameter, this separate parameter can be used.
   #     "=MANDATORY"
diff -NrU2 ruby-1.8.7/lib/pstore.rb ruby-1.8.7-p17/lib/pstore.rb
--- ruby-1.8.7/lib/pstore.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/pstore.rb	2008-06-06 17:05:24.000000000 +0900
@@ -12,5 +12,5 @@
 
 #
-# PStore implements a file based persistance mechanism based on a Hash.  User
+# PStore implements a file based persistence mechanism based on a Hash.  User
 # code can store hierarchies of Ruby objects (values) into the data store file
 # by name (keys).  An object hierarchy may be just a single object.  User code 
@@ -19,5 +19,5 @@
 # The transactional behavior ensures that any changes succeed or fail together.
 # This can be used to ensure that the data store is not left in a transitory
-# state, where some values were upated but others were not.
+# state, where some values were updated but others were not.
 # 
 # Behind the scenes, Ruby objects are stored to the data store file with 
diff -NrU2 ruby-1.8.7/lib/rdoc/parsers/parse_c.rb ruby-1.8.7-p17/lib/rdoc/parsers/parse_c.rb
--- ruby-1.8.7/lib/rdoc/parsers/parse_c.rb	2007-06-14 17:08:13.000000000 +0900
+++ ruby-1.8.7-p17/lib/rdoc/parsers/parse_c.rb	2008-06-06 17:05:24.000000000 +0900
@@ -118,8 +118,8 @@
   # as the rb_define_method.
   #
-  # C classes can be diagramed (see /tc/dl/ruby/ruby/error.c), and RDoc
+  # C classes can be diagrammed (see /tc/dl/ruby/ruby/error.c), and RDoc
   # integrates C and Ruby source into one tree
   #
-  # The comment blocks may include special direcives:
+  # The comment blocks may include special directives:
   #
   # [Document-class: <i>name</i>]
@@ -132,8 +132,8 @@
   #
   # [call-seq:  <i>text up to an empty line</i>]
-  #   Because C source doesn't give descripive names to Ruby-level parameters,
+  #   Because C source doesn't give descriptive names to Ruby-level parameters,
   #   you need to document the calling sequence explicitly
   #
-  # In additon, RDoc assumes by default that the C method implementing a 
+  # In addition, RDoc assumes by default that the C method implementing a 
   # Ruby function is in the same source file as the rb_define_method call.
   # If this isn't the case, add the comment 
diff -NrU2 ruby-1.8.7/lib/rdoc/parsers/parse_f95.rb ruby-1.8.7-p17/lib/rdoc/parsers/parse_f95.rb
--- ruby-1.8.7/lib/rdoc/parsers/parse_f95.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/rdoc/parsers/parse_f95.rb	2008-06-06 17:05:24.000000000 +0900
@@ -202,5 +202,5 @@
     end
 
-    # devine code constructs
+    # define code constructs
     def scan
 
@@ -1066,5 +1066,5 @@
     # If "all" argument is true, information of all arguments are returned.
     # If "modified_params" is true, list of arguments are decorated,
-    # for exameple, optional arguments are parenthetic as "[arg]".
+    # for example, optional arguments are parenthetic as "[arg]".
     #
     def find_arguments(args, text, all=nil, indent=nil, modified_params=nil)
@@ -1144,6 +1144,6 @@
     #
     # Comments just after module or subprogram, or arguments are
-    # returnd. If "COMMENTS_ARE_UPPER" is true, comments just before
-    # modules or subprograms are returnd
+    # returned. If "COMMENTS_ARE_UPPER" is true, comments just before
+    # modules or subprograms are returned
     #
     def find_comments text
diff -NrU2 ruby-1.8.7/lib/resolv.rb ruby-1.8.7-p17/lib/resolv.rb
--- ruby-1.8.7/lib/resolv.rb	2008-04-10 14:13:15.000000000 +0900
+++ ruby-1.8.7-p17/lib/resolv.rb	2008-06-06 17:05:24.000000000 +0900
@@ -253,5 +253,5 @@
 
     ##
-    # Iterates over all hostnames for +address+ retrived from the hosts file.
+    # Iterates over all hostnames for +address+ retrieved from the hosts file.
 
     def each_name(address, &proc)
@@ -2016,5 +2016,5 @@
 
     ##
-    # A String reperesentation of this IPv4 address.
+    # A String representation of this IPv4 address.
 
     ##
diff -NrU2 ruby-1.8.7/lib/rexml/attlistdecl.rb ruby-1.8.7-p17/lib/rexml/attlistdecl.rb
--- ruby-1.8.7/lib/rexml/attlistdecl.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/attlistdecl.rb	2008-06-06 17:05:24.000000000 +0900
@@ -45,5 +45,5 @@
 		end
 
-		# Itterate over the key/value pairs:
+		# Iterate over the key/value pairs:
 		#  attlist_decl.each { |attribute_name, attribute_value| ... }
 		def each(&block)
diff -NrU2 ruby-1.8.7/lib/rexml/document.rb ruby-1.8.7-p17/lib/rexml/document.rb
--- ruby-1.8.7/lib/rexml/document.rb	2008-04-18 16:22:13.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/document.rb	2008-06-06 17:05:24.000000000 +0900
@@ -148,5 +148,5 @@
     # declaration (<?xml version='1.0'?>) whether or not one is given by the
     # user (or source document).  REXML does not write one if one was not
-    # specified, because it adds unneccessary bandwidth to applications such
+    # specified, because it adds unnecessary bandwidth to applications such
     # as XML-RPC.
     #
diff -NrU2 ruby-1.8.7/lib/rexml/element.rb ruby-1.8.7-p17/lib/rexml/element.rb
--- ruby-1.8.7/lib/rexml/element.rb	2008-04-18 16:22:13.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/element.rb	2008-06-06 17:05:24.000000000 +0900
@@ -361,5 +361,5 @@
     # has a particular text set.
     # text:: 
-    #   the text to search for.  If nil, or not supplied, will itterate
+    #   the text to search for.  If nil, or not supplied, will iterate
     #   over all +Element+ children that contain at least one +Text+ node.
     # max:: 
@@ -990,5 +990,5 @@
     alias :size :length
 
-    # Itterates over the attributes of an Element.  Yields actual Attribute
+    # Iterates over the attributes of an Element.  Yields actual Attribute
     # nodes, not String values.
     # 
@@ -1007,5 +1007,5 @@
     end
 
-    # Itterates over each attribute of an Element, yielding the expanded name
+    # Iterates over each attribute of an Element, yielding the expanded name
     # and value as a pair of Strings.
     #
diff -NrU2 ruby-1.8.7/lib/rexml/formatters/pretty.rb ruby-1.8.7-p17/lib/rexml/formatters/pretty.rb
--- ruby-1.8.7/lib/rexml/formatters/pretty.rb	2007-07-30 11:26:17.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/formatters/pretty.rb	2008-06-06 17:05:24.000000000 +0900
@@ -126,5 +126,5 @@
 
       def wrap(string, width)
-        # Recursivly wrap string at width.
+        # Recursively wrap string at width.
         return string if string.length <= width
         place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
diff -NrU2 ruby-1.8.7/lib/rexml/functions.rb ruby-1.8.7-p17/lib/rexml/functions.rb
--- ruby-1.8.7/lib/rexml/functions.rb	2008-04-18 16:22:13.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/functions.rb	2008-06-06 17:05:24.000000000 +0900
@@ -236,5 +236,5 @@
       # subsequent mappings
       #
-      # if a charactcer maps to nil then we delete it
+      # if a character maps to nil then we delete it
       # in the output.  This happens if the from
       # string is longer than the to string
diff -NrU2 ruby-1.8.7/lib/rexml/text.rb ruby-1.8.7-p17/lib/rexml/text.rb
--- ruby-1.8.7/lib/rexml/text.rb	2008-04-18 16:22:13.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/text.rb	2008-06-06 17:05:24.000000000 +0900
@@ -190,5 +190,5 @@
  
      def wrap(string, width, addnewline=false)
-       # Recursivly wrap string at width.
+       # Recursively wrap string at width.
        return string if string.length <= width
        place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
diff -NrU2 ruby-1.8.7/lib/rexml/xpath.rb ruby-1.8.7-p17/lib/rexml/xpath.rb
--- ruby-1.8.7/lib/rexml/xpath.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/rexml/xpath.rb	2008-06-06 17:05:24.000000000 +0900
@@ -31,5 +31,5 @@
 		end
 
-		# Itterates over nodes that match the given path, calling the supplied
+		# Iterates over nodes that match the given path, calling the supplied
 		# block with the match.
 		# element::
diff -NrU2 ruby-1.8.7/lib/rinda/ring.rb ruby-1.8.7-p17/lib/rinda/ring.rb
--- ruby-1.8.7/lib/rinda/ring.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/rinda/ring.rb	2008-06-06 17:05:24.000000000 +0900
@@ -20,5 +20,5 @@
   # 2. A RingFinger sends a UDP packet containing the DRb URI where it will
   #    listen for a reply.
-  # 3. The RingServer recieves the UDP packet and connects back to the
+  # 3. The RingServer receives the UDP packet and connects back to the
   #    provided DRb URI with the DRb service.
 
@@ -120,5 +120,5 @@
 
     ##
-    # Contains all discoverd TupleSpaces except for the primary.
+    # Contains all discovered TupleSpaces except for the primary.
 
     def self.to_a
diff -NrU2 ruby-1.8.7/lib/set.rb ruby-1.8.7-p17/lib/set.rb
--- ruby-1.8.7/lib/set.rb	2008-04-23 14:18:50.000000000 +0900
+++ ruby-1.8.7-p17/lib/set.rb	2008-06-09 18:20:43.000000000 +0900
@@ -10,5 +10,5 @@
 # terms as Ruby.
 #
-#   $Id: set.rb 16171 2008-04-23 05:18:50Z knu $
+#   $Id: set.rb 17051 2008-06-09 09:20:43Z knu $
 #
 # == Overview 
@@ -235,5 +235,5 @@
   # true, and returns self.
   def delete_if
-    @hash.delete_if { |o,| yield(o) }
+    to_a.each { |o| @hash.delete(o) if yield(o) }
     self
   end
@@ -493,5 +493,5 @@
 	  def delete_if
 	    n = @hash.size
-	    @hash.delete_if { |o,| yield(o) }
+	    super
 	    @keys = nil if @hash.size != n
 	    self
@@ -506,4 +506,5 @@
 	    block_given? or return enum_for(__method__)
 	    to_a.each { |o| yield(o) }
+	    self
 	  end
 
@@ -922,4 +923,7 @@
     set = Set.new(ary)
 
+    ret = set.each { |o| }
+    assert_same(set, ret)
+
     e = set.each
     assert_instance_of(Enumerable::Enumerator, e)
@@ -1168,9 +1172,31 @@
 
     prev = nil
-    s.each { |o| assert(prev < o) if prev; prev = o }
+    ret = s.each { |o| assert(prev < o) if prev; prev = o }
     assert_not_nil(prev)
+    assert_same(s, ret)
 
     s = SortedSet.new([2,1,3]) { |o| o * -2 }
     assert_equal([-6,-4,-2], s.to_a)
+
+    s = SortedSet.new(['one', 'two', 'three', 'four'])
+    a = []
+    ret = s.delete_if { |o| a << o; o.start_with?('t') }
+    assert_same(s, ret)
+    assert_equal(['four', 'one'], s.to_a)
+    assert_equal(['four', 'one', 'three', 'two'], a)
+
+    s = SortedSet.new(['one', 'two', 'three', 'four'])
+    a = []
+    ret = s.reject! { |o| a << o; o.start_with?('t') }
+    assert_same(s, ret)
+    assert_equal(['four', 'one'], s.to_a)
+    assert_equal(['four', 'one', 'three', 'two'], a)
+
+    s = SortedSet.new(['one', 'two', 'three', 'four'])
+    a = []
+    ret = s.reject! { |o| a << o; false }
+    assert_same(nil, ret)
+    assert_equal(['four', 'one', 'three', 'two'], s.to_a)
+    assert_equal(['four', 'one', 'three', 'two'], a)
   end
 end
diff -NrU2 ruby-1.8.7/lib/time.rb ruby-1.8.7-p17/lib/time.rb
--- ruby-1.8.7/lib/time.rb	2008-01-14 09:33:29.000000000 +0900
+++ ruby-1.8.7-p17/lib/time.rb	2008-06-06 17:05:24.000000000 +0900
@@ -364,5 +364,5 @@
         sec = $6.to_i
         usec = 0
-        usec = $7.to_f * 1000000 if $7
+        usec = ($7[1..-1] + '000000')[0,6].to_i if $7
         if $8
           zone = $8
@@ -622,4 +622,6 @@
         assert_equal("1960-12-31T23:00:00.123456Z", t.xmlschema(6))
       end
+
+      assert_equal(249, Time.xmlschema("2008-06-05T23:49:23.000249+09:00").usec)
     end
 
diff -NrU2 ruby-1.8.7/lib/webrick/httpproxy.rb ruby-1.8.7-p17/lib/webrick/httpproxy.rb
--- ruby-1.8.7/lib/webrick/httpproxy.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/webrick/httpproxy.rb	2008-06-06 17:05:24.000000000 +0900
@@ -48,5 +48,5 @@
     end
 
-    # Some header fields shuold not be transfered.
+    # Some header fields should not be transferred.
     HopByHop = %w( connection keep-alive proxy-authenticate upgrade
                    proxy-authorization te trailers transfer-encoding )
diff -NrU2 ruby-1.8.7/lib/webrick/httpresponse.rb ruby-1.8.7-p17/lib/webrick/httpresponse.rb
--- ruby-1.8.7/lib/webrick/httpresponse.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/lib/webrick/httpresponse.rb	2008-06-06 17:05:24.000000000 +0900
@@ -133,5 +133,5 @@
       end
 
-      # Determin the message length (RFC2616 -- 4.4 Message Length)
+      # Determine the message length (RFC2616 -- 4.4 Message Length)
       if @status == 304 || @status == 204 || HTTPStatus::info?(@status)
         @header.delete('content-length')
diff -NrU2 ruby-1.8.7/marshal.c ruby-1.8.7-p17/marshal.c
--- ruby-1.8.7/marshal.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/marshal.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Thu Apr 27 16:30:01 JST 1995
 
@@ -131,5 +131,5 @@
 static void
 w_nbyte(s, n, arg)
-    char *s;
+    const char *s;
     int n;
     struct dump_arg *arg;
@@ -154,5 +154,5 @@
 static void
 w_bytes(s, n, arg)
-    char *s;
+    const char *s;
     int n;
     struct dump_arg *arg;
@@ -355,5 +355,5 @@
 static void
 w_unique(s, arg)
-    char *s;
+    const char *s;
     struct dump_arg *arg;
 {
@@ -992,5 +992,5 @@
 static VALUE
 path2class(path)
-    char *path;
+    const char *path;
 {
     VALUE v = rb_path2class(path);
@@ -1004,5 +1004,5 @@
 static VALUE
 path2module(path)
-    char *path;
+    const char *path;
 {
     VALUE v = rb_path2class(path);
diff -NrU2 ruby-1.8.7/missing/crypt.c ruby-1.8.7-p17/missing/crypt.c
--- ruby-1.8.7/missing/crypt.c	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/missing/crypt.c	2008-06-06 19:39:57.000000000 +0900
@@ -108,11 +108,13 @@
 #endif
 
+int des_setkey(), des_cipher();
+
 /* compile with "-DSTATIC=int" when profiling */
 #ifndef STATIC
 #define	STATIC	static
 #endif
-STATIC init_des(), init_perm(), permute();
+STATIC void init_des(), init_perm(), permute();
 #ifdef DEBUG
-STATIC prtab();
+STATIC void prtab();
 #endif
 
@@ -300,5 +302,5 @@
 	{ C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); }
 
-STATIC
+STATIC void
 permute(cp, out, p, chars_in)
 	unsigned char *cp;
@@ -378,4 +380,5 @@
 
 static unsigned char S[8][64] = {	/* 48->32 bit substitution tables */
+    {
 					/* S[1]			*/
 	14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7,
@@ -383,4 +386,6 @@
 	 4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0,
 	15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13,
+    },
+    {
 					/* S[2]			*/
 	15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10,
@@ -388,4 +393,6 @@
 	 0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15,
 	13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9,
+    },
+    {
 					/* S[3]			*/
 	10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8,
@@ -393,4 +400,6 @@
 	13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7,
 	 1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12,
+    },
+    {
 					/* S[4]			*/
 	 7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15,
@@ -398,4 +407,6 @@
 	10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4,
 	 3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14,
+    },
+    {
 					/* S[5]			*/
 	 2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9,
@@ -403,4 +414,6 @@
 	 4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14,
 	11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3,
+    },
+    {
 					/* S[6]			*/
 	12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11,
@@ -408,4 +421,6 @@
 	 9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6,
 	 4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13,
+    },
+    {
 					/* S[7]			*/
 	 4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1,
@@ -413,4 +428,6 @@
 	 1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2,
 	 6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12,
+    },
+    {
 					/* S[8]			*/
 	13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7,
@@ -418,4 +435,5 @@
 	 7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8,
 	 2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11,
+    },
 };
 
@@ -581,4 +599,5 @@
  * Set up the key schedule from the key.
  */
+int
 des_setkey(key)
 	register const char *key;
@@ -615,4 +634,5 @@
  * compiler and machine architecture.
  */
+int
 des_cipher(in, out, salt, num_iter)
 	const char *in;
@@ -735,5 +755,5 @@
  * done at compile time, if the compiler were capable of that sort of thing.
  */
-STATIC
+STATIC void
 init_des()
 {
@@ -879,5 +899,5 @@
  * "perm" must be all-zeroes on entry to this routine.
  */
-STATIC
+STATIC void
 init_perm(perm, p, chars_in, chars_out)
 	C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
@@ -903,4 +923,5 @@
  * "setkey" routine (for backwards compatibility)
  */
+int
 setkey(key)
 	register const char *key;
@@ -923,4 +944,5 @@
  * "encrypt" routine (for backwards compatibility)
  */
+int
 encrypt(block, flag)
 	register char *block;
@@ -951,5 +973,5 @@
 
 #ifdef DEBUG
-STATIC
+STATIC void
 prtab(s, t, num_rows)
 	char *s;
diff -NrU2 ruby-1.8.7/missing/vsnprintf.c ruby-1.8.7-p17/missing/vsnprintf.c
--- ruby-1.8.7/missing/vsnprintf.c	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/missing/vsnprintf.c	2008-06-06 17:05:24.000000000 +0900
@@ -497,5 +497,5 @@
 	/*
 	 * Choose PADSIZE to trade efficiency vs. size.  If larger printf
-	 * fields occur frequently, increase PADSIZE and make the initialisers
+	 * fields occur frequently, increase PADSIZE and make the initializers
 	 * below longer.
 	 */
diff -NrU2 ruby-1.8.7/missing.h ruby-1.8.7-p17/missing.h
--- ruby-1.8.7/missing.h	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/missing.h	2008-06-06 19:39:57.000000000 +0900
@@ -4,6 +4,6 @@
   	      for missing timeval struct
 
-  $Author: shyouhei $
-  $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
+  $Author: knu $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Sat May 11 23:46:03 JST 2002
 
@@ -33,5 +33,5 @@
 
 #ifndef HAVE_CRYPT
-extern char *crypt _((char *, char *));
+extern char *crypt _((const char *, const char *));
 #endif
 
diff -NrU2 ruby-1.8.7/mkconfig.rb ruby-1.8.7-p17/mkconfig.rb
--- ruby-1.8.7/mkconfig.rb	2008-05-29 20:23:36.000000000 +0900
+++ ruby-1.8.7-p17/mkconfig.rb	2008-06-06 19:39:57.000000000 +0900
@@ -76,4 +76,5 @@
     next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
     next if $so_name and /^RUBY_SO_NAME$/ =~  name
+    next if /^(?:X|(?:MINI|RUN)RUBY$)/ =~ name
     if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val
       next if $install_name
diff -NrU2 ruby-1.8.7/object.c ruby-1.8.7-p17/object.c
--- ruby-1.8.7/object.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/object.c	2008-06-06 17:05:24.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 17:05:24 +0900 (Fri, 06 Jun 2008) $
   created at: Thu Jul 15 12:01:24 JST 1993
 
@@ -1574,6 +1574,19 @@
  *     class.allocate()   =>   obj
  *  
- *  Allocates space for a new object of <i>class</i>'s class. The
- *  returned object must be an instance of <i>class</i>.
+ *  Allocates space for a new object of <i>class</i>'s class and does not
+ *  call initialize on the new instance. The returned object must be an
+ *  instance of <i>class</i>.
+ *  
+ *      klass = Class.new do
+ *        def initialize(*args)
+ *          @initialized = true
+ *        end
+ *      
+ *        def initialized?
+ *          @initialized || false
+ *        end
+ *      end
+ *      
+ *      klass.allocate.initialized? #=> false
  *     
  */
diff -NrU2 ruby-1.8.7/pack.c ruby-1.8.7-p17/pack.c
--- ruby-1.8.7/pack.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/pack.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Thu Feb 10 15:17:05 JST 1994
 
@@ -1885,6 +1885,6 @@
 	  case 'P':
 	    if (sizeof(char *) <= send - s) {
+		VALUE tmp = Qnil;
 		char *t;
-		VALUE tmp;
 
 		memcpy(&t, s, sizeof(char *));
@@ -1916,7 +1916,4 @@
 		    }
 		}
-		else {
-		    tmp = Qnil;
-		}
 		rb_ary_push(ary, tmp);
 	    }
@@ -1930,5 +1927,5 @@
 		    break;
 		else {
-		    VALUE tmp;
+		    VALUE tmp = Qnil;
 		    char *t;
 
@@ -1955,7 +1952,4 @@
 			}
 		    }
-		    else {
-			tmp = Qnil;
-		    }
 		    rb_ary_push(ary, tmp);
 		}
diff -NrU2 ruby-1.8.7/parse.c ruby-1.8.7-p17/parse.c
--- ruby-1.8.7/parse.c	2008-06-01 00:18:45.000000000 +0900
+++ ruby-1.8.7-p17/parse.c	2008-06-09 18:38:05.000000000 +0900
@@ -11032,4 +11032,8 @@
 {
 #if defined(YYMALLOC)
+    (void)rb_parser_realloc;
+    (void)rb_parser_calloc;
+    (void)nodetype;
+    (void)nodeline;
     return Qfalse;
 #else
diff -NrU2 ruby-1.8.7/parse.y ruby-1.8.7-p17/parse.y
--- ruby-1.8.7/parse.y	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/parse.y	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Fri May 28 18:02:42 JST 1993
 
@@ -5892,4 +5892,8 @@
 {
 #if defined(YYMALLOC)
+    (void)rb_parser_realloc;
+    (void)rb_parser_calloc;
+    (void)nodetype;
+    (void)nodeline;
     return Qfalse;
 #else
diff -NrU2 ruby-1.8.7/process.c ruby-1.8.7-p17/process.c
--- ruby-1.8.7/process.c	2008-05-27 19:07:07.000000000 +0900
+++ ruby-1.8.7-p17/process.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-27 19:07:07 +0900 (Tue, 27 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Tue Aug 10 14:30:50 JST 1993
 
@@ -1025,7 +1025,9 @@
     const char *str;
 {
+#ifndef _WIN32
     const char *s = str;
     char *ss, *t;
     char **argv, **a;
+#endif
 
     while (*str && ISSPACE(*str))
@@ -1090,5 +1092,7 @@
     char *prog;
 {
+#if defined(__human68k__)
     char *extension;
+#endif
     int status;
 
@@ -1406,10 +1410,10 @@
     static int overriding;
 #ifdef SIGHUP
-    RETSIGTYPE (*hfunc)_((int));
+    RETSIGTYPE (*hfunc)_((int)) = 0;
 #endif
 #ifdef SIGQUIT
-    RETSIGTYPE (*qfunc)_((int));
+    RETSIGTYPE (*qfunc)_((int)) = 0;
 #endif
-    RETSIGTYPE (*ifunc)_((int));
+    RETSIGTYPE (*ifunc)_((int)) = 0;
     int status;
     int i, hooked = Qfalse;
@@ -1651,5 +1655,7 @@
 proc_getpgrp()
 {
+#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
     int pgrp;
+#endif
 
     rb_secure(2);
diff -NrU2 ruby-1.8.7/re.c ruby-1.8.7-p17/re.c
--- ruby-1.8.7/re.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/re.c	2008-06-06 19:39:57.000000000 +0900
@@ -624,5 +624,5 @@
 {
     Regexp *rp;
-    char *err;
+    const char *err;
 
     /* Handle escaped characters first. */
@@ -847,5 +847,5 @@
 
     if (need_recompile) {
-	char *err;
+	const char *err;
 
 	if (FL_TEST(re, KCODE_FIXED))
diff -NrU2 ruby-1.8.7/regex.c ruby-1.8.7-p17/regex.c
--- ruby-1.8.7/regex.c	2008-04-23 02:29:39.000000000 +0900
+++ ruby-1.8.7-p17/regex.c	2008-06-06 19:39:57.000000000 +0900
@@ -165,5 +165,5 @@
 static void store_jump_n _((char*, int, char*, unsigned));
 static void insert_jump_n _((int, char*, char*, char*, unsigned));
-static void insert_op _((int, char*, char*));
+/*static void insert_op _((int, char*, char*));*/
 static void insert_op_2 _((int, char*, char*, int, int));
 static int memcmp_translate _((unsigned char*, unsigned char*, int));
@@ -509,4 +509,5 @@
 }
 
+#if 0
 static void
 print_mbc(c)
@@ -539,4 +540,5 @@
   }
 }
+#endif
 
 /* If the buffer isn't allocated when it comes in, use this.  */
@@ -753,4 +755,5 @@
 }
 
+#if 0
 static void
 print_partial_compiled_pattern(start, end)
@@ -1007,4 +1010,5 @@
   print_partial_compiled_pattern(buffer, buffer + bufp->used);
 }
+#endif
 
 static char*
@@ -1209,5 +1213,5 @@
    re_compile_pattern returns. */
 
-char *
+const char *
 re_compile_pattern(pattern, size, bufp)
      const char *pattern;
@@ -2581,4 +2585,5 @@
 
 
+#if 0
 /* Open up space at location THERE, and insert operation OP.
    CURRENT_END gives the end of the storage in use, so
@@ -2600,4 +2605,5 @@
   there[0] = (char)op;
 }
+#endif
 
 
diff -NrU2 ruby-1.8.7/regex.h ruby-1.8.7-p17/regex.h
--- ruby-1.8.7/regex.h	2007-02-13 08:01:19.000000000 +0900
+++ ruby-1.8.7-p17/regex.h	2008-06-06 19:39:57.000000000 +0900
@@ -185,5 +185,5 @@
 #ifdef __STDC__
 
-extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
+extern const char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
 void re_free_pattern (struct re_pattern_buffer *);
 /* Is this really advertised?  */
@@ -206,5 +206,5 @@
 #else /* !__STDC__ */
 
-extern char *re_compile_pattern ();
+extern const char *re_compile_pattern ();
 void re_free_regexp ();
 /* Is this really advertised? */
diff -NrU2 ruby-1.8.7/ruby.c ruby-1.8.7-p17/ruby.c
--- ruby-1.8.7/ruby.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/ruby.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Tue Aug 10 12:47:31 JST 1993
 
@@ -810,4 +810,7 @@
 	else {
 	    script = argv[0];
+#if defined DOSISH || defined __CYGWIN__
+	    translate_char(argv[0], '\\', '/');
+#endif
 	    if (script[0] == '\0') {
 		script = "-";
@@ -826,8 +829,8 @@
 		script = ruby_sourcefile = rb_source_filename(script);
 		script_node = NEW_NEWLINE(0);
-	    }
 #if defined DOSISH || defined __CYGWIN__
-	    translate_char(script, '\\', '/');
+		translate_char(ruby_sourcefile, '\\', '/');
 #endif
+	    }
 	    argc--; argv++;
 	}
diff -NrU2 ruby-1.8.7/signal.c ruby-1.8.7-p17/signal.c
--- ruby-1.8.7/signal.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/signal.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Tue Dec 20 10:13:44 JST 1994
 
@@ -686,4 +686,5 @@
 };
 
+#if USE_TRAP_MASK
 # ifdef HAVE_SIGPROCMASK
 static sigset_t trap_last_mask;
@@ -691,4 +692,5 @@
 static int trap_last_mask;
 # endif
+#endif
 
 static RETSIGTYPE sigexit _((int));
@@ -992,4 +994,5 @@
 #endif
 
+#if defined(SIGCLD) || defined(SIGCHLD)
 static void
 init_sigchld(sig)
@@ -1033,4 +1036,5 @@
 #endif
 }
+#endif
 
 /*
diff -NrU2 ruby-1.8.7/sprintf.c ruby-1.8.7-p17/sprintf.c
--- ruby-1.8.7/sprintf.c	2008-05-19 14:44:47.000000000 +0900
+++ ruby-1.8.7-p17/sprintf.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-19 14:44:47 +0900 (Mon, 19 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Fri Oct 15 10:39:26 JST 1993
 
@@ -719,5 +719,5 @@
 #if defined(_WIN32) && !defined(__BORLANDC__)
 		if (isnan(fval) || isinf(fval)) {
-		    char *expr;
+		    const char *expr;
 
 		    if  (isnan(fval)) {
diff -NrU2 ruby-1.8.7/string.c ruby-1.8.7-p17/string.c
--- ruby-1.8.7/string.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/string.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Mon Aug  9 17:12:58 JST 1993
 
@@ -4480,5 +4480,5 @@
     VALUE str, salt;
 {
-    extern char *crypt();
+    extern char *crypt _((const char *, const char*));
     VALUE result;
     const char *s;
diff -NrU2 ruby-1.8.7/test/erb/test_erb.rb ruby-1.8.7-p17/test/erb/test_erb.rb
--- ruby-1.8.7/test/erb/test_erb.rb	2008-02-12 11:52:43.000000000 +0900
+++ ruby-1.8.7-p17/test/erb/test_erb.rb	2008-06-03 10:18:47.000000000 +0900
@@ -45,24 +45,24 @@
   end
 
-  def test_01
-    _test_01(nil)
-    _test_01(0)
-    _test_01(1)
-    _test_01(2)
-    _test_01(3)
+  def test_core
+    _test_core(nil)
+    _test_core(0)
+    _test_core(1)
+    _test_core(2)
+    _test_core(3)
   end
 
-  def _test_01(safe)
+  def _test_core(safe)
     erb = @erb.new("hello")
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 0)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 1)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 2)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     src = <<EOS
@@ -158,12 +158,12 @@
   end
 
-  def test_02_safe_04
+  def test_safe_04
     erb = @erb.new('<%=$SAFE%>', 4)
-    assert_equal(erb.result(TOPLEVEL_BINDING.taint), '4')
+    assert_equal('4', erb.result(TOPLEVEL_BINDING.taint))
   end
 
   class Foo; end
 
-  def test_03_def_class
+  def test_def_class
     erb = @erb.new('hello')
     cls = erb.def_class
@@ -178,5 +178,5 @@
   end
 
-  def test_04_percent
+  def test_percent
     src = <<EOS
 %n = 1
@@ -219,24 +219,22 @@
   end
 
-  class Bar; end
-
-  def test_05_def_method
-    assert(! Bar.new.respond_to?('hello'))
-    Bar.module_eval do
+  def test_def_method
+    klass = Class.new
+    klass.module_eval do
       extend ERB::DefMethod
       fname = File.join(File.dirname(File.expand_path(__FILE__)), 'hello.erb')
       def_erb_method('hello', fname)
     end
-    assert(Bar.new.respond_to?('hello'))
+    assert(klass.new.respond_to?('hello'))
 
-    assert(! Bar.new.respond_to?('hello_world'))
+    assert(! klass.new.respond_to?('hello_world'))
     erb = @erb.new('hello, world')
-    Bar.module_eval do
+    klass.module_eval do
       def_erb_method('hello_world', erb)
     end
-    assert(Bar.new.respond_to?('hello_world'))    
+    assert(klass.new.respond_to?('hello_world'))    
   end
 
-  def test_06_escape
+  def test_escape
     src = <<EOS
 1.<%% : <%="<%%"%>
@@ -275,5 +273,5 @@
   end
 
-  def test_07_keep_lineno
+  def test_keep_lineno
     src = <<EOS
 Hello, 
@@ -379,5 +377,5 @@
   end
 
-  def test_08_explicit
+  def test_explicit
     src = <<EOS
 <% x = %w(hello world) -%>
@@ -412,2 +410,15 @@
   end
 end
+
+class TestERBCoreWOStrScan < TestERBCore
+  def setup
+    @save_map = ERB::Compiler::Scanner.instance_variable_get('@scanner_map')
+    map = {[nil, false]=>ERB::Compiler::SimpleScanner}
+    ERB::Compiler::Scanner.instance_variable_set('@scanner_map', map)
+    super
+  end
+
+  def teardown
+    ERB::Compiler::Scanner.instance_variable_set('@scanner_map', @save_map)
+  end
+end
diff -NrU2 ruby-1.8.7/test/iconv/test_basic.rb ruby-1.8.7-p17/test/iconv/test_basic.rb
--- ruby-1.8.7/test/iconv/test_basic.rb	1970-01-01 09:00:00.000000000 +0900
+++ ruby-1.8.7-p17/test/iconv/test_basic.rb	2008-06-06 18:36:19.000000000 +0900
@@ -0,0 +1,49 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Basic < TestIconv
+  def test_euc2sjis
+    iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str)
+    iconv.close
+  end
+
+  def test_close
+    iconv = Iconv.new('Shift_JIS', 'EUC-JP')
+    output = ""
+    begin
+      output += iconv.iconv(EUCJ_STR)
+      output += iconv.iconv(nil)
+    ensure
+      assert_respond_to(iconv, :close)
+      assert_equal("", iconv.close)
+      assert_equal(SJIS_STR, output)
+    end
+  end
+
+  def test_open_without_block
+    assert_respond_to(Iconv, :open)
+    iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str )
+    iconv.close
+  end
+
+  def test_open_with_block
+    input = "#{EUCJ_STR}\n"*2
+    output = ""
+    Iconv.open("Shift_JIS", "EUC-JP") do |cd|
+      input.each_line do |s|
+        output << cd.iconv(s)
+      end
+      output << cd.iconv(nil)
+    end
+    assert_equal("#{SJIS_STR}\n"*2, output)
+  end
+
+  def test_unknown_encoding
+    assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") }
+  end
+end if defined?(TestIconv)
diff -NrU2 ruby-1.8.7/test/iconv/test_option.rb ruby-1.8.7-p17/test/iconv/test_option.rb
--- ruby-1.8.7/test/iconv/test_option.rb	1970-01-01 09:00:00.000000000 +0900
+++ ruby-1.8.7-p17/test/iconv/test_option.rb	2008-06-06 18:36:19.000000000 +0900
@@ -0,0 +1,31 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Option < TestIconv
+  def test_ignore_option
+    iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str)
+    iconv.close
+
+    iconv = Iconv.new('SHIFT_JIS//IGNORE', 'EUC-JP//ignore')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str)
+    iconv.close
+  end
+
+  def test_translit_option
+    iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str)
+    iconv.close
+
+    iconv = Iconv.new('SHIFT_JIS//TRANSLIT', 'EUC-JP//translit//ignore')
+    str = iconv.iconv(EUCJ_STR)
+    str << iconv.iconv(nil)
+    assert_equal(SJIS_STR, str)
+    iconv.close
+  end
+end if defined?(TestIconv)
diff -NrU2 ruby-1.8.7/test/iconv/test_partial.rb ruby-1.8.7-p17/test/iconv/test_partial.rb
--- ruby-1.8.7/test/iconv/test_partial.rb	1970-01-01 09:00:00.000000000 +0900
+++ ruby-1.8.7-p17/test/iconv/test_partial.rb	2008-06-06 18:36:19.000000000 +0900
@@ -0,0 +1,41 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Partial < TestIconv
+  def test_partial_ascii
+    c = Iconv.open(ASCII, ASCII)
+    ref = '[ruby-core:17092]'
+  rescue
+    return
+  else
+    assert_equal("abc", c.iconv("abc"))
+    assert_equal("c",   c.iconv("abc", 2),     "#{ref}: with start")
+    assert_equal("c",   c.iconv("abc", 2, 1),  "#{ref}: with start, length")
+    assert_equal("c",   c.iconv("abc", 2, 5),  "#{ref}: with start, longer length")
+    assert_equal("bc",  c.iconv("abc", -2),    "#{ref}: with nagative start")
+    assert_equal("b",   c.iconv("abc", -2, 1), "#{ref}: with nagative start, length")
+    assert_equal("bc",  c.iconv("abc", -2, 5), "#{ref}: with nagative start, longer length")
+    assert_equal("",    c.iconv("abc", 5),     "#{ref}: with OOB")
+    assert_equal("",    c.iconv("abc", 5, 2),  "#{ref}: with OOB, length")
+  ensure
+    c.close if c
+  end
+
+  def test_partial_euc2sjis
+    c = Iconv.open('SHIFT_JIS', 'EUC-JP')
+  rescue
+    return
+  else
+    assert_equal(SJIS_STR[0, 2],   c.iconv(EUCJ_STR, 0, 2))
+    assert_equal(SJIS_STR,         c.iconv(EUCJ_STR, 0, 20))
+    assert_equal(SJIS_STR[2..-1],  c.iconv(EUCJ_STR, 2))
+    assert_equal(SJIS_STR[2, 2],   c.iconv(EUCJ_STR, 2, 2))
+    assert_equal(SJIS_STR[2..-1],  c.iconv(EUCJ_STR, 2, 20))
+    assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4))
+    assert_equal(SJIS_STR[-4, 2],  c.iconv(EUCJ_STR, -4, 2))
+    assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4, 20))
+    assert_equal("",               c.iconv(EUCJ_STR, 20))
+    assert_equal("",               c.iconv(EUCJ_STR, 20, 2))
+  ensure
+    c.close
+  end
+end if defined?(TestIconv)
diff -NrU2 ruby-1.8.7/test/iconv/utils.rb ruby-1.8.7-p17/test/iconv/utils.rb
--- ruby-1.8.7/test/iconv/utils.rb	1970-01-01 09:00:00.000000000 +0900
+++ ruby-1.8.7-p17/test/iconv/utils.rb	2008-06-06 18:36:19.000000000 +0900
@@ -0,0 +1,26 @@
+begin
+  require 'iconv'
+rescue LoadError
+else
+  require 'test/unit'
+end
+
+class TestIconv < ::Test::Unit::TestCase
+  if defined?(::Encoding) and String.method_defined?(:force_encoding)
+    def self.encode(str, enc)
+      str.force_encoding(enc)
+    end
+  else
+    def self.encode(str, enc)
+      str
+    end
+  end
+
+  def default_test
+    self.class == TestIconv or super
+  end
+
+  ASCII = "ascii"
+  EUCJ_STR = encode("\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa", "EUC-JP").freeze
+  SJIS_STR = encode("\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8", "Shift_JIS").freeze
+end if defined?(::Iconv)
diff -NrU2 ruby-1.8.7/test/openssl/test_ssl.rb ruby-1.8.7-p17/test/openssl/test_ssl.rb
--- ruby-1.8.7/test/openssl/test_ssl.rb	2008-04-25 15:51:21.000000000 +0900
+++ ruby-1.8.7-p17/test/openssl/test_ssl.rb	2008-06-06 17:05:24.000000000 +0900
@@ -500,5 +500,10 @@
       10.times do |i|
         sock = TCPSocket.new("127.0.0.1", port)
-        ssl = OpenSSL::SSL::SSLSocket.new(sock)
+        ctx = OpenSSL::SSL::SSLContext.new
+        if defined?(OpenSSL::SSL::OP_NO_TICKET)
+          # disable RFC4507 support
+          ctx.options = OpenSSL::SSL::OP_NO_TICKET
+        end
+        ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
         ssl.sync_close = true
         ssl.session = first_session if first_session
diff -NrU2 ruby-1.8.7/test/ruby/test_enumerator.rb ruby-1.8.7-p17/test/ruby/test_enumerator.rb
--- ruby-1.8.7/test/ruby/test_enumerator.rb	1970-01-01 09:00:00.000000000 +0900
+++ ruby-1.8.7-p17/test/ruby/test_enumerator.rb	2008-06-03 20:06:38.000000000 +0900
@@ -0,0 +1,105 @@
+require 'test/unit'
+
+class TestEnumerator < Test::Unit::TestCase
+  def setup
+    @obj = Object.new
+    class << @obj
+      include Enumerable
+      def foo(*a)
+        a.each {|x| yield x }
+      end
+    end
+  end
+
+  def enum_test obj
+    i = 0
+    obj.map{|e|
+      e
+    }.sort
+  end
+
+  def test_iterators
+    assert_equal [0, 1, 2], enum_test(3.times)
+    assert_equal ["x", "y", "z"], enum_test(["z", "y", "x"].each)
+    assert_equal [["x", 1], ["y", 2]], enum_test({"y"=>2, "x"=>1})
+  end
+
+  ## Enumerator as Iterator
+
+  def test_next
+    e = 3.times
+    3.times{|i|
+      assert_equal i, e.next
+    }
+    assert_raise(StopIteration){e.next}
+  end
+
+  def test_loop
+    e = 3.times
+    i = 0
+    loop{
+      assert_equal(i, e.next)
+      i += 1
+    }
+  end
+
+  def test_nested_itaration
+    def (o = Object.new).each
+      yield :ok1
+      yield [:ok2, :x].each.next
+    end
+    e = o.to_enum
+    assert_equal :ok1, e.next
+    assert_equal :ok2, e.next
+    assert_raise(StopIteration){e.next}
+  end
+
+
+  def test_initialize
+    assert_equal([1, 2, 3], @obj.to_enum(:foo, 1, 2, 3).to_a)
+    assert_equal([1, 2, 3], Enumerable::Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
+    assert_raise(ArgumentError) { Enumerable::Enumerator.new }
+  end
+
+  def test_initialize_copy
+    assert_equal([1, 2, 3], @obj.to_enum(:foo, 1, 2, 3).dup.to_a)
+    e = @obj.to_enum(:foo, 1, 2, 3)
+    assert_nothing_raised { assert_equal(1, e.next) }
+    #assert_raise(TypeError) { e.dup }
+  end
+
+  def test_gc
+    assert_nothing_raised do
+      1.times do
+        foo = [1,2,3].to_enum
+        GC.start
+      end
+      GC.start
+    end
+  end
+
+  def test_slice
+    assert_equal([[1,2,3],[4,5,6],[7,8,9],[10]], (1..10).each_slice(3).to_a)
+  end
+
+  def test_cons
+    a = [[1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9,10]]
+    assert_equal(a, (1..10).each_cons(3).to_a)
+  end
+
+  def test_with_index
+    assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
+  end
+
+  def test_next_rewind
+    e = @obj.to_enum(:foo, 1, 2, 3)
+    assert_equal(1, e.next)
+    assert_equal(2, e.next)
+    e.rewind
+    assert_equal(1, e.next)
+    assert_equal(2, e.next)
+    assert_equal(3, e.next)
+    assert_raise(StopIteration) { e.next }
+  end
+end
+
diff -NrU2 ruby-1.8.7/test/ruby/test_hash.rb ruby-1.8.7-p17/test/ruby/test_hash.rb
--- ruby-1.8.7/test/ruby/test_hash.rb	2007-08-15 13:50:12.000000000 +0900
+++ ruby-1.8.7-p17/test/ruby/test_hash.rb	2008-06-09 03:25:01.000000000 +0900
@@ -636,3 +636,6 @@
   end
 
+  def test_hash_hash
+    assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
+  end
 end
diff -NrU2 ruby-1.8.7/time.c ruby-1.8.7-p17/time.c
--- ruby-1.8.7/time.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/time.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,5 +4,5 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Tue Dec 28 14:31:59 JST 1993
 
@@ -760,5 +760,8 @@
 {
     time_t t;
-    struct tm *tmp, buf;
+#ifdef NEGATIVE_TIME_T
+    struct tm *tmp;
+#endif
+    struct tm buf;
     buf = *tptr;
     if (utc_p) {
diff -NrU2 ruby-1.8.7/util.c ruby-1.8.7-p17/util.c
--- ruby-1.8.7/util.c	2008-05-31 20:44:49.000000000 +0900
+++ ruby-1.8.7-p17/util.c	2008-06-06 19:39:57.000000000 +0900
@@ -4,8 +4,8 @@
 
   $Author: knu $
-  $Date: 2008-05-31 20:44:49 +0900 (Sat, 31 May 2008) $
+  $Date: 2008-06-06 19:39:57 +0900 (Fri, 06 Jun 2008) $
   created at: Fri Mar 10 17:22:34 JST 1995
 
-  Copyright (C) 1993-2003 Yukihiro Matsumoto
+  Copyright (C) 1993-2008 Yukihiro Matsumoto
 
 **********************************************************************/
@@ -22,4 +22,7 @@
 #include "missing/file.h"
 #endif
+#if defined(__CYGWIN32__) || defined(_WIN32)
+#include <io.h>
+#endif
 
 #include "util.h"
@@ -51,5 +54,5 @@
     int *retlen;
 {
-    static char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
+    static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
     register const char *s = start;
     register unsigned long retval = 0;
@@ -150,6 +153,6 @@
 static int valid_filename(char *s);
 
-static char suffix1[] = ".$$$";
-static char suffix2[] = ".~~~";
+static const char suffix1[] = ".$$$";
+static const char suffix2[] = ".~~~";
 
 #define ext (&buf[1000])
@@ -229,4 +232,10 @@
 
 #if defined(__CYGWIN32__) || defined(_WIN32)
+#if defined __CYGWIN32__ || defined __MINGW32__
+extern int _open(const char *, int, ...);
+extern int _close(int);
+extern int _unlink(const char *);
+#endif
+
 static int 
 valid_filename(char *s)
@@ -2104,4 +2113,5 @@
 #endif
 
+    errno = 0;
     sign = nz0 = nz = 0;
     dval(rv) = 0.;
@@ -2283,5 +2293,5 @@
         dval(rv) = tens[k - 9] * dval(rv) + z;
     }
-    bd0 = 0;
+    bd0 = bb = bd = bs = delta = 0;
     if (nd <= DBL_DIG
 #ifndef RND_PRODQUOT
@@ -3209,5 +3219,5 @@
     ULong x;
 #endif
-    Bigint *b, *b1, *delta, *mlo, *mhi, *S;
+    Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S;
     double d2, ds, eps;
     char *s, *s0;
@@ -3562,5 +3572,4 @@
     m2 = b2;
     m5 = b5;
-    mhi = mlo = 0;
     if (leftright) {
         i =
diff -NrU2 ruby-1.8.7/version.h ruby-1.8.7-p17/version.h
--- ruby-1.8.7/version.h	2008-05-31 22:37:06.000000000 +0900
+++ ruby-1.8.7-p17/version.h	2008-06-09 18:21:29.000000000 +0900
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2008-05-31"
+#define RUBY_RELEASE_DATE "2008-06-09"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20080531
-#define RUBY_PATCHLEVEL 0
+#define RUBY_RELEASE_CODE 20080609
+#define RUBY_PATCHLEVEL 17
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,6 +9,6 @@
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2008
-#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 31
+#define RUBY_RELEASE_MONTH 6
+#define RUBY_RELEASE_DAY 9
 
 #ifdef RUBY_EXTERN
diff -NrU2 ruby-1.8.7/win32/Makefile.sub ruby-1.8.7-p17/win32/Makefile.sub
--- ruby-1.8.7/win32/Makefile.sub	2008-05-29 20:23:36.000000000 +0900
+++ ruby-1.8.7-p17/win32/Makefile.sub	2008-06-06 21:19:21.000000000 +0900
@@ -250,5 +250,5 @@
 COMMON_HEADERS = winsock.h
 !else
-COMMON_HEADERS = winsock2.h
+COMMON_HEADERS = winsock2.h ws2tcpip.h
 !endif
 COMMON_HEADERS = $(COMMON_HEADERS) windows.h
diff -NrU2 ruby-1.8.7/win32/setup.mak ruby-1.8.7-p17/win32/setup.mak
--- ruby-1.8.7/win32/setup.mak	2008-01-22 11:24:11.000000000 +0900
+++ ruby-1.8.7-p17/win32/setup.mak	2008-06-06 21:19:21.000000000 +0900
@@ -42,6 +42,6 @@
 prefix = $(prefix:\=/)
 EXTSTATIC = $(EXTSTATIC)
-!if "$(USE_WINSOCK2)" != "0"
-USE_WINSOCK2 = 1
+!if defined(USE_WINSOCK2)
+USE_WINSOCK2 = $(USE_WINSOCK2)
 !endif
 !if defined(RDOCTARGET)
diff -NrU2 ruby-1.8.7/win32/win32.c ruby-1.8.7-p17/win32/win32.c
--- ruby-1.8.7/win32/win32.c	2008-05-19 00:02:36.000000000 +0900
+++ ruby-1.8.7-p17/win32/win32.c	2008-06-06 19:39:57.000000000 +0900
@@ -22,4 +22,5 @@
 #include <errno.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <windows.h>
@@ -209,5 +210,5 @@
 #define map_errno rb_w32_map_errno
 
-static char *NTLoginName;
+static const char *NTLoginName;
 
 #ifdef WIN95
@@ -449,8 +450,4 @@
 NtInitialize(int *argc, char ***argv)
 {
-
-    WORD version;
-    int ret;
-
 #if _MSC_VER >= 1400
     static void set_pioinfo_extra(void);
@@ -491,5 +488,5 @@
 getlogin()
 {
-    return NTLoginName;
+    return (char *)NTLoginName;
 }
 
@@ -507,13 +504,4 @@
 
 static struct ChildRecord *
-FindFirstChildSlot(void)
-{
-    FOREACH_CHILD(child) {
-	if (child->pid) return child;
-    } END_FOREACH_CHILD;
-    return NULL;
-}
-
-static struct ChildRecord *
 FindChildSlot(rb_pid_t pid)
 {
@@ -666,5 +654,5 @@
 
 rb_pid_t
-pipe_exec(char *cmd, int mode, FILE **fpr, FILE **fpw)
+pipe_exec(const char *cmd, int mode, FILE **fpr, FILE **fpw)
 {
     struct ChildRecord* child;
@@ -805,5 +793,5 @@
 
 int
-do_spawn(int mode, char *cmd)
+do_spawn(int mode, const char *cmd)
 {
     struct ChildRecord *child;
@@ -842,5 +830,5 @@
 
 int
-do_aspawn(int mode, char *prog, char **argv)
+do_aspawn(int mode, const char *prog, char **argv)
 {
     char *cmd, *p, *q, *s, **t;
@@ -1212,5 +1200,5 @@
 rb_w32_cmdvector(const char *cmd, char ***vec)
 {
-    int cmdlen, globbing, len, i;
+    int globbing, len;
     int elements, strsz, done;
     int slashes, escape;
@@ -3937,7 +3925,5 @@
 {
     HANDLE hFile;
-    SYSTEMTIME st;
     FILETIME atime, mtime;
-    struct tm *tm;
     struct stat stat;
     int ret = 0;
diff -NrU2 ruby-1.8.7/win32/win32.h ruby-1.8.7-p17/win32/win32.h
--- ruby-1.8.7/win32/win32.h	2008-04-15 12:35:55.000000000 +0900
+++ ruby-1.8.7-p17/win32/win32.h	2008-06-06 19:39:57.000000000 +0900
@@ -26,4 +26,5 @@
 #ifdef USE_WINSOCK2
 #include <winsock2.h>
+#include <ws2tcpip.h>
 #include <windows.h>
 #else
@@ -160,5 +161,5 @@
 extern void   NtInitialize(int *, char ***);
 extern int    rb_w32_cmdvector(const char *, char ***);
-extern rb_pid_t pipe_exec(char *, int, FILE **, FILE **);
+extern rb_pid_t pipe_exec(const char *, int, FILE **, FILE **);
 extern int    flock(int fd, int oper);
 extern int    rb_w32_accept(int, struct sockaddr *, int *);
@@ -206,6 +207,6 @@
 extern int gettimeofday(struct timeval *, struct timezone *);
 extern rb_pid_t waitpid (rb_pid_t, int *, int);
-extern int do_spawn(int, char *);
-extern int do_aspawn(int, char *, char **);
+extern int do_spawn(int, const char *);
+extern int do_aspawn(int, const char *, char **);
 extern int kill(int, int);
 extern int fcntl(int, int, ...);
