Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

Bugs in win32/bin/search.pl #2376

Closed p5pRT closed 19 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#3712 (status was 'resolved')

Searchable as RT3712$

p5pRT commented 24 years ago

From argoalby@yahoo.co.uk

Bugs in win32/bin/search.pl

The version of win32/bin/search.pl in perl-5.6.0 is out of date\, see bug report​:- "Out of date version of win32/bin/search.pl"

The constants defined to access elements of the response from stat() are wrong. I have changed $STAT_DEV to 0 and $STAT_INODE to 1.

The following command and associated warnings are from search.bat on a windows 95 system\, but search.bat is automatically generated from search.pl.

C​:\> perl -x -W C​:\PERL\bin\search.bat "test[^x]test" Argument "[^" isn't numeric in substr at C​:\PERL\bin\search.bat line 503. Argument "test[^x]test" isn't numeric in numeric ge (>=) at C​:\PERL\bin\search.bat line 503. Use of uninitialized value in concatenation (.) at C​:\PERL\bin\search.bat line 504.

The deprecated $CTRL-W is used to disable warnings during some processsing\, this does not work on some systems\, so I have changed it to $^W.

The messages due to the problems below are normally suppressed on most systems due to the $CTRL-W. So the -W option to perl may be needed to see them\, if -W option is available on the system.

Messages for search.bat line 503 are due to the wrong perl function being used. I have changed "substr" to "index". The surrounding code indicates that the author's intention was a simple test of whether or not $regex contains [^ as a substring.

Message for search.bat line 504 is due to variable $mflag being uninitialised. So I have moved its initialisation up one line\, ie. before conditional block\, so it will always be initialised before use.

Version 960908.11 only\, man page info for -R says "Undoes -T"\, but there is no -T option\, I have changed it to "Undoes -F".

Version 960908.11 only\, the default filter through zcat is used for extensions .gz and .Z\, but the earlier versions included .z in the default case-insensitive iskip option. So I have added .z to the default filter through zcat. It might also be sensible to add .taz/.tgz/.tpz to the filter\, I think zcat will convert them to tar files. The .tarz in default iskip might also be moved\, case-insensitively.

patch for search.pl version 960908.11 attached.

____________________________________________________________ Do You Yahoo!? Get your free @​yahoo.co.uk address at http​://mail.yahoo.co.uk or your free @​yahoo.ie address at http​://mail.yahoo.ie

p5pRT commented 24 years ago

From argoalby@yahoo.co.uk

search.pl.patch ```diff --- win32/bin/search.pl.orig Sat Aug 12 12:29:16 2000 +++ win32/bin/search.pl Tue Aug 15 14:30:15 2000 @@ -22,7 +22,15 @@ ## Return value: 2=error, 1=nothing found, 0=something found. ## -$version = "960908.11"; +$version = "20000815.??"; +## "20000815.??"; +## Fixed element indexes for stat() response bug. +## Fixed recognition of [^ in regular expression bug. +## Fixed uninitialized $mflag warning. +## Changed deprecated $CTRL-W to $^W. +## Added .z to default filter through zcat. +## Corrected man page info for -R. +## ## "960908.11" ## Added -depth=0, 'cause I needed it. ## @@ -124,8 +132,8 @@ $DESCEND_SUBDIRECTORIES=1;## set to false by -depth=0 ## various elements of stat() that we might access - $STAT_DEV = 1; - $STAT_INODE = 2; + $STAT_DEV = 0; + $STAT_INODE = 1; $STAT_MTIME = 9; $VV_PRINT_COUNT = 50; ## with -vv, print every VV_PRINT_COUNT files, or... @@ -485,8 +493,8 @@ local(@regex_tests); local(@mark_commands); + $mflag = ''; if ($LIST_ONLY) { - $mflag = ''; ## need to have $* set, but perl5 just won't shut up about it. if ($] >= 5) { $mflag = 'm'; @@ -564,7 +572,7 @@ } $regex = join($regex, '\b', '\b'); } - $CAN_USE_FAST_LISTONLY = 0 if substr($regex, "[^") >= 0; + $CAN_USE_FAST_LISTONLY = 0 if index($regex, "[^") >= 0; push(@regex_tests, "m'$regex'$iflag$mflag"); } @@ -704,7 +712,7 @@ local($line_num, $ln, $tag) = 0; local($use_default, @default) = 0; - { package magic; $ = 0; } ## turn off warnings for when we run EXPR's + { package magic; $^W = 0; } ## turn off warnings for when we run EXPR's unless (open(RC, "$file")) { $use_default=1; @@ -712,7 +720,7 @@ ## no RC file -- use this default. @default = split(/\n/,<<'--------INLINE_LITERAL_TEXT'); magic: 32 : $H =~ m/[\x00-\x06\x10-\x1a\x1c-\x1f\x80\xff]{2}/ - filter: $N =~ m/\.(gz|Z)$/ : "zcat %" + filter: $N =~ m/\.(gz|z|Z)$/ : "zcat %" option: -skip '.a .COM .elc .EXE .o .pbm .xbm .dvi' option: -iskip '.tarz .zip .lzh .jpg .jpeg .gif .uu' option: -skip '~ #' @@ -1633,7 +1641,7 @@ .TP \fB-R\fP or \fB-regex\fP Undoes -.BR -T . +.BR -F . Regex arguments are indeed taken as perl regular expressions. .TP .B -i @@ -1785,7 +1793,7 @@ .nf magic: 32 : $H =~ m/[\ex00-\ex06\ex10-\ex1a\ex1c-\ex1f\ex80\exff]{2}/ - filter: $N =~ m/\.(gz|Z)$/ : "zcat %" + filter: $N =~ m/\.(gz|z|Z)$/ : "zcat %" option: -skip '.a .COM .elc .EXE .o .pbm .xbm .dvi' option: -iskip '.tarz .zip .lzh .jpg .jpeg .gif .uu' option: -skip '~ #' @@ -1847,7 +1855,7 @@ The most common example would be to uncompress a file on the fly, i.e. .nf - filter: $N =~ m/\.(gz|Z)$/ : "zcat %" + filter: $N =~ m/\.(gz|z|Z)$/ : "zcat %" .fi Note that had the ``\fBzcat\fP'' been ``\fBgunzip\fP'' instead, you'd uncompress your files in place instead of searching them, so take care when @@ -1855,7 +1863,7 @@ an old one, you might use seperate ones as with: .nf filter: $N =~ m/\.gz$/ : "/my/GNU/binaries/zcat %" - filter: $N =~ m/\.Z$/ : "/the/non-GNU/binaries/zcat %" + filter: $N =~ m/\.(z|Z)$/ : "/the/non-GNU/binaries/zcat %" .fi Also note that when a filter is applied, the ```
p5pRT commented 19 years ago

From @smpeters

[argoalby@​yahoo.co.uk - Tue Aug 15 19​:42​:43 2000]​:

Bugs in win32/bin/search.pl

The version of win32/bin/search.pl in perl-5.6.0 is out of date\, see bug report​:- "Out of date version of win32/bin/search.pl"

The constants defined to access elements of the response from stat() are wrong. I have changed $STAT_DEV to 0 and $STAT_INODE to 1.

The following command and associated warnings are from search.bat on a windows 95 system\, but search.bat is automatically generated from search.pl.

C​:\> perl -x -W C​:\PERL\bin\search.bat "test[^x]test" Argument "[^" isn't numeric in substr at C​:\PERL\bin\search.bat line 503. Argument "test[^x]test" isn't numeric in numeric ge (>=) at C​:\PERL\bin\search.bat line 503. Use of uninitialized value in concatenation (.) at C​:\PERL\bin\search.bat line 504.

The deprecated $CTRL-W is used to disable warnings during some processsing\, this does not work on some systems\, so I have changed it to $^W.

The messages due to the problems below are normally suppressed on most systems due to the $CTRL-W. So the -W option to perl may be needed to see them\, if -W option is available on the system.

Messages for search.bat line 503 are due to the wrong perl function being used. I have changed "substr" to "index". The surrounding code indicates that the author's intention was a simple test of whether or not $regex contains [^ as a substring.

Message for search.bat line 504 is due to variable $mflag being uninitialised. So I have moved its initialisation up one line\, ie. before conditional block\, so it will always be initialised before use.

Version 960908.11 only\, man page info for -R says "Undoes -T"\, but there is no -T option\, I have changed it to "Undoes -F".

Version 960908.11 only\, the default filter through zcat is used for extensions .gz and .Z\, but the earlier versions included .z in the default case-insensitive iskip option. So I have added .z to the default filter through zcat. It might also be sensible to add .taz/.tgz/.tpz to the filter\, I think zcat will convert them to tar files. The .tarz in default iskip might also be moved\, case-insensitively.

patch for search.pl version 960908.11 attached.

This file has been forked from the original and updated separately. This ticket is resolved.

p5pRT commented 19 years ago

@smpeters - Status changed from 'open' to 'resolved'