aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-14 08:36:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-14 08:36:49 +0000
commitb6a69b9e762e1bb2e81c2b978f2635166fee49c3 (patch)
tree01475f3c7b7fe9a38d1d563e8358f25a19e41cb3 /re.c
parent8801161f73398580d54760239553065caf28c9bb (diff)
downloadruby-b6a69b9e762e1bb2e81c2b978f2635166fee49c3.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.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/re.c b/re.c
index d827e05245..f8ea30f393 100644
--- a/re.c
+++ b/re.c
@@ -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)
{