[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:403

From: ko1 atdot.net
Date: 3 Nov 2006 21:00:17 +0900
Subject: [yarv-diff:403] r571 - in trunk: . ext/nkf/nkf-utf8 test/ruby test/socket test/strscan test/testunit/collector

Author: ko1
Date: 2006-11-03 21:00:17 +0900 (Fri, 03 Nov 2006)
New Revision: 571

Added:
   trunk/ext/nkf/nkf-utf8/utf8tbl.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/test/ruby/test_array.rb
   trunk/test/ruby/test_assignment.rb
   trunk/test/ruby/test_clone.rb
   trunk/test/socket/test_socket.rb
   trunk/test/socket/test_unix.rb
   trunk/test/strscan/test_stringscanner.rb
   trunk/test/testunit/collector/test_dir.rb
Log:
	* ext/nkf/nkf-utf8/utf8tbl.h : missed to add

	* configure.in : import ruby HEAD

	* test/ruby/test_array.rb : ditto

	* test/ruby/test_assignment.rb : ditto

	* test/ruby/test_clone.rb : ditto

	* test/socket/test_socket.rb : ditto

	* test/socket/test_unix.rb : ditto

	* test/strscan/test_stringscanner.rb : ditto

	* test/testunit/collector/test_dir.rb : ditto



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/ChangeLog	2006-11-03 12:00:17 UTC (rev 571)
@@ -4,6 +4,27 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-11-03(Fri) 20:58:36 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* ext/nkf/nkf-utf8/utf8tbl.h : missed to add
+
+	* configure.in : import ruby HEAD
+
+	* test/ruby/test_array.rb : ditto
+
+	* test/ruby/test_assignment.rb : ditto
+
+	* test/ruby/test_clone.rb : ditto
+
+	* test/socket/test_socket.rb : ditto
+
+	* test/socket/test_unix.rb : ditto
+
+	* test/strscan/test_stringscanner.rb : ditto
+
+	* test/testunit/collector/test_dir.rb : ditto
+
+
 2006-11-03(Fri) 20:22:24 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* array.c : import current ruby HEAD and apply API changes

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/configure.in	2006-11-03 12:00:17 UTC (rev 571)
@@ -3,7 +3,7 @@
 
 AC_PREREQ(2.58)
 
-AC_DEFUN(RUBY_MINGW32,
+AC_DEFUN([RUBY_MINGW32],
 [case "$host_os" in
 cygwin*)
 AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
@@ -17,7 +17,7 @@
   ;;
 esac])
 
-AC_DEFUN(RUBY_CPPOUTFILE,
+AC_DEFUN([RUBY_CPPOUTFILE],
 [AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
 [cppflags=$CPPFLAGS
 CPPFLAGS='-o conftest.i'
@@ -33,7 +33,7 @@
 fi
 AC_SUBST(CPPOUTFILE)])
 
-AC_DEFUN(RUBY_PROG_GNU_LD,
+AC_DEFUN([RUBY_PROG_GNU_LD],
 [AC_CACHE_CHECK(whether the linker is GNU ld, rb_cv_prog_gnu_ld,
 [if `$CC $CFLAGS $CPPFLAGS $LDFLAGS --print-prog-name=ld 2>&1` -v 2>&1 | grep "GNU ld" > /dev/null; then
   rb_cv_prog_gnu_ld=yes
@@ -74,6 +74,7 @@
 
 AC_CANONICAL_TARGET
 target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
+ac_install_sh='' # unusable for extension libraries.
 
 dnl checks for fat-binary
 AC_ARG_ENABLE(fat-binary,
@@ -165,6 +166,10 @@
   AC_CHECK_PROGS(AR, aal, ar)
 fi
 
+AC_CHECK_TOOL(AS, as)
+ASFLAGS=$ASFLAGS
+AC_SUBST(ASFLAGS)
+
 case "$target_os" in
 cygwin*|mingw*)
     AC_CHECK_TOOL(NM, nm)
@@ -181,8 +186,8 @@
 		    [rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
 		     		   tr A-Z a-z |
 				   sed -n '/^[[ 	]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
-		    [rb_cv_msvcrt=msvcrt])])
-	test "$rb_cv_msvcrt" = "" && AC_MSG_ERROR([must be linked to DLL])
+		    [rb_cv_msvcrt=msvcrt])
+	test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
     esac
     : ${enable_shared=yes}
     ;;
@@ -214,6 +219,13 @@
 dnl check for large file stuff
 AC_SYS_LARGEFILE
 
+case "$target_os" in
+mingw*)
+	ac_cv_type_off_t=yes
+	ac_cv_sizeof_off_t=8
+	;;
+esac
+
 AC_CHECK_TYPES([long long, off_t])
 
 AC_CHECK_SIZEOF(int, 4)
@@ -269,7 +281,7 @@
   AC_DEFINE(HAVE_STDARG_PROTOTYPES)
 fi
 
-AC_DEFUN(RUBY_FUNC_ATTRIBUTE, [dnl
+AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
 m4_ifval([$2], dnl
   [AS_VAR_PUSHDEF([attrib],[$2])], dnl
   [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
@@ -361,6 +373,7 @@
 		ac_cv_header_sys_param_h=no
 		ac_cv_header_sys_resource_h=no
 		ac_cv_header_sys_select_h=no
+		ac_cv_header_sys_time_h=no
 		ac_cv_header_sys_times_h=no
 		ac_cv_func_times=yes
 		ac_cv_func_waitpid=yes
@@ -373,10 +386,14 @@
 		ac_cv_func_isnan=yes
 		ac_cv_func_finite=yes
 		ac_cv_func_link=yes
+		ac_cv_func_truncate=yes
+		ac_cv_func_fseeko=yes
+		ac_cv_func_ftello=yes
 		ac_cv_lib_crypt_crypt=no
 		ac_cv_func_getpgrp_void=no
 		ac_cv_func_setpgrp_void=yes
 		ac_cv_func_memcmp_working=yes
+		ac_cv_lib_dl_dlopen=no
 		rb_cv_binary_elf=no
 		rb_cv_negative_time_t=no
 		enable_pthread=no
@@ -430,7 +447,9 @@
 		;;
 superux*)     ac_cv_func_setitimer=no
               ;;
-solaris*2.10)  ac_cv_func_isinf=yes
+solaris*2.10)  if test -z "$GCC"; then
+                      ac_cv_func_isinf=yes
+              fi
                LIBS="-lm $LIBS"
               ;;
 *) LIBS="-lm $LIBS";;
@@ -497,7 +516,17 @@
 dnl Checks for library functions.
 AC_TYPE_GETGROUPS
 AC_TYPE_SIGNAL
-AC_FUNC_ALLOCA
+case "${target_cpu}-${target_os}" in
+powerpc-darwin*)
+  AC_LIBSOURCES(alloca.c)
+  AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
+  AC_DEFINE(C_ALLOCA)
+  AC_DEFINE_UNQUOTED(alloca, alloca)
+  ;;
+*)
+  AC_FUNC_ALLOCA
+  ;;
+esac
 AC_FUNC_MEMCMP
 AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
 		 strchr strstr strtoul crypt flock\
@@ -507,9 +536,9 @@
 	      setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
 	      setrgid setegid setregid setresgid issetugid pause lchown lchmod\
 	      getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
-	      getpriority getrlimit setrlimit\
+	      getpriority getrlimit setrlimit sysconf\
 	      dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
-	      setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
+	      setsid telldir seekdir fchmod mktime timegm cosh sinh tanh log2\
 	      setuid setgid daemon select_large_fdset setenv unsetenv)
 AC_ARG_ENABLE(setreuid,
        [  --enable-setreuid       use setreuid()/setregid() according to need even if obsolete.],
@@ -725,6 +754,22 @@
   AC_DEFINE(HUGE_ST_INO)
 fi
 
+if test "$ac_cv_func_sysconf" = yes; then
+  AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl
+  AC_CACHE_CHECK([whether _SC_$1 is supported], rb_cv_have_sc_[]m4_tolower($1),
+    [AC_TRY_COMPILE([#include <unistd.h>
+      ],
+      [_SC_$1 >= 0],
+      rb_cv_have_sc_[]m4_tolower($1)=yes,
+      rb_cv_have_sc_[]m4_tolower($1)=no)
+    ])
+  if test "$rb_cv_have_sc_[]m4_tolower($1)" = yes; then
+    AC_DEFINE(HAVE__SC_$1)
+  fi
+  ])
+  RUBY_CHECK_SYSCONF(CLK_TCK)
+fi
+
 case "$target_cpu" in
 m68*|i?86|ia64|sparc*|alpha*) rb_cv_stack_grow_dir=-1;;
 hppa*) rb_cv_stack_grow_dir=+1;;
@@ -889,10 +934,9 @@
 			: ${LIBPATHENV=SHLIB_PATH}
 			rb_cv_dlopen=yes;;
 	solaris*) 	if test "$GCC" = yes; then
-			   : ${LDSHARED='$(CC) -Wl,-G'}
+                          : ${LDSHARED='$(CC) -shared'}
 			   if test "$rb_cv_prog_gnu_ld" = yes; then
 	 		       LDFLAGS="$LDFLAGS -Wl,-E"
-			       LDSHARED="$LDSHARED -shared"
 			   fi
 			else
 			   : ${LDSHARED='ld -G'}
@@ -950,16 +994,22 @@
 			: ${LDFLAGS=""}
 			: ${LIBPATHENV=DYLD_LIBRARY_PATH}
 			rb_cv_dlopen=yes ;;
-	aix*)		: ${LDSHARED='/usr/ccs/bin/ld'}
-			XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp"
-			DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS"
-			LDFLAGS="-brtl $LDFLAGS"
+        aix*)           if test "$GCC" = yes; then
+			    : ${LDSHARED='$(CC) -shared'}
+			    DLDFLAGS='-Wl,-G -eInit_$(TARGET)'
+			    LDFLAGS='-Wl,-brtl'
+			    XLDFLAGS='-Wl,-bE:ruby.imp'
+			else
+			    : ${LDSHARED='/usr/ccs/bin/ld'}
+			    DLDFLAGS='-G -eInit_$(TARGET)'
+			    LDFLAGS='-brtl'
+			    XLDFLAGS='-bE:ruby.imp'
+                        fi
 			: ${ARCHFILE="ruby.imp"}
-			TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)'
-			TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
+                        TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
+                        TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
 			: ${LIBPATHENV=SHLIB_PATH}
 			rb_cv_dlopen=yes ;;
-
 	human*)		: ${DLDFLAGS=''}
 			: ${LDSHARED=''}
 			: ${LDFLAGS=''}
@@ -1265,8 +1315,6 @@
 	LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
 	if test "$GCC" = yes; then
 	    LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
-	else
-	    enable_rpath=no
 	fi
 	XLDFLAGS="$XLDFLAGS "'-R${libdir}'
  	;;
@@ -1277,13 +1325,12 @@
 	;;
     aix*)
 	if test "$GCC" = yes; then
-	    LIBRUBY_LDSHARED='$(CC) -shared'
-	    LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
+	    LIBRUBY_DLDFLAGS='-Wl,-G -Wl,-bnoentry'
 	else
-	    LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
-	    LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
+	    LIBRUBY_DLDFLAGS='-G -bnoentry'
 	fi
-	LIBRUBYARG_SHARED='-L${libdir} -Wl,lib$(RUBY_SO_NAME).so'
+	LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS $XLDFLAGS"
+	LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
 	SOLIBS='-lm -lc'
 	;;
     beos*)
@@ -1307,7 +1354,11 @@
   esac
 fi
 if test "$enable_rpath" = yes; then
+    if test "$GCC" = yes; then
     LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
+    else
+       LIBRUBYARG_SHARED='-R $(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
+    fi
 fi
 
 XLDFLAGS="$XLDFLAGS -L."

Added: trunk/ext/nkf/nkf-utf8/utf8tbl.h
===================================================================
--- trunk/ext/nkf/nkf-utf8/utf8tbl.h	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/ext/nkf/nkf-utf8/utf8tbl.h	2006-11-03 12:00:17 UTC (rev 571)
@@ -0,0 +1,34 @@
+#ifndef _UTF8TBL_H_
+#define _UTF8TBL_H_
+
+#ifdef UTF8_OUTPUT_ENABLE
+extern const unsigned short euc_to_utf8_1byte[];
+extern const unsigned short *const euc_to_utf8_2bytes[];
+extern const unsigned short *const euc_to_utf8_2bytes_ms[];
+extern const unsigned short *const x0212_to_utf8_2bytes[];
+#endif /* UTF8_OUTPUT_ENABLE */
+
+#ifdef UTF8_INPUT_ENABLE
+extern const unsigned short *const utf8_to_euc_2bytes[];
+extern const unsigned short *const utf8_to_euc_2bytes_ms[];
+extern const unsigned short *const utf8_to_euc_2bytes_932[];
+extern const unsigned short *const *const utf8_to_euc_3bytes[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_ms[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_932[];
+#endif /* UTF8_INPUT_ENABLE */
+
+#ifdef UNICODE_NORMALIZATION
+extern const struct normalization_pair normalization_table[];
+#endif
+
+#ifdef SHIFTJIS_CP932
+extern const unsigned short shiftjis_cp932[3][189];
+extern const unsigned short cp932inv[2][189];
+#endif /* SHIFTJIS_CP932 */
+
+#ifdef X0212_ENABLE
+extern const unsigned short shiftjis_x0212[3][189];
+extern const unsigned short *const x0212_shiftjis[];
+#endif /* X0212_ENABLE */
+
+#endif

Modified: trunk/test/ruby/test_array.rb
===================================================================
--- trunk/test/ruby/test_array.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/ruby/test_array.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -1126,15 +1126,15 @@
 
     $, = ""
     a = @cls[1, 2]
-    assert_equal("12", a.to_s)
+    assert_equal("[1, 2]", a.to_s)
 
     $, = ""
     a = @cls[1, 2, 3]
-    assert_equal("123", a.to_s)
+    assert_equal("[1, 2, 3]", a.to_s)
 
     $, = ":"
     a = @cls[1, 2, 3]
-    assert_equal("1:2:3", a.to_s)
+    assert_equal("[1, 2, 3]", a.to_s)
 
     $, = ""
   end

Modified: trunk/test/ruby/test_assignment.rb
===================================================================
--- trunk/test/ruby/test_assignment.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/ruby/test_assignment.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -29,25 +29,25 @@
     a = [*[1]]; assert_equal([1], a)
     a = [*[1,2]]; assert_equal([1,2], a)
 
-    a = *[]; assert_nil(a)
-    a = *[1]; assert_equal(1, a)
-    a = *[nil]; assert_nil(a)
-    a = *[[]]; assert_equal([], a)
+    a = *[]; assert_equal([], a)
+    a = *[1]; assert_equal([1], a)
+    a = *[nil]; assert_equal([nil], a)
+    a = *[[]]; assert_equal([[]], a)
     a = *[1,2]; assert_equal([1,2], a)
-    a = *[*[]]; assert_nil(a)
-    a = *[*[1]]; assert_equal(1, a)
+    a = *[*[]]; assert_equal([], a)
+    a = *[*[1]]; assert_equal([1], a)
     a = *[*[1,2]]; assert_equal([1,2], a)
 
     *a = nil; assert_equal([nil], a)
     *a = 1; assert_equal([1], a)
-    *a = []; assert_equal([[]], a)
-    *a = [1]; assert_equal([[1]], a)
-    *a = [nil]; assert_equal([[nil]], a)
-    *a = [[]]; assert_equal([[[]]], a)
-    *a = [1,2]; assert_equal([[1,2]], a)
-    *a = [*[]]; assert_equal([[]], a)
-    *a = [*[1]]; assert_equal([[1]], a)
-    *a = [*[1,2]]; assert_equal([[1,2]], a)
+    *a = []; assert_equal([], a)
+    *a = [1]; assert_equal([1], a)
+    *a = [nil]; assert_equal([nil], a)
+    *a = [[]]; assert_equal([[]], a)
+    *a = [1,2]; assert_equal([1,2], a)
+    *a = [*[]]; assert_equal([], a)
+    *a = [*[1]]; assert_equal([1], a)
+    *a = [*[1,2]]; assert_equal([1,2], a)
 
     *a = *[]; assert_equal([], a)
     *a = *[1]; assert_equal([1], a)
@@ -90,22 +90,22 @@
     def f; yield([*[1]]); end; f {|a| assert_equal([1], a)}; undef f
     def f; yield([*[1,2]]); end; f {|a| assert_equal([1,2], a)}; undef f
 
-    def f; yield(*[1]); end; f {|a| assert_equal(1, a)}; undef f
-    def f; yield(*[nil]); end; f {|a| assert_nil(a)}; undef f
-    def f; yield(*[[]]); end; f {|a| assert_equal([], a)}; undef f
-    def f; yield(*[*[1]]); end; f {|a| assert_equal(1, a)}; undef f
+    def f; yield(*[1]); end; f {|a| assert_equal([1], a)}; undef f
+    def f; yield(*[nil]); end; f {|a| assert_equal([nil], a)}; undef f
+    def f; yield(*[[]]); end; f {|a| assert_equal([[]], a)}; undef f
+    def f; yield(*[*[1]]); end; f {|a| assert_equal([1], a)}; undef f
 
     def f; yield; end; f {|*a| assert_equal([], a)}; undef f
     def f; yield(nil); end; f {|*a| assert_equal([nil], a)}; undef f
     def f; yield(1); end; f {|*a| assert_equal([1], a)}; undef f
-    def f; yield([]); end; f {|*a| assert_equal([[]], a)}; undef f
-    def f; yield([1]); end; f {|*a| assert_equal([[1]], a)}; undef f
-    def f; yield([nil]); end; f {|*a| assert_equal([[nil]], a)}; undef f
-    def f; yield([[]]); end; f {|*a| assert_equal([[[]]], a)}; undef f
-    def f; yield([1,2]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
-    def f; yield([*[]]); end; f {|*a| assert_equal([[]], a)}; undef f
-    def f; yield([*[1]]); end; f {|*a| assert_equal([[1]], a)}; undef f
-    def f; yield([*[1,2]]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
+    def f; yield([]); end; f {|*a| assert_equal([], a)}; undef f
+    def f; yield([1]); end; f {|*a| assert_equal([1], a)}; undef f
+    def f; yield([nil]); end; f {|*a| assert_equal([nil], a)}; undef f
+    def f; yield([[]]); end; f {|*a| assert_equal([[]], a)}; undef f
+    def f; yield([1,2]); end; f {|*a| assert_equal([1,2], a)}; undef f
+    def f; yield([*[]]); end; f {|*a| assert_equal([], a)}; undef f
+    def f; yield([*[1]]); end; f {|*a| assert_equal([1], a)}; undef f
+    def f; yield([*[1,2]]); end; f {|*a| assert_equal([1,2], a)}; undef f
 
     def f; yield(*[]); end; f {|*a| assert_equal([], a)}; undef f
     def f; yield(*[1]); end; f {|*a| assert_equal([1], a)}; undef f
@@ -147,39 +147,39 @@
     def r; return [*[1]]; end; a = r(); assert_equal([1], a); undef r
     def r; return [*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
 
-    def r; return *[]; end; a = r(); assert_nil(a); undef r
-    def r; return *[1]; end; a = r(); assert_equal(1, a); undef r
-    def r; return *[nil]; end; a = r(); assert_nil(a); undef r
-    def r; return *[[]]; end; a = r(); assert_equal([], a); undef r
-    def r; return *[*[]]; end; a = r(); assert_nil(a); undef r
-    def r; return *[*[1]]; end; a = r(); assert_equal(1, a); undef r
+    def r; return *[]; end; a = r(); assert_equal([], a); undef r
+    def r; return *[1]; end; a = r(); assert_equal([1], a); undef r
+    def r; return *[nil]; end; a = r(); assert_equal([nil], a); undef r
+    def r; return *[[]]; end; a = r(); assert_equal([[]], a); undef r
+    def r; return *[*[]]; end; a = r(); assert_equal([], a); undef r
+    def r; return *[*[1]]; end; a = r(); assert_equal([1], a); undef r
     def r; return *[*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
 
-    def r; return *[[]]; end; a = *r(); assert_nil(a); undef r
+    def r; return *[[]]; end; a = *r(); assert_equal([[]], a); undef r
     def r; return *[*[1,2]]; end; a = *r(); assert_equal([1,2], a); undef r
 
     def r; return; end; *a = r(); assert_equal([nil], a); undef r
     def r; return nil; end; *a = r(); assert_equal([nil], a); undef r
     def r; return 1; end; *a = r(); assert_equal([1], a); undef r
-    def r; return []; end; *a = r(); assert_equal([[]], a); undef r
-    def r; return [1]; end; *a = r(); assert_equal([[1]], a); undef r
-    def r; return [nil]; end; *a = r(); assert_equal([[nil]], a); undef r
-    def r; return [[]]; end; *a = r(); assert_equal([[[]]], a); undef r
-    def r; return [1,2]; end; *a = r(); assert_equal([[1,2]], a); undef r
-    def r; return [*[]]; end; *a = r(); assert_equal([[]], a); undef r
-    def r; return [*[1]]; end; *a = r(); assert_equal([[1]], a); undef r
-    def r; return [*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
+    def r; return []; end; *a = r(); assert_equal([], a); undef r
+    def r; return [1]; end; *a = r(); assert_equal([1], a); undef r
+    def r; return [nil]; end; *a = r(); assert_equal([nil], a); undef r
+    def r; return [[]]; end; *a = r(); assert_equal([[]], a); undef r
+    def r; return [1,2]; end; *a = r(); assert_equal([1,2], a); undef r
+    def r; return [*[]]; end; *a = r(); assert_equal([], a); undef r
+    def r; return [*[1]]; end; *a = r(); assert_equal([1], a); undef r
+    def r; return [*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
 
-    def r; return *[]; end; *a = r(); assert_equal([nil], a); undef r
+    def r; return *[]; end; *a = r(); assert_equal([], a); undef r
     def r; return *[1]; end; *a = r(); assert_equal([1], a); undef r
     def r; return *[nil]; end; *a = r(); assert_equal([nil], a); undef r
     def r; return *[[]]; end; *a = r(); assert_equal([[]], a); undef r
-    def r; return *[1,2]; end; *a = r(); assert_equal([[1,2]], a); undef r
-    def r; return *[*[]]; end; *a = r(); assert_equal([nil], a); undef r
+    def r; return *[1,2]; end; *a = r(); assert_equal([1,2], a); undef r
+    def r; return *[*[]]; end; *a = r(); assert_equal([], a); undef r
     def r; return *[*[1]]; end; *a = r(); assert_equal([1], a); undef r
-    def r; return *[*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
+    def r; return *[*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
 
-    def r; return *[[]]; end; *a = *r(); assert_equal([], a); undef r
+    def r; return *[[]]; end; *a = *r(); assert_equal([[]], a); undef r
     def r; return *[1,2]; end; *a = *r(); assert_equal([1,2], a); undef r
     def r; return *[*[1,2]]; end; *a = *r(); assert_equal([1,2], a); undef r
 
@@ -198,7 +198,7 @@
     def r; return *[]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
     def r; return *[1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
     def r; return *[nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
-    def r; return *[[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
+    def r; return *[[]]; end; a,b,*c = r(); assert_equal([[],nil,[]], [a,b,c]); undef r
     def r; return *[1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
     def r; return *[*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
     def r; return *[*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
@@ -260,36 +260,36 @@
     a = loop do break [*[1]]; end; assert_equal([1], a)
     a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
 
-    a = loop do break *[]; end; assert_nil(a)
-    a = loop do break *[1]; end; assert_equal(1, a)
-    a = loop do break *[nil]; end; assert_nil(a)
-    a = loop do break *[[]]; end; assert_equal([], a)
-    a = loop do break *[*[]]; end; assert_nil(a)
-    a = loop do break *[*[1]]; end; assert_equal(1, a)
+    a = loop do break *[]; end; assert_equal([], a)
+    a = loop do break *[1]; end; assert_equal([1], a)
+    a = loop do break *[nil]; end; assert_equal([nil], a)
+    a = loop do break *[[]]; end; assert_equal([[]], a)
+    a = loop do break *[*[]]; end; assert_equal([], a)
+    a = loop do break *[*[1]]; end; assert_equal([1], a)
     a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
 
     *a = loop do break; end; assert_equal([nil], a)
     *a = loop do break nil; end; assert_equal([nil], a)
     *a = loop do break 1; end; assert_equal([1], a)
-    *a = loop do break []; end; assert_equal([[]], a)
-    *a = loop do break [1]; end; assert_equal([[1]], a)
-    *a = loop do break [nil]; end; assert_equal([[nil]], a)
-    *a = loop do break [[]]; end; assert_equal([[[]]], a)
-    *a = loop do break [1,2]; end; assert_equal([[1,2]], a)
-    *a = loop do break [*[]]; end; assert_equal([[]], a)
-    *a = loop do break [*[1]]; end; assert_equal([[1]], a)
-    *a = loop do break [*[1,2]]; end; assert_equal([[1,2]], a)
+    *a = loop do break []; end; assert_equal([], a)
+    *a = loop do break [1]; end; assert_equal([1], a)
+    *a = loop do break [nil]; end; assert_equal([nil], a)
+    *a = loop do break [[]]; end; assert_equal([[]], a)
+    *a = loop do break [1,2]; end; assert_equal([1,2], a)
+    *a = loop do break [*[]]; end; assert_equal([], a)
+    *a = loop do break [*[1]]; end; assert_equal([1], a)
+    *a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
 
-    *a = loop do break *[]; end; assert_equal([nil], a)
+    *a = loop do break *[]; end; assert_equal([], a)
     *a = loop do break *[1]; end; assert_equal([1], a)
     *a = loop do break *[nil]; end; assert_equal([nil], a)
     *a = loop do break *[[]]; end; assert_equal([[]], a)
-    *a = loop do break *[1,2]; end; assert_equal([[1,2]], a)
-    *a = loop do break *[*[]]; end; assert_equal([nil], a)
+    *a = loop do break *[1,2]; end; assert_equal([1,2], a)
+    *a = loop do break *[*[]]; end; assert_equal([], a)
     *a = loop do break *[*[1]]; end; assert_equal([1], a)
-    *a = loop do break *[*[1,2]]; end; assert_equal([[1,2]], a)
+    *a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
 
-    *a = *loop do break *[[]]; end; assert_equal([], a)
+    *a = *loop do break *[[]]; end; assert_equal([[]], a)
     *a = *loop do break *[1,2]; end; assert_equal([1,2], a)
     *a = *loop do break *[*[1,2]]; end; assert_equal([1,2], a)
 
@@ -308,7 +308,7 @@
     a,b,*c = loop do break *[]; end; assert_equal([nil,nil,[]], [a,b,c])
     a,b,*c = loop do break *[1]; end; assert_equal([1,nil,[]], [a,b,c])
     a,b,*c = loop do break *[nil]; end; assert_equal([nil,nil,[]], [a,b,c])
-    a,b,*c = loop do break *[[]]; end; assert_equal([nil,nil,[]], [a,b,c])
+    a,b,*c = loop do break *[[]]; end; assert_equal([[],nil,[]], [a,b,c])
     a,b,*c = loop do break *[1,2]; end; assert_equal([1,2,[]], [a,b,c])
     a,b,*c = loop do break *[*[]]; end; assert_equal([nil,nil,[]], [a,b,c])
     a,b,*c = loop do break *[*[1]]; end; assert_equal([1,nil,[]], [a,b,c])
@@ -328,12 +328,12 @@
     r([1]){next [*[1]]}
     r([1,2]){next [*[1,2]]}
 
-    r(nil){next *[]}
-    r(1){next *[1]}
-    r(nil){next *[nil]}
-    r([]){next *[[]]}
-    r(nil){next *[*[]]}
-    r(1){next *[*[1]]}
+    r([]){next *[]}
+    r([1]){next *[1]}
+    r([nil]){next *[nil]}
+    r([[]]){next *[[]]}
+    r([]){next *[*[]]}
+    r([1]){next *[*[1]]}
     r([1,2]){next *[*[1,2]]}
     undef r
 
@@ -341,18 +341,18 @@
     r([nil]){next}
     r([nil]){next nil}
     r([1]){next 1}
-    r([[]]){next []}
-    r([[1]]){next [1]}
-    r([[nil]]){next [nil]}
-    r([[[]]]){next [[]]}
-    r([[1,2]]){next [1,2]}
-    r([[]]){next [*[]]}
-    r([[1]]){next [*[1]]}
-    r([[1,2]]){next [*[1,2]]}
+    r([]){next []}
+    r([1]){next [1]}
+    r([nil]){next [nil]}
+    r([[]]){next [[]]}
+    r([1,2]){next [1,2]}
+    r([]){next [*[]]}
+    r([1]){next [*[1]]}
+    r([1,2]){next [*[1,2]]}
     undef r
 
     def r(val); *a = *yield(); assert_equal(val, a); end
-    r([]){next *[[]]}
+    r([[]]){next *[[]]}
     r([1,2]){next *[1,2]}
     r([1,2]){next *[*[1,2]]}
     undef r
@@ -372,7 +372,7 @@
     undef r
 
     def r(val); a,b,*c = *yield(); assert_equal(val, [a,b,c]); end
-    r([nil,nil,[]]){next *[[]]}
+    r([[],nil,[]]){next *[[]]}
     r([1,2,[]]){next *[1,2]}
     r([1,2,[]]){next *[*[1,2]]}
     undef r

Modified: trunk/test/ruby/test_clone.rb
===================================================================
--- trunk/test/ruby/test_clone.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/ruby/test_clone.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -23,6 +23,6 @@
 
     assert_raises(NoMethodError) {foo.test2}
 
-    assert_equal([M003, M002, M001], M003.ancestors)
+    assert_equal([M003, M002, M001, M002], M003.ancestors)
   end
 end

Modified: trunk/test/socket/test_socket.rb
===================================================================
--- trunk/test/socket/test_socket.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/socket/test_socket.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -72,3 +72,26 @@
     end
   end
 end if defined?(Socket)
+
+class TestSocket < Test::Unit::TestCase
+  def test_unpack_sockaddr
+    sockaddr_in = Socket.sockaddr_in(80, "")
+    assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) }
+    sockaddr_un = Socket.sockaddr_un("/tmp/s")
+    assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
+  end if Socket.respond_to?(:sockaddr_un)
+
+  def test_sysaccept
+    serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+    serv.bind(Socket.sockaddr_in(0, "127.0.0.1"))
+    serv.listen 5
+    c = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+    c.connect(serv.getsockname)
+    fd, peeraddr = serv.sysaccept
+    assert_equal(c.getsockname, peeraddr)
+  ensure
+    serv.close if serv
+    c.close if c
+    IO.for_fd(fd).close if fd
+  end
+end if defined?(Socket)

Modified: trunk/test/socket/test_unix.rb
===================================================================
--- trunk/test/socket/test_unix.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/socket/test_unix.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -1,9 +1,11 @@
 begin
   require "socket"
-  require "test/unit"
 rescue LoadError
 end
 
+require "test/unit"
+require "tempfile"
+
 class TestUNIXSocket < Test::Unit::TestCase
   def test_fd_passing
     r1, w = IO.pipe
@@ -27,4 +29,113 @@
       r2.close if r2 && !r2.closed?
     end
   end
-end if defined?(UNIXSocket)
+
+  def bound_unix_socket(klass)
+    tmpfile = Tempfile.new("testrubysock")
+    path = tmpfile.path
+    tmpfile.close(true)
+    yield klass.new(path), path
+  ensure
+    File.unlink path if path && File.socket?(path)
+  end
+
+  def test_addr
+    bound_unix_socket(UNIXServer) {|serv, path|
+      c = UNIXSocket.new(path)
+      s = serv.accept
+      assert_equal(["AF_UNIX", path], c.peeraddr)
+      assert_equal(["AF_UNIX", ""], c.addr)
+      assert_equal(["AF_UNIX", ""], s.peeraddr)
+      assert_equal(["AF_UNIX", path], s.addr)
+      assert_equal(path, s.path)
+      assert_equal("", c.path)
+    }
+  end
+
+  def test_noname_path
+    s1, s2 = UNIXSocket.pair
+    assert_equal("", s1.path)
+    assert_equal("", s2.path)
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_noname_addr
+    s1, s2 = UNIXSocket.pair
+    assert_equal(["AF_UNIX", ""], s1.addr)
+    assert_equal(["AF_UNIX", ""], s2.addr)
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_noname_peeraddr
+    s1, s2 = UNIXSocket.pair
+    assert_equal(["AF_UNIX", ""], s1.peeraddr)
+    assert_equal(["AF_UNIX", ""], s2.peeraddr)
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_noname_unpack_sockaddr_un
+    s1, s2 = UNIXSocket.pair
+    n = nil
+    assert_equal("", Socket.unpack_sockaddr_un(n)) if (n = s1.getsockname) != ""
+    assert_equal("", Socket.unpack_sockaddr_un(n)) if (n = s1.getsockname) != ""
+    assert_equal("", Socket.unpack_sockaddr_un(n)) if (n = s2.getsockname) != ""
+    assert_equal("", Socket.unpack_sockaddr_un(n)) if (n = s1.getpeername) != ""
+    assert_equal("", Socket.unpack_sockaddr_un(n)) if (n = s2.getpeername) != ""
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_noname_recvfrom
+    s1, s2 = UNIXSocket.pair
+    s2.write("a")
+    assert_equal(["a", ["AF_UNIX", ""]], s1.recvfrom(10))
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_noname_recv_nonblock
+    s1, s2 = UNIXSocket.pair
+    s2.write("a")
+    IO.select [s1]
+    assert_equal("a", s1.recv_nonblock(10))
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_too_long_path
+    assert_raise(ArgumentError) { Socket.sockaddr_un("a" * 300) }
+    assert_raise(ArgumentError) { UNIXServer.new("a" * 300) }
+  end
+
+  def test_nul
+    assert_raise(ArgumentError) { Socket.sockaddr_un("a\0b") }
+    assert_raise(ArgumentError) { UNIXServer.new("a\0b") }
+  end
+
+  def test_dgram_pair
+    s1, s2 = UNIXSocket.pair(Socket::SOCK_DGRAM)
+    assert_raise(Errno::EAGAIN) { s1.recv_nonblock(10) }
+    s2.send("", 0)
+    s2.send("haha", 0)
+    s2.send("", 0)
+    s2.send("", 0)
+    assert_equal("", s1.recv(10))
+    assert_equal("haha", s1.recv(10))
+    assert_equal("", s1.recv(10))
+    assert_equal("", s1.recv(10))
+    assert_raise(Errno::EAGAIN) { s1.recv_nonblock(10) }
+  ensure
+    s1.close if s1
+    s2.close if s2
+  end
+
+end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM

Modified: trunk/test/strscan/test_stringscanner.rb
===================================================================
--- trunk/test/strscan/test_stringscanner.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/strscan/test_stringscanner.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -242,6 +242,11 @@
     s.string.replace ''
     # unspecified: assert_equal 2, s.pos
     assert_equal nil, s.scan(/test/)
+
+    # [ruby-bugs:4361]
+    s = StringScanner.new("")
+    assert_equal "", s.scan(//)
+    assert_equal "", s.scan(//)
   end
 
   def test_skip
@@ -259,6 +264,11 @@
     s.scan(/te/)
     s.string.replace ''
     assert_equal nil, s.skip(/./)
+
+    # [ruby-bugs:4361]
+    s = StringScanner.new("")
+    assert_equal 0, s.skip(//)
+    assert_equal 0, s.skip(//)
   end
 
   def test_getch

Modified: trunk/test/testunit/collector/test_dir.rb
===================================================================
--- trunk/test/testunit/collector/test_dir.rb	2006-11-03 11:31:58 UTC (rev 570)
+++ trunk/test/testunit/collector/test_dir.rb	2006-11-03 12:00:17 UTC (rev 571)
@@ -89,19 +89,19 @@
           end
 
           def directory?(name)
+            return true if (base = basename(name)) == '/'
             e = find(dirname(name))
             return false unless(e)
-            e.directory?(basename(name))
+            e.directory?(base)
           end
 
           def find(path)
             if(/\A\// =~ path)
-              path = path.sub(/\A\//, '')
               thing = @root
             else
               thing = @pwd
             end
-            split(path).each do |e|
+            path.scan(/[^\/]+/) do |e|
               break thing = false unless(thing.kind_of?(Directory))
               thing = thing[e]
             end
@@ -109,15 +109,19 @@
           end
 
           def dirname(name)
-            join(*split(name)[0..-2])
+            if (name = name.tr_s('/', '/')) == '/'
+              name
+            else
+              name[%r"\A.+(?=/[^/]+/?\z)|\A/"] || "."
+            end
           end
 
           def basename(name)
-            split(name)[-1]
+            name[%r"(\A/|[^/]+)/*\z", 1]
           end
 
           def split(name)
-            name.split('/')
+            [dirname(name), basename(name)]
           end
 
           def join(*parts)
@@ -140,6 +144,19 @@
             @pwd = e
           end
 
+          def expand_path(path, base = nil)
+            until /\A\// =~ path
+              base ||= pwd
+              path = join(base, path)
+              base = nil
+            end
+            path.gsub!(%r"(?:/\.)+(?=/)", '')
+            nil while path.sub!(%r"/(?!\.\./)[^/]+/\.\.(?=/)", '')
+            path.sub!(%r"\A(?:/\.\.)+(?=/)", '')
+            path.sub!(%r"(?:\A(/)|/)\.\.?\z", '\1')
+            path
+          end
+
           def require_directory(path)
             raise Errno::ENOTDIR, path unless(directory?(path))
           end


--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]