зеркало из https://github.com/github/ruby.git
* regparse.c (onig_syntax_warn): added.
* regparse.c (CC_ESC_WARN, CLOSE_BRACKET_WITHOUT_ESC_WARN, CC_DUP_WARN, UNKNOWN_ESC_WARN): use onig_syntax_warn. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
95b3da63f1
Коммит
8e9fb2e14c
|
@ -1,3 +1,10 @@
|
|||
Sun Oct 11 03:10:50 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* regparse.c (onig_syntax_warn): added.
|
||||
|
||||
* regparse.c (CC_ESC_WARN, CLOSE_BRACKET_WITHOUT_ESC_WARN,
|
||||
CC_DUP_WARN, UNKNOWN_ESC_WARN): use onig_syntax_warn.
|
||||
|
||||
Sun Oct 11 00:14:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* marshal.c (marshal_dump, marshal_load): prevent from GC.
|
||||
|
|
49
regparse.c
49
regparse.c
|
@ -2844,6 +2844,22 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
}
|
||||
#endif /* USE_NAMED_GROUP */
|
||||
|
||||
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,
|
||||
env->pattern, env->pattern_end,
|
||||
(const UChar *)fmt, args);
|
||||
va_end(args);
|
||||
if (env->sourcefile == NULL)
|
||||
rb_warn(fmt, buf);
|
||||
else
|
||||
rb_compile_warn(env->sourcefile, env->sourceline, fmt, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
CC_ESC_WARN(ScanEnv *env, UChar *c)
|
||||
{
|
||||
|
@ -2851,11 +2867,7 @@ CC_ESC_WARN(ScanEnv* env, UChar *c)
|
|||
|
||||
if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED) &&
|
||||
IS_SYNTAX_BV(env->syntax, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC)) {
|
||||
UChar buf[WARN_BUFSIZE];
|
||||
onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
|
||||
env->pattern, env->pattern_end,
|
||||
(UChar* )"character class has '%s' without escape", c);
|
||||
(*onig_warn)((char* )buf);
|
||||
onig_syntax_warn(env, "character class has '%s' without escape", c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2865,48 +2877,27 @@ CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* env, UChar* c)
|
|||
if (onig_warn == onig_null_warn) return ;
|
||||
|
||||
if (IS_SYNTAX_BV((env)->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED)) {
|
||||
UChar buf[WARN_BUFSIZE];
|
||||
onig_snprintf_with_pattern(buf, WARN_BUFSIZE, (env)->enc,
|
||||
(env)->pattern, (env)->pattern_end,
|
||||
(UChar* )"regular expression has '%s' without escape", c);
|
||||
(*onig_warn)((char* )buf);
|
||||
onig_syntax_warn(env, "regular expression has '%s' without escape", c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CC_DUP_WARN(ScanEnv *env)
|
||||
{
|
||||
UChar buf[WARN_BUFSIZE];
|
||||
if (onig_warn == onig_null_warn || !RTEST(ruby_verbose)) return ;
|
||||
|
||||
if (IS_SYNTAX_BV((env)->syntax, ONIG_SYN_WARN_CC_DUP) &&
|
||||
!((env)->warnings_flag & ONIG_SYN_WARN_CC_DUP)) {
|
||||
(env)->warnings_flag |= ONIG_SYN_WARN_CC_DUP;
|
||||
onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
|
||||
env->pattern, env->pattern_end,
|
||||
(UChar* )"character class has duplicated range");
|
||||
|
||||
if (env->sourcefile == NULL)
|
||||
(*onig_warn)((char* )buf);
|
||||
else
|
||||
rb_compile_warn(env->sourcefile, env->sourceline, (char* )buf);
|
||||
onig_syntax_warn(env, "character class has duplicated range");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
UNKNOWN_ESC_WARN(ScanEnv *env, int c)
|
||||
{
|
||||
UChar buf[WARN_BUFSIZE];
|
||||
if (onig_warn == onig_null_warn || !RTEST(ruby_verbose)) return ;
|
||||
|
||||
onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
|
||||
env->pattern, env->pattern_end,
|
||||
(UChar* )"Unknown escape \\%c is ignored", c);
|
||||
|
||||
if (env->sourcefile == NULL)
|
||||
(*onig_warn)((char* )buf);
|
||||
else
|
||||
rb_compile_warn(env->sourcefile, env->sourceline, (char* )buf);
|
||||
onig_syntax_warn(env, "Unknown escape \\%c is ignored", c);
|
||||
}
|
||||
|
||||
static UChar*
|
||||
|
|
Загрузка…
Ссылка в новой задаче