Skip to content

Commit 5484f8f

Browse files
committed
New upstream version 2.6.7
1 parent a5385a0 commit 5484f8f

File tree

114 files changed

+7368
-4443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+7368
-4443
lines changed

ChangeLog

Lines changed: 801 additions & 2 deletions
Large diffs are not rendered by default.

ast.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,10 @@ node_children(rb_ast_t *ast, NODE *node)
443443
NEW_CHILD(ast, node->nd_args->nd_head),
444444
NEW_CHILD(ast, node->nd_args->nd_body));
445445
case NODE_OP_ASGN2:
446-
return rb_ary_new_from_args(4, NEW_CHILD(ast, node->nd_recv),
446+
return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv),
447447
node->nd_next->nd_aid ? Qtrue : Qfalse,
448448
ID2SYM(node->nd_next->nd_vid),
449+
ID2SYM(node->nd_next->nd_mid),
449450
NEW_CHILD(ast, node->nd_value));
450451
case NODE_OP_ASGN_AND:
451452
return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idANDOP),

bignum.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
bignum.c -
44
5-
$Author: nobu $
5+
$Author: usa $
66
created at: Fri Jun 10 00:48:55 JST 1994
77
88
Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -6875,7 +6875,15 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
68756875
rshift /= 2;
68766876
rshift += (2-(len&1))*BITSPERDIG/2;
68776877
if (rshift >= 0) {
6878-
d <<= rshift;
6878+
if (nlz((BDIGIT)d) + rshift >= BITSPERDIG) {
6879+
/* (d << rshift) does cause overflow.
6880+
* example: Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)
6881+
*/
6882+
d = ~(BDIGIT_DBL)0;
6883+
}
6884+
else {
6885+
d <<= rshift;
6886+
}
68796887
}
68806888
BDIGITS_ZERO(xds, xn-2);
68816889
bdigitdbl2bary(&xds[xn-2], 2, d);

class.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
class.c -
44
5-
$Author: naruse $
5+
$Author: usa $
66
created at: Tue Aug 10 15:05:44 JST 1993
77
88
Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -32,6 +32,9 @@
3232

3333
#define id_attached id__attached__
3434

35+
#define METACLASS_OF(k) RBASIC(k)->klass
36+
#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
37+
3538
void
3639
rb_class_subclass_add(VALUE super, VALUE klass)
3740
{
@@ -367,22 +370,35 @@ rb_singleton_class_clone(VALUE obj)
367370
return rb_singleton_class_clone_and_attach(obj, Qundef);
368371
}
369372

373+
// Clone and return the singleton class of `obj` if it has been created and is attached to `obj`.
370374
VALUE
371375
rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
372376
{
373377
const VALUE klass = RBASIC(obj)->klass;
374378

375-
if (!FL_TEST(klass, FL_SINGLETON))
376-
return klass;
379+
// Note that `rb_singleton_class()` can create situations where `klass` is
380+
// attached to an object other than `obj`. In which case `obj` does not have
381+
// a material singleton class attached yet and there is no singleton class
382+
// to clone.
383+
if (!(FL_TEST(klass, FL_SINGLETON) && rb_attr_get(klass, id_attached) == obj)) {
384+
// nothing to clone
385+
return klass;
386+
}
377387
else {
378388
/* copy singleton(unnamed) class */
389+
bool klass_of_clone_is_new;
379390
VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
380391

381392
if (BUILTIN_TYPE(obj) == T_CLASS) {
393+
klass_of_clone_is_new = true;
382394
RBASIC_SET_CLASS(clone, clone);
383395
}
384396
else {
385-
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(klass));
397+
VALUE klass_metaclass_clone = rb_singleton_class_clone(klass);
398+
// When `METACLASS_OF(klass) == klass_metaclass_clone`, it means the
399+
// recursive call did not clone `METACLASS_OF(klass)`.
400+
klass_of_clone_is_new = (METACLASS_OF(klass) != klass_metaclass_clone);
401+
RBASIC_SET_CLASS(clone, klass_metaclass_clone);
386402
}
387403

388404
RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass));
@@ -406,7 +422,9 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
406422
arg.new_klass = clone;
407423
rb_id_table_foreach(RCLASS_M_TBL(klass), clone_method_i, &arg);
408424
}
409-
rb_singleton_class_attached(RBASIC(clone)->klass, clone);
425+
if (klass_of_clone_is_new) {
426+
rb_singleton_class_attached(RBASIC(clone)->klass, clone);
427+
}
410428
FL_SET(clone, FL_SINGLETON);
411429

412430
return clone;
@@ -428,11 +446,6 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
428446
}
429447
}
430448

431-
432-
433-
#define METACLASS_OF(k) RBASIC(k)->klass
434-
#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
435-
436449
/*!
437450
* whether k is a meta^(n)-class of Class class
438451
* @retval 1 if \a k is a meta^(n)-class of Class class (n >= 0)

common.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ PHONY:
845845
{$(srcdir)}.y.c:
846846
$(ECHO) generating $@
847847
$(Q)$(BASERUBY) $(srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(SRC_FILE) > parse.tmp.y
848+
$(Q)$(BASERUBY) $(srcdir)/tool/pure_parser.rb parse.tmp.y $(YACC)
848849
$(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y
849850
$(Q)$(RM) parse.tmp.y
850851
$(Q)sed -f $(srcdir)/tool/ytab.sed -e "/^#/s|parse\.tmp\.[iy]|$(SRC_FILE)|" -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
@@ -2985,6 +2986,7 @@ transcode.$(OBJEXT): $(top_srcdir)/include/ruby.h
29852986
transcode.$(OBJEXT): {$(VPATH)}config.h
29862987
transcode.$(OBJEXT): {$(VPATH)}defines.h
29872988
transcode.$(OBJEXT): {$(VPATH)}encoding.h
2989+
transcode.$(OBJEXT): {$(VPATH)}id.h
29882990
transcode.$(OBJEXT): {$(VPATH)}intern.h
29892991
transcode.$(OBJEXT): {$(VPATH)}internal.h
29902992
transcode.$(OBJEXT): {$(VPATH)}io.h

0 commit comments

Comments
 (0)