diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-05 10:57:38 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-05 10:57:38 +0000 |
commit | 500c78c610d9cde2f7a85755f8eb4105e5889ea4 (patch) | |
tree | 19e4f3c669e30af5f04c331d8e96a69637bc3290 | |
parent | 54da3ecbcbfd6cda2451da9aceafb3ef72a1c70e (diff) |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | re.c | 26 |
2 files changed, 32 insertions, 2 deletions
@@ -1,3 +1,11 @@ +Mon Apr 5 19:54:58 2010 NARUSE, Yui <naruse@ruby-lang.org> + + * 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@ruby-lang.org> * include/ruby/win32.h, win32/win32.c (EWOULDBLOCK): VC10 already @@ -725,6 +725,28 @@ rb_reg_named_captures(VALUE re) 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 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu 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; |