beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 138 forks source link

Improve --smart-case handling of meta-characters #672

Open timgimyee opened 5 years ago

timgimyee commented 5 years ago

For #670.

Ignore uppercase characters in regex meta-characters, character escapes, and other constructs. For example, --smart-case should see all lowercase here:

ack --smart-case '--s\x6Dart\Wcas\N{LATIN SMALL LETTER E}'

On the other hand, it will now see uppercase "M" and "E" here:

ack --smart-case '--s\115art-cas\x{0045}'
petdance commented 5 years ago

Thanks, this could be very useful.

Can you tell us more about this? How it's working? What version of Perl is it requiring?

petdance commented 5 years ago

Before you make more changes, can we discuss this a bit please? I don't want you to make changes that I might not be able to take. Also, we should be looking at this on ack3 before ack2. ack2 might never get another release.

timgimyee commented 5 years ago

Works by replacing/removing all backslashed escapes/sequences before checking if all lowercase. Requires 5.10 since it uses named captures ($+{capture}, $+{escape}, $+{octal}). Switch to $1, $2, etc... if earlier versions of Perl are required.

petdance commented 5 years ago

This has been fixed in ack3. It won't be fixed in ack2 because there won't be more releases of ack2.

petdance commented 5 years ago

You've taken a very different approach to your fix than what I implemented in ack3. Would you please look at my ack3 implementation and let me know if you see anything that I might have missed?