Skip to content

Commit

Permalink
* eval.c (rb_mod_define_method): should save safe_level in the
Browse files Browse the repository at this point in the history
  proc object.  [ruby-dev:28146]

* test/drb/drbtest.rb (DRbService::self.ext_service): increase
  timeout limit.  a patch from Kazuhiro NISHIYAMA
  <zn at mbf.nifty.com>. [ruby-dev:28132]

* eval.c (ev_const_get): fixed a bug in constant reference during
  instance_eval.  [yarv-dev:707]

* eval.c (ev_const_defined): ditto.

* lib/yaml.rb (YAML::add_domain_type): typo fixed.  a patch from
  Joel VanderWerf <vjoel at path.berkeley.edu>.
  [ruby-talk:165285] [ruby-core:6995]

* ext/digest/sha2/sha2.c (ULL): support AIX C.  a patch from
  Kailden <kailden at gmail.com>.  [ruby-core:06984]

* ext/syck/rubyext.c (rb_syck_compile): avoid potential memory
  leak.

* ext/syck/rubyext.c (syck_set_ivars): avoid potential memory
  leak by explicit symbol allocation.

* lib/delegate.rb (Delegator::method_missing): should delegate
  block as well.

* lib/cgi.rb (CGI::QueryExtension::MorphingBody): fix criteria to
  use Tempfile.  A fix from Zev Blut <rubyzbibd at ubit.com>.
  [ruby-core:06076]

* string.c: remove global functions work on $_.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 29, 2005
1 parent e5226ea commit de3bff1
Show file tree
Hide file tree
Showing 13 changed files with 338 additions and 366 deletions.
48 changes: 48 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Thu Dec 29 17:02:07 2005 Tanaka Akira <[email protected]>
* test/ruby/envutil.rb (EnvUtil.rubybin): search "ruby" instead of
"miniruby". [ruby-dev:28140]

Thu Dec 29 14:35:10 2005 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_mod_define_method): should save safe_level in the
proc object. [ruby-dev:28146]

Thu Dec 29 11:22:34 2005 Hirokazu Yamamoto <[email protected]>

* lib/generator.rb: reimplemented Generator class with Thread instead of
Expand All @@ -23,6 +28,12 @@ Tue Dec 27 23:59:53 2005 Nobuyoshi Nakada <[email protected]>

* lib/optparse.rb (CompletingHash#match): fix for 1.9.

Tue Dec 27 16:59:52 2005 Yukihiro Matsumoto <[email protected]>

* test/drb/drbtest.rb (DRbService::self.ext_service): increase
timeout limit. a patch from Kazuhiro NISHIYAMA
<zn at mbf.nifty.com>. [ruby-dev:28132]

Tue Dec 27 14:17:55 2005 Tanaka Akira <[email protected]>

* configure.in: define IA64 for portability. (HP aC++/ANSI C doesn't
Expand Down Expand Up @@ -74,6 +85,22 @@ Tue Dec 27 08:22:15 2005 GOTOU Yuuzou <[email protected]>
* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLSocket#post_connection_chech):
treat wildcard character in commonName. [ruby-dev:28121]

Mon Dec 26 08:50:36 2005 Yukihiro Matsumoto <[email protected]>

* eval.c (ev_const_get): fixed a bug in constant reference during
instance_eval. [yarv-dev:707]

* eval.c (ev_const_defined): ditto.

* lib/yaml.rb (YAML::add_domain_type): typo fixed. a patch from
Joel VanderWerf <vjoel at path.berkeley.edu>.
[ruby-talk:165285] [ruby-core:6995]

Fri Dec 23 10:30:23 2005 Yukihiro Matsumoto <[email protected]>

* ext/digest/sha2/sha2.c (ULL): support AIX C. a patch from
Kailden <kailden at gmail.com>. [ruby-core:06984]

Wed Dec 21 16:47:35 2005 Hirokazu Yamamoto <[email protected]>

* file.c (w32_io_info): should return handle because FileIndex is
Expand Down Expand Up @@ -179,6 +206,14 @@ Sat Dec 17 21:50:41 2005 Hirokazu Yamamoto <[email protected]>
* ext/syck/rubyext.c (syck_mark_parser): should mark anchor nodes
because they hold ruby objects. (ie: rb_syck_bad_anchor_handler)

Sat Dec 17 11:00:17 2005 Yukihiro Matsumoto <[email protected]>

* ext/syck/rubyext.c (rb_syck_compile): avoid potential memory
leak.

* ext/syck/rubyext.c (syck_set_ivars): avoid potential memory
leak by explicit symbol allocation.

Sat Dec 17 03:57:01 2005 Tanaka Akira <[email protected]>

* bignum.c (rb_big_rshift): fix a GC problem on
Expand Down Expand Up @@ -206,6 +241,19 @@ Fri Dec 16 11:44:43 2005 Hirokazu Yamamoto <[email protected]>

... these fixes won't fix [ruby-dev:27839]. more work is needed.

Fri Dec 16 04:38:55 2005 Yukihiro Matsumoto <[email protected]>

* lib/delegate.rb (Delegator::method_missing): should delegate
block as well.

Thu Dec 15 19:57:12 2005 Yukihiro Matsumoto <[email protected]>

* lib/cgi.rb (CGI::QueryExtension::MorphingBody): fix criteria to
use Tempfile. A fix from Zev Blut <rubyzbibd at ubit.com>.
[ruby-core:06076]

* string.c: remove global functions work on $_.

Thu Dec 15 12:35:14 2005 Yukihiro Matsumoto <[email protected]>

* lib/tmpdir.rb: merged RDoc patch from Eric Hodel <drbrain at
Expand Down
112 changes: 106 additions & 6 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ all_i(VALUE i, VALUE *memo)
* <code>all?</code> will return <code>true</code> only if none of the
* collection members are <code>false</code> or <code>nil</code>.)
*
* %w{ ant bear cat}.all? {|word| word.length >= 3} #=> true
* %w{ ant bear cat}.all? {|word| word.length >= 4} #=> false
* [ nil, true, 99 ].all? #=> false
* %w{ant bear cat}.all? {|word| word.length >= 3} #=> true
* %w{ant bear cat}.all? {|word| word.length >= 4} #=> false
* [ nil, true, 99 ].all? #=> false
*
*/

Expand Down Expand Up @@ -617,9 +617,9 @@ any_i(VALUE i, VALUE *memo)
* of the collection members is not <code>false</code> or
* <code>nil</code>.
*
* %w{ ant bear cat}.any? {|word| word.length >= 3} #=> true
* %w{ ant bear cat}.any? {|word| word.length >= 4} #=> true
* [ nil, true, 99 ].any? #=> true
* %w{ant bear cat}.any? {|word| word.length >= 3} #=> true
* %w{ant bear cat}.any? {|word| word.length >= 4} #=> true
* [ nil, true, 99 ].any? #=> true
*
*/

Expand All @@ -632,6 +632,104 @@ enum_any(VALUE obj)
return result;
}

static VALUE
one_iter_i(VALUE i, VALUE *memo)
{
if (RTEST(rb_yield(i))) {
if (*memo == Qundef) {
*memo = Qtrue;
}
else if (*memo == Qtrue) {
*memo = Qfalse;
}
}
return Qnil;
}

static VALUE
one_i(VALUE i, VALUE *memo)
{
if (RTEST(i)) {
if (*memo == Qundef) {
*memo = Qtrue;
}
else if (*memo == Qtrue) {
*memo = Qfalse;
}
}
return Qnil;
}

/*
* call-seq:
* enum.one? [{|obj| block }] => true or false
*
* Passes each element of the collection to the given block. The method
* returns <code>true</code> if the block returns <code>true</code>
* exactly once. If the block is not given, <code>one?</code> will return
* <code>true</code> only if exactly one of the collection members are
* true.
*
* %w{ant bear cat}.one? {|word| word.length == 4} #=> true
* %w{ant bear cat}.one? {|word| word.length >= 4} #=> false
* [ nil, true, 99 ].one? #=> true
*
*/

static VALUE
enum_one(VALUE obj)
{
VALUE result = Qundef;

rb_iterate(rb_each, obj, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
if (result == Qundef) return Qfalse;
return result;
}

static VALUE
none_iter_i(VALUE i, VALUE *memo)
{
if (RTEST(rb_yield(i))) {
*memo = Qfalse;
rb_iter_break();
}
return Qnil;
}

static VALUE
none_i(VALUE i, VALUE *memo)
{
if (RTEST(i)) {
*memo = Qfalse;
rb_iter_break();
}
return Qnil;
}

/*
* call-seq:
* enum.none? [{|obj| block }] => true or false
*
* Passes each element of the collection to the given block. The method
* returns <code>true</code> if the block never returns <code>true</code>
* for all elements. If the block is not given, <code>one?</code> will return
* <code>true</code> only if any of the collection members is true.
*
* %w{ant bear cat}.one? {|word| word.length == 4} #=> true
* %w{ant bear cat}.one? {|word| word.length >= 4} #=> false
* [ nil, true, 99 ].one? #=> true
*
*/

static VALUE
enum_none(VALUE obj)
{
VALUE result = Qtrue;

rb_iterate(rb_each, obj, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
return result;
}

static VALUE
min_i(VALUE i, VALUE *memo)
{
Expand Down Expand Up @@ -998,6 +1096,8 @@ Init_Enumerable(void)
rb_define_method(rb_mEnumerable,"partition", enum_partition, 0);
rb_define_method(rb_mEnumerable,"all?", enum_all, 0);
rb_define_method(rb_mEnumerable,"any?", enum_any, 0);
rb_define_method(rb_mEnumerable,"one?", enum_one, 0);
rb_define_method(rb_mEnumerable,"none?", enum_none, 0);
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
rb_define_method(rb_mEnumerable,"min_by", enum_min_by, 0);
Expand Down
35 changes: 19 additions & 16 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ static ID init, eqq, each, aref, aset, match, missing;
static ID added, singleton_added;
static ID __id__, __send__, respond_to;

#define NOEX_TAINTED 8
#define NOEX_SAFE(n) ((n) >> 4)
#define NOEX_WITH(n, v) ((n) | (v) << 4)
#define NOEX_WITH_SAFE(n) NOEX_WITH(n, ruby_safe_level)
Expand Down Expand Up @@ -1766,12 +1765,13 @@ ev_const_defined(NODE *cref, ID id, VALUE self)
while (cbase && cbase->nd_next) {
struct RClass *klass = RCLASS(cbase->nd_clss);

if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
return Qfalse;
if (!NIL_P(klass)) {
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
return Qfalse;
}
return Qtrue;
}
return Qtrue;
}
cbase = cbase->nd_next;
}
Expand All @@ -1787,13 +1787,15 @@ ev_const_get(NODE *cref, ID id, VALUE self)
while (cbase && cbase->nd_next) {
VALUE klass = cbase->nd_clss;

if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
if (result == Qundef) {
if (!RTEST(rb_autoload_load(klass, id))) break;
continue;
if (!NIL_P(klass)) {
while (RCLASS(klass)->iv_tbl &&
st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
if (result == Qundef) {
if (!RTEST(rb_autoload_load(klass, id))) break;
continue;
}
return result;
}
return result;
}
cbase = cbase->nd_next;
}
Expand Down Expand Up @@ -8038,18 +8040,19 @@ bind_eval(int argc, VALUE *argv, VALUE bind)
#define PROC_TSHIFT (FL_USHIFT+1)
#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
#define PROC_NOSAFE FL_USER4
#define PROC_SAFE_SAVED FL_USER4

#define SAFE_LEVEL_MAX PROC_TMASK

#define proc_safe_level_p(data) (!(RBASIC(data)->flags & PROC_NOSAFE))
#define proc_safe_level_p(data) (RBASIC(data)->flags & PROC_SAFE_SAVED)

static void
proc_save_safe_level(VALUE data)
{
int safe = ruby_safe_level;
if (safe > PROC_TMAX) safe = PROC_TMAX;
FL_SET(data, (safe << PROC_TSHIFT) & PROC_TMASK);
FL_SET(data, PROC_SAFE_SAVED);
}

static int
Expand Down Expand Up @@ -8887,7 +8890,7 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
rb_raise(rb_eTypeError, "can't call unbound method; bind first");
}
if (OBJ_TAINTED(method)) {
safe = NOEX_WITH(data->safe_level, 4)|NOEX_TAINTED;
safe = NOEX_WITH(data->safe_level, 4);
}
else {
safe = data->safe_level;
Expand Down Expand Up @@ -9328,7 +9331,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
struct BLOCK *block;

body = proc_clone(body);
RBASIC(body)->flags |= PROC_NOSAFE;
proc_save_safe_level(body);
Data_Get_Struct(body, struct BLOCK, block);
block->frame.callee = id;
block->frame.this_func = id;
Expand Down
2 changes: 1 addition & 1 deletion ext/digest/sha2/sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef uint8_t sha2_byte; /* Exactly 1 byte */
typedef uint32_t sha2_word32; /* Exactly 4 bytes */
typedef uint64_t sha2_word64; /* Exactly 8 bytes */

#if defined(__GNUC__) || defined(_HPUX_SOURCE)
#if defined(__GNUC__) || defined(_HPUX_SOURCE) || defined(__IBMC__)
#define ULL(number) number##ULL
#else
#define ULL(number) (uint64_t)(number)
Expand Down
13 changes: 7 additions & 6 deletions ext/syck/rubyext.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ rb_syck_compile(self, port)
oid = syck_parse( parser );
syck_lookup_sym( parser, oid, (char **)&sav );

ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 );
bc = rb_str_new(0, strlen( sav->buffer ) + 3);
ret = RSTRING(bc)->ptr;
ret[0] = '\0';
strcat( ret, "D\n" );
strcat( ret, sav->buffer );

syck_free_parser( parser );

bc = rb_str_new2( ret ); S_FREE( ret );
rb_str_resize( bc, strlen(ret) );
if ( taint ) OBJ_TAINT( bc );
return bc;
}
Expand Down Expand Up @@ -1042,13 +1043,13 @@ syck_set_ivars( vars, obj )
{
VALUE ivname = rb_ary_entry( vars, 0 );
char *ivn;
ID ivns;
StringValue( ivname );
ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 );
ivn[0] = '@';
ivn[1] = '\0';
strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len );
rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
snprintf(ivn, RSTRING(ivname)->len + 1, "@%s", RSTRING(ivname)->ptr);
ivns = rb_intern(ivn);
S_FREE( ivn );
rb_ivar_set( obj, ivns, rb_ary_entry( vars, 1 ) );
return Qnil;
}

Expand Down
Loading

0 comments on commit de3bff1

Please sign in to comment.