Skip to content

Commit 220f6fe

Browse files
committed
Merge pull request #26 from github/dbussink/ruby-2-1-6
Update to Ruby 2.1.6
2 parents 71c83aa + b432a4f commit 220f6fe

Some content is hidden

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

77 files changed

+4879
-251
lines changed

ChangeLog

Lines changed: 395 additions & 1 deletion
Large diffs are not rendered by default.

class.c

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,6 @@ rb_class_new(VALUE super)
233233
return rb_class_boot(super);
234234
}
235235

236-
static void
237-
rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr)
238-
{
239-
NODE *new_node;
240-
while (node) {
241-
if (node->nd_clss == old_klass) {
242-
new_node = NEW_CREF(new_klass);
243-
RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next);
244-
*new_cref_ptr = new_node;
245-
return;
246-
}
247-
new_node = NEW_CREF(node->nd_clss);
248-
node = node->nd_next;
249-
*new_cref_ptr = new_node;
250-
new_cref_ptr = &new_node->nd_next;
251-
}
252-
*new_cref_ptr = NULL;
253-
}
254-
255236
static void
256237
clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
257238
{
@@ -261,7 +242,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
261242
NODE *new_cref;
262243
newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass);
263244
GetISeqPtr(newiseqval, iseq);
264-
rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref);
245+
rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref);
265246
RB_OBJ_WRITE(iseq->self, &iseq->cref_stack, new_cref);
266247
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag);
267248
RB_GC_GUARD(newiseqval);
@@ -957,7 +938,7 @@ rb_prepend_module(VALUE klass, VALUE module)
957938
OBJ_WB_UNPROTECT(origin); /* TODO: conservertive shading. Need more survery. */
958939
RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass));
959940
RCLASS_SET_SUPER(klass, origin);
960-
RCLASS_ORIGIN(klass) = origin;
941+
RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
961942
RCLASS_M_TBL_WRAPPER(origin) = RCLASS_M_TBL_WRAPPER(klass);
962943
RCLASS_M_TBL_INIT(klass);
963944
st_foreach(RCLASS_M_TBL(origin), move_refined_method,
@@ -1118,25 +1099,32 @@ ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary)
11181099
return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PUBLIC);
11191100
}
11201101

1102+
struct method_entry_arg {
1103+
st_table *list;
1104+
int recur;
1105+
};
1106+
11211107
static int
11221108
method_entry_i(st_data_t key, st_data_t value, st_data_t data)
11231109
{
11241110
const rb_method_entry_t *me = (const rb_method_entry_t *)value;
1125-
st_table *list = (st_table *)data;
1111+
struct method_entry_arg *arg = (struct method_entry_arg *)data;
11261112
long type;
11271113

11281114
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
1115+
VALUE klass = me->klass;
11291116
me = rb_resolve_refined_method(Qnil, me, NULL);
11301117
if (!me) return ST_CONTINUE;
1118+
if (!arg->recur && me->klass != klass) return ST_CONTINUE;
11311119
}
1132-
if (!st_lookup(list, key, 0)) {
1120+
if (!st_lookup(arg->list, key, 0)) {
11331121
if (UNDEFINED_METHOD_ENTRY_P(me)) {
11341122
type = -1; /* none */
11351123
}
11361124
else {
11371125
type = VISI(me->flag);
11381126
}
1139-
st_add_direct(list, key, type);
1127+
st_add_direct(arg->list, key, type);
11401128
}
11411129
return ST_CONTINUE;
11421130
}
@@ -1146,7 +1134,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func
11461134
{
11471135
VALUE ary;
11481136
int recur, prepended = 0;
1149-
st_table *list;
1137+
struct method_entry_arg me_arg;
11501138

11511139
if (argc == 0) {
11521140
recur = TRUE;
@@ -1162,16 +1150,17 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func
11621150
prepended = 1;
11631151
}
11641152

1165-
list = st_init_numtable();
1153+
me_arg.list = st_init_numtable();
1154+
me_arg.recur = recur;
11661155
for (; mod; mod = RCLASS_SUPER(mod)) {
1167-
if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list);
1156+
if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)&me_arg);
11681157
if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue;
11691158
if (obj && FL_TEST(mod, FL_SINGLETON)) continue;
11701159
if (!recur) break;
11711160
}
11721161
ary = rb_ary_new();
1173-
st_foreach(list, func, ary);
1174-
st_free_table(list);
1162+
st_foreach(me_arg.list, func, ary);
1163+
st_free_table(me_arg.list);
11751164

11761165
return ary;
11771166
}
@@ -1393,7 +1382,8 @@ VALUE
13931382
rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
13941383
{
13951384
VALUE recur, ary, klass, origin;
1396-
st_table *list, *mtbl;
1385+
struct method_entry_arg me_arg;
1386+
st_table *mtbl;
13971387

13981388
if (argc == 0) {
13991389
recur = Qtrue;
@@ -1403,22 +1393,23 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
14031393
}
14041394
klass = CLASS_OF(obj);
14051395
origin = RCLASS_ORIGIN(klass);
1406-
list = st_init_numtable();
1396+
me_arg.list = st_init_numtable();
1397+
me_arg.recur = recur;
14071398
if (klass && FL_TEST(klass, FL_SINGLETON)) {
14081399
if ((mtbl = RCLASS_M_TBL(origin)) != 0)
1409-
st_foreach(mtbl, method_entry_i, (st_data_t)list);
1400+
st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg);
14101401
klass = RCLASS_SUPER(klass);
14111402
}
14121403
if (RTEST(recur)) {
14131404
while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
14141405
if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0)
1415-
st_foreach(mtbl, method_entry_i, (st_data_t)list);
1406+
st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg);
14161407
klass = RCLASS_SUPER(klass);
14171408
}
14181409
}
14191410
ary = rb_ary_new();
1420-
st_foreach(list, ins_methods_i, ary);
1421-
st_free_table(list);
1411+
st_foreach(me_arg.list, ins_methods_i, ary);
1412+
st_free_table(me_arg.list);
14221413

14231414
return ary;
14241415
}

common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUBYLIB = $(PATH_SEPARATOR)
1414
RUBYOPT = -
1515
RUN_OPTS = --disable-gems
1616

17-
SPEC_GIT_BASE = git://github.com/nurse
17+
SPEC_GIT_BASE = git://github.com/ruby
1818
MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git
1919
RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git
2020

complex.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y)
433433
*
434434
* Complex(1, 2) #=> (1+2i)
435435
* Complex('1+2i') #=> (1+2i)
436+
* Complex(nil) #=> TypeError
437+
* Complex(1, nil) #=> TypeError
436438
*
437439
* Syntax of string form:
438440
*

configure.in

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,13 @@ if test "$GCC" = yes; then
816816
],
817817
[
818818
# ANSI (no XCFLAGS because this is C only)
819-
RUBY_TRY_CFLAGS(-ansi -std=iso9899:199409, [
820-
RUBY_APPEND_OPTION(warnflags, -ansi -std=iso9899:199409)
821-
RUBY_APPEND_OPTION(strict_warnflags, -ansi -std=iso9899:199409)
822-
])
819+
for ansi_options in -std=iso9899:1999 "-ansi -std=iso9899:199409"; do
820+
RUBY_TRY_CFLAGS(${ansi_options}, [
821+
RUBY_APPEND_OPTIONS(warnflags, ${ansi_options})
822+
RUBY_APPEND_OPTIONS(strict_warnflags, ${ansi_options})
823+
], [ansi_options=])
824+
test "x${ansi_options}" = x || break
825+
done
823826
])
824827

825828
# suppress annoying -Wstrict-overflow warnings
@@ -1054,8 +1057,8 @@ main()
10541057
ac_cv_func_malloc_usable_size=no
10551058
{ test "$target_cpu" = x64 && ac_cv_func___builtin_setjmp=no; }
10561059
AC_CHECK_TYPE([NET_LUID], [], [],
1057-
[@%:@include <windows.h>
1058-
@%:@include <iphlpapi.h>])
1060+
[@%:@include <winsock2.h>
1061+
@%:@include <iphlpapi.h>])
10591062
if test x"$ac_cv_type_NET_LUID" = xyes; then
10601063
AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
10611064
fi
@@ -2075,7 +2078,7 @@ if test ${setjmp_prefix+set}; then
20752078
if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp${setjmp_suffix} = no; then
20762079
AC_MSG_ERROR(${setjmp_prefix}setjmp${setjmp_suffix} is not available)
20772080
fi
2078-
elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]); }; then
2081+
elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]) }; then
20792082
setjmp_cast=`expr "$ac_cv_func___builtin_setjmp" : "yes with cast (\(.*\))"`
20802083
setjmp_prefix=__builtin_
20812084
setjmp_suffix=
@@ -2617,8 +2620,8 @@ AC_ARG_WITH(dln-a-out,
26172620

26182621
AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
26192622
[AC_TRY_LINK([],[], [
2620-
AS_CASE(["`head -1 conftest$EXEEXT | cat -e`"],
2621-
['^?ELF'*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])],
2623+
AS_CASE(["`head -1 conftest$EXEEXT | tr -dc '\177ELF' | tr '\177' .`"],
2624+
[.ELF*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])],
26222625
rb_cv_binary_elf=no)])
26232626

26242627
if test "$rb_cv_binary_elf" = yes; then
@@ -2699,7 +2702,7 @@ if test "$with_dln_a_out" != yes; then
26992702
RPATHFLAG=' +b %1$-s'
27002703
fi
27012704
rb_cv_dlopen=yes],
2702-
[solaris*], [ if test "$GCC" = yes; then
2705+
[solaris*], [ if test "$GCC" = yes; then
27032706
: ${LDSHARED='$(CC) -shared'}
27042707
if test "$rb_cv_prog_gnu_ld" = yes; then
27052708
LDFLAGS="$LDFLAGS -Wl,-E"
@@ -2818,7 +2821,7 @@ if test "$with_dln_a_out" != yes; then
28182821
[os2-emx*], [ LDFLAGS="$LDFLAGS -Zomf"
28192822
],
28202823
[nacl], [ LDSHARED='$(CC) -shared' ],
2821-
[ : ${LDSHARED='$(LD)'}])
2824+
[ : ${LDSHARED='$(LD)'}])
28222825
AC_MSG_RESULT($rb_cv_dlopen)
28232826
fi
28242827
if test "${LDSHAREDXX}" = ""; then

eval.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,19 @@ prev_frame_func(void)
978978
return frame_func_id(prev_cfp);
979979
}
980980

981+
ID
982+
rb_frame_last_func(void)
983+
{
984+
rb_thread_t *th = GET_THREAD();
985+
rb_control_frame_t *cfp = th->cfp;
986+
ID mid;
987+
988+
while (!(mid = frame_func_id(cfp)) &&
989+
(cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp),
990+
!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)));
991+
return mid;
992+
}
993+
981994
/*
982995
* call-seq:
983996
* append_features(mod) -> mod

ext/etc/etc.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,15 @@ etc_getlogin(VALUE obj)
6767
login = getenv("USER");
6868
#endif
6969

70-
if (login)
71-
return rb_tainted_str_new2(login);
70+
if (login) {
71+
#ifdef _WIN32
72+
rb_encoding *extenc = rb_utf8_encoding();
73+
#else
74+
rb_encoding *extenc = rb_locale_encoding();
75+
#endif
76+
return rb_external_str_new_with_enc(login, strlen(login), extenc);
77+
}
78+
7279
return Qnil;
7380
}
7481

ext/io/console/console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ console_dev(VALUE klass)
689689
if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1)
690690
return con;
691691
}
692-
rb_mod_remove_const(klass, ID2SYM(id_console));
692+
rb_const_remove(klass, id_console);
693693
}
694694
{
695695
VALUE args[2];

ext/io/console/io-console.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- ruby -*-
2-
_VERSION = "0.4.2"
2+
_VERSION = "0.4.3"
33
date = %w$Date:: $[1]
44

55
Gem::Specification.new do |s|

ext/io/wait/wait.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ io_nread(VALUE io)
6262
GetOpenFile(io, fptr);
6363
rb_io_check_readable(fptr);
6464
len = rb_io_read_pending(fptr);
65-
if (len > 0) return len;
65+
if (len > 0) return INT2FIX(len);
6666
if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
6767
if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
6868
if (n > 0) return ioctl_arg2num(n);

0 commit comments

Comments
 (0)