Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix a bug of Regexp#match. Regexp#match(str, pos) was broken when was…

… passed a pos.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

str = 'This is an example string'
reg = Regexp.new(/\w+/)
assert_equal("is", reg.match(str, 4)[0])
assert_equal("an", reg.match(str, 8)[0])
assert_equal("g", reg.match(str, -1)[0])

puts :ok
}}}
  • Loading branch information...
commit f04df77691d7f2e3bbd5005183d34c9ed972274c 1 parent 724676f
@Watson1978 Watson1978 authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  re.h
View
2  re.h
@@ -70,7 +70,7 @@ rb_match_result_t *rb_reg_match_results(VALUE match, int *count);
static inline int
rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, bool reverse)
{
- return reverse ? -pos : rb_str_chars_len(str) - pos;
+ return reverse ? -pos : pos;
}
#if defined(__cplusplus)
Please sign in to comment.
Something went wrong with that request. Please try again.