Skip to content

Commit

Permalink
merge revision(s) 37175:
Browse files Browse the repository at this point in the history
	* regparse.c (parse_char_class): should match with a hyphen after a
	  range in a character class.

	* test/ruby/test_regexp.rb (TestRegexp#test_char_class): fixed wrong
	  test.

	* test/ruby/test_regexp.rb (TestRegexp#check): now can accept the
	  error message.

	* test/ruby/test_regexp.rb
	  (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): renamed
	  because the previous name was wrong.

	* test/ruby/test_regexp.rb
	  (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): added
	  more test pattern.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Oct 13, 2012
1 parent 88e264d commit c3e874d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
19 changes: 19 additions & 0 deletions ChangeLog
@@ -1,3 +1,22 @@
Sun Oct 14 01:21:42 2012 NAKAMURA Usaku <usa@ruby-lang.org>

* regparse.c (parse_char_class): should match with a hyphen after a
range in a character class.

* test/ruby/test_regexp.rb (TestRegexp#test_char_class): fixed wrong
test.

* test/ruby/test_regexp.rb (TestRegexp#check): now can accept the
error message.

* test/ruby/test_regexp.rb
(TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): renamed
because the previous name was wrong.

* test/ruby/test_regexp.rb
(TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): added
more test pattern.

Sat Oct 13 01:41:38 2012 NAKAMURA Usaku <usa@ruby-lang.org>

* regparse.c (parse_char_class): also need to check the type of token
Expand Down
5 changes: 1 addition & 4 deletions regparse.c
Expand Up @@ -4491,10 +4491,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,

if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
CC_ESC_WARN(env, (UChar* )"-");
if (tok->type == TK_CHAR_TYPE)
goto next_class; /* [0-9-\s] is allowed as [0-9\-\s] */
else
goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */
goto range_end_val; /* [0-9-a] is allowed as [0-9\-a] */
}
r = ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS;
goto err;
Expand Down
14 changes: 7 additions & 7 deletions test/ruby/test_regexp.rb
Expand Up @@ -498,17 +498,17 @@ def test_taint
assert(m.tainted?)
end

def check(re, ss, fs = [])
def check(re, ss, fs = [], msg = nil)
re = Regexp.new(re) unless re.is_a?(Regexp)
ss = [ss] unless ss.is_a?(Array)
ss.each do |e, s|
s ||= e
assert_match(re, s)
assert_match(re, s, msg)
m = re.match(s)
assert_equal(e, m[0])
assert_equal(e, m[0], msg)
end
fs = [fs] unless fs.is_a?(Array)
fs.each {|s| assert_no_match(re, s) }
fs.each {|s| assert_no_match(re, s, msg) }
end

def failcheck(re)
Expand Down Expand Up @@ -688,7 +688,7 @@ def test_char_class
check(/\A[a-b-]\z/, %w(a b -), ["", "c"])
check('\A[a-b-&&\w]\z', %w(a b), ["", "-"])
check('\A[a-b-&&\W]\z', "-", ["", "a", "b"])
check('\A[a-c-e]\z', %w(a b c e), %w(- d)) # is it OK?
check('\A[a-c-e]\z', %w(a b c e -), %w(d))
check(/\A[a-f&&[^b-c]&&[^e]]\z/, %w(a d f), %w(b c e g 0))
check(/\A[[^b-c]&&[^e]&&a-f]\z/, %w(a d f), %w(b c e g 0))
check(/\A[\n\r\t]\z/, ["\n", "\r", "\t"])
Expand Down Expand Up @@ -868,11 +868,11 @@ def test_invalid_escape_error
assert_equal(1, error.message.scan(/.*invalid .*escape.*/i).size, bug3539)
end

def test_raw_hyphen_and_type_char_after_range
def test_raw_hyphen_and_tk_char_type_after_range
bug6853 = '[ruby-core:47115]'
begin
verbose, $VERBOSE = $VERBOSE, nil
assert_match(/[0-1-\s]/, ' ', bug6853)
check(/[0-1-\s]/, [' ', '-'], [], bug6853)
ensure
$VERBOSE = verbose
end
Expand Down
6 changes: 3 additions & 3 deletions version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "1.9.3"
#define RUBY_PATCHLEVEL 288
#define RUBY_PATCHLEVEL 289

#define RUBY_RELEASE_DATE "2012-10-13"
#define RUBY_RELEASE_DATE "2012-10-14"
#define RUBY_RELEASE_YEAR 2012
#define RUBY_RELEASE_MONTH 10
#define RUBY_RELEASE_DAY 13
#define RUBY_RELEASE_DAY 14

#include "ruby/version.h"

Expand Down

0 comments on commit c3e874d

Please sign in to comment.