summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-17 06:38:18 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-17 06:38:18 +0000
commite78cb14774c3c08f1475299bb684b933ba2591b0 (patch)
treea4b269efa6e8341c107625d3ceb4344374cc8595
parent1c1d2b9c34f6adcaf25667ab51f7f3720b4d8abe (diff)
* lib/cgi.rb (CGI::QueryExtension::Value::[]): should work like
String#[] if more than one arguments are specified. * lib/delegate.rb: avoid using common instance name as "@obj". * lib/cgi.rb (CGI::QueryExtension::Value): Value is no longer subclass of String, but DelegateClass(String). * ext/curses/extconf.rb: restore function check for init_color. [ruby-list:38905] * Makefile.in: need to specify $(MAINLIBS) for the miniruby generation rule. * configure.in: better FreeBSD -lc_r support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog18
-rw-r--r--Makefile.in2
-rw-r--r--configure.in39
-rw-r--r--eval.c12
-rw-r--r--ext/curses/extconf.rb2
-rw-r--r--lib/cgi.rb12
-rw-r--r--lib/delegate.rb13
-rw-r--r--test/testunit/util/test_procwrapper.rb2
8 files changed, 53 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index f75b27aaa3..8da0cd0bc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Wed Dec 17 15:15:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::QueryExtension::Value::[]): should work like
+ String#[] if more than one arguments are specified.
+
+ * lib/delegate.rb: avoid using common instance name as "@obj".
+
+ * lib/cgi.rb (CGI::QueryExtension::Value): Value is no longer
+ subclass of String, but DelegateClass(String).
+
+ * ext/curses/extconf.rb: restore function check for init_color.
+ [ruby-list:38905]
+
+ * Makefile.in: need to specify $(MAINLIBS) for the miniruby
+ generation rule.
+
+ * configure.in: better FreeBSD -lc_r support.
+
Wed Dec 17 00:16:14 2003 Minero Aoki <aamine@loveruby.net>
* ext/strscan/strscan.c: new method
diff --git a/Makefile.in b/Makefile.in
index 64110b8761..1a9179dda1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -115,7 +115,7 @@ all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY)
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(DMYEXT)
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(DMYEXT) $(LIBRUBY_A) $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINLIBS) $(MAINOBJ) $(DMYEXT) $(LIBRUBY_A) $(LIBS) -o $@
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) $(SETUP) miniruby$(EXEEXT)
@rm -f $@
diff --git a/configure.in b/configure.in
index 9d26600869..ee6cf7bb94 100644
--- a/configure.in
+++ b/configure.in
@@ -323,7 +323,7 @@ freebsd*) LIBS="-lm $LIBS"
if test "$rb_cv_lib_xpg4_needed" = yes; then
AC_CHECK_LIB(xpg4, setlocale)
fi
- if test "$with_libc_r" = yes -a "$enable_pthread" = 'yes'; then
+ if test "$with_libc_r" = yes; then
AC_CACHE_CHECK([whether libc_r is supplementary to libc],
rb_cv_supplementary_lib_c_r,
[AC_TRY_CPP([
@@ -335,12 +335,8 @@ freebsd*) LIBS="-lm $LIBS"
rb_cv_supplementary_lib_c_r=no,
rb_cv_supplementary_lib_c_r=yes,
rb_cv_supplementary_lib_c_r=yes)])
- if test "$rb_cv_supplementary_lib_c_r" = yes; then
- MAINLIBS="-lc_r $MAINLIBS"
- else
- AC_DEFINE(HAVE_LIBPTHREAD)
- MAINLIBS="-pthread $MAINLIBS"
- CFLAGS="-D_THREAD_SAFE -D_REENTRANT $CFLAGS"
+ if test ; then
+ MAINLIBS="-lc_r $MAINLIBS"
fi
fi
;;
@@ -679,19 +675,15 @@ int main()
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
if test "$enable_pthread" = "yes"; then
- AC_CHECK_LIB(pthread, pthread_mutex_init,
+ AC_CHECK_LIB(pthread, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
- if test "$rb_with_pthread" = "no"; then
- AC_CHECK_LIB(pthread, __pthread_mutex_init,
- rb_with_pthread=yes, rb_with_pthread=no)
- fi
if test "$rb_with_pthread" = "yes"; then
LIBS="-lpthread $LIBS"
AC_DEFINE(_REENTRANT)
AC_DEFINE(_THREAD_SAFE)
AC_DEFINE(HAVE_LIBPTHREAD)
else
- AC_CHECK_LIB(pthreads, pthread_mutex_init,
+ AC_CHECK_LIB(pthreads, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
if test "$rb_with_pthread" = "yes"; then
LIBS="-lpthreads $LIBS"
@@ -699,29 +691,20 @@ if test "$enable_pthread" = "yes"; then
AC_DEFINE(_THREAD_SAFE)
AC_DEFINE(HAVE_LIBPTHREAD)
else
- AC_CHECK_LIB(c, pthread_mutex_init,
+ AC_CHECK_LIB(c, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
if test "$rb_with_pthread" = "yes"; then
AC_DEFINE(_REENTRANT)
AC_DEFINE(_THREAD_SAFE)
AC_DEFINE(HAVE_LIBPTHREAD)
else
- AC_CHECK_LIB(c_r, pthread_mutex_init,
+ AC_CHECK_LIB(c_r, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
if test "$rb_with_pthread" = "yes"; then
- if test "$with_libc_r" = "yes"; then
- if test "$rb_cv_supplementary_lib_c_r" = "yes"; then
- AC_DEFINE(_REENTRANT)
- AC_DEFINE(_THREAD_SAFE)
- AC_DEFINE(HAVE_LIBPTHREAD)
- MAINLIBS="-pthread $MAINLIBS"
- fi
- else
- MAINLIBS="-pthread $MAINLIBS"
- AC_DEFINE(_REENTRANT)
- AC_DEFINE(_THREAD_SAFE)
- AC_DEFINE(HAVE_LIBPTHREAD)
- fi
+ AC_DEFINE(_REENTRANT)
+ AC_DEFINE(_THREAD_SAFE)
+ AC_DEFINE(HAVE_LIBPTHREAD)
+ MAINLIBS="-pthread $MAINLIBS"
else
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
fi
diff --git a/eval.c b/eval.c
index a793ae64b5..078d095ecf 100644
--- a/eval.c
+++ b/eval.c
@@ -9492,12 +9492,6 @@ static int thread_init = 0;
# define PTHREAD_TIMER
#endif
-#if defined(POSIX_SIGNAL)
-# define ruby_signal(x,y) posix_signal((x), (y))
-#else
-# define ruby_signal(x,y) signal((x), (y))
-#endif
-
#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER)
static void
catch_timer(sig)
@@ -9589,7 +9583,11 @@ rb_thread_start_0(fn, arg, th)
if (!thread_init) {
thread_init = 1;
#if defined(HAVE_SETITIMER) || defined(PTHREAD_TIMER)
- ruby_signal(SIGVTALRM, catch_timer);
+#if defined(POSIX_SIGNAL)
+ posix_signal(SIGVTALRM, catch_timer);
+#else
+ signal(SIGVTALRM, catch_timer);
+#endif
#ifdef PTHREAD_TIMER
pthread_create(&time_thread, 0, thread_timer, 0);
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index d0eed198d3..9b319ba30e 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -19,7 +19,7 @@ elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr")
end
if make
- for f in %w(beep bkgd bkgdset color curs deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay)
+ for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color)
have_func(f)
end
flag = "-D_XOPEN_SOURCE_EXTENDED"
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 103452a762..772696068b 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1141,14 +1141,18 @@ class CGI
@multipart
end
- class Value < String # :nodoc:
+ class Value < DelegateClass(String) # :nodoc:
def initialize(str, params)
@params = params
super(str)
end
- def [](idx)
- warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
- self
+ def [](idx, *args)
+ if args.size == 0
+ warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
+ self
+ else
+ self.to_s[idx,*args]
+ end
end
def first
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 41d35477e4..1ba4cf1e1b 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -64,15 +64,15 @@ class SimpleDelegator<Delegator
def initialize(obj)
super
- @obj = obj
+ @_sd_obj = obj
end
def __getobj__
- @obj
+ @_sd_obj
end
def __setobj__(obj)
- @obj = obj
+ @_sd_obj = obj
end
end
@@ -88,7 +88,7 @@ def DelegateClass(superclass)
methods |= ["to_s","to_a","inspect","==","=~","==="]
klass.module_eval <<-EOS
def initialize(obj)
- @obj = obj
+ @_dc_obj = obj
end
EOS
for method in methods
@@ -96,7 +96,7 @@ def DelegateClass(superclass)
klass.module_eval <<-EOS
def #{method}(*args, &block)
begin
- @obj.__send__(:#{method}, *args, &block)
+ @_dc_obj.__send__(:#{method}, *args, &block)
rescue
$@[0,2] = nil
raise
@@ -107,6 +107,9 @@ def DelegateClass(superclass)
raise NameError, "invalid identifier %s" % method, caller(3)
end
end
+ def __getobj__
+ @_dc_obj
+ end
return klass;
end
diff --git a/test/testunit/util/test_procwrapper.rb b/test/testunit/util/test_procwrapper.rb
index b939b1aebf..3e552c7711 100644
--- a/test/testunit/util/test_procwrapper.rb
+++ b/test/testunit/util/test_procwrapper.rb
@@ -22,13 +22,13 @@ module Test
assert_same(@original, @wrapped_original.to_proc, "The wrapper should return what was wrapped")
end
def test_hashing
- assert_not_equal(@original.hash, @munged.hash, "The original and munged procs should not have the same hash")
assert_equal(@wrapped_original.hash, @wrapped_munged.hash, "The original and munged should have the same hash when wrapped")
assert_equal(@wrapped_original, @wrapped_munged, "The wrappers should be equivalent")
a_hash = {@wrapped_original => @original}
assert(a_hash[@wrapped_original], "Should be able to access the wrapper in the hash")
+ assert_equal(a_hash[@wrapped_original], @original, "Should be able to access the wrapper in the hash")
end
end
end