diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-14 08:36:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-14 08:36:49 +0000 |
commit | 92e803c9c8e7cebe937c5ba05312417dbf99d688 (patch) | |
tree | 01475f3c7b7fe9a38d1d563e8358f25a19e41cb3 /re.c | |
parent | 1301d1f5bccc10daf93c816ef4e177776d0668de (diff) | |
download | ruby-92e803c9c8e7cebe937c5ba05312417dbf99d688.tar.gz |
variable.c: matched backrefs only
* variable.c (rb_f_global_variables): add matched back references
only, as well as defiend? operator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -1265,6 +1265,33 @@ rb_match_busy(VALUE match) FL_SET(match, MATCH_BUSY); } +int +rb_match_count(VALUE match) +{ + struct re_registers *regs; + if (NIL_P(match)) return -1; + regs = RMATCH_REGS(match); + if (!regs) return -1; + return regs->num_regs; +} + +int +rb_match_nth_defined(int nth, VALUE match) +{ + struct re_registers *regs; + if (NIL_P(match)) return FALSE; + regs = RMATCH_REGS(match); + if (!regs) return FALSE; + if (nth >= regs->num_regs) { + return FALSE; + } + if (nth < 0) { + nth += regs->num_regs; + if (nth <= 0) return FALSE; + } + return (BEG(nth) != -1); +} + static void match_set_string(VALUE m, VALUE string, long pos, long len) { |