Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The following bundled gems are promoted from default gems.
* rdoc 6.15.1
* win32ole 1.9.2
* irb 1.15.3
* reline 0.6.2
* reline 0.6.3
* readline 0.0.4
* fiddle 1.1.8

Expand Down
2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ logger 1.7.0 https://github.com/ruby/logger
rdoc 6.15.1 https://github.com/ruby/rdoc
win32ole 1.9.2 https://github.com/ruby/win32ole
irb 1.15.3 https://github.com/ruby/irb
reline 0.6.2 https://github.com/ruby/reline
reline 0.6.3 https://github.com/ruby/reline
readline 0.0.4 https://github.com/ruby/readline
fiddle 1.1.8 https://github.com/ruby/fiddle
57 changes: 9 additions & 48 deletions include/ruby/internal/core/rstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,41 +369,6 @@ RSTRING_LEN(VALUE str)
return RSTRING(str)->len;
}

RBIMPL_WARNING_PUSH()
#if RBIMPL_COMPILER_IS(Intel)
RBIMPL_WARNING_IGNORED(413)
#endif

RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
* "Expands" an embedded string into an ordinal one. This is a function that
* returns aggregated type. The returned struct always has its `as.heap.len`
* an `as.heap.ptr` fields set appropriately.
*
* This is an implementation detail that 3rd parties should never bother.
*/
static inline struct RString
rbimpl_rstring_getmem(VALUE str)
{
RBIMPL_ASSERT_TYPE(str, RUBY_T_STRING);

if (RB_FL_ANY_RAW(str, RSTRING_NOEMBED)) {
return *RSTRING(str);
}
else {
/* Expecting compilers to optimize this on-stack struct away. */
struct RString retval = {RBASIC_INIT};
retval.len = RSTRING_LEN(str);
retval.as.heap.ptr = RSTRING(str)->as.embed.ary;
return retval;
}
}

RBIMPL_WARNING_POP()

RBIMPL_ATTR_ARTIFICIAL()
/**
* Queries the contents pointer of the string.
Expand All @@ -415,7 +380,9 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline char *
RSTRING_PTR(VALUE str)
{
char *ptr = rbimpl_rstring_getmem(str).as.heap.ptr;
char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
RSTRING(str)->as.heap.ptr :
RSTRING(str)->as.embed.ary;

if (RUBY_DEBUG && RB_UNLIKELY(! ptr)) {
/* :BEWARE: @shyouhei thinks that currently, there are rooms for this
Expand All @@ -441,14 +408,17 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline char *
RSTRING_END(VALUE str)
{
struct RString buf = rbimpl_rstring_getmem(str);
char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
RSTRING(str)->as.heap.ptr :
RSTRING(str)->as.embed.ary;
long len = RSTRING_LEN(str);

if (RUBY_DEBUG && RB_UNLIKELY(! buf.as.heap.ptr)) {
if (RUBY_DEBUG && RB_UNLIKELY(!ptr)) {
/* Ditto. */
rb_debug_rstring_null_ptr("RSTRING_END");
}

return &buf.as.heap.ptr[buf.len];
return &ptr[len];
}

RBIMPL_ATTR_ARTIFICIAL()
Expand Down Expand Up @@ -477,16 +447,7 @@ RSTRING_LENINT(VALUE str)
* @param ptrvar Variable where its contents is stored.
* @param lenvar Variable where its length is stored.
*/
#ifdef HAVE_STMT_AND_DECL_IN_EXPR
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
__extension__ ({ \
struct RString rbimpl_str = rbimpl_rstring_getmem(str); \
(ptrvar) = rbimpl_str.as.heap.ptr; \
(lenvar) = rbimpl_str.len; \
})
#else
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
((ptrvar) = RSTRING_PTR(str), \
(lenvar) = RSTRING_LEN(str))
#endif /* HAVE_STMT_AND_DECL_IN_EXPR */
#endif /* RBIMPL_RSTRING_H */
4 changes: 1 addition & 3 deletions spec/bundler/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,11 @@ def required_ruby_version=(*reqs)
end

class BundlerBuilder
SPEC = Gem::Specification.load(Spec::Path.relative_gemspec)

def initialize(context, name, version)
raise "can only build bundler" unless name == "bundler"

@context = context
@spec = SPEC.dup
@spec = Spec::Path.loaded_gemspec.dup
@spec.version = version || Bundler::VERSION
end

Expand Down
11 changes: 4 additions & 7 deletions spec/ruby/core/math/lgamma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
Math.lgamma(0).should == [infinity_value, 1]
end

platform_is_not :windows do
it "returns [Infinity, 1] when passed -1" do
Math.lgamma(-1).should == [infinity_value, 1]
end
it "returns [Infinity, ...] when passed -1" do
Math.lgamma(-1)[0].should == infinity_value
end

it "returns [Infinity, -1] when passed -0.0" do
Expand Down Expand Up @@ -47,8 +45,7 @@
Math.lgamma(infinity_value).should == [infinity_value, 1]
end

it "returns [NaN, 1] when passed NaN" do
Math.lgamma(nan_value)[0].nan?.should be_true
Math.lgamma(nan_value)[1].should == 1
it "returns [NaN, ...] when passed NaN" do
Math.lgamma(nan_value)[0].should.nan?
end
end
12 changes: 11 additions & 1 deletion test/ruby/test_math.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,21 @@ def test_lgamma
assert_float_and_int([Math.log(6), 1], Math.lgamma(4))

assert_raise_with_message(Math::DomainError, /\blgamma\b/) { Math.lgamma(-Float::INFINITY) }

x, sign = Math.lgamma(+0.0)
mesg = "Math.lgamma(+0.0) should be [INF, +1]"
assert_infinity(x, mesg)
assert_equal(+1, sign, mesg)

x, sign = Math.lgamma(-0.0)
mesg = "Math.lgamma(-0.0) should be [INF, -1]"
assert_infinity(x, mesg)
assert_equal(-1, sign, mesg)
x, sign = Math.lgamma(Float::NAN)

x, = Math.lgamma(-1)
assert_infinity(x, "Math.lgamma(-1) should be +INF")

x, = Math.lgamma(Float::NAN)
assert_nan(x)
end

Expand Down