зеркало из https://github.com/github/ruby.git
Expose rb_str_chilled_p
Some extensions (like stringio) may need to differentiate between chilled strings and frozen strings. They can now use rb_str_chilled_p but must check for its presence since the function will be removed when chilled strings are removed. [Bug #20389] [Feature #20205] Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
This commit is contained in:
Родитель
8cfa8e87b2
Коммит
2b08406cd0
|
@ -0,0 +1,13 @@
|
|||
#include "ruby.h"
|
||||
|
||||
static VALUE
|
||||
bug_s_rb_str_chilled_p(VALUE self, VALUE str)
|
||||
{
|
||||
return rb_str_chilled_p(str) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
void
|
||||
Init_string_chilled(VALUE klass)
|
||||
{
|
||||
rb_define_singleton_method(klass, "rb_str_chilled_p", bug_s_rb_str_chilled_p, 1);
|
||||
}
|
|
@ -173,6 +173,165 @@ capacity.o: $(hdrdir)/ruby/subst.h
|
|||
capacity.o: $(top_srcdir)/internal/compilers.h
|
||||
capacity.o: $(top_srcdir)/internal/string.h
|
||||
capacity.o: capacity.c
|
||||
chilled.o: $(RUBY_EXTCONF_H)
|
||||
chilled.o: $(arch_hdrdir)/ruby/config.h
|
||||
chilled.o: $(hdrdir)/ruby.h
|
||||
chilled.o: $(hdrdir)/ruby/assert.h
|
||||
chilled.o: $(hdrdir)/ruby/backward.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/assume.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/attributes.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/bool.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/inttypes.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/limits.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/long_long.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
||||
chilled.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
chilled.o: $(hdrdir)/ruby/defines.h
|
||||
chilled.o: $(hdrdir)/ruby/intern.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/abi.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/char.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/double.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/int.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/long.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/short.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/assume.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/artificial.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/cold.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/const.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/constexpr.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/deprecated.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/error.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/forceinline.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/format.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/noalias.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/noexcept.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/noinline.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/nonnull.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/noreturn.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/pure.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/restrict.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/warning.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/attr/weakref.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/cast.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/compiler_since.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/config.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/constant_p.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rarray.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rbasic.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rbignum.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rclass.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rdata.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rfile.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rhash.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/robject.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rregexp.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rstring.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rstruct.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/error.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/eval.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/event.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/fl_type.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/gc.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/glob.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/globals.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/attribute.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/builtin.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/c_attribute.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/extension.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/feature.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/has/warning.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/array.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/bignum.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/class.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/compar.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/complex.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/cont.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/dir.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/enum.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/enumerator.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/error.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/eval.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/file.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/hash.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/io.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/load.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/marshal.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/numeric.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/object.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/parse.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/proc.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/process.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/random.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/range.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/rational.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/re.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/ruby.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/select.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/signal.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/sprintf.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/string.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/struct.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/thread.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/time.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/variable.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/intern/vm.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/interpreter.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/iterator.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/memory.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/method.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/module.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/newobj.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/scan_args.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/special_consts.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/static_assert.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/stdalign.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/stdbool.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/symbol.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/value.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/value_type.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/variable.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
chilled.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
chilled.o: $(hdrdir)/ruby/missing.h
|
||||
chilled.o: $(hdrdir)/ruby/ruby.h
|
||||
chilled.o: $(hdrdir)/ruby/st.h
|
||||
chilled.o: $(hdrdir)/ruby/subst.h
|
||||
chilled.o: chilled.c
|
||||
coderange.o: $(RUBY_EXTCONF_H)
|
||||
coderange.o: $(arch_hdrdir)/ruby/config.h
|
||||
coderange.o: $(hdrdir)/ruby/assert.h
|
||||
|
|
|
@ -601,6 +601,21 @@ VALUE rb_str_dup(VALUE str);
|
|||
*/
|
||||
VALUE rb_str_resurrect(VALUE str);
|
||||
|
||||
/**
|
||||
* Returns whether a string is chilled or not.
|
||||
*
|
||||
* This function is temporary and users must check for its presence using
|
||||
* #ifdef HAVE_RB_STR_CHILLED_P. If HAVE_RB_STR_CHILLED_P is not defined, then
|
||||
* strings can't be chilled.
|
||||
*
|
||||
* @param[in] str A string.
|
||||
* @retval 1 The string is chilled.
|
||||
* @retval 0 Otherwise.
|
||||
*/
|
||||
bool rb_str_chilled_p(VALUE str);
|
||||
|
||||
#define HAVE_RB_STR_CHILLED_P 1
|
||||
|
||||
/**
|
||||
* Obtains a "temporary lock" of the string. This advisory locking mechanism
|
||||
* prevents other cooperating threads from tampering the receiver. The same
|
||||
|
|
6
string.c
6
string.c
|
@ -1833,6 +1833,12 @@ rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str, bool chil
|
|||
return new_str;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_str_chilled_p(VALUE str)
|
||||
{
|
||||
return CHILLED_STRING_P(str);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* call-seq:
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
require 'test/unit'
|
||||
require '-test-/string'
|
||||
|
||||
class Test_String_ChilledString < Test::Unit::TestCase
|
||||
def test_rb_str_chilled_p
|
||||
str = ""
|
||||
assert_equal true, Bug::String.rb_str_chilled_p(str)
|
||||
end
|
||||
|
||||
def test_rb_str_chilled_p_frozen
|
||||
str = "".freeze
|
||||
assert_equal false, Bug::String.rb_str_chilled_p(str)
|
||||
end
|
||||
|
||||
def test_rb_str_chilled_p_mutable
|
||||
str = "".dup
|
||||
assert_equal false, Bug::String.rb_str_chilled_p(str)
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче