scripts: fix perl indentation, whitespace, semicolons

Ref: #17116

Closes #17209
This commit is contained in:
Viktor Szakats 2025-04-28 14:57:16 +02:00
parent fd4c342d88
commit 3fcddc835c
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
14 changed files with 1418 additions and 1422 deletions

View file

@ -39,268 +39,268 @@ BEGIN {
my %file_chmod1 = (
'name' => 'chmod1',
'content' => "This file should have permissions 444\n",
'perm' => 'r--r--r--',
'time' => 'Jan 11 10:00',
'dostime' => '01-11-10 10:00AM',
'name' => 'chmod1',
'content' => "This file should have permissions 444\n",
'perm' => 'r--r--r--',
'time' => 'Jan 11 10:00',
'dostime' => '01-11-10 10:00AM',
);
my %file_chmod2 = (
'name' => 'chmod2',
'content' => "This file should have permissions 666\n",
'perm' => 'rw-rw-rw-',
'time' => 'Feb 1 8:00',
'dostime' => '02-01-10 08:00AM',
'name' => 'chmod2',
'content' => "This file should have permissions 666\n",
'perm' => 'rw-rw-rw-',
'time' => 'Feb 1 8:00',
'dostime' => '02-01-10 08:00AM',
);
my %file_chmod3 = (
'name' => 'chmod3',
'content' => "This file should have permissions 777\n",
'perm' => 'rwxrwxrwx',
'time' => 'Feb 1 8:00',
'dostime' => '02-01-10 08:00AM',
'name' => 'chmod3',
'content' => "This file should have permissions 777\n",
'perm' => 'rwxrwxrwx',
'time' => 'Feb 1 8:00',
'dostime' => '02-01-10 08:00AM',
);
my %file_chmod4 = (
'type' => 'd',
'name' => 'chmod4',
'content' => "This file should have permissions 001\n",
'perm' => '--S--S--t',
'time' => 'May 4 4:31',
'dostime' => '05-04-10 04:31AM'
'type' => 'd',
'name' => 'chmod4',
'content' => "This file should have permissions 001\n",
'perm' => '--S--S--t',
'time' => 'May 4 4:31',
'dostime' => '05-04-10 04:31AM'
);
my %file_chmod5 = (
'type' => 'd',
'name' => 'chmod5',
'content' => "This file should have permissions 110\n",
'perm' => '--s--s--T',
'time' => 'May 4 4:31',
'dostime' => '05-04-10 04:31AM'
'type' => 'd',
'name' => 'chmod5',
'content' => "This file should have permissions 110\n",
'perm' => '--s--s--T',
'time' => 'May 4 4:31',
'dostime' => '05-04-10 04:31AM'
);
my %link_link = (
'type' => 'l',
'name' => 'link -> file.txt',
'size' => '8',
'perm' => 'rwxrwxrwx',
'time' => 'Jan 6 4:42'
'type' => 'l',
'name' => 'link -> file.txt',
'size' => '8',
'perm' => 'rwxrwxrwx',
'time' => 'Jan 6 4:42'
);
my %link_link_absolute = (
'type' => 'l',
'name' => 'link_absolute -> /data/ftp/file.txt',
'size' => '15',
'perm' => 'rwxrwxrwx',
'time' => 'Jan 6 4:45'
'type' => 'l',
'name' => 'link_absolute -> /data/ftp/file.txt',
'size' => '15',
'perm' => 'rwxrwxrwx',
'time' => 'Jan 6 4:45'
);
my %dir_dot = (
'type' => "d",
'name' => ".",
'hlink' => "4",
'time' => "Apr 27 5:12",
'size' => "20480",
'dostime' => "04-27-10 05:12AM",
'perm' => "rwxrwxrwx"
'type' => "d",
'name' => ".",
'hlink' => "4",
'time' => "Apr 27 5:12",
'size' => "20480",
'dostime' => "04-27-10 05:12AM",
'perm' => "rwxrwxrwx"
);
my %dir_ddot = (
'type' => "d",
'name' => "..",
'hlink' => "4",
'size' => "20480",
'time' => "Apr 23 3:12",
'dostime' => "04-23-10 03:12AM",
'perm' => "rwxrwxrwx"
'type' => "d",
'name' => "..",
'hlink' => "4",
'size' => "20480",
'time' => "Apr 23 3:12",
'dostime' => "04-23-10 03:12AM",
'perm' => "rwxrwxrwx"
);
my %dir_weirddir_txt = (
'type' => "d",
'name' => "weirddir.txt",
'hlink' => "2",
'size' => "4096",
'time' => "Apr 23 3:12",
'dostime' => "04-23-10 03:12AM",
'perm' => "rwxr-xrwx"
'type' => "d",
'name' => "weirddir.txt",
'hlink' => "2",
'size' => "4096",
'time' => "Apr 23 3:12",
'dostime' => "04-23-10 03:12AM",
'perm' => "rwxr-xrwx"
);
my %dir_UNIX = (
'type' => "d",
'name' => "UNIX",
'hlink' => "11",
'size' => "4096",
'time' => "Nov 01 2008",
'dostime' => "11-01-08 11:11AM",
'perm' => "rwx--x--x"
'type' => "d",
'name' => "UNIX",
'hlink' => "11",
'size' => "4096",
'time' => "Nov 01 2008",
'dostime' => "11-01-08 11:11AM",
'perm' => "rwx--x--x"
);
my %dir_DOS = (
'type' => "d",
'name' => "DOS",
'hlink' => "11",
'size' => "4096",
'time' => "Nov 01 2008",
'dostime' => "11-01-08 11:11AM",
'perm' => "rwx--x--x"
'type' => "d",
'name' => "DOS",
'hlink' => "11",
'size' => "4096",
'time' => "Nov 01 2008",
'dostime' => "11-01-08 11:11AM",
'perm' => "rwx--x--x"
);
my %dir_dot_NeXT = (
'type' => "d",
'name' => ".NeXT",
'hlink' => "4",
'size' => "4096",
'time' => "Jan 23 2:05",
'dostime' => "01-23-05 02:05AM",
'perm' => "rwxrwxrwx"
'type' => "d",
'name' => ".NeXT",
'hlink' => "4",
'size' => "4096",
'time' => "Jan 23 2:05",
'dostime' => "01-23-05 02:05AM",
'perm' => "rwxrwxrwx"
);
my %file_empty_file_dat = (
'name' => "empty_file.dat",
'content' => "",
'perm' => "rw-r--r--",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM"
'name' => "empty_file.dat",
'content' => "",
'perm' => "rw-r--r--",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM"
);
my %file_file_txt = (
'name' => "file.txt",
'content' => "This is content of file \"file.txt\"\n",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM",
'perm' => "rw-r--r--"
'name' => "file.txt",
'content' => "This is content of file \"file.txt\"\n",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM",
'perm' => "rw-r--r--"
);
my %file_someothertext_txt = (
'name' => "someothertext.txt",
'content' => "Some junk ;-) This file does not really exist.\n",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM",
'perm' => "rw-r--r--"
'name' => "someothertext.txt",
'content' => "Some junk ;-) This file does not really exist.\n",
'time' => "Apr 27 11:01",
'dostime' => "04-27-10 11:01AM",
'perm' => "rw-r--r--"
);
my %lists = (
'/fully_simulated/' => {
'files' => [ \%dir_dot, \%dir_ddot, \%dir_DOS, \%dir_UNIX ],
'eol' => "\r\n",
'type' => "unix"
},
'/fully_simulated/UNIX/' => {
'files' => [ \%dir_dot, \%dir_ddot,
\%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
\%file_empty_file_dat, \%file_file_txt,
\%link_link, \%link_link_absolute, \%dir_dot_NeXT,
\%file_someothertext_txt, \%dir_weirddir_txt ],
'eol' => "\r\n",
'type' => 'unix'
},
'/fully_simulated/DOS/' => {
'files' => [ \%dir_dot, \%dir_ddot,
\%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
\%file_empty_file_dat, \%file_file_txt,
\%dir_dot_NeXT, \%file_someothertext_txt, \%dir_weirddir_txt ],
'eol' => "\r\n",
'type' => 'dos'
}
'/fully_simulated/' => {
'files' => [ \%dir_dot, \%dir_ddot, \%dir_DOS, \%dir_UNIX ],
'eol' => "\r\n",
'type' => "unix"
},
'/fully_simulated/UNIX/' => {
'files' => [ \%dir_dot, \%dir_ddot,
\%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
\%file_empty_file_dat, \%file_file_txt,
\%link_link, \%link_link_absolute, \%dir_dot_NeXT,
\%file_someothertext_txt, \%dir_weirddir_txt ],
'eol' => "\r\n",
'type' => 'unix'
},
'/fully_simulated/DOS/' => {
'files' => [ \%dir_dot, \%dir_ddot,
\%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
\%file_empty_file_dat, \%file_file_txt,
\%dir_dot_NeXT, \%file_someothertext_txt, \%dir_weirddir_txt ],
'eol' => "\r\n",
'type' => 'dos'
}
);
sub ftp_createcontent {
my ($list) = $_[0];
my ($list) = $_[0];
my $type = $$list{'type'};
my $eol = $$list{'eol'};
my $list_ref = $$list{'files'};
my $type = $$list{'type'};
my $eol = $$list{'eol'};
my $list_ref = $$list{'files'};
my @contentlist;
if($type eq "unix") {
for(@$list_ref) {
my %file = %$_;
my $line = "";
my $ftype = $file{'type'} ? $file{'type'} : "-";
my $fperm = $file{'perm'} ? $file{'perm'} : "rwxr-xr-x";
my $fuser = $file{'user'} ? sprintf("%15s", $file{'user'}) : "ftp-default";
my $fgroup = $file{'group'} ? sprintf("%15s", $file{'group'}) : "ftp-default";
my $fsize = "";
if(exists($file{'type'}) && $file{'type'} eq "d") {
$fsize = $file{'size'} ? sprintf("%7s", $file{'size'}) : sprintf("%7d", 4096);
}
else {
$fsize = sprintf("%7d", exists($file{'content'}) ? length $file{'content'} : 0);
}
my $fhlink = $file{'hlink'} ? sprintf("%4d", $file{'hlink'}) : " 1";
my $ftime = $file{'time'} ? sprintf("%10s", $file{'time'}) : "Jan 9 1933";
push(@contentlist, "$ftype$fperm $fhlink $fuser $fgroup $fsize $ftime $file{'name'}$eol");
my @contentlist;
if($type eq "unix") {
for(@$list_ref) {
my %file = %$_;
my $line = "";
my $ftype = $file{'type'} ? $file{'type'} : "-";
my $fperm = $file{'perm'} ? $file{'perm'} : "rwxr-xr-x";
my $fuser = $file{'user'} ? sprintf("%15s", $file{'user'}) : "ftp-default";
my $fgroup = $file{'group'} ? sprintf("%15s", $file{'group'}) : "ftp-default";
my $fsize = "";
if(exists($file{'type'}) && $file{'type'} eq "d") {
$fsize = $file{'size'} ? sprintf("%7s", $file{'size'}) : sprintf("%7d", 4096);
}
else {
$fsize = sprintf("%7d", exists($file{'content'}) ? length $file{'content'} : 0);
}
my $fhlink = $file{'hlink'} ? sprintf("%4d", $file{'hlink'}) : " 1";
my $ftime = $file{'time'} ? sprintf("%10s", $file{'time'}) : "Jan 9 1933";
push(@contentlist, "$ftype$fperm $fhlink $fuser $fgroup $fsize $ftime $file{'name'}$eol");
}
return @contentlist;
}
return @contentlist;
}
elsif($type =~ /^dos$/) {
for(@$list_ref) {
my %file = %$_;
my $line = "";
my $time = $file{'dostime'} ? $file{'dostime'} : "06-25-97 09:12AM";
my $size_or_dir;
if(exists($file{'type'}) && $file{'type'} =~ /^d$/) {
$size_or_dir = " <DIR> ";
}
else {
$size_or_dir = sprintf("%20d", length $file{'content'});
}
push(@contentlist, "$time $size_or_dir $file{'name'}$eol");
elsif($type =~ /^dos$/) {
for(@$list_ref) {
my %file = %$_;
my $line = "";
my $time = $file{'dostime'} ? $file{'dostime'} : "06-25-97 09:12AM";
my $size_or_dir;
if(exists($file{'type'}) && $file{'type'} =~ /^d$/) {
$size_or_dir = " <DIR> ";
}
else {
$size_or_dir = sprintf("%20d", length $file{'content'});
}
push(@contentlist, "$time $size_or_dir $file{'name'}$eol");
}
return @contentlist;
}
return @contentlist;
}
}
sub wildcard_filesize {
my ($list_type, $file) = @_;
my $list = $lists{$list_type};
if($list) {
my $files = $list->{'files'};
for(@$files) {
my %f = %$_;
if ($f{'name'} eq $file) {
if($f{'content'}) {
return length $f{'content'};
my ($list_type, $file) = @_;
my $list = $lists{$list_type};
if($list) {
my $files = $list->{'files'};
for(@$files) {
my %f = %$_;
if($f{'name'} eq $file) {
if($f{'content'}) {
return length $f{'content'};
}
elsif($f{'type'} ne "d"){
return 0;
}
else {
return -1;
}
}
}
elsif ($f{'type'} ne "d"){
return 0;
}
else {
return -1;
}
}
}
}
return -1;
return -1;
}
sub wildcard_getfile {
my ($list_type, $file) = @_;
my $list = $lists{$list_type};
if($list) {
my $files = $list->{'files'};
for(@$files) {
my %f = %$_;
if ($f{'name'} eq $file) {
if($f{'content'}) {
return (length $f{'content'}, $f{'content'});
my ($list_type, $file) = @_;
my $list = $lists{$list_type};
if($list) {
my $files = $list->{'files'};
for(@$files) {
my %f = %$_;
if($f{'name'} eq $file) {
if($f{'content'}) {
return (length $f{'content'}, $f{'content'});
}
elsif(!exists($f{'type'}) or $f{'type'} ne "d"){
return (0, "");
}
else {
return (-1, 0);
}
}
}
elsif (!exists($f{'type'}) or $f{'type'} ne "d"){
return (0, "");
}
else {
return (-1, 0);
}
}
}
}
return (-1, 0);
return (-1, 0);
}
sub ftp_contentlist {
my $listname = $_[0];
my $list = $lists{$listname};
return ftp_createcontent($list);
my $listname = $_[0];
my $list = $lists{$listname};
return ftp_createcontent($list);
}

View file

@ -2024,26 +2024,26 @@ sub REST_ftp {
}
sub switch_directory_goto {
my $target_dir = $_;
my $target_dir = $_;
if(!$ftptargetdir) {
$ftptargetdir = "/";
}
if(!$ftptargetdir) {
$ftptargetdir = "/";
}
if($target_dir eq "") {
$ftptargetdir = "/";
}
elsif($target_dir eq "..") {
if($ftptargetdir eq "/") {
$ftptargetdir = "/";
if($target_dir eq "") {
$ftptargetdir = "/";
}
elsif($target_dir eq "..") {
if($ftptargetdir eq "/") {
$ftptargetdir = "/";
}
else {
$ftptargetdir =~ s/[[:alnum:]]+\/$//;
}
}
else {
$ftptargetdir =~ s/[[:alnum:]]+\/$//;
$ftptargetdir .= $target_dir . "/";
}
}
else {
$ftptargetdir .= $target_dir . "/";
}
}
sub switch_directory {
@ -2740,47 +2740,47 @@ sub PORT_ftp {
sub datasockf_state {
my $state = $_[0];
if($state eq 'STOPPED') {
# Data sockfilter initial state, not running,
# not connected and not used.
$datasockf_state = $state;
$datasockf_mode = 'none';
$datasockf_runs = 'no';
$datasockf_conn = 'no';
}
elsif($state eq 'PASSIVE') {
# Data sockfilter accepted connection from client.
$datasockf_state = $state;
$datasockf_mode = 'passive';
$datasockf_runs = 'yes';
$datasockf_conn = 'yes';
}
elsif($state eq 'ACTIVE') {
# Data sockfilter has connected to client.
$datasockf_state = $state;
$datasockf_mode = 'active';
$datasockf_runs = 'yes';
$datasockf_conn = 'yes';
}
elsif($state eq 'PASSIVE_NODATACONN') {
# Data sockfilter bound port without listening,
# client won't be able to establish data connection.
$datasockf_state = $state;
$datasockf_mode = 'passive';
$datasockf_runs = 'yes';
$datasockf_conn = 'no';
}
elsif($state eq 'ACTIVE_NODATACONN') {
# Data sockfilter does not even run,
# client awaits data connection from server in vain.
$datasockf_state = $state;
$datasockf_mode = 'active';
$datasockf_runs = 'no';
$datasockf_conn = 'no';
}
else {
die "Internal error. Unknown datasockf state: $state!";
}
if($state eq 'STOPPED') {
# Data sockfilter initial state, not running,
# not connected and not used.
$datasockf_state = $state;
$datasockf_mode = 'none';
$datasockf_runs = 'no';
$datasockf_conn = 'no';
}
elsif($state eq 'PASSIVE') {
# Data sockfilter accepted connection from client.
$datasockf_state = $state;
$datasockf_mode = 'passive';
$datasockf_runs = 'yes';
$datasockf_conn = 'yes';
}
elsif($state eq 'ACTIVE') {
# Data sockfilter has connected to client.
$datasockf_state = $state;
$datasockf_mode = 'active';
$datasockf_runs = 'yes';
$datasockf_conn = 'yes';
}
elsif($state eq 'PASSIVE_NODATACONN') {
# Data sockfilter bound port without listening,
# client won't be able to establish data connection.
$datasockf_state = $state;
$datasockf_mode = 'passive';
$datasockf_runs = 'yes';
$datasockf_conn = 'no';
}
elsif($state eq 'ACTIVE_NODATACONN') {
# Data sockfilter does not even run,
# client awaits data connection from server in vain.
$datasockf_state = $state;
$datasockf_mode = 'active';
$datasockf_runs = 'no';
$datasockf_conn = 'no';
}
else {
die "Internal error. Unknown datasockf state: $state!";
}
}
#**********************************************************************

View file

@ -293,56 +293,56 @@ sub striparray {
# pass array *REFERENCES* !
#
sub compareparts {
my ($firstref, $secondref)=@_;
my ($firstref, $secondref)=@_;
# we cannot compare arrays index per index since with data chunks,
# they may not be "evenly" distributed
my $first = join("", @$firstref);
my $second = join("", @$secondref);
# we cannot compare arrays index per index since with data chunks,
# they may not be "evenly" distributed
my $first = join("", @$firstref);
my $second = join("", @$secondref);
if($first =~ /%alternatives\[/) {
die "bad use of compareparts\n";
}
if($first =~ /%alternatives\[/) {
die "bad use of compareparts\n";
}
if($second =~ /%alternatives\[([^,]*),([^\]]*)\]/) {
# there can be many %alternatives in this chunk, so we call
# this function recursively
my $alt = $second;
$alt =~ s/%alternatives\[([^,]*),([^\]]*)\]/$1/;
if($second =~ /%alternatives\[([^,]*),([^\]]*)\]/) {
# there can be many %alternatives in this chunk, so we call
# this function recursively
my $alt = $second;
$alt =~ s/%alternatives\[([^,]*),([^\]]*)\]/$1/;
# check first alternative
{
my @f;
my @s;
push @f, $first;
push @s, $alt;
if(!compareparts(\@f, \@s)) {
return 0;
}
}
# check first alternative
{
my @f;
my @s;
push @f, $first;
push @s, $alt;
if(!compareparts(\@f, \@s)) {
return 0;
}
}
$alt = $second;
$alt =~ s/%alternatives\[([^,]*),([^\]]*)\]/$2/;
# check second alternative
{
my @f;
my @s;
push @f, $first;
push @s, $alt;
if(!compareparts(\@f, \@s)) {
return 0;
}
}
$alt = $second;
$alt =~ s/%alternatives\[([^,]*),([^\]]*)\]/$2/;
# check second alternative
{
my @f;
my @s;
push @f, $first;
push @s, $alt;
if(!compareparts(\@f, \@s)) {
return 0;
}
}
# neither matched
return 1;
}
# neither matched
return 1;
}
if($first ne $second) {
return 1;
}
if($first ne $second) {
return 1;
}
return 0;
return 0;
}
#

View file

@ -219,47 +219,47 @@ sub initserverconfig {
# possible servers.
#
sub init_serverpidfile_hash {
for my $proto (('ftp', 'gopher', 'http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) {
for my $ssl (('', 's')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2, 3)) {
my $serv = servername_id("$proto$ssl", $ipvnum, $idnum);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
$ipvnum, $idnum);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
$ipvnum, $idnum);
$serverportfile{$serv} = $portf;
for my $proto (('ftp', 'gopher', 'http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) {
for my $ssl (('', 's')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2, 3)) {
my $serv = servername_id("$proto$ssl", $ipvnum, $idnum);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
$ipvnum, $idnum);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
$ipvnum, $idnum);
$serverportfile{$serv} = $portf;
}
}
}
}
}
}
for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls',
'dict', 'smb', 'smbs', 'telnet', 'mqtt', 'https-mtls',
'dns')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2)) {
my $serv = servername_id($proto, $ipvnum, $idnum);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
$idnum);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
$idnum);
$serverportfile{$serv} = $portf;
}
for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls',
'dict', 'smb', 'smbs', 'telnet', 'mqtt', 'https-mtls',
'dns')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2)) {
my $serv = servername_id($proto, $ipvnum, $idnum);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
$idnum);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
$idnum);
$serverportfile{$serv} = $portf;
}
}
}
}
for my $proto (('http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) {
for my $ssl (('', 's')) {
my $serv = servername_id("$proto$ssl", "unix", 1);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
"unix", 1);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
"unix", 1);
$serverportfile{$serv} = $portf;
for my $proto (('http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) {
for my $ssl (('', 's')) {
my $serv = servername_id("$proto$ssl", "unix", 1);
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
"unix", 1);
$serverpidfile{$serv} = $pidf;
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
"unix", 1);
$serverportfile{$serv} = $portf;
}
}
}
}

View file

@ -195,13 +195,13 @@ sub scanmanpage {
}
}
}
elsif($inex) {
elsif($inex) {
$exsize++;
if($_ =~ /[^\\]\\n/) {
print STDERR "$file:$line '\\n' need to be '\\\\n'!\n";
}
}
elsif($insynop) {
elsif($insynop) {
$synopsize++;
if(($synopsize == 1) && ($_ !~ /\.nf/)) {
print STDERR "$file:$line:1:ERROR: be .nf for proper formatting\n";

View file

@ -59,84 +59,84 @@ sub scan_header {
open(my $h, "<", "$f");
while(<$h>) {
s/^\s*(.*?)\s*$/$1/; # Trim.
# Remove multi-line comment trail.
if($incomment) {
if($_ !~ /.*?\*\/\s*(.*)$/) {
next;
s/^\s*(.*?)\s*$/$1/; # Trim.
# Remove multi-line comment trail.
if($incomment) {
if($_ !~ /.*?\*\/\s*(.*)$/) {
next;
}
$_ = $1;
$incomment = 0;
}
$_ = $1;
$incomment = 0;
}
if($line ne "") {
# Unfold line.
$_ = "$line $1";
$line = "";
}
# Remove comments.
while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) {
$_ = "$1 $2";
}
if($_ =~ /^(.*)\/\*/) {
$_ = "$1 ";
$incomment = 1;
}
s/^\s*(.*?)\s*$/$1/; # Trim again.
# Ignore preprocessor directives and blank lines.
if($_ =~ /^(?:#|$)/) {
next;
}
# Handle lines that may be continued as if they were folded.
if($_ !~ /[;,{}]$/) {
# Folded line.
$line = $_;
next;
}
if($_ =~ /CURLOPTDEPRECATED\(/) {
# Handle deprecated CURLOPT_* option.
if($_ !~ /CURLOPTDEPRECATED\(\s*(\S+)\s*,(?:.*?,){2}\s*(.*?)\s*,.*"\)/) {
# Folded line.
$line = $_;
next;
if($line ne "") {
# Unfold line.
$_ = "$line $1";
$line = "";
}
$hdr{$1} = $2;
}
elsif($_ =~ /CURLOPT\(/) {
# Handle non-deprecated CURLOPT_* option.
if($_ !~ /CURLOPT\(\s*(\S+)\s*(?:,.*?){2}\)/) {
# Folded line.
$line = $_;
next;
# Remove comments.
while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) {
$_ = "$1 $2";
}
$hdr{$1} = "X";
}
else {
my $version = "X";
# Get other kind of deprecation from this line.
if($_ =~ /CURL_DEPRECATED\(/) {
if($_ !~ /^(.*)CURL_DEPRECATED\(\s*(\S+?)\s*,.*?"\)(.*)$/) {
if($_ =~ /^(.*)\/\*/) {
$_ = "$1 ";
$incomment = 1;
}
s/^\s*(.*?)\s*$/$1/; # Trim again.
# Ignore preprocessor directives and blank lines.
if($_ =~ /^(?:#|$)/) {
next;
}
# Handle lines that may be continued as if they were folded.
if($_ !~ /[;,{}]$/) {
# Folded line.
$line = $_;
next;
}
$version = $2;
$_ = "$1 $3";
}
if($_ =~ /^CURL_EXTERN\s+.*\s+(\S+?)\s*\(/) {
# Flag public function.
$hdr{$1} = $version;
if($_ =~ /CURLOPTDEPRECATED\(/) {
# Handle deprecated CURLOPT_* option.
if($_ !~ /CURLOPTDEPRECATED\(\s*(\S+)\s*,(?:.*?,){2}\s*(.*?)\s*,.*"\)/) {
# Folded line.
$line = $_;
next;
}
$hdr{$1} = $2;
}
elsif($inenum && $_ =~ /(\w+)\s*[,=}]/) {
# Flag enum value.
$hdr{$1} = $version;
elsif($_ =~ /CURLOPT\(/) {
# Handle non-deprecated CURLOPT_* option.
if($_ !~ /CURLOPT\(\s*(\S+)\s*(?:,.*?){2}\)/) {
# Folded line.
$line = $_;
next;
}
$hdr{$1} = "X";
}
else {
my $version = "X";
# Get other kind of deprecation from this line.
if($_ =~ /CURL_DEPRECATED\(/) {
if($_ !~ /^(.*)CURL_DEPRECATED\(\s*(\S+?)\s*,.*?"\)(.*)$/) {
# Folded line.
$line = $_;
next;
}
$version = $2;
$_ = "$1 $3";
}
if($_ =~ /^CURL_EXTERN\s+.*\s+(\S+?)\s*\(/) {
# Flag public function.
$hdr{$1} = $version;
}
elsif($inenum && $_ =~ /(\w+)\s*[,=}]/) {
# Flag enum value.
$hdr{$1} = $version;
}
}
# Remember if we are in an enum definition.
$inenum |= ($_ =~ /\benum\b/);
if($_ =~ /}/) {
$inenum = 0;
}
}
# Remember if we are in an enum definition.
$inenum |= ($_ =~ /\benum\b/);
if($_ =~ /}/) {
$inenum = 0;
}
}
close $h;
}
@ -151,31 +151,31 @@ sub scan_man_for_opts {
open(my $m, "<", "$f");
while(<$m>) {
if($_ =~ /^\./) {
# roff directive found: end current option paragraph.
my $o = $opt;
$opt = "";
if($_ =~ /^\.IP\s+((?:$prefix)_\w+)/) {
# A new option has been found.
$opt = $1;
if($_ =~ /^\./) {
# roff directive found: end current option paragraph.
my $o = $opt;
$opt = "";
if($_ =~ /^\.IP\s+((?:$prefix)_\w+)/) {
# A new option has been found.
$opt = $1;
}
$_ = $line; # Get full paragraph.
$line = "";
s/\\f.//g; # Remove font formatting.
s/\s+/ /g; # One line with single space only.
if($o) {
$funcman{$o} = "X";
# Check if paragraph is mentioning deprecation.
while($_ =~ /(?:deprecated|obsoleted?)\b\s*(?:in\b|since\b)?\s*(?:version\b|curl\b|libcurl\b)?\s*(\d[0-9.]*\d)?\b\s*(.*)$/i) {
$funcman{$o} = $1 || "?";
$_ = $2;
}
}
}
$_ = $line; # Get full paragraph.
$line = "";
s/\\f.//g; # Remove font formatting.
s/\s+/ /g; # One line with single space only.
if($o) {
$funcman{$o} = "X";
# Check if paragraph is mentioning deprecation.
while($_ =~ /(?:deprecated|obsoleted?)\b\s*(?:in\b|since\b)?\s*(?:version\b|curl\b|libcurl\b)?\s*(\d[0-9.]*\d)?\b\s*(.*)$/i) {
$funcman{$o} = $1 || "?";
$_ = $2;
}
else {
# Text line: accumulate.
$line .= $_;
}
}
else {
# Text line: accumulate.
$line .= $_;
}
}
close $m;
}
@ -186,52 +186,52 @@ sub scan_man_page {
my $version = "X";
if(open(my $fh, "<", "$path")) {
my $section = "";
my $line = "";
my $section = "";
my $line = "";
while(<$fh>) {
if($_ =~ /\.so\s+man3\/(.*\.3\b)/) {
# Handle manpage inclusion.
scan_man_page(dirname($path) . "/$1", $sym, $table);
$version = exists($$table{$sym})? $$table{$sym}: $version;
}
elsif($_ =~ /^\./) {
# Line is a roff directive.
if($_ =~ /^\.SH\b\s*(\w*)/) {
# Section starts. End previous one.
my $sh = $section;
$section = $1;
$_ = $line; # Previous section text.
$line = "";
s/\\f.//g;
s/\s+/ /g;
s/\\f.//g; # Remove font formatting.
s/\s+/ /g; # One line with single space only.
if($sh =~ /DESCRIPTION|DEPRECATED/) {
while($_ =~ /(?:deprecated|obsoleted?)\b\s*(?:in\b|since\b)?\s*(?:version\b|curl\b|libcurl\b)?\s*(\d[0-9.]*\d)?\b\s*(.*)$/i) {
# Flag deprecation status.
if($version ne "X" && $version ne "?") {
if($1 && $1 ne $version) {
print "error: $sym manpage lists unmatching deprecation versions $version and $1\n";
$errcode++;
}
}
else {
$version = $1 || "?";
}
$_ = $2;
}
while(<$fh>) {
if($_ =~ /\.so\s+man3\/(.*\.3\b)/) {
# Handle manpage inclusion.
scan_man_page(dirname($path) . "/$1", $sym, $table);
$version = exists($$table{$sym})? $$table{$sym}: $version;
}
elsif($_ =~ /^\./) {
# Line is a roff directive.
if($_ =~ /^\.SH\b\s*(\w*)/) {
# Section starts. End previous one.
my $sh = $section;
$section = $1;
$_ = $line; # Previous section text.
$line = "";
s/\\f.//g;
s/\s+/ /g;
s/\\f.//g; # Remove font formatting.
s/\s+/ /g; # One line with single space only.
if($sh =~ /DESCRIPTION|DEPRECATED/) {
while($_ =~ /(?:deprecated|obsoleted?)\b\s*(?:in\b|since\b)?\s*(?:version\b|curl\b|libcurl\b)?\s*(\d[0-9.]*\d)?\b\s*(.*)$/i) {
# Flag deprecation status.
if($version ne "X" && $version ne "?") {
if($1 && $1 ne $version) {
print "error: $sym manpage lists unmatching deprecation versions $version and $1\n";
$errcode++;
}
}
else {
$version = $1 || "?";
}
$_ = $2;
}
}
}
}
else {
# Text line: accumulate.
$line .= $_;
}
}
}
else {
# Text line: accumulate.
$line .= $_;
}
}
close $fh;
$$table{$sym} = $version;
close $fh;
$$table{$sym} = $version;
}
}
@ -240,14 +240,14 @@ sub scan_man_page {
open(my $fh, "<", "$libdocdir/symbols-in-versions") ||
die "$libdocdir/symbols-in-versions";
while(<$fh>) {
if($_ =~ /^((?:CURL|LIBCURL)\S+)\s+\S+\s*(\S*)\s*(\S*)$/) {
if($3 eq "") {
$syminver{$1} = "X";
if($2 ne "" && $2 ne ".") {
$syminver{$1} = $2;
}
if($_ =~ /^((?:CURL|LIBCURL)\S+)\s+\S+\s*(\S*)\s*(\S*)$/) {
if($3 eq "") {
$syminver{$1} = "X";
if($2 ne "" && $2 ne ".") {
$syminver{$1} = $2;
}
}
}
}
}
close($fh);
@ -258,14 +258,14 @@ closedir $dh;
# Get functions and enum symbols from header files.
for(@hfiles) {
scan_header("$incdir/$_");
scan_header("$incdir/$_");
}
# Get function statuses from manpages.
foreach my $sym (keys %hdr) {
if($sym =~/^(?:curl|curlx)_\w/) {
scan_man_page("$libdocdir/$sym.3", $sym, \%funcman);
}
if($sym =~/^(?:curl|curlx)_\w/) {
scan_man_page("$libdocdir/$sym.3", $sym, \%funcman);
}
}
# Get options from function manpages.
@ -274,9 +274,9 @@ scan_man_for_opts("$libdocdir/curl_easy_getinfo.3", "CURLINFO");
# Get deprecation status from option manpages.
foreach my $sym (keys %syminver) {
if($sym =~ /^(?:CURLOPT|CURLINFO)_\w+$/) {
scan_man_page("$libdocdir/opts/$sym.3", $sym, \%optman);
}
if($sym =~ /^(?:CURLOPT|CURLINFO)_\w+$/) {
scan_man_page("$libdocdir/opts/$sym.3", $sym, \%optman);
}
}
# Print results.
@ -293,37 +293,37 @@ Symbol symbols-in func man opt man .h
HEADER
;
foreach my $sym (sort {$a cmp $b} keys %keys) {
if($sym =~ /^(?:CURLOPT|CURLINFO|curl|curlx)_\w/) {
my $s = exists($syminver{$sym})? $syminver{$sym}: " ";
my $f = exists($funcman{$sym})? $funcman{$sym}: " ";
my $o = exists($optman{$sym})? $optman{$sym}: " ";
my $h = exists($hdr{$sym})? $hdr{$sym}: " ";
my $r = " ";
if($sym =~ /^(?:CURLOPT|CURLINFO|curl|curlx)_\w/) {
my $s = exists($syminver{$sym})? $syminver{$sym}: " ";
my $f = exists($funcman{$sym})? $funcman{$sym}: " ";
my $o = exists($optman{$sym})? $optman{$sym}: " ";
my $h = exists($hdr{$sym})? $hdr{$sym}: " ";
my $r = " ";
# There are deprecated symbols in symbols-in-versions that are aliases
# and thus not listed anywhere else. Ignore them.
"$f$o$h" =~ /[X ]{3}/ && next;
# There are deprecated symbols in symbols-in-versions that are aliases
# and thus not listed anywhere else. Ignore them.
"$f$o$h" =~ /[X ]{3}/ && next;
# Check for inconsistencies between deprecations from the different sources.
foreach my $k ($s, $f, $o, $h) {
$r = $r eq " "? $k: $r;
if($k ne " " && $r ne $k) {
if($r eq "?") {
$r = $k ne "X"? $k: "!";
# Check for inconsistencies between deprecations from the different sources.
foreach my $k ($s, $f, $o, $h) {
$r = $r eq " "? $k: $r;
if($k ne " " && $r ne $k) {
if($r eq "?") {
$r = $k ne "X"? $k: "!";
}
elsif($r eq "X" || $k ne "?") {
$r = "!";
}
}
}
elsif($r eq "X" || $k ne "?") {
$r = "!";
}
}
}
if($r eq "!") {
print $leader;
$leader = "";
printf("%-38s %-11s %-9s %-9s %s\n", $sym, $s, $f, $o, $h);
$errcode++;
if($r eq "!") {
print $leader;
$leader = "";
printf("%-38s %-11s %-9s %-9s %s\n", $sym, $s, $f, $o, $h);
$errcode++;
}
}
}
}
exit $errcode;

View file

@ -44,47 +44,47 @@ sub scan_header {
open(my $h, "<", "$f");
while(<$h>) {
s/^\s*(.*?)\s*$/$1/; # Trim.
# Remove multi-line comment trail.
if($incomment) {
if($_ !~ /.*?\*\/\s*(.*)$/) {
next;
s/^\s*(.*?)\s*$/$1/; # Trim.
# Remove multi-line comment trail.
if($incomment) {
if($_ !~ /.*?\*\/\s*(.*)$/) {
next;
}
$_ = $1;
$incomment = 0;
}
if($line ne "") {
# Unfold line.
$_ = "$line $1";
$line = "";
}
if($_ =~ /^(.*)\\$/) {
$line = "$1 ";
next;
}
# Remove comments.
while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) {
$_ = "$1 $2";
}
if($_ =~ /^(.*)\/\*/) {
$_ = "$1 ";
$incomment = 1;
}
s/^\s*(.*?)\s*$/$1/; # Trim again.
# Ignore preprocessor directives and blank lines.
if($_ =~ /^(?:#|$)/) {
next;
}
# Handle lines that may be continued as if they were folded.
if($_ !~ /[;,{}]$/ || $_ =~ /[^)],$/) {
# Folded line.
$line = $_;
next;
}
# Keep string options only.
if($_ =~ /CURLOPT(?:DEPRECATED)?\s*\(\s*([^, \t]+)\s*,\s*CURLOPTTYPE_STRINGPOINT/) {
push(@stringopts, $1);
}
$_ = $1;
$incomment = 0;
}
if($line ne "") {
# Unfold line.
$_ = "$line $1";
$line = "";
}
if($_ =~ /^(.*)\\$/) {
$line = "$1 ";
next;
}
# Remove comments.
while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) {
$_ = "$1 $2";
}
if($_ =~ /^(.*)\/\*/) {
$_ = "$1 ";
$incomment = 1;
}
s/^\s*(.*?)\s*$/$1/; # Trim again.
# Ignore preprocessor directives and blank lines.
if($_ =~ /^(?:#|$)/) {
next;
}
# Handle lines that may be continued as if they were folded.
if($_ !~ /[;,{}]$/ || $_ =~ /[^)],$/) {
# Folded line.
$line = $_;
next;
}
# Keep string options only.
if($_ =~ /CURLOPT(?:DEPRECATED)?\s*\(\s*([^, \t]+)\s*,\s*CURLOPTTYPE_STRINGPOINT/) {
push(@stringopts, $1);
}
}
close $h;
return @stringopts;
@ -98,12 +98,12 @@ sub scan_wrapper_for_strings {
open(my $h, "<", "$f");
while(<$h>) {
if($_ =~ /(BEGIN|END) TRANSLATABLE STRING OPTIONS/) {
$inarmor = $1 eq "BEGIN";
}
elsif($inarmor && $_ =~ /case\s+([^:]+):/) {
push(@stringopts, $1);
}
if($_ =~ /(BEGIN|END) TRANSLATABLE STRING OPTIONS/) {
$inarmor = $1 eq "BEGIN";
}
elsif($inarmor && $_ =~ /case\s+([^:]+):/) {
push(@stringopts, $1);
}
}
close $h;
return @stringopts;
@ -121,27 +121,27 @@ my %diff;
delete @diff{@stringrefs};
foreach(keys %diff) {
print "$_ is not translated\n";
delete $diff{$_};
$errcount++;
print "$_ is not translated\n";
delete $diff{$_};
$errcount++;
}
@diff{@stringrefs} = 0..$#stringrefs;
delete @diff{@stringdefs};
foreach(keys %diff) {
print "translated option $_ does not exist\n";
$errcount++;
print "translated option $_ does not exist\n";
$errcount++;
}
# Check translated string option cases are sorted alphanumerically.
foreach(my $i = 1; $i < $#stringrefs; $i++) {
if($stringrefs[$i] lt $stringrefs[$i - 1]) {
print("Translated string options are not sorted (" . $stringrefs[$i - 1] .
"/" . $stringrefs[$i] . ")\n");
$errcount++;
last;
}
if($stringrefs[$i] lt $stringrefs[$i - 1]) {
print("Translated string options are not sorted (" . $stringrefs[$i - 1] .
"/" . $stringrefs[$i] . ")\n");
$errcount++;
last;
}
}
exit !!$errcount;

File diff suppressed because it is too large Load diff