Feature #1831

Suggestion: warn on repeated character in character class

Added by Brian Candler over 2 years ago. Updated 10 months ago.

[ruby-core:24593]
Status:Closed Start date:07/29/2009
Priority:Low Due date:
Assignee:Yui NARUSE % Done:

100%

Category:core
Target version:1.9.2

Description

Suggestion: warn if the same character appears more than once in a character class (or more restrictedly: if the character ':' appears both at the start and end of a character class)

This is to give some indication of the problem if you do the following:

>> RUBY_DESCRIPTION
=> "ruby 1.9.2dev (2009-07-18 trunk 24186) [i686-linux]"
>> $WARN=true
=> true
>> "uber" =~ /[:lower:]/
=> 2

ruby-core-24593.patch (18.2 kB) Yui NARUSE, 07/31/2009 08:00 am

Associated revisions

Revision 24387
Added by Yui NARUSE over 2 years ago

Warn duplicated characters in character class of regexp. [ruby-core:24593] * include/ruby/oniguruma.h (ONIG_SYN_WARN_CC_DUP): defined. * regparse.h (ScanEnv): add warnings_flag. * regparse.c (CC_DUP_WARN): defined for warn duplicated characters in character class of regexp. [ruby-core:24593] (add_code_range_to_buf): add CC_DUP_WARN. (next_state_val): add CC_DUP_WARN. (OnigSyntaxRuby): add ONIG_SYN_WARN_CC_DUP. (SET_ALL_MULTI_BYTE_RANGE): add env to arguments. (add_code_range): ditto. (add_code_range_to_buf): ditto. (not_code_range_buf): ditto. (or_code_range_buf): ditto. (and_code_range1): ditto. (and_code_range_buf): ditto. (and_cclass): ditto. (or_cclass): ditto. (add_ctype_to_cc_by_range): ditto. (add_ctype_to_cc): ditto. (parse_char_class): ditto.

History

Updated by Brian Candler over 2 years ago

That should have said $VERBOSE=true, but it makes no difference

Updated by Yui NARUSE over 2 years ago

  • File ruby-core-24593_1_.patch added
I'm interested in your suggestion, and wrote a patch.

Updated by Yui NARUSE over 2 years ago

  • File ruby-core-24593.patch added
  • Status changed from Open to Assigned
  • Assignee set to Yui NARUSE
  • Target version set to 1.9.2

Updated by Yui NARUSE over 2 years ago

  • File deleted (ruby-core-24593_1_.patch)

Updated by Yui NARUSE over 2 years ago

Patch updated.

Matz, can I commit this patch?

Updated by Yukihiro Matsumoto over 2 years ago

Hi,

In message "Re: [ruby-core:24627] [Feature #1831] Suggestion: warn on repeated character in character class"
    on Fri, 31 Jul 2009 08:01:30 +0900, Yui NARUSE <redmine@ruby-lang.org> writes:

|Patch updated.
|
|Matz, can I commit this patch?

OK.

Updated by Yui NARUSE over 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
Applied in changeset r24387.

Also available in: Atom PDF