1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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>
* 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.
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>
* 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
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>
* ext/openssl/extconf.rb: add check for OpenSSL version.

22
eval.c
View file

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

View file

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

3
gc.c
View file

@ -777,7 +777,6 @@ gc_mark_children(ptr, lev)
case NODE_SUPER: /* 3 */
case NODE_FCALL:
case NODE_DEFN:
case NODE_NEWLINE:
ptr = (VALUE)obj->as.node.u3.node;
goto again;
@ -1431,7 +1430,7 @@ Init_stack(addr)
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 */
/* when if STACK_LEVEL_MAX is greater than this magic number */
/* I know this is a kludge. I suspect optimizer bug */

View file

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

View file

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

View file

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

6
node.h
View file

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

4
ruby.c
View file

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

View file

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