diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-11 00:48:35 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-11 00:48:35 +0000 |
commit | c506f190e142ad8cda2be386180c51d428a937fc (patch) | |
tree | c52bde6924eaa562e434a01ef2cdc83b06e8bd8b | |
parent | 2503de61fc96c932c4172d7c4b48d2dded5679e6 (diff) |
* regerror.c (onig_vsnprintf_with_pattern): added.
* regparse.c (onig_syntax_warn): use above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | regerror.c | 42 | ||||
-rw-r--r-- | regparse.c | 9 |
3 files changed, 37 insertions, 20 deletions
@@ -1,3 +1,9 @@ +Sun Oct 11 09:44:46 2009 NARUSE, Yui <[email protected]> + + * regerror.c (onig_vsnprintf_with_pattern): added. + + * regparse.c (onig_syntax_warn): use above. + Sun Oct 11 09:04:08 2009 Nobuyoshi Nakada <[email protected]> * include/ruby/ruby.h (RB_GC_GUARD_PTR): workaround for gcc diff --git a/regerror.c b/regerror.c index 358ce0ce5a..a9d0eb647d 100644 --- a/regerror.c +++ b/regerror.c @@ -312,31 +312,16 @@ onig_error_code_to_str(s, code, va_alist) return (int)len; } - void -#ifdef HAVE_STDARG_PROTOTYPES -onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, - UChar* pat, UChar* pat_end, const UChar *fmt, ...) -#else -onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) - UChar buf[]; - int bufsize; - OnigEncoding enc; - UChar* pat; - UChar* pat_end; - const UChar *fmt; - va_dcl -#endif +onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, + UChar* pat, UChar* pat_end, const UChar *fmt, va_list args) { size_t need; int n, len; UChar *p, *s, *bp; UChar bs[6]; - va_list args; - va_init_list(args, fmt); n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args); - va_end(args); need = (pat_end - pat) * 4 + 4; @@ -387,3 +372,26 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) *s = '\0'; } } + +void +#ifdef HAVE_STDARG_PROTOTYPES +onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, + UChar* pat, UChar* pat_end, const UChar *fmt, ...) +#else +onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) + UChar buf[]; + int bufsize; + OnigEncoding enc; + UChar* pat; + UChar* pat_end; + const UChar *fmt; + va_dcl +#endif +{ + va_list args; + va_init_list(args, fmt); + onig_vsnprintf_with_pattern(buf, bufsize, enc, + pat, pat_end, fmt, args); + va_end(args); +} + diff --git a/regparse.c b/regparse.c index 8bd89e1fb6..0a6bf199c1 100644 --- a/regparse.c +++ b/regparse.c @@ -2844,20 +2844,23 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end, } #endif /* USE_NAMED_GROUP */ +void onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, + UChar* pat, UChar* pat_end, const UChar *fmt, va_list args); + static void onig_syntax_warn(ScanEnv *env, const char *fmt, ...) { va_list args; UChar buf[WARN_BUFSIZE]; va_start(args, fmt); - onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc, + onig_vsnprintf_with_pattern(buf, WARN_BUFSIZE, env->enc, env->pattern, env->pattern_end, (const UChar *)fmt, args); va_end(args); if (env->sourcefile == NULL) - rb_warn(fmt, buf); + rb_warn((char *)buf); else - rb_compile_warn(env->sourcefile, env->sourceline, fmt, buf); + rb_compile_warn(env->sourcefile, env->sourceline, (char *)buf); } static void |