Removed Process::Status#& and Process::Status#>>

This commit is contained in:
Hiroshi SHIBATA 2024-12-24 15:27:57 +09:00
parent 8f11d6cbe2
commit 9967eccc54
Notes: git 2024-12-25 11:10:37 +00:00
4 changed files with 51 additions and 159 deletions

105
process.c
View file

@ -873,109 +873,6 @@ pst_equal(VALUE st1, VALUE st2)
}
/*
* call-seq:
* stat & mask -> integer
*
* This method is deprecated as #to_i value is system-specific; use
* predicate methods like #exited? or #stopped?, or getters like #exitstatus
* or #stopsig.
*
* Returns the logical AND of the value of #to_i with +mask+:
*
* `cat /nop`
* stat = $? # => #<Process::Status: pid 1155508 exit 1>
* sprintf('%x', stat.to_i) # => "100"
* stat & 0x00 # => 0
*
* ArgumentError is raised if +mask+ is negative.
*/
static VALUE
pst_bitand(VALUE st1, VALUE st2)
{
int status = PST2INT(st1);
int mask = NUM2INT(st2);
if (mask < 0) {
rb_raise(rb_eArgError, "negative mask value: %d", mask);
}
#define WARN_SUGGEST(suggest) \
rb_warn_deprecated_to_remove_at(3.5, "Process::Status#&", suggest)
switch (mask) {
case 0x80:
WARN_SUGGEST("Process::Status#coredump?");
break;
case 0x7f:
WARN_SUGGEST("Process::Status#signaled? or Process::Status#termsig");
break;
case 0xff:
WARN_SUGGEST("Process::Status#exited?, Process::Status#stopped? or Process::Status#coredump?");
break;
case 0xff00:
WARN_SUGGEST("Process::Status#exitstatus or Process::Status#stopsig");
break;
default:
WARN_SUGGEST("other Process::Status predicates");
break;
}
#undef WARN_SUGGEST
status &= mask;
return INT2NUM(status);
}
/*
* call-seq:
* stat >> places -> integer
*
* This method is deprecated as #to_i value is system-specific; use
* predicate methods like #exited? or #stopped?, or getters like #exitstatus
* or #stopsig.
*
* Returns the value of #to_i, shifted +places+ to the right:
*
* `cat /nop`
* stat = $? # => #<Process::Status: pid 1155508 exit 1>
* stat.to_i # => 256
* stat >> 1 # => 128
* stat >> 2 # => 64
*
* ArgumentError is raised if +places+ is negative.
*/
static VALUE
pst_rshift(VALUE st1, VALUE st2)
{
int status = PST2INT(st1);
int places = NUM2INT(st2);
if (places < 0) {
rb_raise(rb_eArgError, "negative shift value: %d", places);
}
#define WARN_SUGGEST(suggest) \
rb_warn_deprecated_to_remove_at(3.5, "Process::Status#>>", suggest)
switch (places) {
case 7:
WARN_SUGGEST("Process::Status#coredump?");
break;
case 8:
WARN_SUGGEST("Process::Status#exitstatus or Process::Status#stopsig");
break;
default:
WARN_SUGGEST("other Process::Status attributes");
break;
}
#undef WARN_SUGGEST
status >>= places;
return INT2NUM(status);
}
/*
* call-seq:
* stopped? -> true or false
@ -9346,8 +9243,6 @@ InitVM_process(void)
rb_define_singleton_method(rb_cProcessStatus, "wait", rb_process_status_waitv, -1);
rb_define_method(rb_cProcessStatus, "==", pst_equal, 1);
rb_define_method(rb_cProcessStatus, "&", pst_bitand, 1);
rb_define_method(rb_cProcessStatus, ">>", pst_rshift, 1);
rb_define_method(rb_cProcessStatus, "to_i", pst_to_i, 0);
rb_define_method(rb_cProcessStatus, "to_s", pst_to_s, 0);
rb_define_method(rb_cProcessStatus, "inspect", pst_inspect, 0);