Negative value to Process::Status method for compatibility
This commit is contained in:
parent
e50fcca9a7
commit
efe5e6e8d0
Notes:
git
2023-09-14 07:41:31 +00:00
19
process.c
19
process.c
@ -877,12 +877,19 @@ pst_equal(VALUE st1, VALUE st2)
|
|||||||
* sprintf('%x', stat.to_i) # => "100"
|
* sprintf('%x', stat.to_i) # => "100"
|
||||||
* stat & 0x00 # => 0
|
* stat & 0x00 # => 0
|
||||||
*
|
*
|
||||||
|
* ArgumentError is raised if +mask+ is negative.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
pst_bitand(VALUE st1, VALUE st2)
|
pst_bitand(VALUE st1, VALUE st2)
|
||||||
{
|
{
|
||||||
int status = PST2INT(st1) & NUM2INT(st2);
|
int status = PST2INT(st1);
|
||||||
|
int mask = NUM2INT(st2);
|
||||||
|
|
||||||
|
if (mask < 0) {
|
||||||
|
rb_raise(rb_eArgError, "negative mask value: %d", mask);
|
||||||
|
}
|
||||||
|
status &= mask;
|
||||||
|
|
||||||
return INT2NUM(status);
|
return INT2NUM(status);
|
||||||
}
|
}
|
||||||
@ -900,13 +907,19 @@ pst_bitand(VALUE st1, VALUE st2)
|
|||||||
* stat >> 1 # => 128
|
* stat >> 1 # => 128
|
||||||
* stat >> 2 # => 64
|
* stat >> 2 # => 64
|
||||||
*
|
*
|
||||||
* The behavior is unspecified if +places+ is negative.
|
* ArgumentError is raised if +places+ is negative.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
pst_rshift(VALUE st1, VALUE st2)
|
pst_rshift(VALUE st1, VALUE st2)
|
||||||
{
|
{
|
||||||
int status = PST2INT(st1) >> NUM2INT(st2);
|
int status = PST2INT(st1);
|
||||||
|
int places = NUM2INT(st2);
|
||||||
|
|
||||||
|
if (places < 0) {
|
||||||
|
rb_raise(rb_eArgError, "negative shift value: %d", places);
|
||||||
|
}
|
||||||
|
status >>= places;
|
||||||
|
|
||||||
return INT2NUM(status);
|
return INT2NUM(status);
|
||||||
}
|
}
|
||||||
|
@ -1453,6 +1453,9 @@ class TestProcess < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal(s.to_i & 0x55555555, s & 0x55555555)
|
assert_equal(s.to_i & 0x55555555, s & 0x55555555)
|
||||||
assert_equal(s.to_i >> 1, s >> 1)
|
assert_equal(s.to_i >> 1, s >> 1)
|
||||||
|
assert_raise(ArgumentError) do
|
||||||
|
s >> -1
|
||||||
|
end
|
||||||
assert_equal(false, s.stopped?)
|
assert_equal(false, s.stopped?)
|
||||||
assert_equal(nil, s.stopsig)
|
assert_equal(nil, s.stopsig)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user