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

ruby-changes:2125

From: ko1@a...
Date: 4 Oct 2007 16:32:00 +0900
Subject: [ruby-changes:2125] matz - Ruby:r13616 (trunk): * re.c (kcode_setter): Perl-ish global variable `$=' no longer

matz	2007-10-04 16:31:50 +0900 (Thu, 04 Oct 2007)

  New Revision: 13616

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/re.h
    trunk/re.c

  Log:
    * re.c (kcode_setter): Perl-ish global variable `$=' no longer
      effective.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13616&r2=13615
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/re.h?r1=13616&r2=13615
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=13616&r2=13615

Index: include/ruby/re.h
===================================================================
--- include/ruby/re.h	(revision 13615)
+++ include/ruby/re.h	(revision 13616)
@@ -43,8 +43,6 @@
 void rb_match_busy(VALUE);
 VALUE rb_reg_quote(VALUE);
 
-RUBY_EXTERN int ruby_ignorecase;
-
 #if defined(__cplusplus)
 #if 0
 { /* satisfy cc-mode */
Index: re.c
===================================================================
--- re.c	(revision 13615)
+++ re.c	(revision 13616)
@@ -94,9 +94,6 @@
 int
 rb_memcmp(const void *p1, const void *p2, long len)
 {
-    if (!ruby_ignorecase) {
-	return memcmp(p1, p2, len);
-    }
     return rb_memcicmp(p1, p2, len);
 }
 
@@ -120,38 +117,20 @@
     d = sizeof(hx) * CHAR_BIT - 1;
     if (d > m) d = m;
 
-    if (ruby_ignorecase) {
-	if (n == m) {
-	    return rb_memcicmp(x, s, m) == 0 ? 0 : -1;
-	}
-	/* Prepare hash value */
-	for (hy = hx = i = 0; i < d; ++i) {
-	    hx = KR_REHASH(0, casetable[x[i]], hx);
-	    hy = KR_REHASH(0, casetable[s[i]], hy);
-	}
-	/* Searching */
-	while (hx != hy || rb_memcicmp(x, s, m)) {
-	    if (s >= e) return -1;
-	    hy = KR_REHASH(casetable[*s], casetable[*(s+d)], hy);
-	    s++;
-	}
+    if (n == m) {
+	return memcmp(x, s, m) == 0 ? 0 : -1;
     }
-    else {
-	if (n == m) {
-	    return memcmp(x, s, m) == 0 ? 0 : -1;
-	}
-	/* Prepare hash value */
-	for (hy = hx = i = 0; i < d; ++i) {
-	    hx = KR_REHASH(0, x[i], hx);
-	    hy = KR_REHASH(0, s[i], hy);
-	}
-	/* Searching */
-	while (hx != hy || memcmp(x, s, m)) {
-	    if (s >= e) return -1;
-	    hy = KR_REHASH(*s, *(s+d), hy);
-	    s++;
-	}
+    /* Prepare hash value */
+    for (hy = hx = i = 0; i < d; ++i) {
+	hx = KR_REHASH(0, x[i], hx);
+	hy = KR_REHASH(0, s[i], hy);
     }
+    /* Searching */
+    while (hx != hy || memcmp(x, s, m)) {
+	if (s >= e) return -1;
+	hy = KR_REHASH(*s, *(s+d), hy);
+	s++;
+    }
     return s-y;
 }
 
@@ -906,7 +885,6 @@
     FL_SET(match, MATCH_BUSY);
 }
 
-int ruby_ignorecase;
 static int may_need_recompile;
 
 static void
@@ -918,17 +896,6 @@
     rb_reg_check(re);
     state = FL_TEST(re, REG_CASESTATE);
     /* ignorecase status */
-    if (ruby_ignorecase && !state) {
-	FL_SET(re, REG_CASESTATE);
-	RREGEXP(re)->ptr->options |= ONIG_OPTION_IGNORECASE;
-	need_recompile = 1;
-    }
-    if (!ruby_ignorecase && state) {
-	FL_UNSET(re, REG_CASESTATE);
-	RREGEXP(re)->ptr->options &= ~ONIG_OPTION_IGNORECASE;
-	need_recompile = 1;
-    }
-
     if (!FL_TEST(re, KCODE_FIXED) &&
 	(RBASIC(re)->flags & KCODE_MASK) != reg_kcode) {
 	need_recompile = 1;
@@ -1516,10 +1483,6 @@
     if (options & ARG_KCODE_MASK) {
 	kcode_set_option((VALUE)re);
     }
-    if (ruby_ignorecase) {
-	options |= ONIG_OPTION_IGNORECASE;
-	FL_SET(re, REG_CASESTATE);
-    }
     re->ptr = make_regexp(s, len, options & ARG_REG_OPTION_MASK, err);
     if (!re->ptr) return -1;
     re->str = ALLOC_N(char, len+1);
@@ -1580,7 +1543,6 @@
     return re;
 }
 
-static int case_cache;
 static int kcode_cache;
 static VALUE reg_cache;
 
@@ -1589,14 +1551,12 @@
 {
     volatile VALUE save_str = str;
     if (reg_cache && RREGEXP(reg_cache)->len == RSTRING_LEN(str)
-	&& case_cache == ruby_ignorecase
 	&& kcode_cache == reg_kcode
 	&& memcmp(RREGEXP(reg_cache)->str, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
 	return reg_cache;
 
-    case_cache = ruby_ignorecase;
     kcode_cache = reg_kcode;
-    return reg_cache = rb_reg_new(save_str, ruby_ignorecase);
+    return reg_cache = rb_reg_new(save_str, 0);
 }
 
 static int
@@ -2351,22 +2311,19 @@
 static void
 kcode_setter(VALUE val)
 {
-    may_need_recompile = 1;
-    rb_set_kcode(StringValuePtr(val));
+    rb_warning("$= no longer effective");
 }
 
 static VALUE
 ignorecase_getter(void)
 {
-    return ruby_ignorecase?Qtrue:Qfalse;
+    return Qfalse;
 }
 
 static void
 ignorecase_setter(VALUE val, ID id)
 {
     rb_warn("modifying %s is deprecated", rb_id2name(id));
-    may_need_recompile = 1;
-    ruby_ignorecase = RTEST(val);
 }
 
 static VALUE
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13615)
+++ ChangeLog	(revision 13616)
@@ -1,3 +1,8 @@
+Thu Oct  4 16:31:17 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* re.c (kcode_setter): Perl-ish global variable `$=' no longer
+	  effective.
+
 Thu Oct  4 16:28:33 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* encoding.c (rb_obj_encoding): returns encoding of the given object.

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

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