mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
2503de61fc
commit
c506f190e1
3 changed files with 37 additions and 20 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Oct 11 09:44:46 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* regerror.c (onig_vsnprintf_with_pattern): added.
|
||||
|
||||
* regparse.c (onig_syntax_warn): use above.
|
||||
|
||||
Sun Oct 11 09:04:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h (RB_GC_GUARD_PTR): workaround for gcc
|
||||
|
|
42
regerror.c
42
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue