summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-04 07:34:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-04 07:34:19 +0000
commitb7bc0cae539617af4dfac5b44b0ebd700efe2084 (patch)
treea65171fc36999a1cc3c537a0b8bf62ddd9b16f77
parent4cb164ee2a30ecb59ce93670e569f384c7da7521 (diff)
* string.c (rb_str_aset): should raise error if an indexing string
is not found in the receiver. * sprintf.c (rb_f_sprintf): "%d" should convert objects into integers using Integer(). * lib/tempfile.rb (Tempfile::size): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--eval.c15
-rw-r--r--ext/socket/extconf.rb5
-rw-r--r--ext/socket/socket.c4
-rw-r--r--lib/singleton.rb12
-rw-r--r--lib/tempfile.rb9
-rw-r--r--numeric.c11
-rw-r--r--parse.y10
-rw-r--r--sprintf.c4
-rw-r--r--string.c5
10 files changed, 54 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 16048a5..8791996 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,10 +23,22 @@ Mon Jun 3 07:07:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* parse.y (yylex): should pushback proper char after '**'.
(ruby-bugs-ja:PR#240)
+Mon Jun 3 05:56:17 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_aset): should raise error if an indexing string
+ is not found in the receiver.
+
+ * sprintf.c (rb_f_sprintf): "%d" should convert objects into
+ integers using Integer().
+
Sat Jun 1 19:20:07 2002 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole: merge from rough.
+Fri May 31 17:11:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/tempfile.rb (Tempfile::size): added.
+
Thu May 30 12:52:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_step): iteration done using "+" if elements are
diff --git a/eval.c b/eval.c
index 64a0ffc..9de3d37 100644
--- a/eval.c
+++ b/eval.c
@@ -840,7 +840,6 @@ static NODE *top_cref;
#define PUSH_CREF(c) ruby_cref = rb_node_newnode(NODE_CREF,(c),0,ruby_cref)
#define POP_CREF() ruby_cref = ruby_cref->nd_next
-#define scope_node super.klass
#define PUSH_SCOPE() do { \
volatile int _vmode = scope_vmode; \
struct SCOPE * volatile _old; \
@@ -2784,7 +2783,6 @@ rb_eval(self, n)
ruby_cref = (NODE*)node->nd_rval;
ruby_frame->cbase = node->nd_rval;
}
- ruby_scope->scope_node = (VALUE)node;
if (node->nd_tbl) {
VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1);
*vars++ = (VALUE)node;
@@ -3064,6 +3062,7 @@ rb_eval(self, n)
NODE *list = node->nd_next;
str = rb_str_new3(node->nd_lit);
+ if (!ruby_dyna_vars) rb_dvar_push(0, 0);
while (list) {
if (list->nd_head) {
switch (nd_type(list->nd_head)) {
@@ -3075,18 +3074,9 @@ rb_eval(self, n)
ruby_errinfo = Qnil;
ruby_sourceline = nd_line(node);
ruby_in_eval++;
- rb_dvar_push(0, 0);
list->nd_head = compile(list->nd_head->nd_lit,
ruby_sourcefile,
ruby_sourceline);
- if (ruby_scope->local_tbl) {
- NODE *body = (NODE *)ruby_scope->scope_node;
- if (body && body->nd_tbl != ruby_scope->local_tbl) {
- if (body->nd_tbl) free(body->nd_tbl);
- ruby_scope->local_vars[-1] =
- (VALUE)(body->nd_tbl = ruby_scope->local_tbl);
- }
- }
ruby_eval_tree = 0;
ruby_in_eval--;
if (ruby_nerrs > 0) {
@@ -3424,7 +3414,6 @@ module_setup(module, n)
PUSH_SCOPE();
PUSH_VARS();
- ruby_scope->scope_node = (VALUE)node;
if (node->nd_tbl) {
VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
*vars++ = (VALUE)node;
@@ -4564,7 +4553,6 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
ruby_cref = (NODE*)body->nd_rval;
ruby_frame->cbase = body->nd_rval;
}
- ruby_scope->scope_node = (VALUE)body;
if (body->nd_tbl) {
local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
*local_vars++ = (VALUE)body;
@@ -5031,6 +5019,7 @@ eval(self, src, scope, file, line)
if (ruby_frame->prev) {
ruby_frame->iter = ruby_frame->prev->iter;
}
+ if (!ruby_dyna_vars) rb_dvar_push(0, 0);
}
if (file == 0) {
file = ruby_sourcefile;
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index c288408..11639c0 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -62,7 +62,7 @@ else
end
$ipv6 = false
-if enable_config("ipv6", false)
+if enable_config("ipv6", true)
if try_link(<<EOF)
#include <sys/types.h>
#include <sys/socket.h>
@@ -226,7 +226,7 @@ have_struct_member('struct msghdr', 'msg_control', header=['sys/types.h', 'sys/s
have_struct_member('struct msghdr', 'msg_accrights', header=['sys/types.h', 'sys/socket.h'])
$getaddr_info_ok = false
-if not enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
+if !enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
@@ -322,6 +322,7 @@ if $ipv6 and not $getaddr_info_ok
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
you cannot compile IPv6 socket classes with broken these functions.
+You can try --enable-wide-getaddrinfo.
EOS
exit
end
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 2fcb4a5..1a27e48 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -590,7 +590,7 @@ sock_addrinfo(host, port, socktype, flags)
portp = 0;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
portp = pbuf;
}
else {
@@ -678,7 +678,7 @@ ipaddr(sockaddr)
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));
+ rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
addr2 = rb_tainted_str_new2(hbuf);
if (do_not_reverse_lookup) {
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 6ff6d19..5839458 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -65,7 +65,7 @@ module Singleton
# This catches ill advisted inclusions of Singleton in
# singletons types (sounds like an oxymoron) and
# helps out people counting on transitive mixins
- unless mod.instance_of? (Class)
+ unless mod.instance_of?(Class)
raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
end
unless (class << mod; self end) <= (class << Object; self end)
@@ -73,7 +73,7 @@ module Singleton
end
super
end
- def included (klass)
+ def included(klass)
# remove build in copying methods
klass.class_eval do
define_method(:clone) {raise TypeError, "can't clone singleton #{self.type}"}
@@ -87,7 +87,7 @@ module Singleton
private :new, :allocate
# declare the self modifying klass#instance method
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
# simple waiting loop hook - should do in most cases
# note the pre/post-conditions of a thread-critical state
@@ -109,7 +109,7 @@ module Singleton
super
sub_klass.instance_eval do @__instance__ = nil end
class << sub_klass
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
end
end
@@ -120,7 +120,7 @@ module Singleton
res = super
res.instance_eval do @__instance__ = nil end
class << res
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
end
res
end
@@ -215,7 +215,7 @@ class Ups < SomeSingletonClass
@__instance__
end
def __sleep
- sleep (rand(0.08))
+ sleep(rand(0.08))
end
def allocate
__sleep
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index a0c7f4c..fd03b2c 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -85,6 +85,15 @@ class Tempfile < SimpleDelegator
def path
@tmpname
end
+
+ def size
+ if @tmpfile
+ @tmpfile.flush
+ @tmpfile.stat.size
+ else
+ 0
+ end
+ end
end
if __FILE__ == $0
diff --git a/numeric.c b/numeric.c
index 2b9d6f5..accd581 100644
--- a/numeric.c
+++ b/numeric.c
@@ -640,7 +640,8 @@ flo_zero_p(num)
return Qfalse;
}
-static VALUE flo_is_nan_p(num)
+static VALUE
+flo_is_nan_p(num)
VALUE num;
{
@@ -649,19 +650,21 @@ static VALUE flo_is_nan_p(num)
return isnan(value) ? Qtrue : Qfalse;
}
-static VALUE flo_is_infinite_p(num)
+static VALUE
+flo_is_infinite_p(num)
VALUE num;
{
double value = RFLOAT(num)->value;
if (isinf(value)) {
- return INT2FIX( value < 0 ? -1 : +1 );
+ return INT2FIX( value < 0 ? -1 : 1 );
}
return Qnil;
}
-static VALUE flo_is_finite_p(num)
+static VALUE
+flo_is_finite_p(num)
VALUE num;
{
double value = RFLOAT(num)->value;
diff --git a/parse.y b/parse.y
index e43f3fe..c51e9ed 100644
--- a/parse.y
+++ b/parse.y
@@ -281,7 +281,6 @@ static void top_local_setup();
%%
program : {
- $<vars>$ = ruby_dyna_vars;
lex_state = EXPR_BEG;
top_local_init();
if ((VALUE)ruby_class == rb_cObject) class_nest = 0;
@@ -303,7 +302,6 @@ program : {
ruby_eval_tree = block_append(ruby_eval_tree, $2);
top_local_setup();
class_nest = 0;
- ruby_dyna_vars = $<vars>1;
}
;
@@ -2170,6 +2168,7 @@ yycompile(f, line)
{
int n;
NODE *node = 0;
+ struct RVarmap *vp, *vars = ruby_dyna_vars;
if (!compile_for_eval && rb_safe_level() == 0 &&
rb_const_defined(rb_cObject, rb_intern("SCRIPT_LINES__"))) {
@@ -2210,6 +2209,13 @@ yycompile(f, line)
in_def = 0;
cur_mid = 0;
+ vp = ruby_dyna_vars;
+ ruby_dyna_vars = vars;
+ while (vp && vp != vars) {
+ struct RVarmap *tmp = vp;
+ vp = vp->next;
+ rb_gc_force_recycle((VALUE)tmp);
+ }
if (n == 0) node = ruby_eval_tree;
return node;
}
diff --git a/sprintf.c b/sprintf.c
index 5f0aeba..bceaf17 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -349,8 +349,8 @@ rb_f_sprintf(argc, argv)
v = FIX2LONG(val);
break;
default:
- v = NUM2LONG(val);
- break;
+ val = rb_Integer(val);
+ goto bin_retry;
}
if (*p == 'u' || *p == 'd' || *p == 'i') base = 10;
diff --git a/string.c b/string.c
index f3c3097..8abce20 100644
--- a/string.c
+++ b/string.c
@@ -1307,9 +1307,10 @@ rb_str_aset(str, indx, val)
case T_STRING:
beg = rb_str_index(str, indx, 0);
- if (beg != -1) {
- rb_str_update(str, beg, RSTRING(indx)->len, val);
+ if (beg < 0) {
+ rb_raise(rb_eIndexError, "string not matched");
}
+ rb_str_update(str, beg, RSTRING(indx)->len, val);
return val;
default: