* 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:
matz 2003-12-17 06:38:18 +00:00
Родитель 1c1d2b9c34
Коммит e78cb14774
8 изменённых файлов: 53 добавлений и 47 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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 $@

Просмотреть файл

@ -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

12
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);

Просмотреть файл

@ -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"

Просмотреть файл

@ -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']"

Просмотреть файл

@ -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

Просмотреть файл

@ -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