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

ruby-changes:15337

From: naruse <ko1@a...>
Date: Mon, 5 Apr 2010 19:57:57 +0900 (JST)
Subject: [ruby-changes:15337] Ruby:r27225 (trunk): * re.c (make_regexp): use onig_new_with_source to keep

naruse	2010-04-05 19:57:38 +0900 (Mon, 05 Apr 2010)

  New Revision: 27225

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

  Log:
    * re.c (make_regexp): use onig_new_with_source to keep
      sourcefile and sourceline.
    
    * re.c (onig_new_with_source): copied from onig_new in
      regcomp.c for keep sourcefile and sourceline.

  Modified files:
    trunk/ChangeLog
    trunk/re.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27224)
+++ ChangeLog	(revision 27225)
@@ -1,3 +1,11 @@
+Mon Apr  5 19:54:58 2010  NARUSE, Yui  <naruse@r...>
+
+	* re.c (make_regexp): use onig_new_with_source to keep
+	  sourcefile and sourceline.
+
+	* re.c (onig_new_with_source): copied from onig_new in
+	  regcomp.c for keep sourcefile and sourceline.
+
 Mon Apr  5 13:20:45 2010  NAKAMURA Usaku  <usa@r...>
 
 	* include/ruby/win32.h, win32/win32.c (EWOULDBLOCK): VC10 already
Index: re.c
===================================================================
--- re.c	(revision 27224)
+++ re.c	(revision 27225)
@@ -725,6 +725,28 @@
     return hash;
 }
 
+static int
+onig_new_with_source(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
+	  OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax,
+	  OnigErrorInfo* einfo, const char *sourcefile, int sourceline)
+{
+  int r;
+
+  *reg = (regex_t* )xmalloc(sizeof(regex_t));
+  if (IS_NULL(*reg)) return ONIGERR_MEMORY;
+
+  r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
+  if (r) goto err;
+
+  r = onig_compile(*reg, pattern, pattern_end, einfo, sourcefile, sourceline);
+  if (r) {
+  err:
+    onig_free(*reg);
+    *reg = NULL;
+  }
+  return r;
+}
+
 static Regexp*
 make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_buffer err,
 	const char *sourcefile, int sourceline)
@@ -740,8 +762,8 @@
        from that.
     */
 
-    r = onig_new(&rp, (UChar*)s, (UChar*)(s + len), flags,
-		 enc, OnigDefaultSyntax, &einfo);
+    r = onig_new_with_source(&rp, (UChar*)s, (UChar*)(s + len), flags,
+		 enc, OnigDefaultSyntax, &einfo, sourcefile, sourceline);
     if (r) {
 	onig_error_code_to_str((UChar*)err, r, &einfo);
 	return 0;

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

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