smart-case not disabled by [:upper:] #205

Closed
adavies42 opened this Issue Dec 19, 2011 · 1 comment

Comments

Projects
None yet
2 participants
@adavies42

smart-case does not consider [:upper:] as a pattern containing upper case. given that perl applies the (?i) modifier to it correctly, IMAO it should.

(i'll note that it also doesn't consider any of the unicode ways to specify uppercase (i found 3 syntaxes for 3 different properties in a quick search), but since perl doesn't seem to apply (?i) to those, it doesn't really matter.)

example and suggested patch follow

$ cat foo.txt
abc
ABC
aBc
$ ack --version
ack 1.96
Running under Perl 5.8.8 at /usr/bin/perl

Copyright 2005-2011 Andy Lester.

This program is free software.  You may modify or distribute it
under the terms of the Artistic License v2.0.
$ ack --noenv --text --smart-case '[A-Z]'
foo.txt
2:ABC
3:aBc
$ ack --noenv --text --smart-case '[[:upper:]]'
foo.txt
1:abc
2:ABC
3:aBc
$ cat patch
--- ack 2011-11-08 09:03:01.000000000 -0500
+++ ack.1   2011-12-19 12:02:07.000000000 -0500
@@ -1662,7 +1662,7 @@
         $str = "$str\\b" if $str =~ /\w$/;
     }

-    my $regex_is_lc = $str eq lc $str;
+    my $regex_is_lc = $str eq lc $str && $str !~ /\Q[:upper:]/i;
     if ( $opt->{i} || ($opt->{smart_case} && $regex_is_lc) ) {
         $str = "(?i)$str";
     }
$ ~/bin/ack.1 --noenv --text --smart-case '[[:upper:]]'
foo.txt
2:ABC
3:aBc

@hoelzro hoelzro referenced this issue in beyondgrep/ack2 Aug 28, 2013

Closed

smart-case not disabled by [:upper:] #342

@hoelzro

This comment has been minimized.

Show comment Hide comment
@hoelzro

hoelzro Aug 28, 2013

Collaborator

Migrated to ack2.

Collaborator

hoelzro commented Aug 28, 2013

Migrated to ack2.

@hoelzro hoelzro closed this Aug 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment