mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (convert_type): [ruby-core:03845]
* eval.c (rb_funcall_rescue): new function. * object.c (rb_Array): avoid using rb_respond_to(). * object.c (rb_Integer): ditto. * eval.c (get_backtrace): no conversion for nil. * parse.y (reduce_nodes): empty body should return nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6e22160537
commit
83cb605d69
9 changed files with 106 additions and 44 deletions
22
ChangeLog
22
ChangeLog
|
@ -8,6 +8,20 @@ Mon Nov 29 13:13:13 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
* win32/win32.c (CreateChild): push back the last space before next
|
* win32/win32.c (CreateChild): push back the last space before next
|
||||||
loop because CharNext() eats it.
|
loop because CharNext() eats it.
|
||||||
|
|
||||||
|
Mon Nov 29 03:08:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (convert_type): [ruby-core:03845]
|
||||||
|
|
||||||
|
* eval.c (rb_funcall_rescue): new function.
|
||||||
|
|
||||||
|
* object.c (rb_Array): avoid using rb_respond_to().
|
||||||
|
|
||||||
|
* object.c (rb_Integer): ditto.
|
||||||
|
|
||||||
|
* eval.c (get_backtrace): no conversion for nil.
|
||||||
|
|
||||||
|
* parse.y (reduce_nodes): empty body should return nil.
|
||||||
|
|
||||||
Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
|
Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* io.c (rb_io_check_writable): call io_seek regardless of
|
* io.c (rb_io_check_writable): call io_seek regardless of
|
||||||
|
@ -52,6 +66,10 @@ Sun Nov 28 12:05:48 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
|
||||||
* regcomp.c, regint.h: fixed PLATFORM_UNALIGNED_WORD_ACCESS
|
* regcomp.c, regint.h: fixed PLATFORM_UNALIGNED_WORD_ACCESS
|
||||||
problem ([ruby-dev:24802] and [ruby-core:3733])
|
problem ([ruby-dev:24802] and [ruby-core:3733])
|
||||||
|
|
||||||
|
Sat Nov 27 23:43:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_initialize): [ruby-dev:24972]
|
||||||
|
|
||||||
Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
|
Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* io.c: avoid data lost with nonblocking fd and
|
* io.c: avoid data lost with nonblocking fd and
|
||||||
|
@ -89,6 +107,10 @@ Sat Nov 27 17:21:30 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* sample/rss/rss_recent.rb: ditto.
|
* sample/rss/rss_recent.rb: ditto.
|
||||||
|
|
||||||
|
Sat Nov 27 14:44:15 2004 Kent Sibilev <ksibilev@bellsouth.net>
|
||||||
|
|
||||||
|
* lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832]
|
||||||
|
|
||||||
Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (io_fread): old rb_io_fread with file closing checking.
|
* io.c (io_fread): old rb_io_fread with file closing checking.
|
||||||
|
|
73
eval.c
73
eval.c
|
@ -1079,7 +1079,9 @@ get_backtrace(info)
|
||||||
VALUE info;
|
VALUE info;
|
||||||
{
|
{
|
||||||
if (NIL_P(info)) return Qnil;
|
if (NIL_P(info)) return Qnil;
|
||||||
return rb_check_array_type(rb_funcall(info, rb_intern("backtrace"), 0));
|
info = rb_funcall(info, rb_intern("backtrace"), 0);
|
||||||
|
if (NIL_P(info)) return Qnil;
|
||||||
|
return rb_check_array_type(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5799,6 +5801,32 @@ rb_f_send(argc, argv, recv)
|
||||||
return vid;
|
return vid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
vafuncall(recv, mid, n, ar)
|
||||||
|
VALUE recv;
|
||||||
|
ID mid;
|
||||||
|
int n;
|
||||||
|
va_list *ar;
|
||||||
|
{
|
||||||
|
VALUE *argv;
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
long i;
|
||||||
|
|
||||||
|
argv = ALLOCA_N(VALUE, n);
|
||||||
|
|
||||||
|
for (i=0;i<n;i++) {
|
||||||
|
argv[i] = va_arg(*ar, VALUE);
|
||||||
|
}
|
||||||
|
va_end(*ar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
argv = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1);
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
#ifdef HAVE_STDARG_PROTOTYPES
|
#ifdef HAVE_STDARG_PROTOTYPES
|
||||||
rb_funcall(VALUE recv, ID mid, int n, ...)
|
rb_funcall(VALUE recv, ID mid, int n, ...)
|
||||||
|
@ -5811,24 +5839,41 @@ rb_funcall(recv, mid, n, va_alist)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
va_list ar;
|
va_list ar;
|
||||||
VALUE *argv;
|
va_init_list(ar, n);
|
||||||
|
|
||||||
if (n > 0) {
|
return vafuncall(recv, mid, n, &ar);
|
||||||
long i;
|
}
|
||||||
|
|
||||||
argv = ALLOCA_N(VALUE, n);
|
VALUE
|
||||||
|
#ifdef HAVE_STDARG_PROTOTYPES
|
||||||
|
rb_funcall_rescue(VALUE recv, ID mid, int n, ...)
|
||||||
|
#else
|
||||||
|
rb_funcall_rescue(recv, mid, n, va_alist)
|
||||||
|
VALUE recv;
|
||||||
|
ID mid;
|
||||||
|
int n;
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VALUE result = Qnil; /* OK */
|
||||||
|
int status;
|
||||||
|
va_list ar;
|
||||||
|
|
||||||
va_init_list(ar, n);
|
va_init_list(ar, n);
|
||||||
for (i=0;i<n;i++) {
|
|
||||||
argv[i] = va_arg(ar, VALUE);
|
|
||||||
}
|
|
||||||
va_end(ar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
argv = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1);
|
PUSH_TAG(PROT_NONE);
|
||||||
|
if ((status = EXEC_TAG()) == 0) {
|
||||||
|
result = vafuncall(recv, mid, n, &ar);
|
||||||
|
}
|
||||||
|
POP_TAG();
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
return result;
|
||||||
|
case TAG_RAISE:
|
||||||
|
return Qundef;
|
||||||
|
default:
|
||||||
|
JUMP_TAG(status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -224,6 +224,7 @@ VALUE rb_thread_main _((void));
|
||||||
VALUE rb_thread_local_aref _((VALUE, ID));
|
VALUE rb_thread_local_aref _((VALUE, ID));
|
||||||
VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
|
VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
|
||||||
void rb_thread_atfork _((void));
|
void rb_thread_atfork _((void));
|
||||||
|
VALUE rb_funcall_rescue __((VALUE, ID, int, ...));
|
||||||
/* file.c */
|
/* file.c */
|
||||||
int eaccess _((const char*, int));
|
int eaccess _((const char*, int));
|
||||||
VALUE rb_file_s_expand_path _((int, VALUE *));
|
VALUE rb_file_s_expand_path _((int, VALUE *));
|
||||||
|
|
10
io.c
10
io.c
|
@ -334,6 +334,7 @@ io_fflush(f, fptr)
|
||||||
if (n != EOF) break;
|
if (n != EOF) break;
|
||||||
if (!rb_io_wait_writable(fileno(f)))
|
if (!rb_io_wait_writable(fileno(f)))
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
|
rb_io_check_closed(fptr);
|
||||||
}
|
}
|
||||||
fptr->mode &= ~FMODE_WBUF;
|
fptr->mode &= ~FMODE_WBUF;
|
||||||
}
|
}
|
||||||
|
@ -1027,6 +1028,7 @@ rb_io_fread(ptr, len, f)
|
||||||
|
|
||||||
of.f = f;
|
of.f = f;
|
||||||
of.f2 = NULL;
|
of.f2 = NULL;
|
||||||
|
of.mode = FMODE_READABLE;
|
||||||
return io_fread(ptr, len, &of);
|
return io_fread(ptr, len, &of);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4030,6 +4032,9 @@ rb_io_initialize(argc, argv, io)
|
||||||
fp->mode = rb_io_modenum_flags(flags);
|
fp->mode = rb_io_modenum_flags(flags);
|
||||||
fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags));
|
fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags));
|
||||||
}
|
}
|
||||||
|
else if (RFILE(io)->fptr) {
|
||||||
|
rb_raise(rb_eRuntimeError, "reinitializing IO");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
GetOpenFile(orig, ofp);
|
GetOpenFile(orig, ofp);
|
||||||
if (ofp->refcnt == LONG_MAX) {
|
if (ofp->refcnt == LONG_MAX) {
|
||||||
|
@ -4047,11 +4052,6 @@ rb_io_initialize(argc, argv, io)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (RFILE(io)->fptr) {
|
|
||||||
rb_io_close(io);
|
|
||||||
free(RFILE(io)->fptr);
|
|
||||||
RFILE(io)->fptr = 0;
|
|
||||||
}
|
|
||||||
ofp->refcnt++;
|
ofp->refcnt++;
|
||||||
RFILE(io)->fptr = ofp;
|
RFILE(io)->fptr = ofp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ class CGI
|
||||||
id = option['session_id']
|
id = option['session_id']
|
||||||
unless id
|
unless id
|
||||||
if option['new_session']
|
if option['new_session']
|
||||||
id = Session::create_new_id
|
id = create_new_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless id
|
unless id
|
||||||
|
@ -261,7 +261,7 @@ class CGI
|
||||||
if option.key?('new_session') and not option['new_session']
|
if option.key?('new_session') and not option['new_session']
|
||||||
raise ArgumentError, "session_key `%s' should be supplied"%session_key
|
raise ArgumentError, "session_key `%s' should be supplied"%session_key
|
||||||
end
|
end
|
||||||
id = Session::create_new_id
|
id = create_new_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@session_id = id
|
@session_id = id
|
||||||
|
|
29
object.c
29
object.c
|
@ -2056,10 +2056,9 @@ convert_type(val, tname, method, raise)
|
||||||
const char *tname, *method;
|
const char *tname, *method;
|
||||||
int raise;
|
int raise;
|
||||||
{
|
{
|
||||||
ID m;
|
VALUE result = rb_funcall_rescue(val, rb_intern(method), 0);
|
||||||
|
|
||||||
m = rb_intern(method);
|
if (result == Qundef) {
|
||||||
if (!rb_respond_to(val, m)) {
|
|
||||||
if (raise) {
|
if (raise) {
|
||||||
rb_raise(rb_eTypeError, "cannot convert %s into %s",
|
rb_raise(rb_eTypeError, "cannot convert %s into %s",
|
||||||
NIL_P(val) ? "nil" :
|
NIL_P(val) ? "nil" :
|
||||||
|
@ -2069,10 +2068,11 @@ convert_type(val, tname, method, raise)
|
||||||
tname);
|
tname);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ruby_errinfo = Qnil;
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rb_funcall(val, m, 0);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -2139,6 +2139,8 @@ VALUE
|
||||||
rb_Integer(val)
|
rb_Integer(val)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
{
|
{
|
||||||
|
VALUE tmp;
|
||||||
|
|
||||||
switch (TYPE(val)) {
|
switch (TYPE(val)) {
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
|
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
|
||||||
|
@ -2157,11 +2159,12 @@ rb_Integer(val)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rb_respond_to(val, rb_intern("to_int"))) {
|
tmp = convert_type(val, "Integer", "to_int", Qfalse);
|
||||||
return rb_to_integer(val, "to_int");
|
if (NIL_P(tmp)) {
|
||||||
}
|
|
||||||
return rb_to_integer(val, "to_i");
|
return rb_to_integer(val, "to_i");
|
||||||
}
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
|
@ -2401,18 +2404,10 @@ rb_Array(val)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
{
|
{
|
||||||
VALUE tmp = rb_check_array_type(val);
|
VALUE tmp = rb_check_array_type(val);
|
||||||
ID to_a;
|
|
||||||
|
|
||||||
if (NIL_P(tmp)) {
|
if (NIL_P(tmp)) {
|
||||||
to_a = rb_intern("to_a");
|
tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a");
|
||||||
if (rb_respond_to(val, to_a)) {
|
if (NIL_P(tmp)) {
|
||||||
val = rb_funcall(val, to_a, 0);
|
|
||||||
if (TYPE(val) != T_ARRAY) {
|
|
||||||
rb_raise(rb_eTypeError, "`to_a' did not return Array");
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return rb_ary_new3(1, val);
|
return rb_ary_new3(1, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
parse.y
4
parse.y
|
@ -7178,6 +7178,10 @@ reduce_nodes(body)
|
||||||
{
|
{
|
||||||
NODE *node = *body;
|
NODE *node = *body;
|
||||||
|
|
||||||
|
if (!node) {
|
||||||
|
*body = NEW_NIL();
|
||||||
|
return;
|
||||||
|
}
|
||||||
#define subnodes(n1, n2) \
|
#define subnodes(n1, n2) \
|
||||||
((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
|
((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
|
||||||
(!node->n2) ? (body = &node->n1, 1) : \
|
(!node->n2) ? (body = &node->n1, 1) : \
|
||||||
|
|
|
@ -28,11 +28,6 @@ END {
|
||||||
puts local_for_end2 # e2
|
puts local_for_end2 # e2
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
|
||||||
raise
|
|
||||||
puts "should not be dumped"
|
|
||||||
}
|
|
||||||
|
|
||||||
eval <<EOE
|
eval <<EOE
|
||||||
BEGIN {
|
BEGIN {
|
||||||
puts "b3"
|
puts "b3"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue