Warn unknown escaped chars in regexp.

* regparse.c (UNKNOWN_ESC_WARN): added.

* regparse.c (conv_backslash_value): Warn unknown
  escaped chars in regexp. [ruby-dev:39104]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2009-09-10 07:00:44 +00:00
Родитель ee647e1b96
Коммит 83b76913d8
2 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Thu Sep 10 15:59:05 2009 NARUSE, Yui <naruse@ruby-lang.org>
* regparse.c (UNKNOWN_ESC_WARN): added.
* regparse.c (conv_backslash_value): Warn unknown
escaped chars in regexp. [ruby-dev:39104]
Wed Sep 9 22:02:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/fileutils.rb (FileUtils::Entry_#copy_file): open the source

Просмотреть файл

@ -2115,6 +2115,8 @@ or_cclass(CClassNode* dest, CClassNode* cc, ScanEnv* env)
return 0;
}
static void UNKNOWN_ESC_WARN(ScanEnv *env, int c);
static int
conv_backslash_value(int c, ScanEnv* env)
{
@ -2133,6 +2135,8 @@ conv_backslash_value(int c, ScanEnv* env)
break;
default:
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
UNKNOWN_ESC_WARN(env, c);
break;
}
}
@ -2885,6 +2889,22 @@ CC_DUP_WARN(ScanEnv *env)
}
}
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);
}
static UChar*
find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to,
UChar **next, OnigEncoding enc)