[前][次][番号順一覧][スレッド一覧]

ruby-changes:25123

From: usa <ko1@a...>
Date: Sat, 13 Oct 2012 23:23:52 +0900 (JST)
Subject: [ruby-changes:25123] usa:r37175 (trunk): * regparse.c (parse_char_class): should match with a hyphen after a

usa	2012-10-13 23:23:40 +0900 (Sat, 13 Oct 2012)

  New Revision: 37175

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37175

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/regparse.c
    trunk/test/ruby/test_regexp.rb

Index: regparse.c
===================================================================
--- regparse.c	(revision 37174)
+++ regparse.c	(revision 37175)
@@ -4706,7 +4706,7 @@
 
 	if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
 	  CC_ESC_WARN(env, (UChar* )"-");
-	  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;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37174)
+++ ChangeLog	(revision 37175)
@@ -1,3 +1,22 @@
+Sat Oct 13 23:15:39 2012  NAKAMURA Usaku  <usa@r...>
+
+	* 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 03:01:53 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* file.c (realpath_rec): prevent link from GC while link_names refers
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 37174)
+++ test/ruby/test_regexp.rb	(revision 37175)
@@ -542,17 +542,17 @@
     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)
@@ -732,7 +732,7 @@
     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"])
@@ -912,11 +912,11 @@
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]