Skip to content

Commit

Permalink
Merge pull request #13 from github/merge-upstream-2.1.1
Browse files Browse the repository at this point in the history
Merge upstream 2.1.1
  • Loading branch information
dbussink committed Mar 15, 2014
2 parents f08d508 + 5b54c3b commit ef85955
Show file tree
Hide file tree
Showing 159 changed files with 2,518 additions and 681 deletions.
572 changes: 571 additions & 1 deletion ChangeLog

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ with all sufficient information, see the ChangeLog file.
* Process.clock_getres

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

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

* Dir
* incompatible changes:
* Dir#glob returns composed characters (previously Apple Modofied UTF-8).

* Hash
* incompatible changes:
* Hash#reject will return plain Hash object in the future versions, that
Expand Down Expand Up @@ -250,7 +255,7 @@ String
* REXML::Parsers::SAX2Parser
* Fixes wrong number of arguments of entitydecl event. Document of the event
says "an array of the entity declaration" but implementation passes two
or more arguments. It is an implementation bug but it breaks backword
or more arguments. It is an implementation bug but it breaks backward
compatibility.

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

* Updated to 2.2.2. Fixes some minor bugs and performance regressions.

For a complete list of enhancements and bug fixes see:
https://github.com/rubygems/rubygems/tree/master/History.txt

Expand Down
2 changes: 1 addition & 1 deletion benchmark/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def measure executable, file
cmd = "#{executable} #{@ruby_arg} #{file}"

m = Benchmark.measure{
`#{cmd}`
system(cmd, out: File::NULL)
}

if $? != 0
Expand Down
4 changes: 2 additions & 2 deletions bootstraptest/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,8 @@ class C < B

assert_normal_exit %q{
begin
Process.setrlimit(Process::RLIMIT_STACK, 4_202_496)
# FreeBSD fails this less than 4M + 8K bytes.
Process.setrlimit(Process::RLIMIT_STACK, 4_206_592)
# FreeBSD SEGVs this less than 4M + 12K bytes.
rescue Exception
exit
end
Expand Down
2 changes: 1 addition & 1 deletion class.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
if (RB_TYPE_P(clone, T_CLASS)) {
class_init_copy_check(clone, orig);
}
rb_obj_init_copy(clone, orig);
if (!OBJ_INIT_COPY(clone, orig)) return clone;
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig));
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
Expand Down
2 changes: 1 addition & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
node = node->nd_next;
i += 1;
}
iseq->arg_keyword_check = (args->kw_rest_arg->nd_vid & ID_SCOPE_MASK) == ID_JUNK;
iseq->arg_keyword_check = args->kw_rest_arg->nd_cflag != 0;
iseq->arg_keywords = i;
iseq->arg_keyword_required = r;
iseq->arg_keyword_table = ALLOC_N(ID, i);
Expand Down
51 changes: 39 additions & 12 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,22 @@ if test "$GCC" = yes; then
for oflag in -fno-fast-math; do
RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)])
done
AS_CASE(["$target"],
[*-darwin*], [
# doesn't seem necessary on Mac OS X
],
[[i[4-6]86*]], [
RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [
RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse)
])
AS_CASE(["$XCFLAGS"],
[[*-msse2*]], [
RUBY_TRY_CFLAGS(-mstackrealign, [
RUBY_APPEND_OPTION(XCFLAGS, -mstackrealign)
])
])
]
)
fi

AC_ARG_WITH(opt-dir,
Expand All @@ -864,17 +880,11 @@ AC_ARG_WITH(opt-dir,
[
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //"`
CPPFLAGS="$CPPFLAGS $val"
val=`IFS="$PATH_SEPARATOR"
for dir in $withval; do
echo x ${LIBPATHFLAG} ${RPATHFLAG} |
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g"
done | tr '\012' ' '`
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -L\1/lib|g;s/^ //"`
LDFLAGS="$LDFLAGS $val"
LDFLAGS_OPTDIR="$val"
test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS "
LDFLAGS="$LDFLAGS$val"
test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS "
DLDFLAGS="$DLDFLAGS$val"
])
OPT_DIR="$withval"
], [OPT_DIR=])

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

AS_CASE(["$target_os"],
Expand Down Expand Up @@ -1040,6 +1051,7 @@ main()
if test x"$ac_cv_type_NET_LUID" = xyes; then
AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
fi
AC_CHECK_FUNCS(_gmtime64_s)
AC_LIBOBJ([langinfo])
],
[os2-emx*], [ LIBS="-lm $LIBS"
Expand Down Expand Up @@ -2437,7 +2449,7 @@ if test x"$enable_pthread" = xyes; then
pthread_get_stackaddr_np pthread_get_stacksize_np \
thr_stksegment pthread_stackseg_np pthread_getthrds_np \
pthread_cond_init pthread_condattr_setclock pthread_condattr_init \
pthread_sigmask)
pthread_sigmask pthread_setname_np)
if test "${host_os}" = "nacl"; then
ac_cv_func_pthread_attr_init=no
else
Expand Down Expand Up @@ -2657,7 +2669,7 @@ if test "$with_dln_a_out" != yes; then
: ${LDSHARED='$(CC) -shared'}
if test "$rb_cv_binary_elf" = yes; then
LDFLAGS="$LDFLAGS -rdynamic"
DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@'
else
test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable'
fi
Expand Down Expand Up @@ -2760,6 +2772,21 @@ AC_SUBST(RPATHFLAG)
AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}")
AC_SUBST(TRY_LINK)

if test "x$OPT_DIR" != x; then
pat=`echo "${LDFLAGS_OPTDIR}" | sed ['s/[][\\.*|]/\\\\&/']`
LDFLAGS=`echo "${LDFLAGS}" | sed "s| ${pat}||"`
val=`IFS="$PATH_SEPARATOR"
for dir in $OPT_DIR; do
echo x ${LIBPATHFLAG} ${RPATHFLAG} |
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g"
done | tr '\012' ' '`
test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS "
LDFLAGS="$LDFLAGS$val"
test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS "
DLDFLAGS="$DLDFLAGS$val"
LDFLAGS_OPTDIR="$val"
fi

AS_CASE(["$target_cpu-$target_os"],
[*-darwin*], [
AC_CHECK_HEADERS([execinfo.h])
Expand Down
12 changes: 9 additions & 3 deletions encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ must_encindex(int index)
rb_raise(rb_eEncodingError, "encoding index out of bound: %d",
index);
}
if (ENC_TO_ENCINDEX(enc) != index) {
if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) {
rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)",
index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc));
}
Expand Down Expand Up @@ -594,12 +594,18 @@ rb_enc_from_index(int index)
if (!enc_table.list) {
rb_enc_init();
}
if (index < 0 || enc_table.count <= index) {
if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) {
return 0;
}
return enc_table.list[index].enc;
}

rb_encoding *
rb_enc_get_from_index(int index)
{
return must_encindex(index);
}

int
rb_enc_registered(const char *name)
{
Expand Down Expand Up @@ -937,7 +943,7 @@ rb_obj_encoding(VALUE obj)
if (idx < 0) {
rb_raise(rb_eTypeError, "unknown encoding");
}
return rb_enc_from_encoding_index(idx);
return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK);
}

int
Expand Down
4 changes: 2 additions & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
VALUE cbase = 0;
void *data = 0;

if (argc > 0) {
return rb_mod_constants(argc, argv, rb_cModule);
if (argc > 0 || mod != rb_cModule) {
return rb_mod_constants(argc, argv, mod);
}

while (cref) {
Expand Down
3 changes: 1 addition & 2 deletions ext/-test-/tracepoint/tracepoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ tracepoint_track_objspace_events(VALUE self)
VALUE result = rb_ary_new();

rb_tracepoint_enable(tpval);
rb_yield(Qundef);
rb_tracepoint_disable(tpval);
rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval);

rb_ary_push(result, SIZET2NUM(track.newobj_count));
rb_ary_push(result, SIZET2NUM(track.free_count));
Expand Down
8 changes: 5 additions & 3 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2481,7 +2481,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
Real *x = rb_check_typeddata(other, &BigDecimal_data_type);

DATA_PTR(self) = VpCopy(pv, x);
if (self != other) {
DATA_PTR(self) = VpCopy(pv, x);
}
return self;
}

Expand Down Expand Up @@ -2519,8 +2521,8 @@ BigDecimal_new(int argc, VALUE *argv)
case T_RATIONAL:
if (NIL_P(nFig)) {
rb_raise(rb_eArgError,
"can't omit precision for a %s.",
rb_class2name(CLASS_OF(iniValue)));
"can't omit precision for a %"PRIsVALUE".",
rb_obj_class(iniValue));
}
return GetVpValueWithPrec(iniValue, mf, 1);

Expand Down
5 changes: 2 additions & 3 deletions ext/dl/cptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@ rb_dlptr_inspect(VALUE self)
char str[1024];

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

/*
Expand Down
4 changes: 2 additions & 2 deletions ext/fiddle/closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dealloc(void * ptr)
#if USE_FFI_CLOSURE_ALLOC
ffi_closure_free(cls->pcl);
#else
munmap(cls->pcl, sizeof(cls->pcl));
munmap(cls->pcl, sizeof(*cls->pcl));
#endif
if (cls->argv) xfree(cls->argv);
xfree(cls);
Expand Down Expand Up @@ -234,7 +234,7 @@ initialize(int rbargc, VALUE argv[], VALUE self)
#else
result = ffi_prep_closure(pcl, cif, callback, (void *)self);
cl->code = (void *)pcl;
i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC);
i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
if (i) {
rb_sys_fail("mprotect");
}
Expand Down
6 changes: 2 additions & 4 deletions ext/fiddle/pointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,10 @@ static VALUE
rb_fiddle_ptr_inspect(VALUE self)
{
struct ptr_data *data;
char str[1024];

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

/*
Expand Down
2 changes: 1 addition & 1 deletion ext/io/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ console_dev(VALUE klass)
int fd;

#ifdef CONSOLE_DEVICE_FOR_WRITING
fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_WRONLY, 0);
fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
if (fd < 0) return Qnil;
rb_update_max_fd(fd);
args[1] = INT2FIX(O_WRONLY);
Expand Down
1 change: 1 addition & 0 deletions ext/json/generator/depend
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
$(OBJS): $(ruby_headers)
generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
1 change: 1 addition & 0 deletions ext/json/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
{
JSON_Generator_State *objState, *origState;

if (obj == orig) return obj;
Data_Get_Struct(obj, JSON_Generator_State, objState);
Data_Get_Struct(orig, JSON_Generator_State, origState);
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
Expand Down
1 change: 1 addition & 0 deletions ext/json/parser/depend
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
$(OBJS): $(ruby_headers)
parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
18 changes: 11 additions & 7 deletions ext/openssl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,25 +293,29 @@ ossl_to_der_if_possible(VALUE obj)
static VALUE
ossl_make_error(VALUE exc, const char *fmt, va_list args)
{
char buf[BUFSIZ];
VALUE str = Qnil;
const char *msg;
long e;
int len = 0;

#ifdef HAVE_ERR_PEEK_LAST_ERROR
e = ERR_peek_last_error();
#else
e = ERR_peek_error();
#endif
if (fmt) {
len = vsnprintf(buf, BUFSIZ, fmt, args);
str = rb_vsprintf(fmt, args);
}
if (len < BUFSIZ && e) {
if (e) {
if (dOSSL == Qtrue) /* FULL INFO */
msg = ERR_error_string(e, NULL);
else
msg = ERR_reason_error_string(e);
len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg);
if (NIL_P(str)) {
str = rb_str_new_cstr(msg);
}
else {
rb_str_cat2(rb_str_cat2(str, ": "), msg);
}
}
if (dOSSL == Qtrue){ /* show all errors on the stack */
while ((e = ERR_get_error()) != 0){
Expand All @@ -320,8 +324,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
}
ERR_clear_error();

if(len > BUFSIZ) len = rb_long2int(strlen(buf));
return rb_exc_new(exc, buf, len);
if (NIL_P(str)) str = rb_str_new(0, 0);
return rb_exc_new3(exc, str);
}

void
Expand Down
8 changes: 4 additions & 4 deletions ext/openssl/ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ extern VALUE eOSSLError;
*/
#define OSSL_Check_Kind(obj, klass) do {\
if (!rb_obj_is_kind_of((obj), (klass))) {\
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
rb_obj_classname(obj), rb_class2name(klass));\
ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
rb_obj_class(obj), (klass));\
}\
} while (0)

#define OSSL_Check_Instance(obj, klass) do {\
if (!rb_obj_is_instance_of((obj), (klass))) {\
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
rb_obj_classname(obj), rb_class2name(klass));\
ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\
rb_obj_class(obj), (klass));\
}\
} while (0)

Expand Down
Loading

0 comments on commit ef85955

Please sign in to comment.