ruby-changes:52873
From: nobu <ko1@a...>
Date: Mon, 15 Oct 2018 21:31:29 +0900 (JST)
Subject: [ruby-changes:52873] nobu:r65085 (trunk): regparse.c: warn all duplicated ranges when debugging
nobu 2018-10-15 21:31:22 +0900 (Mon, 15 Oct 2018) New Revision: 65085 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65085 Log: regparse.c: warn all duplicated ranges when debugging Modified files: trunk/regparse.c Index: regparse.c =================================================================== --- regparse.c (revision 65084) +++ regparse.c (revision 65085) @@ -108,7 +108,7 @@ extern void onig_set_verb_warn_func(Onig https://github.com/ruby/ruby/blob/trunk/regparse.c#L108 onig_verb_warn = f; } -static void CC_DUP_WARN(ScanEnv *env); +static void CC_DUP_WARN(ScanEnv *env, OnigCodePoint from, OnigCodePoint to); static unsigned int ParseDepthLimit = DEFAULT_PARSE_DEPTH_LIMIT; @@ -174,7 +174,7 @@ bbuf_clone(BBuf** rto, BBuf* from) https://github.com/ruby/ruby/blob/trunk/regparse.c#L174 #define BITSET_SET_BIT_CHKDUP(bs, pos) do { \ - if (BITSET_AT(bs, pos)) CC_DUP_WARN(env); \ + if (BITSET_AT(bs, pos)) CC_DUP_WARN(env, pos, pos); \ BS_ROOM(bs, pos) |= BS_BIT(pos); \ } while (0) @@ -1720,7 +1720,7 @@ add_code_range_to_buf0(BBuf** pbuf, Scan https://github.com/ruby/ruby/blob/trunk/regparse.c#L1720 if (inc_n != 1) { if (checkdup && from <= data[low*2+1] && (data[low*2] <= from || data[low*2+1] <= to)) - CC_DUP_WARN(env); + CC_DUP_WARN(env, from, to); if (from > data[low*2]) from = data[low*2]; if (to < data[(high - 1)*2 + 1]) @@ -2886,14 +2886,18 @@ CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* https://github.com/ruby/ruby/blob/trunk/regparse.c#L2886 #endif static void -CC_DUP_WARN(ScanEnv *env) +CC_DUP_WARN(ScanEnv *env, OnigCodePoint from ARG_UNUSED, OnigCodePoint to ARG_UNUSED) { 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)) { +#ifdef WARN_ALL_CC_DUP + onig_syntax_warn(env, "character class has duplicated range: %04x-%04x", from, to); +#else env->warnings_flag |= ONIG_SYN_WARN_CC_DUP; onig_syntax_warn(env, "character class has duplicated range"); +#endif } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/