8000 Merge pull request #13 from github/merge-upstream-2.1.1 · github/ruby@ef85955 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef85955

Browse files
committed
Merge pull request #13 from github/merge-upstream-2.1.1
Merge upstream 2.1.1
2 parents f08d508 + 5b54c3b commit ef85955

File tree

159 files changed

+2518
-681
lines changed

Some content is hidden

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

159 files changed

+2518
-681
lines changed

ChangeLog

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

NEWS

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ with all sufficient information, see the ChangeLog file.
114114
* Process.clock_getres
115115

116116
* String
117+
* "literal".freeze is now optimized to return the same object
117118
* New methods:
118119
* String#scrub and String#scrub! verify and fix invalid byte sequence.
119120
If you want to use this function with older Ruby,
@@ -133,6 +134,10 @@ with all sufficient information, see the ChangeLog file.
133134

134135
=== Core classes compatibility issues (excluding feature bug fixes)
135136

137+
* Dir
138+
* incompatible changes:
139+
* Dir#glob returns composed characters (previously Apple Modofied UTF-8).
140+
136141
* Hash
137142
* incompatible changes:
138143
* Hash#reject will return plain Hash object in the future versions, that
@@ -250,7 +255,7 @@ String
250255
* REXML::Parsers::SAX2Parser
251256
* Fixes wrong number of arguments of entitydecl event. Document of the event
252257
says "an array of the entity declaration" but implementation passes two
253-
or more arguments. It is an implementation bug but it breaks backword
258+
or more arguments. It is an implementation bug but it breaks backward
254259
compatibility.
255260

256261
* REXML::Parsers::StreamParser
@@ -271,6 +276,8 @@ String
271276
* Improved, iterative resolver (compared to RubyGems 2.1 and earlier)
272277
* Support for a sharing a GEM_HOME across ruby platforms and versions
273278

279+
* Updated to 2.2.2. Fixes some minor bugs and performance regressions.
280+
274281
For a complete list of enhancements and bug fixes see:
275282
https://github.com/rubygems/rubygems/tree/master/History.txt
276283

benchmark/driver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def measure executable, file
242242
cmd = "#{executable} #{@ruby_arg} #{file}"
243243

244244
m = Benchmark.measure{
245-
`#{cmd}`
245+
system(cmd, out: File::NULL)
246246
}
247247

248248
if $? != 0

bootstraptest/test_method.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ class C < B
957957

958958
assert_normal_exit %q{
959959
begin
960-
Process.setrlimit(Process::RLIMIT_STACK, 4_202_496)
961-
# FreeBSD fails this less than 4M + 8K bytes.
960+
Process.setrlimit(Process::RLIMIT_STACK, 4_206_592)
961+
# FreeBSD SEGVs this less than 4M + 12K bytes.
962962
rescue Exception
963963
exit
964964
end

class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
322322
if (RB_TYPE_P(clone, T_CLASS)) {
323323
class_init_copy_check(clone, orig);
324324
}
325-
rb_obj_init_copy(clone, orig);
325+
if (!OBJ_INIT_COPY(clone, orig)) return clone;
326326
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
327327
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig));
328328
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);

compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
12031203
node = node->nd_next;
12041204
i += 1;
12051205
}
1206-
iseq->arg_keyword_check = (args->kw_rest_arg->nd_vid & ID_SCOPE_MASK) == ID_JUNK;
1206+
iseq->arg_keyword_check = args->kw_rest_arg->nd_cflag != 0;
12071207
iseq->arg_keywords = i;
12081208
iseq->arg_keyword_required = r;
12091209
iseq->arg_keyword_table = ALLOC_N(ID, i);

configure.in

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,22 @@ if test "$GCC" = yes; then
856856
for oflag in -fno-fast-math; do
857857
RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)])
858858
done
859+
AS_CASE(["$target"],
860+
[*-darwin*], [
861+
# doesn't seem necessary on Mac OS X
862+
],
863+
[[i[4-6]86*]], [
864+
RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [
865+
RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse)
866+
])
867+
AS_CASE(["$XCFLAGS"],
868+
[[*-msse2*]], [
869+
RUBY_TRY_CFLAGS(-mstackrealign, [
870+
RUBY_APPEND_OPTION(XCFLAGS, -mstackrealign)
871+
])
872+
])
873+
]
874+
)
859875
fi
860876

861877
AC_ARG_WITH(opt-dir,
@@ -864,17 +880,11 @@ AC_ARG_WITH(opt-dir,
864880
[
865881
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //"`
866882
C 48DA PPFLAGS="$CPPFLAGS $val"
867-
val=`IFS="$PATH_SEPARATOR"
868-
for dir in $withval; do
869-
echo x ${LIBPATHFLAG} ${RPATHFLAG} |
870-
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g"
871-
done | tr '\012' ' '`
883+
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -L\1/lib|g;s/^ //"`
884+
LDFLAGS="$LDFLAGS $val"
872885
LDFLAGS_OPTDIR="$val"
873-
test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS "
874-
LDFLAGS="$LDFLAGS$val"
875-
test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS "
876-
DLDFLAGS="$DLDFLAGS$val"
877-
])
886+
OPT_DIR="$withval"
887+
], [OPT_DIR=])
878888

879889
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
880890
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
@@ -888,6 +898,7 @@ AC_ARG_WITH(winnt-ver,
888898
AS_CASE(["$target_os"],
889899
[mingw*], [
890900
RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver)
901+
RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT)
891902
])
892903

893904
AS_CASE(["$target_os"],
@@ -1040,6 +1051,7 @@ main()
10401051
if test x"$ac_cv_type_NET_LUID" = xyes; then
10411052
AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
10421053
fi
1054+
AC_CHECK_FUNCS(_gmtime64_s)
10431055
AC_LIBOBJ([langinfo])
10441056
],
10451057
[os2-emx*], [ LIBS="-lm $LIBS"
@@ -2437,7 +2449,7 @@ if test x"$enable_pthread" = xyes; then
24372449
pthread_get_stackaddr_np pthread_get_stacksize_np \
24382450
thr_stksegment pthread_stackseg_np pthread_getthrds_np \
24392451
pthread_cond_init pthread_condattr_setclock pthread_condattr_init \
2440-
pthread_sigmask)
2452+
pthread_sigmask pthread_setname_np)
24412453
if test "${host_os}" = "nacl"; then
24422454
ac_cv_func_pthread_attr_init=no
24432455
else
@@ -2657,7 +2669,7 @@ if test "$with_dln_a_out" != yes; then
26572669
: ${LDSHARED='$(CC) -shared'}
26582670
if test "$rb_cv_binary_elf" = yes; then
26592671
LDFLAGS="$LDFLAGS -rdynamic"
2660-
DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
2672+
DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@'
26612673
else
26622674
test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable'
26632675
fi
@@ -2760,6 +2772,21 @@ AC_SUBST(RPATHFLAG)
27602772
AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}")
27612773
AC_SUBST(TRY_LINK)
27622774

2775+
if test "x$OPT_DIR" != x; then
2776+
pat=`echo "${LDFLAGS_OPTDIR}" | sed ['s/[][\\.*|]/\\\\&/']`
2777+
LDFLAGS=`echo "${LDFLAGS}" | sed "s| ${pat}||"`
2778+
val=`IFS="$PATH_SEPARATOR"
2779+
for dir in $OPT_DIR; do
2780+
echo x ${LIBPATHFLAG} ${RPATHFLAG} |
2781+
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g"
2782+
done | tr '\012' ' '`
2783+
test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS "
2784+
LDFLAGS="$LDFLAGS$val"
2785+
test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS "
2786+
DLDFLAGS="$DLDFLAGS$val"
2787+
LDFLAGS_OPTDIR="$val"
2788+
fi
2789+
27632790
AS_CASE(["$target_cpu-$target_os"],
27642791
[*-darwin*], [
27652792
AC_CHECK_HEADERS([execinfo.h])

encoding.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ must_encindex(int index)
158158
rb_raise(rb_eEncodingError, "encoding index out of bound: %d",
159159
index);
160160
}
161-
if (ENC_TO_ENCINDEX(enc) != index) {
161+
if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) {
162162
rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)",
163163
index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc));
164164
}
@@ -594,12 +594,18 @@ rb_enc_from_index(int index)
594594
if (!enc_table.list) {
595595
rb_enc_init();
596596
}
597-
if (index < 0 || enc_table.count <= index) {
597+
if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) {
598598
return 0;
599599
}
600600
return enc_table.list[index].enc;
601601
}
602602

603+
rb_encoding *
604+
rb_enc_get_from_index(int index)
605+
{
606+
return must_encindex(index);
607+
}
608+
603609
int
604610
rb_enc_registered(const char *name)
605611
{
@@ -937,7 +943,7 @@ rb_obj_encoding(VALUE obj)
937943
if (idx < 0) {
938944
rb_raise(rb_eTypeError, "unknown encoding");
939945
}
940-
return rb_enc_from_encoding_index(idx);
946+
return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK);
941947
}
942948

943949
int

eval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
380380
VALUE cbase = 0;
381381
void *data = 0;
382382

383-
if (argc > 0) {
384-
return rb_mod_constants(argc, argv, rb_cModule);
383+
if (argc > 0 || mod != rb_cModule) {
384+
return rb_mod_constants(argc, argv, mod);
385385
}
386386

387387
while (cref) {

ext/-test-/tracepoint/tracepoint.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ tracepoint_track_objspace_events(VALUE self)
6464
VALUE result = rb_ary_new();
6565

6666
rb_tracepoint_enable(tpval);
67-
rb_yield(Qundef);
68-
rb_tracepoint_disable(tpval);
67+
rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval);
6968

7069
rb_ary_push(result, SIZET2NUM(track.newobj_count));
7170
rb_ary_push(result, SIZET2NUM(track.free_count));

ext/bigdecimal/bigdecimal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
24812481
Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
24822482
Real *x = rb_check_typeddata(other, &BigDecimal_data_type);
24832483

2484-
DATA_PTR(self) = VpCopy(pv, x);
2484+
if (self != other) {
2485+
DATA_PTR(self) = VpCopy(pv, x);
2486+
}
24852487
return self;
24862488
}
24872489

@@ -2519,8 +2521,8 @@ BigDecimal_new(int argc, VALUE *argv)
25192521
case T_RATIONAL:
25202522
if (NIL_P(nFig)) {
25212523
rb_raise(rb_eArgError,
2522-
"can't omit precision for a %s.",
2523-
rb_class2name(CLASS_OF(iniValue)));
2524+
"can't omit precision for a %"PRIsVALUE".",
2525+
rb_obj_class(iniValue));
25242526
}
25252527
return GetVpValueWithPrec(iniValue, mf, 1);
25262528

ext/dl/cptr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,8 @@ rb_dlptr_inspect(VALUE self)
391391
char str[1024];
392392

393393
TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data);
394-
snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>",
395-
rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
396-
return rb_str_new2(str);
394+
return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
395+
rb_obj_class(self), data, data->ptr, data->size, data->free);
397396
}
398397

399398
/*

ext/fiddle/closure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dealloc(void * ptr)
2727
#if USE_FFI_CLOSURE_ALLOC
2828
ffi_closure_free(cls->pcl);
2929
#else
30-
munmap(cls->pcl, sizeof(cls->pcl));
30+
munmap(cls->pcl, sizeof(*cls->pcl));
3131
#endif
3232
if (cls->argv) xfree(cls->argv);
3333
xfree(cls);
@@ -234,7 +234,7 @@ initialize(int rbargc, VALUE argv[], VALUE self)
234234
#else
235235
result = ffi_prep_closure(pcl, cif, callback, (void *)self);
236236
cl->code = (void *)pcl;
237-
i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC);
237+
i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
238238
if (i) {
239239
rb_sys_fail("mprotect");
240240
}

ext/fiddle/pointer.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,10 @@ static VALUE
427427
rb_fiddle_ptr_inspect(VALUE self)
428428
{
429429
struct ptr_data *data;
430-
char str[1024];
431430

432431
TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
433-
snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>",
434-
rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
435-
return rb_str_new2(str);
432+
return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
433+
rb_obj_class(self), data, data->ptr, data->size, data->free);
436434
}
437435

438436
/*

ext/io/console/console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ console_dev(VALUE klass)
710710
int fd;
711711

712712
#ifdef CONSOLE_DEVICE_FOR_WRITING
713-
fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_WRONLY, 0);
713+
fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
714714
if (fd < 0) return Qnil;
715715
rb_update_max_fd(fd);
716716
args[1] = INT2FIX(O_WRONLY);

ext/json/generator/depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
$(OBJS): $(ruby_headers)
12
generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h

ext/json/generator/generator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
965965
{
966966
JSON_Generator_State *objState, *origState;
967967

968+
if (obj == orig) return obj;
968969
Data_Get_Struct(obj, JSON_Generator_State, objState);
969970
Data_Get_Struct(orig, JSON_Generator_State, origState);
970971
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");

ext/json/parser/depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
$(OBJS): $(ruby_headers)
12
parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h

ext/openssl/ossl.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,25 +293,29 @@ ossl_to_der_if_possible(VALUE obj)
293293
static VALUE
294294
ossl_make_error(VALUE exc, const char *fmt, va_list args)
295295
{
296-
char buf[BUFSIZ];
296+
VALUE str = Qnil;
297297
const char *msg;
298298
long e;
299-
int len = 0;
300299

301300
#ifdef HAVE_ERR_PEEK_LAST_ERROR
302301
e = ERR_peek_last_error();
303302
#else
304303
e = ERR_peek_error();
305304
#endif
306305
if (fmt) {
307-
len = vsnprintf(buf, BUFSIZ, fmt, args);
306+
str = rb_vsprintf(fmt, args);
308307
}
309-
if (len < BUFSIZ && e) {
308+
if (e) {
310309
if (dOSSL == Qtrue) /* FULL INFO */
311310
msg = ERR_error_string(e, NULL);
312311
else
313312
msg = ERR_reason_error_string(e);
314-
len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg);
313+
if (NIL_P(str)) {
314+
str = rb_str_new_cstr(msg);
315+
}
316+
else {
317+
rb_str_cat2(rb_str_cat2(str, ": "), msg);
318+
}
315319
}
316320
if (dOSSL == Qtrue){ /* show all errors on the stack */
317321
while ((e = ERR_get_error()) != 0){
@@ -320,8 +324,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
320324
}
321325
ERR_clear_error();
322326

323-
if(len > BUFSIZ) len = rb_long2int(strlen(buf));
324-
return rb_exc_new(exc, buf, len);
327+
if (NIL_P(str)) str = rb_str_new(0, 0);
328+
return rb_exc_new3(exc, str);
325329
}
326330

327331
void

ext/openssl/ossl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ extern VALUE eOSSLError;
9595
*/
9696
#define OSSL_Check_Kind(obj, klass) do {\
9797
if (!rb_obj_is_kind_of((obj), (klass))) {\
98-
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
99-
rb_obj_classname(obj), rb_class2name(klass));\
98+
ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
99+
rb_obj_class(obj), (klass));\
100100
}\
101101
} while (0)
102102

103103
#define OSSL_Check_Instance(obj, klass) do {\
104104
if (!rb_obj_is_instance_of((obj), (klass))) {\
105-
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
106-
rb_obj_classname(obj), rb_class2name(klass));\
105+
ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\
106+
rb_obj_class(obj), (klass));\
107107
}\
108108
} while (0)
109109

0 commit comments

Comments
 (0)
0