match_at 1 → 2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/ext/match_at/extconf.rb +1 -1
- data/ext/match_at/match_at.c +22 -5
- data/lib/match_at/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b20934cbff3ba306998d01baf791fd6dd2ea9b4b
|
4
|
+
data.tar.gz: fe95877702b2dadaa6df96ce90ce9d12286efc6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad86d7bd9683a9fe869a7c29e22162a15c45d3344a0b7a9456d373366efa3f3362c4b5576f659053dbd991f952d581389d813cfb73b99c1f36f261ee48a48778
|
7
|
+
data.tar.gz: bc97cfe8229b2a181d6ed9cb7ac6a18013673f8bf52a8815fc13ac05a2fa9ee850422df580afa5ade387ac6c595e87a2ae465ec0fdd6be6c1e603346d94c1d02
|
data/.gitignore
CHANGED
data/ext/match_at/extconf.rb
CHANGED
data/ext/match_at/match_at.c
CHANGED
@@ -29,12 +29,33 @@ static VALUE match_at(VALUE RB_UNUSED_VAR(mod), VALUE str, VALUE rexp, VALUE pos
|
|
29
29
|
static VALUE match_at_p(VALUE RB_UNUSED_VAR(mod), VALUE str, VALUE rexp, VALUE pos);
|
30
30
|
static bool do_match(VALUE str, VALUE rexp, VALUE pos, OnigRegion *region);
|
31
31
|
|
32
|
+
/**
|
33
|
+
* Match the rexp against str's position pos. This is lightweight because no
|
34
|
+
* MatchData is allocated.
|
35
|
+
*
|
36
|
+
* @param str [String] target string.
|
37
|
+
* @param rexp [Regexp] pattern to match.
|
38
|
+
* @param pos [Integer] str's index, in character.
|
39
|
+
* @return [true] successful match.
|
40
|
+
* @return [false] failure in match.
|
41
|
+
*/
|
32
42
|
VALUE
|
33
43
|
match_at_p(VALUE mod, VALUE str, VALUE rexp, VALUE pos)
|
34
44
|
{
|
35
45
|
return do_match(str, rexp, pos, NULL) ? Qtrue : Qfalse;
|
36
46
|
}
|
37
47
|
|
48
|
+
/**
|
49
|
+
* Try to construct a MatchData at str's pos position. If that's possible
|
50
|
+
* return the allocated MatchData. Otherwise, returns nil.
|
51
|
+
*
|
52
|
+
* @note It does not update `$~`.
|
53
|
+
* @param str [String] target string.
|
54
|
+
* @param rexp [Regexp] pattern to match.
|
55
|
+
* @param pos [Integer] str's index, in character.
|
56
|
+
* @return [MatchData] successful match.
|
57
|
+
* @return [nil] failure in match.
|
58
|
+
*/
|
38
59
|
VALUE
|
39
60
|
match_at(VALUE mod, VALUE str, VALUE rexp, VALUE pos)
|
40
61
|
{
|
@@ -61,11 +82,7 @@ match_at(VALUE mod, VALUE str, VALUE rexp, VALUE pos)
|
|
61
82
|
}
|
62
83
|
|
63
84
|
bool
|
64
|
-
do_match(
|
65
|
-
VALUE vstr,
|
66
|
-
VALUE vreg,
|
67
|
-
VALUE vpos,
|
68
|
-
OnigRegion *region)
|
85
|
+
do_match(VALUE vstr, VALUE vreg, VALUE vpos, OnigRegion *region)
|
69
86
|
{
|
70
87
|
const char *str;
|
71
88
|
const char *end;
|
data/lib/match_at/version.rb
CHANGED