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

ruby-changes:3391

From: ko1@a...
Date: 5 Jan 2008 01:30:56 +0900
Subject: [ruby-changes:3391] nobu - Ruby:r14884 (trunk): * include/ruby/intern.h, re.c (rb_reg_new): keep interface same as

nobu	2008-01-05 01:30:33 +0900 (Sat, 05 Jan 2008)

  New Revision: 14884

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/encoding.h
    trunk/include/ruby/intern.h
    trunk/insns.def
    trunk/marshal.c
    trunk/re.c
    trunk/version.h

  Log:
    * include/ruby/intern.h, re.c (rb_reg_new): keep interface same as
      1.8.  [ruby-core:14583]
    
    * include/ruby/intern.h, re.c (rb_reg_new_str): renamed, and defines
      HAVE_RB_REG_NEW_STR macro to tell if it is available.
    
    * include/ruby/encoding.h (rb_enc_reg_new): added.
    
    * insns.def (toregexp), marshal.c (r_object0): use rb_reg_new_str().
    
    * re.c (rb_reg_regcomp, rb_reg_s_union): ditto.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/encoding.h?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/marshal.c?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/insns.def?r1=14884&r2=14883&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=14884&r2=14883&diff_format=u

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 14883)
+++ include/ruby/intern.h	(revision 14884)
@@ -454,7 +454,9 @@
 VALUE rb_reg_match_pre(VALUE);
 VALUE rb_reg_match_post(VALUE);
 VALUE rb_reg_match_last(VALUE);
-VALUE rb_reg_new(VALUE, int);
+#define HAVE_RB_REG_NEW_STR 1
+VALUE rb_reg_new_str(VALUE, int);
+VALUE rb_reg_new(const char *, long, int);
 VALUE rb_reg_match(VALUE, VALUE);
 VALUE rb_reg_match2(VALUE);
 int rb_reg_options(VALUE);
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 14883)
+++ include/ruby/encoding.h	(revision 14884)
@@ -58,7 +58,8 @@
 void rb_enc_associate(VALUE, rb_encoding*);
 void rb_enc_copy(VALUE dst, VALUE src);
 
-VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
+VALUE rb_enc_str_new(const char*, long, rb_encoding*);
+VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
 PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
 VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
 long rb_enc_strlen(const char*, const char*, rb_encoding*);
Index: re.c
===================================================================
--- re.c	(revision 14883)
+++ re.c	(revision 14884)
@@ -460,14 +460,14 @@
 }
 
 static VALUE
-rb_reg_error_desc(VALUE str, int options, const char *err)
+rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, const char *err)
 {
     char opts[6];
     VALUE desc = rb_str_buf_new2(err);
 
-    rb_enc_copy(desc, str);
+    rb_enc_associate(desc, enc);
     rb_str_buf_cat2(desc, ": /");
-    rb_reg_expr_str(desc, RSTRING_PTR(str), RSTRING_LEN(str));
+    rb_reg_expr_str(desc, s, len);
     opts[0] = '/';
     option_to_str(opts + 1, options);
     rb_str_buf_cat2(desc, opts);
@@ -475,6 +475,19 @@
 }
 
 static void
+rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err)
+{
+    rb_exc_raise(rb_enc_reg_error_desc(s, len, enc, options, err));
+}
+
+static VALUE
+rb_reg_error_desc(VALUE str, int options, const char *err)
+{
+    return rb_enc_reg_error_desc(RSTRING_PTR(str), RSTRING_LEN(str),
+				 rb_enc_get(str), options, err);
+}
+
+static void
 rb_reg_raise_str(VALUE str, int options, const char *err)
 {
     rb_exc_raise(rb_reg_error_desc(str, options, err));
@@ -2040,7 +2053,7 @@
 }
 
 VALUE
-rb_reg_new(VALUE s, int options)
+rb_reg_new_str(VALUE s, int options)
 {
     VALUE re = rb_reg_s_alloc(rb_cRegexp);
     onig_errmsg_buffer err;
@@ -2053,6 +2066,25 @@
 }
 
 VALUE
+rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
+{
+    VALUE re = rb_reg_s_alloc(rb_cRegexp);
+    onig_errmsg_buffer err;
+
+    if (rb_reg_initialize(re, s, len, enc, options, err) != 0) {
+	rb_enc_reg_raise(s, len, enc, options, err);
+    }
+
+    return re;
+}
+
+VALUE
+rb_reg_new(const char *s, long len, int options)
+{
+    return rb_enc_reg_new(s, len, rb_ascii8bit_encoding(), options);
+}
+
+VALUE
 rb_reg_compile(VALUE str, int options)
 {
     VALUE re = rb_reg_s_alloc(rb_cRegexp);
@@ -2078,7 +2110,7 @@
 	&& memcmp(RREGEXP(reg_cache)->str, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
 	return reg_cache;
 
-    return reg_cache = rb_reg_new(save_str, 0);
+    return reg_cache = rb_reg_new_str(save_str, 0);
 }
 
 /*
@@ -2607,7 +2639,7 @@
         else {
             VALUE quoted;
             quoted = rb_reg_s_quote(Qnil, arg);
-            return rb_reg_new(quoted, 0);
+            return rb_reg_new_str(quoted, 0);
         }
     }
     else {
Index: insns.def
===================================================================
--- insns.def	(revision 14883)
+++ insns.def	(revision 14884)
@@ -403,7 +403,7 @@
 (VALUE val)
 {
     volatile VALUE tmp = str; /* for GC */
-    val = rb_reg_new(str, opt);
+    val = rb_reg_new_str(str, opt);
 }
 
 /**
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14883)
+++ ChangeLog	(revision 14884)
@@ -1,3 +1,17 @@
+Sat Jan  5 01:30:30 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* include/ruby/intern.h, re.c (rb_reg_new): keep interface same as
+	  1.8.  [ruby-core:14583]
+
+	* include/ruby/intern.h, re.c (rb_reg_new_str): renamed, and defines
+	  HAVE_RB_REG_NEW_STR macro to tell if it is available.
+
+	* include/ruby/encoding.h (rb_enc_reg_new): added.
+
+	* insns.def (toregexp), marshal.c (r_object0): use rb_reg_new_str().
+
+	* re.c (rb_reg_regcomp, rb_reg_s_union): ditto.
+
 Fri Jan  4 23:08:48 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* time.c (time_arg): use converted object.  [ruby-core:14759]
Index: version.h
===================================================================
--- version.h	(revision 14883)
+++ version.h	(revision 14884)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-01-04"
+#define RUBY_RELEASE_DATE "2008-01-05"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080104
+#define RUBY_RELEASE_CODE 20080105
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 5
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: marshal.c
===================================================================
--- marshal.c	(revision 14883)
+++ marshal.c	(revision 14884)
@@ -1307,7 +1307,7 @@
 	{
 	    volatile VALUE str = r_bytes(arg);
 	    int options = r_byte(arg);
-	    v = r_entry(rb_reg_new(str, options), arg);
+	    v = r_entry(rb_reg_new_str(str, options), arg);
             v = r_leave(v, arg);
 	}
 	break;

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

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