smart-case not disabled by [:upper:]

8 views
Skip to first unread message

Aaron Davies

unread,
Dec 19, 2011, 12:05:50 PM12/19/11
to ack dev/users
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 --noenv --text --smart-case '[[:upper:]]'
foo.txt
2:ABC
3:aBc
--
Aaron Davies
aaron....@gmail.com

Andy Lester

unread,
Dec 19, 2011, 12:14:12 PM12/19/11
to ack-...@googlegroups.com

On Dec 19, 2011, at 11:05 AM, Aaron Davies wrote:

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.

Any bugs or issues should be submitted to the issues queue at https://github.com/petdance/ack/issues, not posted to the list.

Thanks,
Andy

Aaron Davies

unread,
Dec 19, 2011, 4:03:20 PM12/19/11
to ack dev/users
On Dec 19, 12:14 pm, Andy Lester <a...@petdance.com> wrote:

> On Dec 19, 2011, at 11:05 AM, Aaron Davies wrote:
>
> > 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.
>

> Any bugs or issues should be submitted to the issues queue athttps://github.com/petdance/ack/issues, not posted to the list.

relocated to https://github.com/petdance/ack/issues/205
--
Aaron Davies
aaron....@gmail.com

Offer Kaye

unread,
Dec 19, 2011, 6:34:34 PM12/19/11
to ack-...@googlegroups.com
On Mon, Dec 19, 2011 at 7:05 PM, Aaron Davies wrote:
> smart-case does not consider [:upper:] as a pattern containing upper
> case. given that perl applies the (?i) modifier to it correctly

Actually, perl *used to* (apply the modifier correctly)... and will
again some day! ;-)

http://perl5.git.perl.org/perl.git/commitdiff/4f03b4b


Regards,
Offer Kaye

Reply all
Reply to author
Forward
0 new messages