Skip to content

Commit fdfcfc5

Browse files
committed
Merge tag 'upstream/2.2.7' into master-2.2
Upstream version 2.2.7
2 parents 8fc361d + ad2bcfc commit fdfcfc5

Some content is hidden

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

78 files changed

+2142
-671
lines changed

ChangeLog

Lines changed: 632 additions & 0 deletions
Large diffs are not rendered by default.

README.EXT

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,10 +1314,9 @@ int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optiona
13141314
+optional+ is negative) number of IDs are optional. If a
13151315
mandatory key is not contained in +keyword_hash+, raises "missing
13161316
keyword" +ArgumentError+. If an optional key is not present in
1317-
+keyword_hash+, the corresponding element in +values+ is not changed.
1318-
If +optional+ is negative, rest of +keyword_hash+ are stored in the
1319-
next to optional +values+ as a new Hash, otherwise raises "unknown
1320-
keyword" +ArgumentError+.
1317+
+keyword_hash+, the corresponding element in +values+ is set to +Qundef+.
1318+
If +optional+ is negative, rest of +keyword_hash+ are ignored, otherwise
1319+
raises "unknown keyword" +ArgumentError+.
13211320

13221321
VALUE rb_extract_keywords(VALUE *original_hash)
13231322

README.EXT.ja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,10 +1315,10 @@ int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optiona
13151315
optional (optionalが負の場合は-optional-1) 個のIDは省略可能
13161316
キーワードです.必須キーワードがkeyword_hash中にない場合,
13171317
"missing keyword"ArgumentErrorが発生します.省略可能キーワー
1318-
ドがない場合は,values中の対応する要素は変更されません.
1319-
keyword_hashに使用されない要素がある場合は,optionalが負なら
1320-
新しいHashとして省略可能引数の次に保存されますが,そうでなけ
1321-
れば"unknown keyword"ArgumentErrorが発生します.
1318+
ドがない場合は,values中の対応する要素にはQundefがセットされ
1319+
ます.keyword_hashに使用されない要素がある場合は,optionalが
1320+
負なら無視されますが,そうでなければ"unknown keyword"
1321+
ArgumentErrorが発生します.
13221322

13231323
VALUE rb_extract_keywords(VALUE *original_hash)
13241324

array.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4985,7 +4985,7 @@ rb_ary_combination(VALUE ary, VALUE num)
49854985
rb_yield(rb_ary_new2(0));
49864986
}
49874987
else if (n == 1) {
4988-
for (i = 0; i < len; i++) {
4988+
for (i = 0; i < RARRAY_LEN(ary); i++) {
49894989
rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i)));
49904990
}
49914991
}
@@ -5184,7 +5184,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num)
51845184
rb_yield(rb_ary_new2(0));
51855185
}
51865186
else if (n == 1) {
5187-
for (i = 0; i < len; i++) {
5187+
for (i = 0; i < RARRAY_LEN(ary); i++) {
51885188
rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i)));
51895189
}
51905190
}
@@ -5486,7 +5486,8 @@ rb_ary_any_p(VALUE ary)
54865486
* This method is safe to use with mutable objects such as hashes, strings or
54875487
* other arrays:
54885488
*
5489-
* Array.new(4) { Hash.new } #=> [{}, {}, {}, {}]
5489+
* Array.new(4) { Hash.new } #=> [{}, {}, {}, {}]
5490+
* Array.new(4) {|i| i.to_s } #=> ["0", "1", "2", "3"]
54905491
*
54915492
* This is also a quick way to build up multi-dimensional arrays:
54925493
*

class.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,9 @@ rb_extract_keywords(VALUE *orighash)
19141914
}
19151915
st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
19161916
*orighash = parthash[1];
1917+
if (parthash[1] && RBASIC_CLASS(hash) != rb_cHash) {
1918+
RBASIC_SET_CLASS(parthash[1], RBASIC_CLASS(hash));
1919+
}
19171920
return parthash[0];
19181921
}
19191922

@@ -1969,7 +1972,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
19691972
}
19701973
}
19711974
if (!rest && keyword_hash) {
1972-
if (RHASH_SIZE(keyword_hash) > (unsigned int)j) {
1975+
if (RHASH_SIZE(keyword_hash) > (unsigned int)(values ? 0 : j)) {
19731976
unknown_keyword_error(keyword_hash, table, required+optional);
19741977
}
19751978
}

compile.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ static void
478478
validate_labels(rb_iseq_t *iseq, st_table *labels_table)
479479
{
480480
st_foreach(labels_table, validate_label, (st_data_t)iseq);
481-
if (!NIL_P(iseq->compile_data->err_info)) {
482-
rb_exc_raise(iseq->compile_data->err_info);
483-
}
484481
}
485482

486483
VALUE
@@ -1046,6 +1043,10 @@ new_child_iseq(rb_iseq_t *iseq, NODE *node,
10461043
static int
10471044
iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
10481045
{
1046+
if (!NIL_P(iseq->compile_data->err_info)) {
1047+
return COMPILE_NG;
1048+
}
1049+
10491050
/* debugs("[compile step 2] (iseq_array_to_linkedlist)\n"); */
10501051

10511052
if (compile_debug > 5)
@@ -3267,7 +3268,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, r
32673268
switch (nd_type(argn)) {
32683269
case NODE_SPLAT: {
32693270
COMPILE(args, "args (splat)", argn->nd_head);
3270-
ADD_INSN1(args, nd_line(argn), splatarray, Qfalse);
3271+
ADD_INSN1(args, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
32713272
argc = INT2FIX(1);
32723273
nsplat++;
32733274
*flag |= VM_CALL_ARGS_SPLAT;
@@ -3281,7 +3282,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, r
32813282
INIT_ANCHOR(tmp);
32823283
COMPILE(tmp, "args (cat: splat)", argn->nd_body);
32833284
if (nd_type(argn) == NODE_ARGSCAT) {
3284-
ADD_INSN1(tmp, nd_line(argn), splatarray, Qfalse);
3285+
ADD_INSN1(tmp, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
32853286
}
32863287
else {
32873288
ADD_INSN1(tmp, nd_line(argn), newarray, INT2FIX(1));

configure.in

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ AS_CASE(["$build_os"],
255255
[xgcc-4.2|x/usr/bin/gcc-4.2], [: ${CXX=g++-4.2}],
256256
[xgcc|x/usr/bin/gcc], [: ${CXX=g++}],
257257
[xcc|x/usr/bin/cc], [: ${CXX=c++}],
258+
[xicc], [: ${CXX=icpc}],
258259
[xclang|x/usr/bin/clang], [: ${CXX=clang++}])
259260
])
260261
test -z "$CC" || ac_cv_prog_CC="$CC"
@@ -794,6 +795,7 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then
794795
extra_warning=
795796
fi
796797
for wflag in -Wno-unused-parameter -Wno-parentheses -Wno-long-long \
798+
-diag-disable=2259 \
797799
-Wno-missing-field-initializers \
798800
-Wunused-variable \
799801
-Werror=pointer-arith \
@@ -866,6 +868,33 @@ if test "$GCC" = yes; then
866868
# various headers. Most frequent situation is the use of //
867869
# comments. We bypass ANSI C mode for them. Otherwise
868870
# extension libs cannot include those headers.
871+
872+
# Since math.h in some mingw64 wrongly delcares frexp and modf
873+
# to be pure, the variables pointed by the second arguments are
874+
# considered uninitialized unexpectedly.
875+
AC_CACHE_CHECK([whether frexp and modf are broken],
876+
rb_cv_mingw64_broken_frexp_modf,
877+
[
878+
save_CFLAGS="$CFLAGS"
879+
if test "$particular_werror_flags" = "yes"; then
880+
CFLAGS="$CFLAGS -Werror=uninitialized"
881+
else
882+
CFLAGS="$CFLAGS -Werror -Wuninitialized"
883+
fi
884+
AC_TRY_COMPILE([@%:@include <math.h>
885+
int foo(double x)
886+
{
887+
int exp;
888+
frexp(x, &exp);
889+
return exp;
890+
}], [if (foo(0.0)) return 1;],
891+
[rb_cv_mingw64_broken_frexp_modf=no],
892+
[rb_cv_mingw64_broken_frexp_modf=yes])
893+
CFLAGS="$save_CFLAGS"
894+
])
895+
if test "$rb_cv_mingw64_broken_frexp_modf" = yes; then
896+
AC_DEFINE(RUBY_MINGW64_BROKEN_FREXP_MODF)
897+
fi
869898
],
870899
[cygwin*|darwin*|netbsd*|nacl], [
871900
# need lgamma_r(), finite()
@@ -921,7 +950,7 @@ if test "$GCC" = yes; then
921950
])
922951

923952
# disable fast-math
924-
for oflag in -fno-fast-math; do
953+
for oflag in -fno-fast-math -fp-model\ precise; do
925954
RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)])
926955
done
927956
fi
@@ -997,6 +1026,12 @@ AS_CASE(["$target_os"],
9971026
],
9981027
[macosx_10_5=yes], [macosx_10_5=no])
9991028
AC_MSG_RESULT($macosx_10_5)
1029+
AS_IF([test "${target_os@%:@darwin}" -ge 16], [
1030+
ac_cv_func___syscall=no
1031+
ac_cv_func_syscall=no
1032+
ac_cv_header_sys_syscall_h=no
1033+
ac_cv_header_syscall_h=no
1034+
])
10001035
if test $macosx_10_5 = yes; then
10011036
ac_cv_func_getcontext=no
10021037
ac_cv_func_setcontext=no
@@ -3544,8 +3579,8 @@ AS_CASE("$enable_shared", [yes], [
35443579
LIBRUBY_RELATIVE=yes
35453580
fi
35463581
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-install_name '${libprefix}'/$(LIBRUBY_SO)'
3547-
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-current_version $(MAJOR).$(MINOR).$(TEENY)'
3548-
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-compatibility_version $(ruby_version)'
3582+
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-compatibility_version $(MAJOR).$(MINOR)'
3583+
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-current_version $(RUBY_PROGRAM_VERSION)'
35493584
if test "$visibility_option" = ld; then
35503585
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,_Init_*'
35513586
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,*_threadptr_*'

cont.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static VALUE rb_eFiberError;
167167
if (!(ptr)) rb_raise(rb_eFiberError, "uninitialized fiber"); \
168168
} while (0)
169169

170-
NOINLINE(static VALUE cont_capture(volatile int *stat));
170+
NOINLINE(static VALUE cont_capture(volatile int *volatile stat));
171171

172172
#define THREAD_MUST_BE_RUNNING(th) do { \
173173
if (!(th)->tag) rb_raise(rb_eThreadError, "not running thread"); \
@@ -478,13 +478,9 @@ cont_new(VALUE klass)
478478
}
479479

480480
static VALUE
481-
cont_capture(volatile int *stat)
482-
#if defined(__clang__) && \
483-
__clang_major__ == 3 && __clang_minor__ == 8 && __clang_patch__ == 0
484-
__attribute__ ((optnone))
485-
#endif
481+
cont_capture(volatile int *volatile stat)
486482
{
487-
rb_context_t *cont;
483+
rb_context_t *volatile cont;
488484
rb_thread_t *th = GET_THREAD();
489485
volatile VALUE contval;
490486

dln.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,9 @@ dln_load(const char *file)
13351335
void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc");
13361336
if (ex && ex != ruby_xmalloc) {
13371337

1338-
# if defined __APPLE__
1338+
# if defined __APPLE__ && \
1339+
defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
1340+
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11)
13391341
/* dlclose() segfaults */
13401342
rb_fatal("%s - %s", incompatible, file);
13411343
# else

doc/syntax/literals.rdoc

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,33 @@ Any internal <tt>"</tt> must be escaped:
8383

8484
"This string has a quote: \". As you can see, it is escaped"
8585

86-
Double-quote strings allow escaped characters such as <tt>\n</tt> for newline,
87-
<tt>\t</tt> for tab, etc.
86+
Double-quote strings allow escaped characters such as <tt>\n</tt> for
87+
newline, <tt>\t</tt> for tab, etc. The full list of supported escape
88+
sequences are as follows:
89+
90+
\a bell, ASCII 07h (BEL)
91+
\b backspace, ASCII 08h (BS)
92+
\t horizontal tab, ASCII 09h (TAB)
93+
\n newline (line feed), ASCII 0Ah (LF)
94+
\v vertical tab, ASCII 0Bh (VT)
95+
\f form feed, ASCII 0Ch (FF)
96+
\r carriage return, ASCII 0Dh (CR)
97+
\e escape, ASCII 1Bh (ESC)
98+
\s space, ASCII 20h (SPC)
99+
\\ backslash, \
100+
\nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7])
101+
\xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
102+
\unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
103+
\u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
104+
\cx or \C-x control character, where x is an ASCII printable character
105+
\M-x meta character, where x is an ASCII printable character
106+
\M-\C-x meta control character, where x is an ASCII printable character
107+
\M-\cx same as above
108+
\c\M-x same as above
109+
\c? or \C-? delete, ASCII 7Fh (DEL)
110+
111+
Any other character following a backslash is interpreted as the
112+
character itself.
88113

89114
Double-quote strings allow interpolation of other values using
90115
<tt>#{...}</tt>:
@@ -124,6 +149,23 @@ be concatenated as long as a percent-string is not last.
124149
%q{a} 'b' "c" #=> "abc"
125150
"a" 'b' %q{c} #=> NameError: uninitialized constant q
126151

152+
One more way of writing strings is using <tt>?</tt>:
153+
154+
?a #=> "a"
155+
156+
Basically only one character can be placed after <tt>?</tt>:
157+
158+
?abc #=> SyntaxError
159+
160+
Exceptionally, <tt>\C-</tt>, <tt>\M-</tt> and their combination are allowed
161+
before a character. They mean "control", "meta" and "control-meta"
162+
respectively:
163+
164+
?\C-a #=> "\x01"
165+
?\M-a #=> "\xE1"
166+
?\M-\C-a #=> "\x81"
167+
?\C-\M-a #=> "\x81", same as above
168+
127169
=== Here Documents
128170

129171
If you are writing a large block of text you may use a "here document" or

0 commit comments

Comments
 (0)