match_at 2 → 3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/ext/match_at/match_at.c +24 -11
 - data/lib/match_at/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d5eee137912b36f2e3d5cd1338d6519bbf530bd3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9d9cffc18535c9cf277455dfc17b6964bce74b7b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c144b85c5c41c5aea39e86d0bda594ba5b812ee45d3cf27960d28ad1efc5e19049b568b542a81556f5dbe8a4c921fb7bfa1aaab01e57638014084be8bf66397e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bd71a51305170776436d503ebc1cff1e0f8fe7ee236f1a1f993a568b43c83669215a281e38dbed95861e961e4193d668d8c17a493056b8b252263208561bccf9
         
     | 
    
        data/ext/match_at/match_at.c
    CHANGED
    
    | 
         @@ -27,7 +27,7 @@ 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
            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 
     | 
    
         
            -
            static  
     | 
| 
      
 30 
     | 
    
         
            +
            static OnigPosition do_match(VALUE str, VALUE rexp, VALUE pos, OnigRegion *region);
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
            /**
         
     | 
| 
       33 
33 
     | 
    
         
             
             * Match the rexp  against str's position pos.  This is  lightweight because no
         
     | 
| 
         @@ -42,7 +42,22 @@ static bool do_match(VALUE str, VALUE rexp, VALUE pos, OnigRegion *region); 
     | 
|
| 
       42 
42 
     | 
    
         
             
            VALUE
         
     | 
| 
       43 
43 
     | 
    
         
             
            match_at_p(VALUE mod, VALUE str, VALUE rexp, VALUE pos)
         
     | 
| 
       44 
44 
     | 
    
         
             
            {
         
     | 
| 
       45 
     | 
    
         
            -
                 
     | 
| 
      
 45 
     | 
    
         
            +
                OnigPosition result = do_match(str, rexp, pos, NULL);
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                if (result >= 0) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    long n           = NUM2LONG(pos);
         
     | 
| 
      
 49 
     | 
    
         
            +
                    rb_encoding *enc = rb_enc_get(str);
         
     | 
| 
      
 50 
     | 
    
         
            +
                    const char *beg  = rb_string_value_ptr(&str);
         
     | 
| 
      
 51 
     | 
    
         
            +
                    const char *end  = RSTRING_END(str);
         
     | 
| 
      
 52 
     | 
    
         
            +
                    const char *ptr  = rb_enc_nth(beg, end, n, enc);
         
     | 
| 
      
 53 
     | 
    
         
            +
                    const char *term = &ptr[result];
         
     | 
| 
      
 54 
     | 
    
         
            +
                    long len         = rb_enc_strlen(ptr, term, enc);
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    return LONG2NUM(len);
         
     | 
| 
      
 57 
     | 
    
         
            +
                }
         
     | 
| 
      
 58 
     | 
    
         
            +
                else {
         
     | 
| 
      
 59 
     | 
    
         
            +
                    return Qnil;
         
     | 
| 
      
 60 
     | 
    
         
            +
                }
         
     | 
| 
       46 
61 
     | 
    
         
             
            }
         
     | 
| 
       47 
62 
     | 
    
         | 
| 
       48 
63 
     | 
    
         
             
            /**
         
     | 
| 
         @@ -59,10 +74,11 @@ match_at_p(VALUE mod, VALUE str, VALUE rexp, VALUE pos) 
     | 
|
| 
       59 
74 
     | 
    
         
             
            VALUE
         
     | 
| 
       60 
75 
     | 
    
         
             
            match_at(VALUE mod, VALUE str, VALUE rexp, VALUE pos)
         
     | 
| 
       61 
76 
     | 
    
         
             
            {
         
     | 
| 
       62 
     | 
    
         
            -
                OnigRegion region 
     | 
| 
       63 
     | 
    
         
            -
                VALUE ret 
     | 
| 
      
 77 
     | 
    
         
            +
                OnigRegion region   = { 0 };
         
     | 
| 
      
 78 
     | 
    
         
            +
                VALUE ret           = Qnil;
         
     | 
| 
      
 79 
     | 
    
         
            +
                OnigPosition result = do_match(str, rexp, pos, ®ion);
         
     | 
| 
       64 
80 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                if ( 
     | 
| 
      
 81 
     | 
    
         
            +
                if (result >= 0) {
         
     | 
| 
       66 
82 
     | 
    
         
             
                    int err;
         
     | 
| 
       67 
83 
     | 
    
         
             
                    ret = rb_funcall(rb_cMatch, rb_intern("allocate"), 0);
         
     | 
| 
       68 
84 
     | 
    
         
             
                    err = rb_reg_region_copy(RMATCH_REGS(ret), ®ion);
         
     | 
| 
         @@ -81,7 +97,7 @@ match_at(VALUE mod, VALUE str, VALUE rexp, VALUE pos) 
     | 
|
| 
       81 
97 
     | 
    
         
             
                return ret;
         
     | 
| 
       82 
98 
     | 
    
         
             
            }
         
     | 
| 
       83 
99 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
            OnigPosition
         
     | 
| 
       85 
101 
     | 
    
         
             
            do_match(VALUE vstr, VALUE vreg, VALUE vpos, OnigRegion *region)
         
     | 
| 
       86 
102 
     | 
    
         
             
            {
         
     | 
| 
       87 
103 
     | 
    
         
             
                const char *str;
         
     | 
| 
         @@ -119,11 +135,8 @@ do_match(VALUE vstr, VALUE vreg, VALUE vpos, OnigRegion *region) 
     | 
|
| 
       119 
135 
     | 
    
         
             
            	}
         
     | 
| 
       120 
136 
     | 
    
         
             
                }
         
     | 
| 
       121 
137 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                if (result >= 0) {
         
     | 
| 
       123 
     | 
    
         
            -
                    return  
     | 
| 
       124 
     | 
    
         
            -
                }
         
     | 
| 
       125 
     | 
    
         
            -
                else if (result == ONIG_MISMATCH) {
         
     | 
| 
       126 
     | 
    
         
            -
                    return false;
         
     | 
| 
      
 138 
     | 
    
         
            +
                if ((result >= 0) || (result == ONIG_MISMATCH)) {
         
     | 
| 
      
 139 
     | 
    
         
            +
                    return result;
         
     | 
| 
       127 
140 
     | 
    
         
             
                }
         
     | 
| 
       128 
141 
     | 
    
         
             
                else {
         
     | 
| 
       129 
142 
     | 
    
         
             
                    OnigUChar err[ONIG_MAX_ERROR_MESSAGE_LEN] = { 0 };
         
     | 
    
        data/lib/match_at/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: match_at
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: ' 
     | 
| 
      
 4 
     | 
    
         
            +
              version: '3'
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Urabe, Shyouhei
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-08- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-08-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |