* 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. * 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
This commit is contained in:
parent
a5fd4cec84
commit
22010642b2
29
ChangeLog
29
ChangeLog
@ -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)
|
* 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>
|
Sun Jun 9 17:40:41 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
|
||||||
|
|
||||||
* ext/dl: change the callback mechanism.
|
* 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>
|
Thu Jun 6 19:50:39 2002 KONISHI Hiromasa <H_Konishi@ruby-lang.org>
|
||||||
|
|
||||||
* sample/biorhythm.rb (getPosiiton,etc)
|
* sample/biorhythm.rb (getPosiiton,etc)
|
||||||
fix at changing Date module ( Date is changed Fixnum to Rational )
|
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>
|
Thu Jun 6 12:04:30 2002 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32/Makefile.sub (config.status): use sub! instead of []= because
|
* win32/Makefile.sub (config.status): use sub! instead of []= because
|
||||||
@ -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.
|
* 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>
|
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.
|
* ext/socket/extconf.rb: The IPv6 stack of Cygwin is still incomplete.
|
||||||
|
10
bignum.c
10
bignum.c
@ -1352,20 +1352,18 @@ rb_big_pow(x, y)
|
|||||||
case T_FIXNUM:
|
case T_FIXNUM:
|
||||||
yy = NUM2LONG(y);
|
yy = NUM2LONG(y);
|
||||||
if (yy > 0) {
|
if (yy > 0) {
|
||||||
VALUE z;
|
VALUE z = x;
|
||||||
|
|
||||||
z = x;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
yy = yy - 1;
|
yy -= 1;
|
||||||
if (yy == 0) break;
|
if (yy == 0) break;
|
||||||
while (yy % 2 == 0) {
|
while (yy % 2 == 0) {
|
||||||
yy = yy / 2;
|
yy /= 2;
|
||||||
x = rb_big_mul(x, x);
|
x = rb_big_mul(x, x);
|
||||||
}
|
}
|
||||||
z = rb_big_mul(z, x);
|
z = rb_big_mul(z, x);
|
||||||
}
|
}
|
||||||
if (!FIXNUM_P(z)) z = bignorm(z);
|
return bignorm(z);
|
||||||
return z;
|
|
||||||
}
|
}
|
||||||
d = (double)yy;
|
d = (double)yy;
|
||||||
break;
|
break;
|
||||||
|
11
eval.c
11
eval.c
@ -2745,9 +2745,14 @@ rb_eval(self, n)
|
|||||||
TMP_PROTECT;
|
TMP_PROTECT;
|
||||||
|
|
||||||
if (ruby_frame->last_class == 0) {
|
if (ruby_frame->last_class == 0) {
|
||||||
rb_name_error(ruby_frame->last_func,
|
if (ruby_frame->last_func) {
|
||||||
"superclass method `%s' disabled",
|
rb_name_error(ruby_frame->last_func,
|
||||||
rb_id2name(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) {
|
if (nd_type(node) == NODE_ZSUPER) {
|
||||||
argc = ruby_frame->argc;
|
argc = ruby_frame->argc;
|
||||||
|
@ -336,7 +336,7 @@ bsock_getsockopt(sock, lev, optname)
|
|||||||
if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0)
|
if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0)
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
|
|
||||||
return rb_tainted_str_new(buf, len);
|
return rb_str_new(buf, len);
|
||||||
#else
|
#else
|
||||||
rb_notimplement();
|
rb_notimplement();
|
||||||
#endif
|
#endif
|
||||||
@ -353,7 +353,7 @@ bsock_getsockname(sock)
|
|||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
|
if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
|
||||||
rb_sys_fail("getsockname(2)");
|
rb_sys_fail("getsockname(2)");
|
||||||
return rb_tainted_str_new(buf, len);
|
return rb_str_new(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -367,7 +367,7 @@ bsock_getpeername(sock)
|
|||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
|
if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
|
||||||
rb_sys_fail("getpeername(2)");
|
rb_sys_fail("getpeername(2)");
|
||||||
return rb_tainted_str_new(buf, len);
|
return rb_str_new(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -480,7 +480,7 @@ s_recvfrom(sock, argc, argv, from)
|
|||||||
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)buf));
|
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)buf));
|
||||||
#endif
|
#endif
|
||||||
case RECV_SOCKET:
|
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:
|
default:
|
||||||
rb_bug("s_recvfrom called with bad value");
|
rb_bug("s_recvfrom called with bad value");
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ mkipaddr(addr)
|
|||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
mkipaddr0(addr, buf, sizeof(buf));
|
mkipaddr0(addr, buf, sizeof(buf));
|
||||||
return rb_tainted_str_new2(buf);
|
return rb_str_new2(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -673,14 +673,14 @@ ipaddr(sockaddr)
|
|||||||
if (error) {
|
if (error) {
|
||||||
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(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),
|
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
|
||||||
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
|
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||||
if (error) {
|
if (error) {
|
||||||
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(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) {
|
if (do_not_reverse_lookup) {
|
||||||
addr1 = addr2;
|
addr1 = addr2;
|
||||||
}
|
}
|
||||||
@ -1078,11 +1078,11 @@ tcp_s_gethostbyname(obj, host)
|
|||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
ary = rb_ary_new();
|
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();
|
names = rb_ary_new();
|
||||||
rb_ary_push(ary, names);
|
rb_ary_push(ary, names);
|
||||||
for (pch = h->h_aliases; *pch; pch++) {
|
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));
|
rb_ary_push(ary, INT2NUM(h->h_addrtype));
|
||||||
#ifdef h_addr
|
#ifdef h_addr
|
||||||
@ -1464,7 +1464,7 @@ unix_path(sock)
|
|||||||
rb_sys_fail(0);
|
rb_sys_fail(0);
|
||||||
fptr->path = strdup(addr.sun_path);
|
fptr->path = strdup(addr.sun_path);
|
||||||
}
|
}
|
||||||
return rb_tainted_str_new2(fptr->path);
|
return rb_str_new2(fptr->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1677,7 +1677,7 @@ unixaddr(sockaddr)
|
|||||||
struct sockaddr_un *sockaddr;
|
struct sockaddr_un *sockaddr;
|
||||||
{
|
{
|
||||||
return rb_assoc_new(rb_str_new2("AF_UNIX"),
|
return rb_assoc_new(rb_str_new2("AF_UNIX"),
|
||||||
rb_tainted_str_new2(sockaddr->sun_path));
|
rb_str_new2(sockaddr->sun_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1931,7 +1931,7 @@ sock_accept(sock)
|
|||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
sock2 = s_accept(rb_cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);
|
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
|
static VALUE
|
||||||
@ -1946,7 +1946,7 @@ sock_sysaccept(sock)
|
|||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
sock2 = s_accept(0,fileno(fptr->f),(struct sockaddr*)buf,&len);
|
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
|
#ifdef HAVE_GETHOSTNAME
|
||||||
@ -1961,7 +1961,7 @@ sock_gethostname(obj)
|
|||||||
rb_sys_fail("gethostname");
|
rb_sys_fail("gethostname");
|
||||||
|
|
||||||
buf[sizeof buf - 1] = '\0';
|
buf[sizeof buf - 1] = '\0';
|
||||||
return rb_tainted_str_new2(buf);
|
return rb_str_new2(buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_UNAME
|
#ifdef HAVE_UNAME
|
||||||
@ -1976,7 +1976,7 @@ sock_gethostname(obj)
|
|||||||
|
|
||||||
rb_secure(3);
|
rb_secure(3);
|
||||||
uname(&un);
|
uname(&un);
|
||||||
return rb_tainted_str_new2(un.nodename);
|
return rb_str_new2(un.nodename);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2004,19 +2004,19 @@ sock_mkhostent(h)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ary = rb_ary_new();
|
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();
|
names = rb_ary_new();
|
||||||
rb_ary_push(ary, names);
|
rb_ary_push(ary, names);
|
||||||
for (pch = h->h_aliases; *pch; pch++) {
|
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));
|
rb_ary_push(ary, INT2NUM(h->h_addrtype));
|
||||||
#ifdef h_addr
|
#ifdef h_addr
|
||||||
for (pch = h->h_addr_list; *pch; pch++) {
|
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
|
#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
|
#endif
|
||||||
|
|
||||||
return ary;
|
return ary;
|
||||||
@ -2304,7 +2304,7 @@ sock_s_getnameinfo(argc, argv)
|
|||||||
}
|
}
|
||||||
freeaddrinfo(res);
|
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:
|
error_exit_addr:
|
||||||
if (res) freeaddrinfo(res);
|
if (res) freeaddrinfo(res);
|
||||||
@ -2334,13 +2334,16 @@ sock_s_unpack_sockaddr_in(self, addr)
|
|||||||
VALUE self, addr;
|
VALUE self, addr;
|
||||||
{
|
{
|
||||||
struct sockaddr_in * sockaddr;
|
struct sockaddr_in * sockaddr;
|
||||||
|
VALUE host;
|
||||||
|
|
||||||
sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
|
sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
|
||||||
if (RSTRING(addr)->len != sizeof(struct sockaddr_in)) {
|
if (RSTRING(addr)->len != sizeof(struct sockaddr_in)) {
|
||||||
rb_raise(rb_eTypeError, "sockaddr_in size differs - %d required; %d given",
|
rb_raise(rb_eTypeError, "sockaddr_in size differs - %d required; %d given",
|
||||||
RSTRING(addr)->len, sizeof(struct sockaddr_in));
|
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
|
#ifdef HAVE_SYS_UN_H
|
||||||
@ -2365,6 +2368,7 @@ sock_s_unpack_sockaddr_un(self, addr)
|
|||||||
VALUE self, addr;
|
VALUE self, addr;
|
||||||
{
|
{
|
||||||
struct sockaddr_un * sockaddr;
|
struct sockaddr_un * sockaddr;
|
||||||
|
VALUE path;
|
||||||
|
|
||||||
sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
|
sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
|
||||||
if (RSTRING(addr)->len != sizeof(struct sockaddr_un)) {
|
if (RSTRING(addr)->len != sizeof(struct sockaddr_un)) {
|
||||||
@ -2372,7 +2376,9 @@ sock_s_unpack_sockaddr_un(self, addr)
|
|||||||
RSTRING(addr)->len, sizeof(struct sockaddr_un));
|
RSTRING(addr)->len, sizeof(struct sockaddr_un));
|
||||||
}
|
}
|
||||||
/* xxx: should I check against sun_path size? */
|
/* 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
|
#endif
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# --
|
# --
|
||||||
# Usage:
|
# Usage:
|
||||||
# class Rational < Numeric
|
# class Rational < Numeric
|
||||||
# (include Compareable)
|
# (include Comparable)
|
||||||
#
|
#
|
||||||
# Rational(a, b) --> a/b
|
# Rational(a, b) --> a/b
|
||||||
#
|
#
|
||||||
@ -47,7 +47,7 @@ class Rational < Numeric
|
|||||||
@RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-'
|
@RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-'
|
||||||
|
|
||||||
def Rational.reduce(num, den = 1)
|
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
|
if den < 0
|
||||||
num = -num
|
num = -num
|
||||||
@ -132,7 +132,7 @@ class Rational < Numeric
|
|||||||
den = @denominator * a.numerator
|
den = @denominator * a.numerator
|
||||||
Rational(num, den)
|
Rational(num, den)
|
||||||
elsif a.kind_of?(Integer)
|
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)
|
self / Rational.new!(a, 1)
|
||||||
elsif a.kind_of?(Float)
|
elsif a.kind_of?(Float)
|
||||||
Float(self) / a
|
Float(self) / a
|
||||||
|
41
parse.y
41
parse.y
@ -435,7 +435,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| lhs '=' command_call
|
| lhs '=' command_call
|
||||||
{
|
{
|
||||||
value_expr($3);
|
|
||||||
$$ = node_assign($1, $3);
|
$$ = node_assign($1, $3);
|
||||||
}
|
}
|
||||||
| mlhs '=' command_call
|
| mlhs '=' command_call
|
||||||
@ -446,6 +445,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| var_lhs tOP_ASGN command_call
|
| var_lhs tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
|
value_expr($3);
|
||||||
if ($1) {
|
if ($1) {
|
||||||
ID vid = $1->nd_vid;
|
ID vid = $1->nd_vid;
|
||||||
if ($2 == tOROP) {
|
if ($2 == tOROP) {
|
||||||
@ -471,8 +471,10 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| primary_value '[' aref_args ']' tOP_ASGN command_call
|
| primary_value '[' aref_args ']' tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
NODE *args = NEW_LIST($6);
|
NODE *args;
|
||||||
|
|
||||||
|
value_expr($5);
|
||||||
|
args = NEW_LIST($6);
|
||||||
$3 = list_append($3, NEW_NIL());
|
$3 = list_append($3, NEW_NIL());
|
||||||
list_concat(args, $3);
|
list_concat(args, $3);
|
||||||
if ($5 == tOROP) {
|
if ($5 == tOROP) {
|
||||||
@ -486,6 +488,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| primary_value '.' tIDENTIFIER tOP_ASGN command_call
|
| primary_value '.' tIDENTIFIER tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -497,6 +500,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| primary_value '.' tCONSTANT tOP_ASGN command_call
|
| primary_value '.' tCONSTANT tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -508,6 +512,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
}
|
}
|
||||||
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -805,11 +810,11 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
|
|||||||
|
|
||||||
arg : lhs '=' arg
|
arg : lhs '=' arg
|
||||||
{
|
{
|
||||||
value_expr($3);
|
|
||||||
$$ = node_assign($1, $3);
|
$$ = node_assign($1, $3);
|
||||||
}
|
}
|
||||||
| var_lhs tOP_ASGN arg
|
| var_lhs tOP_ASGN arg
|
||||||
{
|
{
|
||||||
|
value_expr($3);
|
||||||
if ($1) {
|
if ($1) {
|
||||||
ID vid = $1->nd_vid;
|
ID vid = $1->nd_vid;
|
||||||
if ($2 == tOROP) {
|
if ($2 == tOROP) {
|
||||||
@ -835,8 +840,10 @@ arg : lhs '=' arg
|
|||||||
}
|
}
|
||||||
| primary_value '[' aref_args ']' tOP_ASGN arg
|
| primary_value '[' aref_args ']' tOP_ASGN arg
|
||||||
{
|
{
|
||||||
NODE *args = NEW_LIST($6);
|
NODE *args;
|
||||||
|
|
||||||
|
value_expr($6);
|
||||||
|
args = NEW_LIST($6);
|
||||||
$3 = list_append($3, NEW_NIL());
|
$3 = list_append($3, NEW_NIL());
|
||||||
list_concat(args, $3);
|
list_concat(args, $3);
|
||||||
if ($5 == tOROP) {
|
if ($5 == tOROP) {
|
||||||
@ -850,6 +857,7 @@ arg : lhs '=' arg
|
|||||||
}
|
}
|
||||||
| primary_value '.' tIDENTIFIER tOP_ASGN arg
|
| primary_value '.' tIDENTIFIER tOP_ASGN arg
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -861,6 +869,7 @@ arg : lhs '=' arg
|
|||||||
}
|
}
|
||||||
| primary_value '.' tCONSTANT tOP_ASGN arg
|
| primary_value '.' tCONSTANT tOP_ASGN arg
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -872,6 +881,7 @@ arg : lhs '=' arg
|
|||||||
}
|
}
|
||||||
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
|
||||||
{
|
{
|
||||||
|
value_expr($5);
|
||||||
if ($4 == tOROP) {
|
if ($4 == tOROP) {
|
||||||
$4 = 0;
|
$4 = 0;
|
||||||
}
|
}
|
||||||
@ -916,25 +926,7 @@ arg : lhs '=' arg
|
|||||||
}
|
}
|
||||||
| arg tPOW arg
|
| arg tPOW arg
|
||||||
{
|
{
|
||||||
int need_negate = Qfalse;
|
|
||||||
|
|
||||||
if (nd_type($1) == NODE_LIT) {
|
|
||||||
switch (TYPE($1->nd_lit)) {
|
|
||||||
case T_FIXNUM:
|
|
||||||
case T_FLOAT:
|
|
||||||
case T_BIGNUM:
|
|
||||||
if (RTEST(rb_funcall($1->nd_lit,'<',1,INT2FIX(0)))) {
|
|
||||||
$1->nd_lit = rb_funcall($1->nd_lit,rb_intern("-@"),0,0);
|
|
||||||
need_negate = Qtrue;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$$ = call_op($1, tPOW, 1, $3);
|
$$ = call_op($1, tPOW, 1, $3);
|
||||||
if (need_negate) {
|
|
||||||
$$ = call_op($$, tUMINUS, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
| tUPLUS arg
|
| tUPLUS arg
|
||||||
{
|
{
|
||||||
@ -950,7 +942,7 @@ arg : lhs '=' arg
|
|||||||
if ($2 && nd_type($2) == NODE_LIT && FIXNUM_P($2->nd_lit)) {
|
if ($2 && nd_type($2) == NODE_LIT && FIXNUM_P($2->nd_lit)) {
|
||||||
long i = FIX2LONG($2->nd_lit);
|
long i = FIX2LONG($2->nd_lit);
|
||||||
|
|
||||||
$2->nd_lit = INT2FIX(-i);
|
$2->nd_lit = INT2NUM(-i);
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2540,7 +2532,7 @@ tokadd_escape(term)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (c != '/' || c != term)
|
if (c != '\\' || c != term)
|
||||||
tokadd('\\');
|
tokadd('\\');
|
||||||
tokadd(c);
|
tokadd(c);
|
||||||
}
|
}
|
||||||
@ -5517,3 +5509,4 @@ rb_lastline_set(val)
|
|||||||
special_local_set('_', val);
|
special_local_set('_', val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%%
|
||||||
|
99
range.c
99
range.c
@ -37,8 +37,8 @@ range_failed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
range_init(obj, beg, end, exclude_end)
|
range_init(range, beg, end, exclude_end)
|
||||||
VALUE obj, beg, end;
|
VALUE range, beg, end;
|
||||||
int exclude_end;
|
int exclude_end;
|
||||||
{
|
{
|
||||||
VALUE args[2];
|
VALUE args[2];
|
||||||
@ -48,9 +48,9 @@ range_init(obj, beg, end, exclude_end)
|
|||||||
rb_rescue(range_check, (VALUE)args, range_failed, 0);
|
rb_rescue(range_check, (VALUE)args, range_failed, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_EXCL(obj, exclude_end);
|
SET_EXCL(range, exclude_end);
|
||||||
rb_ivar_set(obj, id_beg, beg);
|
rb_ivar_set(range, id_beg, beg);
|
||||||
rb_ivar_set(obj, id_end, end);
|
rb_ivar_set(range, id_end, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -58,26 +58,26 @@ rb_range_new(beg, end, exclude_end)
|
|||||||
VALUE beg, end;
|
VALUE beg, end;
|
||||||
int exclude_end;
|
int exclude_end;
|
||||||
{
|
{
|
||||||
VALUE obj = rb_obj_alloc(rb_cRange);
|
VALUE range = rb_obj_alloc(rb_cRange);
|
||||||
|
|
||||||
range_init(obj, beg, end, exclude_end);
|
range_init(range, beg, end, exclude_end);
|
||||||
return obj;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
range_initialize(argc, argv, obj)
|
range_initialize(argc, argv, range)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE obj;
|
VALUE range;
|
||||||
{
|
{
|
||||||
VALUE beg, end, flags;
|
VALUE beg, end, flags;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
|
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
|
||||||
/* Ranges are immutable, so that they should be initialized only once. */
|
/* Ranges are immutable, so that they should be initialized only once. */
|
||||||
if (rb_ivar_defined(obj, id_beg)) {
|
if (rb_ivar_defined(range, id_beg)) {
|
||||||
rb_name_error(rb_intern("initialize"), "`initialize' called twice");
|
rb_name_error(rb_intern("initialize"), "`initialize' called twice");
|
||||||
}
|
}
|
||||||
range_init(obj, beg, end, RTEST(flags));
|
range_init(range, beg, end, RTEST(flags));
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,17 +315,17 @@ range_each(range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
range_first(obj)
|
range_first(range)
|
||||||
VALUE obj;
|
VALUE range;
|
||||||
{
|
{
|
||||||
return rb_ivar_get(obj, id_beg);
|
return rb_ivar_get(range, id_beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
range_last(obj)
|
range_last(range)
|
||||||
VALUE obj;
|
VALUE range;
|
||||||
{
|
{
|
||||||
return rb_ivar_get(obj, id_end);
|
return rb_ivar_get(range, id_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -379,6 +379,35 @@ rb_range_beg_len(range, begp, lenp, len, err)
|
|||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
range_min(range)
|
||||||
|
VALUE range;
|
||||||
|
|
||||||
|
{
|
||||||
|
VALUE b, e, step;
|
||||||
|
long unit;
|
||||||
|
|
||||||
|
b = rb_ivar_get(range, id_beg);
|
||||||
|
e = rb_ivar_get(range, id_end);
|
||||||
|
|
||||||
|
if (r_le(b, e)) return b;
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
range_max(range)
|
||||||
|
VALUE range;
|
||||||
|
{
|
||||||
|
VALUE b, e, step;
|
||||||
|
long unit;
|
||||||
|
|
||||||
|
b = rb_ivar_get(range, id_beg);
|
||||||
|
e = rb_ivar_get(range, id_end);
|
||||||
|
|
||||||
|
if (r_gt(b, e)) return b;
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
range_to_s(range)
|
range_to_s(range)
|
||||||
VALUE range;
|
VALUE range;
|
||||||
@ -431,15 +460,9 @@ range_member(range, val)
|
|||||||
beg = rb_ivar_get(range, id_beg);
|
beg = rb_ivar_get(range, id_beg);
|
||||||
end = rb_ivar_get(range, id_end);
|
end = rb_ivar_get(range, id_end);
|
||||||
|
|
||||||
if (rb_obj_is_kind_of(beg, rb_cNumeric) || !rb_respond_to(beg, id_succ)) {
|
if (!rb_respond_to(beg, id_succ)) {
|
||||||
if (r_gt(beg, val)) return Qfalse;
|
rb_raise(rb_eTypeError, "cannot iterate from %s",
|
||||||
if (EXCL(range)) {
|
rb_class2name(CLASS_OF(beg)));
|
||||||
if (r_lt(val, end)) return Qtrue;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (r_le(val, end)) return Qtrue;
|
|
||||||
}
|
|
||||||
return Qfalse;
|
|
||||||
}
|
}
|
||||||
args[0] = val;
|
args[0] = val;
|
||||||
args[1] = Qfalse;
|
args[1] = Qfalse;
|
||||||
@ -447,6 +470,24 @@ range_member(range, val)
|
|||||||
return args[1];
|
return args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
range_include(range, val)
|
||||||
|
VALUE range, val;
|
||||||
|
{
|
||||||
|
VALUE beg, end;
|
||||||
|
|
||||||
|
beg = rb_ivar_get(range, id_beg);
|
||||||
|
end = rb_ivar_get(range, id_end);
|
||||||
|
if (r_gt(beg, val)) return Qfalse;
|
||||||
|
if (EXCL(range)) {
|
||||||
|
if (r_lt(val, end)) return Qtrue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (r_le(val, end)) return Qtrue;
|
||||||
|
}
|
||||||
|
return Qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_Range()
|
Init_Range()
|
||||||
{
|
{
|
||||||
@ -463,6 +504,8 @@ Init_Range()
|
|||||||
rb_define_method(rb_cRange, "last", range_last, 0);
|
rb_define_method(rb_cRange, "last", range_last, 0);
|
||||||
rb_define_method(rb_cRange, "begin", range_first, 0);
|
rb_define_method(rb_cRange, "begin", range_first, 0);
|
||||||
rb_define_method(rb_cRange, "end", range_last, 0);
|
rb_define_method(rb_cRange, "end", range_last, 0);
|
||||||
|
rb_define_method(rb_cRange, "min", range_min, 0);
|
||||||
|
rb_define_method(rb_cRange, "max", range_max, 0);
|
||||||
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
|
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
|
||||||
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
|
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
|
||||||
rb_define_alias(rb_cRange, "to_ary", "to_a");
|
rb_define_alias(rb_cRange, "to_ary", "to_a");
|
||||||
@ -470,7 +513,7 @@ Init_Range()
|
|||||||
rb_define_method(rb_cRange, "exclude_end?", range_exclude_end_p, 0);
|
rb_define_method(rb_cRange, "exclude_end?", range_exclude_end_p, 0);
|
||||||
|
|
||||||
rb_define_method(rb_cRange, "member?", range_member, 1);
|
rb_define_method(rb_cRange, "member?", range_member, 1);
|
||||||
rb_define_method(rb_cRange, "include?", range_member, 1);
|
rb_define_method(rb_cRange, "include?", range_include, 1);
|
||||||
|
|
||||||
id_cmp = rb_intern("<=>");
|
id_cmp = rb_intern("<=>");
|
||||||
id_succ = rb_intern("succ");
|
id_succ = rb_intern("succ");
|
||||||
|
@ -51,7 +51,7 @@ end
|
|||||||
|
|
||||||
def getPosition(z)
|
def getPosition(z)
|
||||||
pi = Math::PI
|
pi = Math::PI
|
||||||
z = Integer(z)
|
z = Integer(z)
|
||||||
phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
|
phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
|
||||||
emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i
|
emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i
|
||||||
geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i
|
geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i
|
||||||
@ -59,7 +59,7 @@ def getPosition(z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parsedate(s)
|
def parsedate(s)
|
||||||
ParseDate::parsedate(s).indexes(0, 1, 2)
|
ParseDate::parsedate(s).select(0, 1, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def name_of_week(date)
|
def name_of_week(date)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user