* 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
This commit is contained in:
parent
1c1d2b9c34
commit
e78cb14774
18
ChangeLog
18
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>
|
Wed Dec 17 00:16:14 2003 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* ext/strscan/strscan.c: new method
|
* ext/strscan/strscan.c: new method
|
||||||
|
@ -115,7 +115,7 @@ all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY)
|
|||||||
|
|
||||||
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(DMYEXT)
|
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(DMYEXT)
|
||||||
@rm -f $@
|
@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)
|
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) $(SETUP) miniruby$(EXEEXT)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
|
39
configure.in
39
configure.in
@ -323,7 +323,7 @@ freebsd*) LIBS="-lm $LIBS"
|
|||||||
if test "$rb_cv_lib_xpg4_needed" = yes; then
|
if test "$rb_cv_lib_xpg4_needed" = yes; then
|
||||||
AC_CHECK_LIB(xpg4, setlocale)
|
AC_CHECK_LIB(xpg4, setlocale)
|
||||||
fi
|
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],
|
AC_CACHE_CHECK([whether libc_r is supplementary to libc],
|
||||||
rb_cv_supplementary_lib_c_r,
|
rb_cv_supplementary_lib_c_r,
|
||||||
[AC_TRY_CPP([
|
[AC_TRY_CPP([
|
||||||
@ -335,12 +335,8 @@ freebsd*) LIBS="-lm $LIBS"
|
|||||||
rb_cv_supplementary_lib_c_r=no,
|
rb_cv_supplementary_lib_c_r=no,
|
||||||
rb_cv_supplementary_lib_c_r=yes,
|
rb_cv_supplementary_lib_c_r=yes,
|
||||||
rb_cv_supplementary_lib_c_r=yes)])
|
rb_cv_supplementary_lib_c_r=yes)])
|
||||||
if test "$rb_cv_supplementary_lib_c_r" = yes; then
|
if test ; then
|
||||||
MAINLIBS="-lc_r $MAINLIBS"
|
MAINLIBS="-lc_r $MAINLIBS"
|
||||||
else
|
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
|
||||||
MAINLIBS="-pthread $MAINLIBS"
|
|
||||||
CFLAGS="-D_THREAD_SAFE -D_REENTRANT $CFLAGS"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -679,19 +675,15 @@ int main()
|
|||||||
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
|
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
|
||||||
|
|
||||||
if test "$enable_pthread" = "yes"; then
|
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)
|
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
|
if test "$rb_with_pthread" = "yes"; then
|
||||||
LIBS="-lpthread $LIBS"
|
LIBS="-lpthread $LIBS"
|
||||||
AC_DEFINE(_REENTRANT)
|
AC_DEFINE(_REENTRANT)
|
||||||
AC_DEFINE(_THREAD_SAFE)
|
AC_DEFINE(_THREAD_SAFE)
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||||
else
|
else
|
||||||
AC_CHECK_LIB(pthreads, pthread_mutex_init,
|
AC_CHECK_LIB(pthreads, pthread_kill,
|
||||||
rb_with_pthread=yes, rb_with_pthread=no)
|
rb_with_pthread=yes, rb_with_pthread=no)
|
||||||
if test "$rb_with_pthread" = "yes"; then
|
if test "$rb_with_pthread" = "yes"; then
|
||||||
LIBS="-lpthreads $LIBS"
|
LIBS="-lpthreads $LIBS"
|
||||||
@ -699,29 +691,20 @@ if test "$enable_pthread" = "yes"; then
|
|||||||
AC_DEFINE(_THREAD_SAFE)
|
AC_DEFINE(_THREAD_SAFE)
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||||
else
|
else
|
||||||
AC_CHECK_LIB(c, pthread_mutex_init,
|
AC_CHECK_LIB(c, pthread_kill,
|
||||||
rb_with_pthread=yes, rb_with_pthread=no)
|
rb_with_pthread=yes, rb_with_pthread=no)
|
||||||
if test "$rb_with_pthread" = "yes"; then
|
if test "$rb_with_pthread" = "yes"; then
|
||||||
AC_DEFINE(_REENTRANT)
|
AC_DEFINE(_REENTRANT)
|
||||||
AC_DEFINE(_THREAD_SAFE)
|
AC_DEFINE(_THREAD_SAFE)
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||||
else
|
else
|
||||||
AC_CHECK_LIB(c_r, pthread_mutex_init,
|
AC_CHECK_LIB(c_r, pthread_kill,
|
||||||
rb_with_pthread=yes, rb_with_pthread=no)
|
rb_with_pthread=yes, rb_with_pthread=no)
|
||||||
if test "$rb_with_pthread" = "yes"; then
|
if test "$rb_with_pthread" = "yes"; then
|
||||||
if test "$with_libc_r" = "yes"; then
|
AC_DEFINE(_REENTRANT)
|
||||||
if test "$rb_cv_supplementary_lib_c_r" = "yes"; then
|
AC_DEFINE(_THREAD_SAFE)
|
||||||
AC_DEFINE(_REENTRANT)
|
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||||
AC_DEFINE(_THREAD_SAFE)
|
MAINLIBS="-pthread $MAINLIBS"
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
|
||||||
MAINLIBS="-pthread $MAINLIBS"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
MAINLIBS="-pthread $MAINLIBS"
|
|
||||||
AC_DEFINE(_REENTRANT)
|
|
||||||
AC_DEFINE(_THREAD_SAFE)
|
|
||||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
|
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
|
||||||
fi
|
fi
|
||||||
|
12
eval.c
12
eval.c
@ -9492,12 +9492,6 @@ static int thread_init = 0;
|
|||||||
# define PTHREAD_TIMER
|
# define PTHREAD_TIMER
|
||||||
#endif
|
#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)
|
#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER)
|
||||||
static void
|
static void
|
||||||
catch_timer(sig)
|
catch_timer(sig)
|
||||||
@ -9589,7 +9583,11 @@ rb_thread_start_0(fn, arg, th)
|
|||||||
if (!thread_init) {
|
if (!thread_init) {
|
||||||
thread_init = 1;
|
thread_init = 1;
|
||||||
#if defined(HAVE_SETITIMER) || defined(PTHREAD_TIMER)
|
#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
|
#ifdef PTHREAD_TIMER
|
||||||
pthread_create(&time_thread, 0, thread_timer, 0);
|
pthread_create(&time_thread, 0, thread_timer, 0);
|
||||||
|
@ -19,7 +19,7 @@ elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr")
|
|||||||
end
|
end
|
||||||
|
|
||||||
if make
|
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)
|
have_func(f)
|
||||||
end
|
end
|
||||||
flag = "-D_XOPEN_SOURCE_EXTENDED"
|
flag = "-D_XOPEN_SOURCE_EXTENDED"
|
||||||
|
12
lib/cgi.rb
12
lib/cgi.rb
@ -1141,14 +1141,18 @@ class CGI
|
|||||||
@multipart
|
@multipart
|
||||||
end
|
end
|
||||||
|
|
||||||
class Value < String # :nodoc:
|
class Value < DelegateClass(String) # :nodoc:
|
||||||
def initialize(str, params)
|
def initialize(str, params)
|
||||||
@params = params
|
@params = params
|
||||||
super(str)
|
super(str)
|
||||||
end
|
end
|
||||||
def [](idx)
|
def [](idx, *args)
|
||||||
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
|
if args.size == 0
|
||||||
self
|
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
|
end
|
||||||
def first
|
def first
|
||||||
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
|
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
|
||||||
|
@ -64,15 +64,15 @@ class SimpleDelegator<Delegator
|
|||||||
|
|
||||||
def initialize(obj)
|
def initialize(obj)
|
||||||
super
|
super
|
||||||
@obj = obj
|
@_sd_obj = obj
|
||||||
end
|
end
|
||||||
|
|
||||||
def __getobj__
|
def __getobj__
|
||||||
@obj
|
@_sd_obj
|
||||||
end
|
end
|
||||||
|
|
||||||
def __setobj__(obj)
|
def __setobj__(obj)
|
||||||
@obj = obj
|
@_sd_obj = obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ def DelegateClass(superclass)
|
|||||||
methods |= ["to_s","to_a","inspect","==","=~","==="]
|
methods |= ["to_s","to_a","inspect","==","=~","==="]
|
||||||
klass.module_eval <<-EOS
|
klass.module_eval <<-EOS
|
||||||
def initialize(obj)
|
def initialize(obj)
|
||||||
@obj = obj
|
@_dc_obj = obj
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
for method in methods
|
for method in methods
|
||||||
@ -96,7 +96,7 @@ def DelegateClass(superclass)
|
|||||||
klass.module_eval <<-EOS
|
klass.module_eval <<-EOS
|
||||||
def #{method}(*args, &block)
|
def #{method}(*args, &block)
|
||||||
begin
|
begin
|
||||||
@obj.__send__(:#{method}, *args, &block)
|
@_dc_obj.__send__(:#{method}, *args, &block)
|
||||||
rescue
|
rescue
|
||||||
$@[0,2] = nil
|
$@[0,2] = nil
|
||||||
raise
|
raise
|
||||||
@ -107,6 +107,9 @@ def DelegateClass(superclass)
|
|||||||
raise NameError, "invalid identifier %s" % method, caller(3)
|
raise NameError, "invalid identifier %s" % method, caller(3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def __getobj__
|
||||||
|
@_dc_obj
|
||||||
|
end
|
||||||
return klass;
|
return klass;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ module Test
|
|||||||
assert_same(@original, @wrapped_original.to_proc, "The wrapper should return what was wrapped")
|
assert_same(@original, @wrapped_original.to_proc, "The wrapper should return what was wrapped")
|
||||||
end
|
end
|
||||||
def test_hashing
|
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.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")
|
assert_equal(@wrapped_original, @wrapped_munged, "The wrappers should be equivalent")
|
||||||
|
|
||||||
a_hash = {@wrapped_original => @original}
|
a_hash = {@wrapped_original => @original}
|
||||||
assert(a_hash[@wrapped_original], "Should be able to access the wrapper in the hash")
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user