diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-11-04 13:33:32 -0800 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-04 21:34:04 +0000 |
| commit | fffa4671a4cfaea6e6eb2bc6a5dde14ad1a5a400 (patch) | |
| tree | 06b31881a435e2afc38a00fa4d8dd96a90d3242b | |
| parent | 962aa14f240f43ca3bf3516432f7c3a6fbd1d3ff (diff) | |
[ruby/strscan] Resurrect a method that has not been obsolete
(https://github.com/ruby/strscan/pull/169)
Partially revert https://github.com/ruby/strscan/pull/168 because
strscan_rest_p did not have `rb_warning("StringScanner#rest? is
obsolete")`.
It is actively used by the latest tzinfo.gem, and we shouldn't remove it
without deprecating it.
https://github.com/ruby/strscan/commit/f3fdf21189
| -rw-r--r-- | ext/strscan/strscan.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 8842bc8e3e..e2b827c63c 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -122,6 +122,7 @@ static VALUE strscan_scan_base10_integer _((VALUE self)); static VALUE strscan_unscan _((VALUE self)); static VALUE strscan_bol_p _((VALUE self)); static VALUE strscan_eos_p _((VALUE self)); +static VALUE strscan_rest_p _((VALUE self)); static VALUE strscan_matched_p _((VALUE self)); static VALUE strscan_matched _((VALUE self)); static VALUE strscan_matched_size _((VALUE self)); @@ -1472,6 +1473,29 @@ strscan_eos_p(VALUE self) } /* + * call-seq: + * rest? + * + * Returns true if and only if there is more data in the string. See #eos?. + * This method is obsolete; use #eos? instead. + * + * s = StringScanner.new('test string') + * # These two are opposites + * s.eos? # => false + * s.rest? # => true + */ + + /* :nodoc: */ +static VALUE +strscan_rest_p(VALUE self) +{ + struct strscanner *p; + + GET_SCANNER(self, p); + return EOS_P(p) ? Qfalse : Qtrue; +} + +/* * :markup: markdown * :include: strscan/link_refs.txt * @@ -2237,6 +2261,7 @@ Init_strscan(void) rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0); rb_alias(StringScanner, rb_intern("bol?"), rb_intern("beginning_of_line?")); rb_define_method(StringScanner, "eos?", strscan_eos_p, 0); + rb_define_method(StringScanner, "rest?", strscan_rest_p, 0); rb_define_method(StringScanner, "matched?", strscan_matched_p, 0); rb_define_method(StringScanner, "matched", strscan_matched, 0); |
