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

ruby-changes:41641

From: naruse <ko1@a...>
Date: Tue, 2 Feb 2016 13:38:39 +0900 (JST)
Subject: [ruby-changes:41641] naruse:r53715 (trunk): * re.c: Introduce RREGEXP_PTR.

naruse	2016-02-02 13:39:44 +0900 (Tue, 02 Feb 2016)

  New Revision: 53715

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53715

  Log:
    * re.c: Introduce RREGEXP_PTR.
      patch by dbussink.
      partially merge https://github.com/ruby/ruby/pull/497
    
    * include/ruby/ruby.h: ditto.
    
    * gc.c: ditto.
    
    * ext/strscan/strscan.c: ditto.
    
    * parse.y: ditto.
    
    * string.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/strscan/strscan.c
    trunk/gc.c
    trunk/include/ruby/ruby.h
    trunk/parse.y
    trunk/re.c
    trunk/string.c
Index: parse.y
===================================================================
--- parse.y	(revision 53714)
+++ parse.y	(revision 53715)
@@ -10625,7 +10625,7 @@ reg_named_capture_assign_gen(struct pars https://github.com/ruby/ruby/blob/trunk/parse.y#L10625
     arg.succ_block = 0;
     arg.fail_block = 0;
     arg.num = 0;
-    onig_foreach_name(RREGEXP(regexp)->ptr, reg_named_capture_assign_iter, &arg);
+    onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
 
     if (arg.num == 0)
         return match;
Index: ext/strscan/strscan.c
===================================================================
--- ext/strscan/strscan.c	(revision 53714)
+++ ext/strscan/strscan.c	(revision 53715)
@@ -460,7 +460,7 @@ strscan_do_scan(VALUE self, VALUE regex, https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L460
 
     p->regex = regex;
     re = rb_reg_prepare_re(regex, p->str);
-    tmpreg = re != RREGEXP(regex)->ptr;
+    tmpreg = re != RREGEXP_PTR(regex);
     if (!tmpreg) RREGEXP(regex)->usecnt++;
 
     if (headonly) {
@@ -480,8 +480,8 @@ strscan_do_scan(VALUE self, VALUE regex, https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L480
             onig_free(re);
         }
         else {
-            onig_free(RREGEXP(regex)->ptr);
-            RREGEXP(regex)->ptr = re;
+            onig_free(RREGEXP_PTR(regex));
+            RREGEXP_PTR(regex) = re;
         }
     }
 
@@ -978,7 +978,7 @@ name_to_backref_number(struct re_registe https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L978
 {
     int num;
 
-    num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
+    num = onig_name_to_backref_number(RREGEXP_PTR(regexp),
 	(const unsigned char* )name, (const unsigned char* )name_end, regs);
     if (num >= 1) {
 	return num;
Index: re.c
===================================================================
--- re.c	(revision 53714)
+++ re.c	(revision 53715)
@@ -357,7 +357,7 @@ rb_char_to_option_kcode(int c, int *opti https://github.com/ruby/ruby/blob/trunk/re.c#L357
 static void
 rb_reg_check(VALUE re)
 {
-    if (!RREGEXP(re)->ptr || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
+    if (!RREGEXP_PTR(re) || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
 	rb_raise(rb_eTypeError, "uninitialized Regexp");
     }
 }
@@ -470,7 +470,7 @@ rb_reg_desc(const char *s, long len, VAL https://github.com/ruby/ruby/blob/trunk/re.c#L470
     if (re) {
 	char opts[4];
 	rb_reg_check(re);
-	if (*option_to_str(opts, RREGEXP(re)->ptr->options))
+	if (*option_to_str(opts, RREGEXP_PTR(re)->options))
 	    rb_str_buf_cat2(str, opts);
 	if (RBASIC(re)->flags & REG_ENCODING_NONE)
 	    rb_str_buf_cat2(str, "n");
@@ -520,7 +520,7 @@ rb_reg_source(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L520
 static VALUE
 rb_reg_inspect(VALUE re)
 {
-    if (!RREGEXP(re)->ptr || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
+    if (!RREGEXP_PTR(re) || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
         return rb_any_to_s(re);
     }
     return rb_reg_desc(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), re);
@@ -561,7 +561,7 @@ rb_reg_to_s(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L561
     rb_reg_check(re);
 
     rb_enc_copy(str, re);
-    options = RREGEXP(re)->ptr->options;
+    options = RREGEXP_PTR(re)->options;
     ptr = (UChar*)RREGEXP_SRC_PTR(re);
     len = RREGEXP_SRC_LEN(re);
   again:
@@ -612,7 +612,7 @@ rb_reg_to_s(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L612
 	    ruby_verbose = verbose;
 	}
 	if (err) {
-	    options = RREGEXP(re)->ptr->options;
+	    options = RREGEXP_PTR(re)->options;
 	    ptr = (UChar*)RREGEXP_SRC_PTR(re);
 	    len = RREGEXP_SRC_LEN(re);
 	}
@@ -717,7 +717,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/re.c#L717
 rb_reg_casefold_p(VALUE re)
 {
     rb_reg_check(re);
-    if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE) return Qtrue;
+    if (RREGEXP_PTR(re)->options & ONIG_OPTION_IGNORECASE) return Qtrue;
     return Qfalse;
 }
 
@@ -782,7 +782,7 @@ rb_reg_names(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L782
 {
     VALUE ary = rb_ary_new();
     rb_reg_check(re);
-    onig_foreach_name(RREGEXP(re)->ptr, reg_names_iter, (void*)ary);
+    onig_foreach_name(RREGEXP_PTR(re), reg_names_iter, (void*)ary);
     return ary;
 }
 
@@ -829,7 +829,7 @@ rb_reg_named_captures(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L829
 {
     VALUE hash = rb_hash_new();
     rb_reg_check(re);
-    onig_foreach_name(RREGEXP(re)->ptr, reg_named_captures_iter, (void*)hash);
+    onig_foreach_name(RREGEXP_PTR(re), reg_named_captures_iter, (void*)hash);
     return hash;
 }
 
@@ -1133,7 +1133,7 @@ match_backref_number(VALUE match, VALUE https://github.com/ruby/ruby/blob/trunk/re.c#L1133
         break;
     }
 
-    num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
+    num = onig_name_to_backref_number(RREGEXP_PTR(regexp),
               (const unsigned char*)name,
               (const unsigned char*)name + strlen(name),
               regs);
@@ -1384,17 +1384,17 @@ rb_reg_prepare_enc(VALUE re, VALUE str, https://github.com/ruby/ruby/blob/trunk/re.c#L1384
     rb_reg_check(re);
     enc = rb_enc_get(str);
     if (!rb_enc_str_asciicompat_p(str)) {
-        if (RREGEXP(re)->ptr->enc != enc) {
+        if (RREGEXP_PTR(re)->enc != enc) {
 	    reg_enc_error(re, str);
 	}
     }
     else if (rb_reg_fixed_encoding_p(re)) {
-        if (RREGEXP(re)->ptr->enc != enc &&
-	    (!rb_enc_asciicompat(RREGEXP(re)->ptr->enc) ||
+        if (RREGEXP_PTR(re)->enc != enc &&
+	    (!rb_enc_asciicompat(RREGEXP_PTR(re)->enc) ||
 	     rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT)) {
 	    reg_enc_error(re, str);
 	}
-	enc = RREGEXP(re)->ptr->enc;
+	enc = RREGEXP_PTR(re)->enc;
     }
     if (warn && (RBASIC(re)->flags & REG_ENCODING_NONE) &&
 	enc != rb_ascii8bit_encoding() &&
@@ -1408,7 +1408,7 @@ rb_reg_prepare_enc(VALUE re, VALUE str, https://github.com/ruby/ruby/blob/trunk/re.c#L1408
 regex_t *
 rb_reg_prepare_re(VALUE re, VALUE str)
 {
-    regex_t *reg = RREGEXP(re)->ptr;
+    regex_t *reg = RREGEXP_PTR(re);
     onig_errmsg_buffer err = "";
     int r;
     OnigErrorInfo einfo;
@@ -1420,7 +1420,7 @@ rb_reg_prepare_re(VALUE re, VALUE str) https://github.com/ruby/ruby/blob/trunk/re.c#L1420
     if (reg->enc == enc) return reg;
 
     rb_reg_check(re);
-    reg = RREGEXP(re)->ptr;
+    reg = RREGEXP_PTR(re);
     pattern = RREGEXP_SRC_PTR(re);
 
     unescaped = rb_reg_preprocess(
@@ -1492,7 +1492,7 @@ rb_reg_search0(VALUE re, VALUE str, long https://github.com/ruby/ruby/blob/trunk/re.c#L1492
     }
 
     reg = rb_reg_prepare_re(re, str);
-    tmpreg = reg != RREGEXP(re)->ptr;
+    tmpreg = reg != RREGEXP_PTR(re);
     if (!tmpreg) RREGEXP(re)->usecnt++;
 
     match = rb_backref_get();
@@ -1522,8 +1522,8 @@ rb_reg_search0(VALUE re, VALUE str, long https://github.com/ruby/ruby/blob/trunk/re.c#L1522
 	    onig_free(reg);
 	}
 	else {
-	    onig_free(RREGEXP(re)->ptr);
-	    RREGEXP(re)->ptr = reg;
+	    onig_free(RREGEXP_PTR(re));
+	    RREGEXP_PTR(re) = reg;
 	}
     }
     if (result < 0) {
@@ -1797,7 +1797,7 @@ match_captures(VALUE match) https://github.com/ruby/ruby/blob/trunk/re.c#L1797
 static int
 name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
 {
-    return onig_name_to_backref_number(RREGEXP(regexp)->ptr,
+    return onig_name_to_backref_number(RREGEXP_PTR(regexp),
 	(const unsigned char* )name, (const unsigned char* )name_end, regs);
 }
 
@@ -1861,7 +1861,7 @@ match_aref(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/re.c#L1861
 	      case T_STRING:
 		p = StringValuePtr(idx);
 		re = RMATCH(match)->regexp;
-		if (NIL_P(re) || !rb_enc_compatible(RREGEXP(re)->src, idx) ||
+		if (NIL_P(re) || !rb_enc_compatible(RREGEXP_SRC(re), idx) ||
 		    (num = name_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp,
 						  p, p + RSTRING_LEN(idx))) < 1) {
 		    name_to_backref_error(idx);
@@ -2010,7 +2010,7 @@ match_inspect(VALUE match) https://github.com/ruby/ruby/blob/trunk/re.c#L2010
     names = ALLOCA_N(struct backref_name_tag, num_regs);
     MEMZERO(names, struct backref_name_tag, num_regs);
 
-    onig_foreach_name(RREGEXP(regexp)->ptr,
+    onig_foreach_name(RREGEXP_PTR(regexp),
             match_inspect_name_iter, names);
 
     str = rb_str_buf_new2("#<");
@@ -2714,7 +2714,7 @@ reg_hash(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L2714
     st_index_t hashval;
 
     rb_reg_check(re);
-    hashval = RREGEXP(re)->ptr->options;
+    hashval = RREGEXP_PTR(re)->options;
     hashval = rb_hash_uint(hashval, rb_memhash(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re)));
     return rb_hash_end(hashval);
 }
@@ -2742,7 +2742,7 @@ rb_reg_equal(VALUE re1, VALUE re2) https://github.com/ruby/ruby/blob/trunk/re.c#L2742
     if (!RB_TYPE_P(re2, T_REGEXP)) return Qfalse;
     rb_reg_check(re1); rb_reg_check(re2);
     if (FL_TEST(re1, KCODE_FIXED) != FL_TEST(re2, KCODE_FIXED)) return Qfalse;
-    if (RREGEXP(re1)->ptr->options != RREGEXP(re2)->ptr->options) return Qfalse;
+    if (RREGEXP_PTR(re1)->options != RREGEXP_PTR(re2)->options) return Qfalse;
     if (RREGEXP_SRC_LEN(re1) != RREGEXP_SRC_LEN(re2)) return Qfalse;
     if (ENCODING_GET(re1) != ENCODING_GET(re2)) return Qfalse;
     if (memcmp(RREGEXP_SRC_PTR(re1), RREGEXP_SRC_PTR(re2), RREGEXP_SRC_LEN(re1)) == 0) {
@@ -3229,7 +3229,7 @@ rb_reg_options(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L3229
     int options;
 
     rb_reg_check(re);
-    options = RREGEXP(re)->ptr->options & ARG_REG_OPTION_MASK;
+    options = RREGEXP_PTR(re)->options & ARG_REG_OPTION_MASK;
     if (RBASIC(re)->flags & KCODE_FIXED) options |= ARG_ENCODING_FIXED;
     if (RBASIC(re)->flags & REG_ENCODING_NONE) options |= ARG_ENCODING_NONE;
     return options;
@@ -3474,7 +3474,7 @@ rb_reg_regsub(VALUE str, VALUE src, stru https://github.com/ruby/ruby/blob/trunk/re.c#L3474
 	switch (c) {
 	  case '1': case '2': case '3': case '4':
 	  case '5': case '6': case '7': case '8': case '9':
-            if (!NIL_P(regexp) && onig_noname_group_capture_is_active(RREGEXP(regexp)->ptr)) {
+            if (!NIL_P(regexp) && onig_noname_group_capture_is_active(RREGEXP_PTR(regexp))) {
                 no = c - '0';
             }
             else {
@@ -3495,7 +3495,7 @@ rb_reg_regsub(VALUE str, VALUE src, stru https://github.com/ruby/ruby/blob/trunk/re.c#L3495
                 if (name_end < e) {
 		    VALUE n = rb_str_subseq(str, (long)(name - RSTRING_PTR(str)),
 					    (long)(name_end - name));
-		    if (!rb_enc_compatible(RREGEXP(regexp)->src, n) ||
+		    if (!rb_enc_compatible(RREGEXP_SRC(regexp), n) ||
 			(no = name_to_backref_number(regs, regexp, name, name_end)) < 1) {
 			name_to_backref_error(n);
 		    }
Index: string.c
===================================================================
--- string.c	(revision 53714)
+++ string.c	(revision 53715)
@@ -3239,7 +3239,7 @@ rb_str_rindex_m(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/string.c#L3239
 	pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
 			 enc, single_byte_optimizable(str));
 
-	if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
+	if (!RREGEXP_PTR(sub) || RREGEXP_SRC_LEN(sub)) {
 	    pos = rb_reg_search(sub, str, pos, 1);
 	    pos = rb_str_sublen(str, pos);
 	}
Index: gc.c
===================================================================
--- gc.c	(revision 53714)
+++ gc.c	(revision 53715)
@@ -3107,8 +3107,8 @@ obj_memsize_of(VALUE obj, int use_all_ty https://github.com/ruby/ruby/blob/trunk/gc.c#L3107
 	}
 	break;
       case T_REGEXP:
-	if (RREGEXP(obj)->ptr) {
-	    size += onig_memsize(RREGEXP(obj)->ptr);
+	if (RREGEXP_PTR(obj)) {
+	    size += onig_memsize(RREGEXP_PTR(obj));
 	}
 	break;
       case T_DATA:
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 53714)
+++ include/ruby/ruby.h	(revision 53715)
@@ -1071,7 +1071,8 @@ struct RRegexp { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1071
     const VALUE src;
     unsigned long usecnt;
 };
-#define RREGEXP_SRC(r) RREGEXP(r)->src
+#define RREGEXP_PTR(r) (RREGEXP(r)->ptr)
+#define RREGEXP_SRC(r) (RREGEXP(r)->src)
 #define RREGEXP_SRC_PTR(r) RSTRING_PTR(RREGEXP(r)->src)
 #define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src)
 #define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53714)
+++ ChangeLog	(revision 53715)
@@ -1,3 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Feb  2 13:02:03 2016  NARUSE, Yui  <naruse@r...>
+
+	* re.c: Introduce RREGEXP_PTR.
+	  patch by dbussink.
+	  partially merge https://github.com/ruby/ruby/pull/497
+
+	* include/ruby/ruby.h: ditto.
+
+	* gc.c: ditto.
+
+	* ext/strscan/strscan.c: ditto.
+
+	* parse.y: ditto.
+
+	* string.c: ditto.
+
 Tue Feb  2 09:08:27 2016  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/rubygems/specification.rb: `coding` is effective only first

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

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