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

* 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
This commit is contained in:
matz 2002-06-04 07:34:19 +00:00
parent 4cb164ee2a
commit b7bc0cae53
10 changed files with 54 additions and 33 deletions

View file

@ -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

15
eval.c
View file

@ -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;

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -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;

10
parse.y
View file

@ -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;
}

View file

@ -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;

View file

@ -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: