Skip to content

Commit

Permalink
* eval.c (rb_eval): ruby_frame->last_func may be null, if it's
Browse files Browse the repository at this point in the history
  called outside of a method.

* parse.y (arg): use INT2NUM, not INT2FIX for tUMINUS.

* parse.y (arg): unnecessary negative tPOW treatment.

* parse.y (tokadd_escape): wrong backslash escapement.

* parse.y (stmt,arg): too much void value check.

* parse.y (stmt,arg): need to check void value on rules which does
  not use node_assign().

* ext/socket/socket.c (ipaddr): need not to taint hostnames.

* range.c (range_include): should be based on "<=>", whereas
  member? still is based on "each".

* range.c (range_min,range_max): redefine methods based on "<=>".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jun 11, 2002
1 parent a5fd4ce commit 2201064
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 88 deletions.
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,37 @@ Mon Jun 10 19:02:19 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>

* parse.y (yylex): `0_' should be an error. (ruby-bugs-ja:PR#249)

Mon Jun 10 01:53:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_eval): ruby_frame->last_func may be null, if it's
called outside of a method.

* parse.y (arg): use INT2NUM, not INT2FIX for tUMINUS.

* parse.y (arg): unnecessary negative tPOW treatment.

* parse.y (tokadd_escape): wrong backslash escapement.

Sun Jun 9 17:40:41 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>

* ext/dl: change the callback mechanism.

Sat Jun 8 00:48:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* parse.y (stmt,arg): too much void value check.

* parse.y (stmt,arg): need to check void value on rules which does
not use node_assign().

Thu Jun 6 19:50:39 2002 KONISHI Hiromasa <H_Konishi@ruby-lang.org>

* sample/biorhythm.rb (getPosiiton,etc)
fix at changing Date module ( Date is changed Fixnum to Rational )

Thu Jun 6 17:42:39 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* ext/socket/socket.c (ipaddr): need not to taint hostnames.

Thu Jun 6 12:04:30 2002 NAKAMURA Usaku <usa@ruby-lang.org>

* win32/Makefile.sub (config.status): use sub! instead of []= because
Expand All @@ -58,6 +80,13 @@ Thu Jun 6 11:42:15 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>

* lib/thread.rb (Queue::pop): get rid of race condition.

Tue Jun 4 23:09:24 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* range.c (range_include): should be based on "<=>", whereas
member? still is based on "each".

* range.c (range_min,range_max): redefine methods based on "<=>".

Tue Jun 4 18:28:37 2002 WATANABE Hirofumi <eban@ruby-lang.org>

* ext/socket/extconf.rb: The IPv6 stack of Cygwin is still incomplete.
Expand Down
10 changes: 4 additions & 6 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,20 +1352,18 @@ rb_big_pow(x, y)
case T_FIXNUM:
yy = NUM2LONG(y);
if (yy > 0) {
VALUE z;
VALUE z = x;

z = x;
for (;;) {
yy = yy - 1;
yy -= 1;
if (yy == 0) break;
while (yy % 2 == 0) {
yy = yy / 2;
yy /= 2;
x = rb_big_mul(x, x);
}
z = rb_big_mul(z, x);
}
if (!FIXNUM_P(z)) z = bignorm(z);
return z;
return bignorm(z);
}
d = (double)yy;
break;
Expand Down
11 changes: 8 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2745,9 +2745,14 @@ rb_eval(self, n)
TMP_PROTECT;

if (ruby_frame->last_class == 0) {
rb_name_error(ruby_frame->last_func,
"superclass method `%s' disabled",
rb_id2name(ruby_frame->last_func));
if (ruby_frame->last_func) {
rb_name_error(ruby_frame->last_func,
"superclass method `%s' disabled",
rb_id2name(ruby_frame->last_func));
}
else {
rb_raise(rb_eNoMethodError, "super called outside of method");
}
}
if (nd_type(node) == NODE_ZSUPER) {
argc = ruby_frame->argc;
Expand Down
50 changes: 28 additions & 22 deletions ext/socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ bsock_getsockopt(sock, lev, optname)
if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0)
rb_sys_fail(fptr->path);

return rb_tainted_str_new(buf, len);
return rb_str_new(buf, len);
#else
rb_notimplement();
#endif
Expand All @@ -353,7 +353,7 @@ bsock_getsockname(sock)
GetOpenFile(sock, fptr);
if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getsockname(2)");
return rb_tainted_str_new(buf, len);
return rb_str_new(buf, len);
}

static VALUE
Expand All @@ -367,7 +367,7 @@ bsock_getpeername(sock)
GetOpenFile(sock, fptr);
if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getpeername(2)");
return rb_tainted_str_new(buf, len);
return rb_str_new(buf, len);
}

static VALUE
Expand Down Expand Up @@ -480,7 +480,7 @@ s_recvfrom(sock, argc, argv, from)
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)buf));
#endif
case RECV_SOCKET:
return rb_assoc_new(str, rb_tainted_str_new(buf, alen));
return rb_assoc_new(str, rb_str_new(buf, alen));
default:
rb_bug("s_recvfrom called with bad value");
}
Expand Down Expand Up @@ -530,7 +530,7 @@ mkipaddr(addr)
char buf[1024];

mkipaddr0(addr, buf, sizeof(buf));
return rb_tainted_str_new2(buf);
return rb_str_new2(buf);
}

static void
Expand Down Expand Up @@ -673,14 +673,14 @@ ipaddr(sockaddr)
if (error) {
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
addr1 = rb_tainted_str_new2(hbuf);
addr1 = rb_str_new2(hbuf);
}
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
addr2 = rb_tainted_str_new2(hbuf);
addr2 = rb_str_new2(hbuf);
if (do_not_reverse_lookup) {
addr1 = addr2;
}
Expand Down Expand Up @@ -1078,11 +1078,11 @@ tcp_s_gethostbyname(obj, host)
size_t size;

ary = rb_ary_new();
rb_ary_push(ary, rb_tainted_str_new2(h->h_name));
rb_ary_push(ary, rb_str_new2(h->h_name));
names = rb_ary_new();
rb_ary_push(ary, names);
for (pch = h->h_aliases; *pch; pch++) {
rb_ary_push(names, rb_tainted_str_new2(*pch));
rb_ary_push(names, rb_str_new2(*pch));
}
rb_ary_push(ary, INT2NUM(h->h_addrtype));
#ifdef h_addr
Expand Down Expand Up @@ -1464,7 +1464,7 @@ unix_path(sock)
rb_sys_fail(0);
fptr->path = strdup(addr.sun_path);
}
return rb_tainted_str_new2(fptr->path);
return rb_str_new2(fptr->path);
}

static VALUE
Expand Down Expand Up @@ -1677,7 +1677,7 @@ unixaddr(sockaddr)
struct sockaddr_un *sockaddr;
{
return rb_assoc_new(rb_str_new2("AF_UNIX"),
rb_tainted_str_new2(sockaddr->sun_path));
rb_str_new2(sockaddr->sun_path));
}

static VALUE
Expand Down Expand Up @@ -1931,7 +1931,7 @@ sock_accept(sock)
GetOpenFile(sock, fptr);
sock2 = s_accept(rb_cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);

return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
return rb_assoc_new(sock2, rb_str_new(buf, len));
}

static VALUE
Expand All @@ -1946,7 +1946,7 @@ sock_sysaccept(sock)
GetOpenFile(sock, fptr);
sock2 = s_accept(0,fileno(fptr->f),(struct sockaddr*)buf,&len);

return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
return rb_assoc_new(sock2, rb_str_new(buf, len));
}

#ifdef HAVE_GETHOSTNAME
Expand All @@ -1961,7 +1961,7 @@ sock_gethostname(obj)
rb_sys_fail("gethostname");

buf[sizeof buf - 1] = '\0';
return rb_tainted_str_new2(buf);
return rb_str_new2(buf);
}
#else
#ifdef HAVE_UNAME
Expand All @@ -1976,7 +1976,7 @@ sock_gethostname(obj)

rb_secure(3);
uname(&un);
return rb_tainted_str_new2(un.nodename);
return rb_str_new2(un.nodename);
}
#else
static VALUE
Expand Down Expand Up @@ -2004,19 +2004,19 @@ sock_mkhostent(h)
#endif
}
ary = rb_ary_new();
rb_ary_push(ary, rb_tainted_str_new2(h->h_name));
rb_ary_push(ary, rb_str_new2(h->h_name));
names = rb_ary_new();
rb_ary_push(ary, names);
for (pch = h->h_aliases; *pch; pch++) {
rb_ary_push(names, rb_tainted_str_new2(*pch));
rb_ary_push(names, rb_str_new2(*pch));
}
rb_ary_push(ary, INT2NUM(h->h_addrtype));
#ifdef h_addr
for (pch = h->h_addr_list; *pch; pch++) {
rb_ary_push(ary, rb_tainted_str_new(*pch, h->h_length));
rb_ary_push(ary, rb_str_new(*pch, h->h_length));
}
#else
rb_ary_push(ary, rb_tainted_str_new(h->h_addr, h->h_length));
rb_ary_push(ary, rb_str_new(h->h_addr, h->h_length));
#endif

return ary;
Expand Down Expand Up @@ -2304,7 +2304,7 @@ sock_s_getnameinfo(argc, argv)
}
freeaddrinfo(res);
}
return rb_assoc_new(rb_tainted_str_new2(hbuf), rb_tainted_str_new2(pbuf));
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));

error_exit_addr:
if (res) freeaddrinfo(res);
Expand Down Expand Up @@ -2334,13 +2334,16 @@ sock_s_unpack_sockaddr_in(self, addr)
VALUE self, addr;
{
struct sockaddr_in * sockaddr;
VALUE host;

sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
if (RSTRING(addr)->len != sizeof(struct sockaddr_in)) {
rb_raise(rb_eTypeError, "sockaddr_in size differs - %d required; %d given",
RSTRING(addr)->len, sizeof(struct sockaddr_in));
}
return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), mkipaddr(sockaddr));
host = mkipaddr(sockaddr);
OBJ_INFECT(host, addr);
return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
}

#ifdef HAVE_SYS_UN_H
Expand All @@ -2365,14 +2368,17 @@ sock_s_unpack_sockaddr_un(self, addr)
VALUE self, addr;
{
struct sockaddr_un * sockaddr;
VALUE path;

sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
if (RSTRING(addr)->len != sizeof(struct sockaddr_un)) {
rb_raise(rb_eTypeError, "sockaddr_un size differs - %d required; %d given",
RSTRING(addr)->len, sizeof(struct sockaddr_un));
}
/* xxx: should I check against sun_path size? */
return rb_tainted_str_new2(sockaddr->sun_path);
path = rb_str_new2(sockaddr->sun_path);
OBJ_INFECT(path, addr);
return path;
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions lib/rational.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# --
# Usage:
# class Rational < Numeric
# (include Compareable)
# (include Comparable)
#
# Rational(a, b) --> a/b
#
Expand Down Expand Up @@ -47,7 +47,7 @@ class Rational < Numeric
@RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-'

def Rational.reduce(num, den = 1)
raise ZeroDivisionError, "denometor is 0" if den == 0
raise ZeroDivisionError, "denominator is 0" if den == 0

if den < 0
num = -num
Expand Down Expand Up @@ -132,7 +132,7 @@ def / (a)
den = @denominator * a.numerator
Rational(num, den)
elsif a.kind_of?(Integer)
raise ZeroDivisionError, "devided by 0" if a == 0
raise ZeroDivisionError, "divided by 0" if a == 0
self / Rational.new!(a, 1)
elsif a.kind_of?(Float)
Float(self) / a
Expand Down
Loading

0 comments on commit 2201064

Please sign in to comment.