match_at 1 → 2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91f41f9404f9926d531ef6c827e0617156bb71bf
4
- data.tar.gz: 28ec30a32bfd55544e760881dd91fcb8ed2a16b9
3
+ metadata.gz: b20934cbff3ba306998d01baf791fd6dd2ea9b4b
4
+ data.tar.gz: fe95877702b2dadaa6df96ce90ce9d12286efc6d
5
5
  SHA512:
6
- metadata.gz: a3a19f48b310d85009e46fe2ba8bc6ba517f2b42576428da4ca57c68743171b81c1160be6093abfe6635c3b44343952a3e49b41bb04da07a44c553004070bc76
7
- data.tar.gz: 1952562c10d176e24f0de5fe980447ce8ca94f9b1d8f87e4160f8c86f0541831bc0ae9e9c9172c8ad16b888d3c5068917303392f7c5c87307ca9a1c0de383052
6
+ metadata.gz: ad86d7bd9683a9fe869a7c29e22162a15c45d3344a0b7a9456d373366efa3f3362c4b5576f659053dbd991f952d581389d813cfb73b99c1f36f261ee48a48778
7
+ data.tar.gz: bc97cfe8229b2a181d6ed9cb7ac6a18013673f8bf52a8815fc13ac05a2fa9ee850422df580afa5ade387ac6c595e87a2ae465ec0fdd6be6c1e603346d94c1d02
data/.gitignore CHANGED
@@ -26,6 +26,7 @@ Gemfile.lock
26
26
  coverage
27
27
  doc
28
28
  stackprof.dump
29
+ pkg
29
30
  tmp
30
31
  vendor
31
32
  *.so
@@ -24,4 +24,4 @@
24
24
  # SOFTWARE.
25
25
 
26
26
  require 'mkmf'
27
- create_makefile 'match_at'
27
+ create_makefile 'match_at/match_at'
@@ -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;
@@ -24,4 +24,4 @@
24
24
  # SOFTWARE.
25
25
  ;
26
26
 
27
- MatchAt::VERSION = 1
27
+ MatchAt::VERSION = 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match_at
3
3
  version: !ruby/object:Gem::Version
4
- version: '1'
4
+ version: '2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urabe, Shyouhei