Skip to content

Commit be9b929

Browse files
committed
Update upstream source from tag 'upstream/3.2.4'
Update to upstream version '3.2.4' with Debian dir f7378fe
2 parents 2a8d0b2 + dd595cd commit be9b929

33 files changed

+1725
-1188
lines changed

ChangeLog

Lines changed: 1442 additions & 1070 deletions
Large diffs are not rendered by default.

common.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ $(arch:noarch=ignore)-fake.rb: $(srcdir)/template/fake.rb.in $(tooldir)/generic_
790790
$(ECHO) generating $@
791791
$(Q) $(CPP) -DRUBY_EXPORT $(INCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \
792792
$(BOOTSTRAPRUBY) "$(tooldir)/generic_erb.rb" -o $@ "$(srcdir)/template/fake.rb.in" \
793-
i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)"
793+
i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)" \
794+
LIBPATHENV="$(LIBPATHENV)" PRELOADENV="$(PRELOADENV)" LIBRUBY_SO="$(LIBRUBY_SO)"
794795

795796
noarch-fake.rb: # prerequisite of yes-fake
796797
$(Q) exit > $@

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30466,7 +30466,7 @@ fi
3046630466
: ${LDSHARED='$(CC) -dynamic -bundle'}
3046730467
: ${DLDSHARED='$(CC) -dynamiclib'}
3046830468
: ${LDFLAGS=""}
30469-
: ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH}
30469+
: ${LIBPATHENV=DYLD_LIBRARY_PATH}
3047030470
: ${PRELOADENV=DYLD_INSERT_LIBRARIES}
3047130471
if test x"$enable_shared" = xyes
3047230472
then :

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ AC_SUBST(EXTOBJS)
30583058
[darwin*], [ : ${LDSHARED='$(CC) -dynamic -bundle'}
30593059
: ${DLDSHARED='$(CC) -dynamiclib'}
30603060
: ${LDFLAGS=""}
3061-
: ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH}
3061+
: ${LIBPATHENV=DYLD_LIBRARY_PATH}
30623062
: ${PRELOADENV=DYLD_INSERT_LIBRARIES}
30633063
AS_IF([test x"$enable_shared" = xyes], [
30643064
# Resolve symbols from libruby.dylib when --enable-shared

enumerator.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ static VALUE sym_each, sym_cycle, sym_yield;
164164

165165
static VALUE lazy_use_super_method;
166166

167+
extern ID ruby_static_id_cause;
168+
167169
#define id_call idCall
170+
#define id_cause ruby_static_id_cause
168171
#define id_each idEach
169172
#define id_eqq idEqq
170173
#define id_initialize idInitialize
@@ -807,8 +810,16 @@ get_next_values(VALUE obj, struct enumerator *e)
807810
{
808811
VALUE curr, vs;
809812

810-
if (e->stop_exc)
811-
rb_exc_raise(e->stop_exc);
813+
if (e->stop_exc) {
814+
VALUE exc = e->stop_exc;
815+
VALUE result = rb_attr_get(exc, id_result);
816+
VALUE mesg = rb_attr_get(exc, idMesg);
817+
if (!NIL_P(mesg)) mesg = rb_str_dup(mesg);
818+
VALUE stop_exc = rb_exc_new_str(rb_eStopIteration, mesg);
819+
rb_ivar_set(stop_exc, id_cause, exc);
820+
rb_ivar_set(stop_exc, id_result, result);
821+
rb_exc_raise(stop_exc);
822+
}
812823

813824
curr = rb_fiber_current();
814825

ext/openssl/ossl_pkey_ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static VALUE ossl_ec_key_check_key(VALUE self)
483483
#ifdef HAVE_EVP_PKEY_CHECK
484484
EVP_PKEY *pkey;
485485
EVP_PKEY_CTX *pctx;
486-
EC_KEY *ec;
486+
const EC_KEY *ec;
487487

488488
GetPKey(self, pkey);
489489
GetEC(self, ec);

hash.c

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -767,31 +767,39 @@ ar_free_and_clear_table(VALUE hash)
767767
HASH_ASSERT(RHASH_TRANSIENT_P(hash) == 0);
768768
}
769769

770-
static void
771-
ar_try_convert_table(VALUE hash)
772-
{
773-
if (!RHASH_AR_TABLE_P(hash)) return;
774-
775-
const unsigned size = RHASH_AR_TABLE_SIZE(hash);
770+
void rb_st_add_direct_with_hash(st_table *tab, st_data_t key, st_data_t value, st_hash_t hash); // st.c
776771

777-
st_table *new_tab;
778-
st_index_t i;
772+
enum ar_each_key_type {
773+
ar_each_key_copy,
774+
ar_each_key_cmp,
775+
ar_each_key_insert,
776+
};
779777

780-
if (size < RHASH_AR_TABLE_MAX_SIZE) {
781-
return;
778+
static inline int
779+
ar_each_key(ar_table *ar, int max, enum ar_each_key_type type, st_data_t *dst_keys, st_table *new_tab, st_hash_t *hashes)
780+
{
781+
for (int i = 0; i < max; i++) {
782+
ar_table_pair *pair = &ar->pairs[i];
783+
784+
switch (type) {
785+
case ar_each_key_copy:
786+
dst_keys[i] = pair->key;
787+
break;
788+
case ar_each_key_cmp:
789+
if (dst_keys[i] != pair->key) return 1;
790+
break;
791+
case ar_each_key_insert:
792+
if (UNDEF_P(pair->key)) continue; // deleted entry
793+
rb_st_add_direct_with_hash(new_tab, pair->key, pair->val, hashes[i]);
794+
break;
795+
}
782796
}
783797

784-
new_tab = st_init_table_with_size(&objhash, size * 2);
785-
786-
for (i = 0; i < RHASH_AR_TABLE_MAX_BOUND; i++) {
787-
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
788-
st_add_direct(new_tab, pair->key, pair->val);
789-
}
790-
ar_free_and_clear_table(hash);
791-
RHASH_ST_TABLE_SET(hash, new_tab);
792-
return;
798+
return 0;
793799
}
794800

801+
802+
795803
static st_table *
796804
ar_force_convert_table(VALUE hash, const char *file, int line)
797805
{
@@ -802,22 +810,32 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
802810
}
803811

804812
if (RHASH_AR_TABLE(hash)) {
805-
unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
806-
807-
#if defined(RHASH_CONVERT_TABLE_DEBUG) && RHASH_CONVERT_TABLE_DEBUG
808-
rb_obj_info_dump(hash);
809-
fprintf(stderr, "force_convert: %s:%d\n", file, line);
810-
RB_DEBUG_COUNTER_INC(obj_hash_force_convert);
811-
#endif
813+
ar_table *ar = RHASH_AR_TABLE(hash);
814+
st_hash_t hashes[RHASH_AR_TABLE_MAX_SIZE];
815+
unsigned int bound, size;
816+
817+
// prepare hash values
818+
do {
819+
st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];
820+
bound = RHASH_AR_TABLE_BOUND(hash);
821+
size = RHASH_AR_TABLE_SIZE(hash);
822+
ar_each_key(ar, bound, ar_each_key_copy, keys, NULL, NULL);
823+
824+
for (unsigned int i = 0; i < bound; i++) {
825+
// do_hash calls #hash method and it can modify hash object
826+
hashes[i] = UNDEF_P(keys[i]) ? 0 : ar_do_hash(keys[i]);
827+
}
812828

813-
new_tab = st_init_table_with_size(&objhash, RHASH_AR_TABLE_SIZE(hash));
829+
// check if modified
830+
if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash);
831+
if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue;
832+
if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue;
833+
} while (0);
814834

815-
for (i = 0; i < bound; i++) {
816-
if (ar_cleared_entry(hash, i)) continue;
817835

818-
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
819-
st_add_direct(new_tab, pair->key, pair->val);
820-
}
836+
// make st
837+
new_tab = st_init_table_with_size(&objhash, size);
838+
ar_each_key(ar, bound, ar_each_key_insert, NULL, new_tab, hashes);
821839
ar_free_and_clear_table(hash);
822840
}
823841
else {
@@ -1724,7 +1742,7 @@ rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func,
17241742
if (RHASH_AR_TABLE_P(hash)) {
17251743
int result = ar_update(hash, key, func, arg);
17261744
if (result == -1) {
1727-
ar_try_convert_table(hash);
1745+
ar_force_convert_table(hash, __FILE__, __LINE__);
17281746
}
17291747
else {
17301748
return result;
@@ -4801,7 +4819,7 @@ rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
48014819
if (ret != -1) {
48024820
return ret;
48034821
}
4804-
ar_try_convert_table(hash);
4822+
ar_force_convert_table(hash, __FILE__, __LINE__);
48054823
}
48064824
tbl = RHASH_TBL_RAW(hash);
48074825
return st_update(tbl, (st_data_t)key, add_new_i, (st_data_t)args);

io.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,13 +1789,11 @@ io_binwrite_string(VALUE arg)
17891789
// Write as much as possible:
17901790
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);
17911791

1792-
// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
1793-
// should try again.
17941792
if (result == 0) {
1795-
errno = EWOULDBLOCK;
1793+
// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
1794+
// should try again immediately.
17961795
}
1797-
1798-
if (result > 0) {
1796+
else if (result > 0) {
17991797
if ((size_t)result == remaining) break;
18001798
ptr += result;
18011799
remaining -= result;

lib/rdoc/store.rb

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,7 @@ def load_all
556556
def load_cache
557557
#orig_enc = @encoding
558558

559-
File.open cache_path, 'rb' do |io|
560-
@cache = Marshal.load io
561-
end
559+
@cache = marshal_load(cache_path)
562560

563561
load_enc = @cache[:encoding]
564562

@@ -615,9 +613,7 @@ def load_class klass_name
615613
def load_class_data klass_name
616614
file = class_file klass_name
617615

618-
File.open file, 'rb' do |io|
619-
Marshal.load io
620-
end
616+
marshal_load(file)
621617
rescue Errno::ENOENT => e
622618
error = MissingFileError.new(self, file, klass_name)
623619
error.set_backtrace e.backtrace
@@ -630,14 +626,10 @@ def load_class_data klass_name
630626
def load_method klass_name, method_name
631627
file = method_file klass_name, method_name
632628

633-
File.open file, 'rb' do |io|
634-
obj = Marshal.load io
635-
obj.store = self
636-
obj.parent =
637-
find_class_or_module(klass_name) || load_class(klass_name) unless
638-
obj.parent
639-
obj
640-
end
629+
obj = marshal_load(file)
630+
obj.store = self
631+
obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name)
632+
obj
641633
rescue Errno::ENOENT => e
642634
error = MissingFileError.new(self, file, klass_name + method_name)
643635
error.set_backtrace e.backtrace
@@ -650,11 +642,9 @@ def load_method klass_name, method_name
650642
def load_page page_name
651643
file = page_file page_name
652644

653-
File.open file, 'rb' do |io|
654-
obj = Marshal.load io
655-
obj.store = self
656-
obj
657-
end
645+
obj = marshal_load(file)
646+
obj.store = self
647+
obj
658648
rescue Errno::ENOENT => e
659649
error = MissingFileError.new(self, file, page_name)
660650
error.set_backtrace e.backtrace
@@ -976,4 +966,21 @@ def unique_modules
976966
@unique_modules
977967
end
978968

969+
private
970+
def marshal_load(file)
971+
File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
972+
end
973+
974+
MarshalFilter = proc do |obj|
975+
case obj
976+
when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text
977+
else
978+
unless obj.class.name.start_with?("RDoc::")
979+
raise TypeError, "not permitted class: #{obj.class.name}"
980+
end
981+
end
982+
obj
983+
end
984+
private_constant :MarshalFilter
985+
979986
end

lib/rdoc/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ module RDoc
55
##
66
# RDoc version you are using
77

8-
VERSION = '6.5.0'
8+
VERSION = '6.5.1.1'
99

1010
end

0 commit comments

Comments
 (0)