Skip to content

Commit 72f175b

Browse files
authored
grep: search results listed in lowercase (#776)
* I noticed that "grep -Fi pattern" was incorrectly listing matching lines in all lowercase * When reading the code, this issue had already been fixed in closures $cls_fgrep_xiv and $cls_fgrep_xi * Apply same pattern in closures $cls_fgrep_i and $cls_fgrep_iv (avoid modification of $_ in match function) * test1: "perl grep -Fin INCLUDE a.c" ---> exercise $cls_fgrep_i (including line numbers) * test2: "perl grep -Fiv INT a.c" ---> exercise $cls_fgrep_iv
1 parent 017a1b6 commit 72f175b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bin/grep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use File::Spec;
5454
use File::Temp qw();
5555
use Getopt::Std;
5656

57-
our $VERSION = '1.007';
57+
our $VERSION = '1.008';
5858

5959
$| = 1; # autoflush output
6060

@@ -171,15 +171,15 @@ sub parse_args {
171171
}
172172
};
173173
my $cls_fgrep_i = sub {
174-
$_ = lc $_;
174+
my $s = lc $_;
175175
for my $pattern (@patterns) {
176-
$Matches++ if index($_, lc $pattern) != -1;
176+
$Matches++ if index($s, lc $pattern) != -1;
177177
}
178178
};
179179
my $cls_fgrep_iv = sub {
180-
$_ = lc $_;
180+
my $s = lc $_;
181181
for my $pattern (@patterns) {
182-
$Matches++ if index($_, lc $pattern) == -1;
182+
$Matches++ if index($s, lc $pattern) == -1;
183183
}
184184
};
185185
my $cls_fgrep_x = sub {

0 commit comments

Comments
 (0)