* parse.y (newline_node): do not use NODE_NEWLINE node anymore,

use NEWLINE flag instead.

* ext/socket/socket.c (sock_gethostbyname): returns host if
  ai_canonname is NULL. (ruby-bugs PR#1243)

* parse.y (block_append): update nd_end for "real" head node.
  [ruby-list:39058]

* marshal.c (w_class): should not dump singleton class.
  [ruby-dev:22631]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-01-21 16:47:23 +00:00
parent d0149b9e21
commit 002517aba8
11 changed files with 74 additions and 103 deletions

View File

@ -1,3 +1,8 @@
Thu Jan 22 01:46:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (newline_node): do not use NODE_NEWLINE node anymore,
use NEWLINE flag instead.
Thu Jan 22 01:12:12 2004 Siena. <siena@faculty.chiba-u.jp> Thu Jan 22 01:12:12 2004 Siena. <siena@faculty.chiba-u.jp>
* missing/os2.c (chdir, getcwd): * missing/os2.c (chdir, getcwd):
@ -57,6 +62,14 @@ Wed Jan 21 16:01:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/digest/rmd160/extconf.rb: have_library appends found library. * ext/digest/rmd160/extconf.rb: have_library appends found library.
Wed Jan 21 11:36:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (sock_gethostbyname): returns host if
ai_canonname is NULL. (ruby-bugs PR#1243)
* parse.y (block_append): update nd_end for "real" head node.
[ruby-list:39058]
Tue Jan 20 14:48:28 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> Tue Jan 20 14:48:28 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: should check <openssl/conf_api.h> instead * ext/openssl/extconf.rb: should check <openssl/conf_api.h> instead
@ -85,6 +98,11 @@ Tue Jan 20 04:41:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_marshal.rb (MarshalTestLibtest_singleton): test * test/ruby/test_marshal.rb (MarshalTestLibtest_singleton): test
for [ruby-dev:22588]. for [ruby-dev:22588].
Tue Jan 20 02:38:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (w_class): should not dump singleton class.
[ruby-dev:22631]
Tue Jan 20 02:49:22 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> Tue Jan 20 02:49:22 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: add check for OpenSSL version. * ext/openssl/extconf.rb: add check for OpenSSL version.

22
eval.c
View File

@ -2358,10 +2358,6 @@ is_defined(self, node, buf)
} }
break; break;
case NODE_NEWLINE:
node = node->nd_next;
goto again;
default: default:
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
@ -2468,7 +2464,7 @@ call_trace_func(event, node, self, id, klass)
if (id == ID_ALLOCATOR) return; if (id == ID_ALLOCATOR) return;
if (!(node_save = ruby_current_node)) { if (!(node_save = ruby_current_node)) {
node_save = NEW_NEWLINE(0); node_save = NEW_BEGIN(0);
} }
tracing = 1; tracing = 1;
prev = ruby_frame; prev = ruby_frame;
@ -2686,6 +2682,11 @@ rb_eval(self, n)
if (!node) RETURN(Qnil); if (!node) RETURN(Qnil);
ruby_current_node = node; ruby_current_node = node;
if (trace_func && FL_TEST(node, NODE_NEWLINE)) {
call_trace_func("line", node, self,
ruby_frame->last_func,
ruby_frame->last_class);
}
switch (nd_type(node)) { switch (nd_type(node)) {
case NODE_BLOCK: case NODE_BLOCK:
if (contnode) { if (contnode) {
@ -3888,15 +3889,6 @@ rb_eval(self, n)
} }
break; break;
case NODE_NEWLINE:
if (trace_func) {
call_trace_func("line", node, self,
ruby_frame->last_func,
ruby_frame->last_class);
}
node = node->nd_next;
goto again;
default: default:
rb_bug("unknown node type %d", nd_type(node)); rb_bug("unknown node type %d", nd_type(node));
} }
@ -6376,7 +6368,7 @@ rb_load(fname, wrap)
last_func = ruby_frame->last_func; last_func = ruby_frame->last_func;
last_node = ruby_current_node; last_node = ruby_current_node;
if (!ruby_current_node && ruby_sourcefile) { if (!ruby_current_node && ruby_sourcefile) {
last_node = NEW_NEWLINE(0); last_node = NEW_BEGIN(0);
} }
ruby_current_node = 0; ruby_current_node = 0;
if (state == 0) { if (state == 0) {

View File

@ -1026,43 +1026,47 @@ socks_s_close(sock)
#endif #endif
static VALUE static VALUE
make_hostent(addr, ipaddr) sock_gethostbyname(host, ipaddr)
struct addrinfo *addr; VALUE host;
VALUE (*ipaddr) _((struct sockaddr*, size_t)); VALUE (*ipaddr) _((struct sockaddr*, size_t));
{ {
struct addrinfo *addr;
struct addrinfo *ai; struct addrinfo *ai;
struct hostent *h; struct hostent *h;
VALUE ary, names; VALUE ary, names;
char *hostname;
char **pch; char **pch;
addr = sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME);
ary = rb_ary_new(); ary = rb_ary_new();
if (addr->ai_canonname) { if (addr->ai_canonname) {
rb_ary_push(ary, rb_str_new2(addr->ai_canonname)); hostname = addr->ai_canonname;
} }
else { else {
rb_ary_push(ary, Qnil); hostname = StringValuePtr(host);
} }
if (addr->ai_canonname) { rb_ary_push(ary, rb_str_new2(hostname));
#if defined(HAVE_GETIPNODEBYNAME) #if defined(HAVE_GETIPNODEBYNAME)
{
int error; int error;
h = getipnodebyname(addr->ai_canonname, addr->ai_family, AI_ALL, &error); h = getipnodebyname(hostname, addr->ai_family, AI_ALL, &error);
}
#elif defined(HAVE_GETHOSTBYNAME2) #elif defined(HAVE_GETHOSTBYNAME2)
h = gethostbyname2(addr->ai_canonname, addr->ai_family); h = gethostbyname2(hostname, addr->ai_family);
#else #else
h = gethostbyname(addr->ai_canonname); h = gethostbyname(hostname);
#endif #endif
if (h) { if (h) {
names = rb_ary_new(); names = rb_ary_new();
if (h->h_aliases != NULL) { if (h->h_aliases != NULL) {
for (pch = h->h_aliases; *pch; pch++) { for (pch = h->h_aliases; *pch; pch++) {
rb_ary_push(names, rb_str_new2(*pch)); rb_ary_push(names, rb_str_new2(*pch));
}
} }
#if defined(HAVE_GETIPNODEBYNAME)
freehostent(h);
#endif
} }
#if defined(HAVE_GETIPNODEBYNAME)
freehostent(h);
#endif
} }
else { else {
names = rb_ary_new2(0); names = rb_ary_new2(0);
@ -1089,7 +1093,7 @@ tcp_s_gethostbyname(obj, host)
VALUE obj, host; VALUE obj, host;
{ {
rb_secure(3); rb_secure(3);
return make_hostent(sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), tcp_sockaddr); return sock_gethostbyname(host, tcp_sockaddr);
} }
static VALUE static VALUE
@ -1981,6 +1985,9 @@ make_addrinfo(res0)
base = rb_ary_new(); base = rb_ary_new();
for (res = res0; res; res = res->ai_next) { for (res = res0; res; res = res->ai_next) {
ary = ipaddr(res->ai_addr); ary = ipaddr(res->ai_addr);
if (res->ai_canonname) {
RARRAY(ary)->ptr[2] = rb_str_new2(res->ai_canonname);
}
rb_ary_push(ary, INT2FIX(res->ai_family)); rb_ary_push(ary, INT2FIX(res->ai_family));
rb_ary_push(ary, INT2FIX(res->ai_socktype)); rb_ary_push(ary, INT2FIX(res->ai_socktype));
rb_ary_push(ary, INT2FIX(res->ai_protocol)); rb_ary_push(ary, INT2FIX(res->ai_protocol));
@ -2002,7 +2009,7 @@ sock_s_gethostbyname(obj, host)
VALUE obj, host; VALUE obj, host;
{ {
rb_secure(3); rb_secure(3);
return make_hostent(sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr); return sock_gethostbyname(host, sock_sockaddr);
} }
static VALUE static VALUE

3
gc.c
View File

@ -777,7 +777,6 @@ gc_mark_children(ptr, lev)
case NODE_SUPER: /* 3 */ case NODE_SUPER: /* 3 */
case NODE_FCALL: case NODE_FCALL:
case NODE_DEFN: case NODE_DEFN:
case NODE_NEWLINE:
ptr = (VALUE)obj->as.node.u3.node; ptr = (VALUE)obj->as.node.u3.node;
goto again; goto again;
@ -1431,7 +1430,7 @@ Init_stack(addr)
STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE); STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
} }
} }
#ifdef __ia64__ #if defined(__ia64__) && (!defined(__GNUC__) || __GNUC__ < 2 || defined(__OPTIMIZE__))
/* ruby crashes on IA64 if compiled with optimizer on */ /* ruby crashes on IA64 if compiled with optimizer on */
/* when if STACK_LEVEL_MAX is greater than this magic number */ /* when if STACK_LEVEL_MAX is greater than this magic number */
/* I know this is a kludge. I suspect optimizer bug */ /* I know this is a kludge. I suspect optimizer bug */

View File

@ -36,7 +36,8 @@ module Find
paths.collect!{|d| d.dup} paths.collect!{|d| d.dup}
while file = paths.shift while file = paths.shift
catch(:prune) do catch(:prune) do
yield file yield file.dup
file.untaint
begin begin
if File.lstat(file).directory? then if File.lstat(file).directory? then
d = Dir.open(file) d = Dir.open(file)

View File

@ -706,7 +706,7 @@ module Net # :nodoc:
end end
if block_given? if block_given?
line = waitfor(/login[: ]*\z/n){|c| yield c } line = waitfor(/[Ll]ogin[: ]*\z/n){|c| yield c }
if password if password
line += cmd({"String" => username, line += cmd({"String" => username,
"Match" => /Password[: ]*\z/n}){|c| yield c } "Match" => /Password[: ]*\z/n}){|c| yield c }
@ -715,7 +715,7 @@ module Net # :nodoc:
line += cmd(username){|c| yield c } line += cmd(username){|c| yield c }
end end
else else
line = waitfor(/login[: ]*\z/n) line = waitfor(/[Ll]ogin[: ]*\z/n)
if password if password
line += cmd({"String" => username, line += cmd({"String" => username,
"Match" => /Password[: ]*\z/n}) "Match" => /Password[: ]*\z/n})

View File

@ -400,7 +400,7 @@ w_class(type, obj, arg, check)
VALUE klass = CLASS_OF(obj); VALUE klass = CLASS_OF(obj);
w_extended(klass, arg, check); w_extended(klass, arg, check);
w_byte(type, arg); w_byte(type, arg);
path = RSTRING(class2path(klass))->ptr; path = RSTRING(class2path(rb_class_real(klass)))->ptr;
w_unique(path, arg); w_unique(path, arg);
} }

6
node.h
View File

@ -113,7 +113,6 @@ enum node_type {
NODE_TRUE, NODE_TRUE,
NODE_FALSE, NODE_FALSE,
NODE_DEFINED, NODE_DEFINED,
NODE_NEWLINE,
NODE_POSTEXE, NODE_POSTEXE,
#ifdef C_ALLOCA #ifdef C_ALLOCA
NODE_ALLOCA, NODE_ALLOCA,
@ -155,10 +154,12 @@ typedef struct RNode {
#define RNODE(obj) (R_CAST(RNode)(obj)) #define RNODE(obj) (R_CAST(RNode)(obj))
#define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0xff)) #define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0x7f))
#define nd_set_type(n,t) \ #define nd_set_type(n,t) \
RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK)) RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))
#define NODE_NEWLINE FL_USER7
#define NODE_LSHIFT (FL_USHIFT+8) #define NODE_LSHIFT (FL_USHIFT+8)
#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1) #define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
#define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK)) #define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
@ -330,7 +331,6 @@ typedef struct RNode {
#define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0) #define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
#define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0) #define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
#define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0) #define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
#define NEW_NEWLINE(n) NEW_NODE(NODE_NEWLINE,0,0,n)
#define NEW_PREEXE(b) NEW_SCOPE(b) #define NEW_PREEXE(b) NEW_SCOPE(b)
#define NEW_POSTEXE() NEW_NODE(NODE_POSTEXE,0,0,0) #define NEW_POSTEXE() NEW_NODE(NODE_POSTEXE,0,0,0)
#define NEW_DMETHOD(b) NEW_NODE(NODE_DMETHOD,0,0,b) #define NEW_DMETHOD(b) NEW_NODE(NODE_DMETHOD,0,0,b)

69
parse.y
View File

@ -384,7 +384,7 @@ stmts : none
} }
| stmts terms stmt | stmts terms stmt
{ {
$$ = block_append($1, newline_node($3)); $$ = block_append($1, $3);
} }
| error stmt | error stmt
{ {
@ -1228,7 +1228,7 @@ aref_args : none
| tSTAR arg opt_nl | tSTAR arg opt_nl
{ {
value_expr($2); value_expr($2);
$$ = NEW_NEWLINE(NEW_SPLAT($2)); $$ = newline_node(NEW_SPLAT($2));
} }
; ;
@ -2071,11 +2071,7 @@ string_content : tSTRING_CONTENT
compstmt '}' compstmt '}'
{ {
lex_strterm = $<node>2; lex_strterm = $<node>2;
if (($$ = $3) && nd_type($$) == NODE_NEWLINE) { $$ = new_evstr($3);
$$ = $$->nd_next;
rb_gc_force_recycle((VALUE)$3);
}
$$ = new_evstr($$);
} }
; ;
@ -4456,14 +4452,8 @@ static NODE*
newline_node(node) newline_node(node)
NODE *node; NODE *node;
{ {
NODE *nl = 0; FL_SET(node, NODE_NEWLINE);
if (node) { return node;
if (nd_type(node) == NODE_NEWLINE) return node;
nl = NEW_NEWLINE(node);
fixpos(nl, node);
nl->nd_nth = nd_line(node);
}
return nl;
} }
static void static void
@ -4510,15 +4500,12 @@ block_append(head, tail)
again: again:
if (h == 0) return tail; if (h == 0) return tail;
switch (nd_type(h)) { switch (nd_type(h)) {
case NODE_NEWLINE:
h = h->nd_next;
goto again;
case NODE_LIT: case NODE_LIT:
case NODE_STR: case NODE_STR:
parser_warning(h, "unused literal ignored"); parser_warning(h, "unused literal ignored");
return tail; return tail;
default: default:
end = NEW_BLOCK(head); h = end = NEW_BLOCK(head);
end->nd_end = end; end->nd_end = end;
fixpos(end, head); fixpos(end, head);
head = end; head = end;
@ -4540,10 +4527,6 @@ block_append(head, tail)
parser_warning(nd, "statement not reached"); parser_warning(nd, "statement not reached");
break; break;
case NODE_NEWLINE:
nd = nd->nd_next;
goto newline;
default: default:
break; break;
} }
@ -4554,7 +4537,7 @@ block_append(head, tail)
tail->nd_end = tail; tail->nd_end = tail;
} }
end->nd_next = tail; end->nd_next = tail;
head->nd_end = tail->nd_end; h->nd_end = tail->nd_end;
return head; return head;
} }
@ -4676,9 +4659,6 @@ new_evstr(node)
switch (nd_type(node)) { switch (nd_type(node)) {
case NODE_STR: case NODE_DSTR: case NODE_EVSTR: case NODE_STR: case NODE_DSTR: case NODE_EVSTR:
return node; return node;
case NODE_NEWLINE:
node = node->nd_next;
goto again;
} }
} }
return NEW_EVSTR(head); return NEW_EVSTR(head);
@ -4995,10 +4975,6 @@ value_expr0(node)
node = node->nd_2nd; node = node->nd_2nd;
break; break;
case NODE_NEWLINE:
node = node->nd_next;
break;
default: default:
return Qtrue; return Qtrue;
} }
@ -5018,10 +4994,6 @@ void_expr0(node)
again: again:
if (!node) return; if (!node) return;
switch (nd_type(node)) { switch (nd_type(node)) {
case NODE_NEWLINE:
node = node->nd_next;
goto again;
case NODE_CALL: case NODE_CALL:
switch (node->nd_mid) { switch (node->nd_mid) {
case '+': case '+':
@ -5124,15 +5096,10 @@ remove_begin(node)
{ {
NODE **n = &node; NODE **n = &node;
while (*n) { while (*n) {
switch (nd_type(*n)) { if (nd_type(*n) != NODE_BEGIN) {
case NODE_NEWLINE:
n = &(*n)->nd_next;
continue;
case NODE_BEGIN:
*n = (*n)->nd_body;
default:
return node; return node;
} }
*n = (*n)->nd_body;
} }
return node; return node;
} }
@ -5152,7 +5119,6 @@ assign_in_cond(node)
case NODE_IASGN: case NODE_IASGN:
break; break;
case NODE_NEWLINE:
default: default:
return 0; return 0;
} }
@ -5221,10 +5187,6 @@ range_op(node)
value_expr(node); value_expr(node);
node = cond0(node); node = cond0(node);
type = nd_type(node); type = nd_type(node);
if (type == NODE_NEWLINE) {
node = node->nd_next;
type = nd_type(node);
}
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) { if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
warn_unless_e_option(node, "integer literal in conditional range"); warn_unless_e_option(node, "integer literal in conditional range");
return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$."))); return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")));
@ -5324,10 +5286,6 @@ cond(node)
{ {
if (node == 0) return 0; if (node == 0) return 0;
value_expr(node); value_expr(node);
if (nd_type(node) == NODE_NEWLINE){
node->nd_next = cond0(node->nd_next);
return node;
}
return cond0(node); return cond0(node);
} }
@ -5359,11 +5317,6 @@ cond_negative(nodep)
case NODE_NOT: case NODE_NOT:
*nodep = c->nd_body; *nodep = c->nd_body;
return 1; return 1;
case NODE_NEWLINE:
if (c->nd_next && nd_type(c->nd_next) == NODE_NOT) {
c->nd_next = c->nd_next->nd_body;
return 1;
}
} }
return 0; return 0;
} }
@ -5386,7 +5339,7 @@ ret_args(node)
if (nd_type(node) == NODE_ARRAY && node->nd_next == 0) { if (nd_type(node) == NODE_ARRAY && node->nd_next == 0) {
node = node->nd_head; node = node->nd_head;
} }
if (node && nd_type(node) == NODE_SPLAT) { else if (node && nd_type(node) == NODE_SPLAT) {
node = NEW_SVALUE(node); node = NEW_SVALUE(node);
} }
} }
@ -5405,7 +5358,7 @@ new_yield(node)
node = node->nd_head; node = node->nd_head;
state = Qfalse; state = Qfalse;
} }
if (node && nd_type(node) == NODE_SPLAT) { else if (node && nd_type(node) == NODE_SPLAT) {
state = Qtrue; state = Qtrue;
} }
} }

4
ruby.c
View File

@ -343,7 +343,7 @@ require_libraries()
Init_ext(); /* should be called here for some reason :-( */ Init_ext(); /* should be called here for some reason :-( */
save[0] = ruby_eval_tree; save[0] = ruby_eval_tree;
save[1] = ruby_eval_tree_begin; save[1] = ruby_eval_tree_begin;
save[2] = NEW_NEWLINE(0); save[2] = NEW_BEGIN(0);
ruby_eval_tree = ruby_eval_tree_begin = 0; ruby_eval_tree = ruby_eval_tree_begin = 0;
req_list_last = 0; req_list_last = 0;
while (list) { while (list) {
@ -753,7 +753,7 @@ proc_options(argc, argv)
} }
if (!script) script = argv[0]; if (!script) script = argv[0];
script = ruby_sourcefile = rb_source_filename(script); script = ruby_sourcefile = rb_source_filename(script);
script_node = NEW_NEWLINE(0); script_node = NEW_BEGIN(0);
} }
#if defined DOSISH || defined __CYGWIN__ #if defined DOSISH || defined __CYGWIN__
translate_char(script, '\\', '/'); translate_char(script, '\\', '/');

View File

@ -1,3 +1,4 @@
$:.unshift(File.dirname(File.expand_path(__FILE__)))
require 'drbtest' require 'drbtest'
class TestDRbCore < Test::Unit::TestCase class TestDRbCore < Test::Unit::TestCase