1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

remove exit 1 from search_pattern_in_file.inc

it broke tests on Windows. Use SEARCH_ABORT instead.
also, remove redundant features and simplify
This commit is contained in:
Sergei Golubchik
2024-01-25 16:02:45 +01:00
parent bc46f1a7d9
commit 6711540518
2 changed files with 16 additions and 41 deletions

View File

@ -48,15 +48,12 @@
# Created: 2011-11-11 mleich # Created: 2011-11-11 mleich
# #
--error 0,1
perl; perl;
use strict; use strict;
die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE}; die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
my @search_files= glob($ENV{SEARCH_FILE}); my @search_files= glob($ENV{SEARCH_FILE});
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set"; my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
my $search_range= $ENV{SEARCH_RANGE}; my $search_range= $ENV{SEARCH_RANGE};
my $silent= $ENV{SEARCH_SILENT};
my $search_result= 0;
my $content; my $content;
foreach my $search_file (@search_files) { foreach my $search_file (@search_files) {
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!"); open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
@ -81,39 +78,18 @@ perl;
$content.= $file_content; $content.= $file_content;
} }
my @matches= ($content =~ /$search_pattern/gs); my @matches= ($content =~ /$search_pattern/gs);
my $res; my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
if (@matches)
{
$res="FOUND " . scalar(@matches);
$search_result= 1;
}
else
{
$res= "NOT FOUND";
}
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1}; $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
if (!$silent || $search_result) if ($ENV{SEARCH_OUTPUT} eq "matches") {
{ foreach (@matches) {
if ($ENV{SEARCH_OUTPUT} eq "matches") print $_ . "\n";
{
foreach (@matches)
{
print $_ . "\n";
}
}
else
{
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
} }
} }
die "$ENV{SEARCH_ABORT}\n" elsif ($ENV{SEARCH_ABORT} and $res =~ /^$ENV{SEARCH_ABORT}/) {
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/; die "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
exit($search_result != 1); } else {
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
}
EOF EOF
let $SEARCH_RESULT= 1; # Found pattern
if ($errno)
{
let $SEARCH_RESULT= 0; # Did not find pattern
}

View File

@ -25,23 +25,23 @@ if (!$_timeout)
} }
let $_timeout_counter=`SELECT $_timeout * 10`; let $_timeout_counter=`SELECT $_timeout * 10`;
let SEARCH_SILENT=1; let SEARCH_ABORT=NOT FOUND;
let $_continue= 1; let $_continue= 1;
disable_abort_on_error;
while ($_continue) while ($_continue)
{ {
source include/search_pattern_in_file.inc; source include/search_pattern_in_file.inc;
if ($SEARCH_RESULT) if (!$errno)
{ {
# Found match # Found match
let $_continue= 0; let $_continue= 0;
} }
if (!$SEARCH_RESULT) if ($errno)
{ {
dec $_timeout_counter; dec $_timeout_counter;
if ($_timeout_counter == 1) if ($_timeout_counter == 1)
{ {
let $SEARCH_SILENT= 0; enable_abort_on_error;
} }
if (!$_timeout_counter) if (!$_timeout_counter)
{ {
@ -49,8 +49,7 @@ while ($_continue)
} }
} }
} }
enable_abort_on_error;
let SEARCH_SILENT=0;
--source include/end_include_file.inc --source include/end_include_file.inc
--let $keep_include_silent=$wait_save_keep_include_silent --let $keep_include_silent=$wait_save_keep_include_silent