mirror of
https://github.com/curl/curl.git
synced 2026-08-24 21:13:40 +03:00
perl: open... || -> open... or (cont.)
Also: unfold a few lines, fix a space, add a missing parentheses.
Follow-up to 678e63934c #22036
Closes #22047
This commit is contained in:
parent
1bb75af8e9
commit
be8f24323e
18 changed files with 44 additions and 58 deletions
|
|
@ -32,7 +32,7 @@ our %pastversion;
|
|||
|
||||
sub allversions {
|
||||
my ($file) = @_;
|
||||
open(A, "<$file") ||
|
||||
open(A, "<$file") or
|
||||
die "cannot open the versions file $file\n";
|
||||
my $before = 1;
|
||||
my $relcount;
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ sub exit_signal_handler {
|
|||
|
||||
sub ftpmsg {
|
||||
# append to the server.input file
|
||||
open(my $input, ">>", "$logdir/server$idstr.input") ||
|
||||
open(my $input, ">>", "$logdir/server$idstr.input") or
|
||||
logmsg "failed to open $logdir/server$idstr.input\n";
|
||||
|
||||
print $input @_;
|
||||
|
|
@ -940,7 +940,7 @@ sub DATA_smtp {
|
|||
|
||||
logmsg "Store test number $testno in $filename\n";
|
||||
|
||||
open(my $file, ">", $filename) ||
|
||||
open(my $file, ">", $filename) or
|
||||
return 0; # failed to open output
|
||||
|
||||
my $line;
|
||||
|
|
@ -1290,7 +1290,7 @@ sub APPEND_imap {
|
|||
|
||||
logmsg "Store test number $testno in $filename\n";
|
||||
|
||||
open(my $file, ">", $filename) ||
|
||||
open(my $file, ">", $filename) or
|
||||
return 0; # failed to open output
|
||||
|
||||
my $received = 0;
|
||||
|
|
@ -2399,7 +2399,7 @@ sub STOR_ftp {
|
|||
|
||||
sendcontrol "125 Gimme gimme gimme!\r\n";
|
||||
|
||||
open(my $file, ">", $filename) ||
|
||||
open(my $file, ">", $filename) or
|
||||
return 0; # failed to open output
|
||||
|
||||
my $line;
|
||||
|
|
@ -2826,7 +2826,7 @@ sub customize {
|
|||
%customcount = (); #
|
||||
%delayreply = (); #
|
||||
|
||||
open(my $custom, "<", "$logdir/$SERVERCMD") ||
|
||||
open(my $custom, "<", "$logdir/$SERVERCMD") or
|
||||
return 1;
|
||||
|
||||
logmsg "FTPD: Getting commands from $logdir/$SERVERCMD\n";
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@ sub errout {
|
|||
|
||||
if($ARGV[0] eq "prepare") {
|
||||
my $dirname = $ARGV[1];
|
||||
mkdir $dirname || errout "$!";
|
||||
mkdir $dirname or errout "$!";
|
||||
chdir $dirname;
|
||||
|
||||
# Create the files in alphabetical order, to increase the chances
|
||||
# of receiving a consistent set of directory contents regardless
|
||||
# of whether the server alphabetizes the results or not.
|
||||
mkdir "asubdir" || errout "$!";
|
||||
mkdir "asubdir" or errout "$!";
|
||||
chmod 0777, "asubdir";
|
||||
|
||||
open(FILE, ">plainfile.txt") || errout "$!";
|
||||
open(FILE, ">plainfile.txt") or errout "$!";
|
||||
binmode FILE;
|
||||
print FILE "Test file to support curl test suite\n";
|
||||
close(FILE);
|
||||
|
|
@ -59,7 +59,7 @@ if($ARGV[0] eq "prepare") {
|
|||
utime time, timegm(0,0,12,1,0,100), "plainfile.txt";
|
||||
chmod 0666, "plainfile.txt";
|
||||
|
||||
open(FILE, ">emptyfile.txt") || errout "$!";
|
||||
open(FILE, ">emptyfile.txt") or errout "$!";
|
||||
binmode FILE;
|
||||
close(FILE);
|
||||
# The mtime is specifically chosen to be an even number so that it can be
|
||||
|
|
@ -67,7 +67,7 @@ if($ARGV[0] eq "prepare") {
|
|||
utime time, timegm(0,0,12,1,0,100), "emptyfile.txt";
|
||||
chmod 0666, "emptyfile.txt";
|
||||
|
||||
open(FILE, ">rofile.txt") || errout "$!";
|
||||
open(FILE, ">rofile.txt") or errout "$!";
|
||||
binmode FILE;
|
||||
print FILE "Read-only test file to support curl test suite\n";
|
||||
close(FILE);
|
||||
|
|
|
|||
|
|
@ -998,8 +998,7 @@ sub singletest_run {
|
|||
logmsg "$CMDLINE\n";
|
||||
}
|
||||
|
||||
open(my $cmdlog, ">", "$LOGDIR/$CURLLOG") ||
|
||||
die "Failure writing log file";
|
||||
open(my $cmdlog, ">", "$LOGDIR/$CURLLOG") or die "Failure writing log file";
|
||||
print $cmdlog "$CMDLINE\n";
|
||||
close($cmdlog) or die "Failure writing log file";
|
||||
|
||||
|
|
|
|||
|
|
@ -356,8 +356,7 @@ sub cleardir {
|
|||
my $file;
|
||||
|
||||
# Get all files
|
||||
opendir(my $dh, $dir) ||
|
||||
return 0; # cannot open dir
|
||||
opendir(my $dh, $dir) or return 0; # cannot open dir
|
||||
while($file = readdir($dh)) {
|
||||
# Do not clear the $PIDDIR or $LOCKDIR since those need to live beyond
|
||||
# one test
|
||||
|
|
@ -2675,7 +2674,7 @@ if(!$randseed) {
|
|||
# seed of the month. December 2019 becomes 201912
|
||||
$randseed = ($year + 1900) * 100 + $mon + 1;
|
||||
print "Using curl: $CURL\n";
|
||||
open(my $curlvh, "-|", exerunner() . shell_quote($CURL) . " --version 2>$dev_null") ||
|
||||
open(my $curlvh, "-|", exerunner() . shell_quote($CURL) . " --version 2>$dev_null") or
|
||||
die "could not get curl version!";
|
||||
my @c = <$curlvh>;
|
||||
close($curlvh) or die "could not get curl version!";
|
||||
|
|
@ -2958,8 +2957,7 @@ sub displaylogcontent {
|
|||
sub displaylogs {
|
||||
my ($runnerid, $testnum) = @_;
|
||||
my $logdir = getrunnerlogdir($runnerid);
|
||||
opendir(DIR, $logdir) ||
|
||||
die "cannot open dir: $!";
|
||||
opendir(DIR, $logdir) or die "cannot open dir: $!";
|
||||
my @logs = readdir(DIR);
|
||||
closedir(DIR);
|
||||
|
||||
|
|
@ -3155,7 +3153,7 @@ while(1) {
|
|||
$endwaitcnt = 0;
|
||||
# This runner is ready to be serviced
|
||||
my $testnum = $runnersrunning{$ridready};
|
||||
defined $testnum || die "Internal error: test for runner $ridready unknown";
|
||||
defined $testnum or die "Internal error: test for runner $ridready unknown";
|
||||
delete $runnersrunning{$ridready};
|
||||
my ($error, $again) = singletest($ridready, $testnum, $countforrunner{$ridready}, $totaltests);
|
||||
if($again) {
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ sub scanheader {
|
|||
|
||||
sub scanallheaders {
|
||||
my $d = "$root/include/curl";
|
||||
opendir(my $dh, $d) ||
|
||||
die "Cannot opendir: $!";
|
||||
opendir(my $dh, $d) or die "Cannot opendir: $!";
|
||||
my @headers = grep { /.h\z/ } readdir($dh);
|
||||
closedir $dh;
|
||||
foreach my $h (@headers) {
|
||||
|
|
@ -130,8 +129,7 @@ sub checkmanpage {
|
|||
|
||||
sub scanman_md_dir {
|
||||
my ($d) = @_;
|
||||
opendir(my $dh, $d) ||
|
||||
die "Cannot opendir: $!";
|
||||
opendir(my $dh, $d) or die "Cannot opendir: $!";
|
||||
my @mans = grep { /.md\z/ } readdir($dh);
|
||||
closedir $dh;
|
||||
for my $m (@mans) {
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ my %alias = (
|
|||
sub scanmdpage {
|
||||
my ($file, @words) = @_;
|
||||
|
||||
open(my $mh, "<", $file) ||
|
||||
die "could not open $file";
|
||||
open(my $mh, "<", $file) or die "could not open $file";
|
||||
my @m;
|
||||
while(<$mh>) {
|
||||
if($_ =~ /^## (.*)/) {
|
||||
|
|
@ -101,8 +100,7 @@ sub scanmdpage {
|
|||
my $r;
|
||||
|
||||
# check for define aliases
|
||||
open($r, "<", $curlh) ||
|
||||
die "no curl.h";
|
||||
open($r, "<", $curlh) or die "no curl.h";
|
||||
while(<$r>) {
|
||||
if(/^\#define (CURL(OPT|INFO|MOPT)_\w+) (.*)/) {
|
||||
$alias{$1} = $3;
|
||||
|
|
@ -113,8 +111,7 @@ close($r);
|
|||
my @curlopt;
|
||||
my @curlinfo;
|
||||
my @curlmopt;
|
||||
open($r, "<", $syms) ||
|
||||
die "no input file";
|
||||
open($r, "<", $syms) or die "no input file";
|
||||
while(<$r>) {
|
||||
chomp;
|
||||
my $l= $_;
|
||||
|
|
@ -187,8 +184,7 @@ my %opts = (
|
|||
|
||||
#########################################################################
|
||||
# parse the curl code that parses the command line arguments!
|
||||
open($r, "<", "$root/src/tool_getparam.c") ||
|
||||
die "no input file";
|
||||
open($r, "<", "$root/src/tool_getparam.c") or die "no input file";
|
||||
my $list;
|
||||
my @getparam; # store all parsed parameters
|
||||
|
||||
|
|
@ -230,7 +226,8 @@ close($r);
|
|||
#########################################################################
|
||||
# parse the curl.1 man page, extract all documented command line options
|
||||
# The man page may or may not be rebuilt, so check both possible locations
|
||||
open($r, "<", "$buildroot/docs/cmdline-opts/curl.1") || open($r, "<", "$root/docs/cmdline-opts/curl.1") ||
|
||||
open($r, "<", "$buildroot/docs/cmdline-opts/curl.1") or
|
||||
open($r, "<", "$root/docs/cmdline-opts/curl.1") or
|
||||
die "failed getting curl.1";
|
||||
my @manpage; # store all parsed parameters
|
||||
while(<$r>) {
|
||||
|
|
@ -258,8 +255,7 @@ close($r);
|
|||
|
||||
#########################################################################
|
||||
# parse the curl code that outputs the curl -h list
|
||||
open($r, "<", "$root/src/tool_listhelp.c") ||
|
||||
die "no input file";
|
||||
open($r, "<", "$root/src/tool_listhelp.c") or die "no input file";
|
||||
my @toolhelp; # store all parsed parameters
|
||||
while(<$r>) {
|
||||
chomp;
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ sub manpresent {
|
|||
|
||||
sub file {
|
||||
my ($f) = @_;
|
||||
open(my $fh, "<", $f) ||
|
||||
die "test1140.pl could not open $f";
|
||||
open(my $fh, "<", $f) or die "test1140.pl could not open $f";
|
||||
my $line = 1;
|
||||
while(<$fh>) {
|
||||
chomp;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ sub scanenums {
|
|||
my ($file) = @_;
|
||||
my $skipit = 0;
|
||||
|
||||
open H_IN, "-|", "$Cpreprocessor -DCURL_DISABLE_DEPRECATION $i$file" ||
|
||||
open(H_IN, "-|", "$Cpreprocessor -DCURL_DISABLE_DEPRECATION $i$file") or
|
||||
die "Cannot preprocess $file";
|
||||
while(<H_IN>) {
|
||||
my ($line, $linenum) = ($_, $.);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ my %deprecated = (
|
|||
CURLOPT_RANDOM_FILE => 1,
|
||||
);
|
||||
sub allsymbols {
|
||||
open(my $f, "<", $symbolsinversions) ||
|
||||
die "$symbolsinversions: $|";
|
||||
open(my $f, "<", $symbolsinversions) or die "$symbolsinversions: $|";
|
||||
while(<$f>) {
|
||||
if($_ =~ /^([^ ]*) +(.*)/) {
|
||||
my ($name, $info) = ($1, $2);
|
||||
|
|
@ -144,8 +143,7 @@ sub scanmanpage {
|
|||
my @separators;
|
||||
my @sepline;
|
||||
|
||||
open(my $m, "<", $file) ||
|
||||
die "test1173.pl could not open $file";
|
||||
open(my $m, "<", $file) or die "test1173.pl could not open $file";
|
||||
if($file =~ /[\/\\](CURL|curl_)([^\/\\]*).3/) {
|
||||
# This is a man page for libcurl. It requires an example unless it is
|
||||
# considered deprecated.
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ sub scan_man_page {
|
|||
}
|
||||
|
||||
# Read symbols-in-versions.
|
||||
open(my $fh, "<", "$root/docs/libcurl/symbols-in-versions") ||
|
||||
open(my $fh, "<", "$root/docs/libcurl/symbols-in-versions") or
|
||||
die "$root/docs/libcurl/symbols-in-versions";
|
||||
while(<$fh>) {
|
||||
if($_ =~ /^((?:CURL|LIBCURL)\S+)\s+\S+\s*(\S*)\s*(\S*)$/) {
|
||||
|
|
|
|||
|
|
@ -97,8 +97,7 @@ sub checkmanpage {
|
|||
|
||||
sub scanman_md_dir {
|
||||
my ($d) = @_;
|
||||
opendir(my $dh, $d) ||
|
||||
die "Cannot opendir: $!";
|
||||
opendir(my $dh, $d) or die "Cannot opendir: $!";
|
||||
my @mans = grep { /.md\z/ } readdir($dh);
|
||||
closedir $dh;
|
||||
for my $m (@mans) {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ use File::Basename;
|
|||
sub valgrindparse {
|
||||
my ($file) = @_;
|
||||
my @o;
|
||||
open(my $val, "<", $file) ||
|
||||
return;
|
||||
open(my $val, "<", $file) or return;
|
||||
@o = <$val>;
|
||||
close($val);
|
||||
return @o;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue