Once upon a time, there was chop, which somply chopped off the last
character of $_ or a given variable, and it was used to take off the
EOL character (\n) of strings.
... but then, you had to check for the presence of such character.
So came chomp, the better chop which checks for \n before chopping it
off. And this worked well, as long as Perl made internally sure that
all EOLs were converted to \n.
These days, though, there seems to be a mixture of perls, so lines
from files in the "wrong" environment might have \r\n as EOL, or just
\r (Mac OS, unless I'm misinformed).
So it's time we went for the more generic variant and use s|\R$||, the
better chomp which recognises all kinds of known EOLs and chops them
off.
A few chops were left alone, as they are use as surgical tools to
remove one last slash or one last comma.
NOTE: \R came with perl 5.10.0. It means that from now on, our
scripts will fail with any older version.
Reviewed-by: Rich Salz <rsalz@openssl.org>
18 files changed:
my @file_vars = ( "database", "certificate", "serial", "crlnumber",
"crl", "private_key", "RANDFILE" );
while(<STDIN>) {
my @file_vars = ( "database", "certificate", "serial", "crlnumber",
"crl", "private_key", "RANDFILE" );
while(<STDIN>) {
foreach my $d (@directory_vars) {
if (/^(\s*\#?\s*${d}\s*=\s*)\.\/([^\s\#]*)([\s\#].*)$/) {
$_ = "$1sys\\\$disk:\[.$2$3";
foreach my $d (@directory_vars) {
if (/^(\s*\#?\s*${d}\s*=\s*)\.\/([^\s\#]*)([\s\#].*)$/) {
$_ = "$1sys\\\$disk:\[.$2$3";
open DEMANGLER_DATA, $ARGV[0]
or die "Couldn't open $ARGV[0]: $!\n";
while(<DEMANGLER_DATA>) {
open DEMANGLER_DATA, $ARGV[0]
or die "Couldn't open $ARGV[0]: $!\n";
while(<DEMANGLER_DATA>) {
(my $translated, my $original) = split /\$/;
$translations{$original} = $translated.'$';
}
(my $translated, my $original) = split /\$/;
$translations{$original} = $translated.'$';
}
# ask user for existing CA certificate
print "CA certificate filename (or enter to create)\n";
$FILE = <STDIN>;
# ask user for existing CA certificate
print "CA certificate filename (or enter to create)\n";
$FILE = <STDIN>;
+ $FILE = s|\R$|| if $FILE;
if ($FILE) {
copy_pemfile($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
if ($FILE) {
copy_pemfile($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
while (<>)
{
next unless /^node/;
while (<>)
{
next unless /^node/;
+ s|\R$||; # Better chomp
@a=split;
$num{$a[3]}++;
}
@a=split;
$num{$a[3]}++;
}
+ chop $out; # Get rid of the last comma
$o++;
s/#.*$//;
next if /^\s*$/;
$o++;
s/#.*$//;
next if /^\s*$/;
$o++;
if (/^!module\s+(.*)$/)
{
$o++;
if (/^!module\s+(.*)$/)
{
+ s|\R$||; # Better chomp
my ($name, $num) = /^(\S+)\s+(\S+)$/;
$oid_tbl{$name} = $num;
}
my ($name, $num) = /^(\S+)\s+(\S+)$/;
$oid_tbl{$name} = $num;
}
+ s|\R$||; # Better chomp
s/#.*$//;
next if (/^\S*$/);
my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
s/#.*$//;
next if (/^\S*$/);
my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
my ($chk) = @_;
if (!exists $oid_tbl{$chk})
{
my ($chk) = @_;
if (!exists $oid_tbl{$chk})
{
- die "Can't find \"$chk\", $!\n";
+ die "Can't find \"$chk\"\n";
if ($flavour eq "mingw64") { $gas=1; $elf=0; $win64=1;
$prefix=`echo __USER_LABEL_PREFIX__ | $ENV{CC} -E -P -`;
if ($flavour eq "mingw64") { $gas=1; $elf=0; $win64=1;
$prefix=`echo __USER_LABEL_PREFIX__ | $ENV{CC} -E -P -`;
+ $prefix =~ s|\R$||; # Better chomp
}
elsif ($flavour eq "macosx") { $gas=1; $elf=0; $prefix="_"; $decor="L\$"; }
elsif ($flavour eq "masm") { $gas=0; $elf=0; $masm=$masmref; $win64=1; $decor="\$L\$"; }
}
elsif ($flavour eq "macosx") { $gas=1; $elf=0; $prefix="_"; $decor="L\$"; }
elsif ($flavour eq "masm") { $gas=0; $elf=0; $masm=$masmref; $win64=1; $decor="\$L\$"; }
+ $line =~ s|\R$||; # Better chomp
$line =~ s|[#!].*$||; # get rid of asm-style comments...
$line =~ s|/\*.*\*/||; # ... and C-style comments...
$line =~ s|[#!].*$||; # get rid of asm-style comments...
$line =~ s|/\*.*\*/||; # ... and C-style comments...
my $searchterm = "";
my $goal = "";
while (<$minfo>) {
my $searchterm = "";
my $goal = "";
while (<$minfo>) {
if (/^RELATIVE_DIRECTORY=(.*)$/) {
$reldir=$1;
if (/^RELATIVE_DIRECTORY=(.*)$/) {
$reldir=$1;
$/ = ""; # Eat a paragraph at once.
while(<STDIN>) {
$/ = ""; # Eat a paragraph at once.
while(<STDIN>) {
s/\n/ /gm;
if (/^=head1 /) {
$name = 0;
s/\n/ /gm;
if (/^=head1 /) {
$name = 0;
s/#.*//;
if (/^([^\s=]+)\s*=\s*(.*)$/)
{
s/#.*//;
if (/^([^\s=]+)\s*=\s*(.*)$/)
{
+ $b=$`; # Keep what is before the backslash
+ $b =~ s|\R$||; # Better chomp
+$pwd=`pwd`; $pwd =~ s|\R$||;
if ($sym{'TOP'} eq ".")
{
if ($sym{'TOP'} eq ".")
{
@_=split(/\//,$pwd);
$z=$#_-$n+1;
foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
@_=split(/\//,$pwd);
$z=$#_-$n+1;
foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
+ chop($dir); # Remove the last slash
}
print "RELATIVE_DIRECTORY=$dir\n";
}
print "RELATIVE_DIRECTORY=$dir\n";
$fips_hash=<$sha1_res>;
close $sha1_res;
unlink $fips_target.".sha1";
$fips_hash=<$sha1_res>;
close $sha1_res;
unlink $fips_target.".sha1";
+$fips_hash =~ s|\R$||; # Better chomp
die "Get hash failure" if $? != 0;
die "Get hash failure" if $? != 0;
$hashfile = <IN>;
close IN;
$hashval = `$sha1_exe ${fips_libdir}/$filename`;
$hashfile = <IN>;
close IN;
$hashval = `$sha1_exe ${fips_libdir}/$filename`;
- chomp $hashfile;
- chomp $hashval;
+ $hashfile =~ s|\R$||; # Better chomp
+ $hashval =~ s|\R$||; # Better chomp
$hashfile =~ s/^.*=\s+//;
$hashval =~ s/^.*=\s+//;
die "Invalid hash syntax in file" if (length($hashfile) != 40);
$hashfile =~ s/^.*=\s+//;
$hashval =~ s/^.*=\s+//;
die "Invalid hash syntax in file" if (length($hashfile) != 40);
{
open (IN, "util/fipslib_path.txt") || fipslib_error();
$fipslibdir = <IN>;
{
open (IN, "util/fipslib_path.txt") || fipslib_error();
$fipslibdir = <IN>;
+ $fipslibdir =~ s|\R$||;
close IN;
}
fips_check_files($fipslibdir,
close IN;
}
fips_check_files($fipslibdir,
elsif ($var eq "SSLOBJ")
{ $ret.="\$(OBJ_D)\\\$(SSL).res "; }
}
elsif ($var eq "SSLOBJ")
{ $ret.="\$(OBJ_D)\\\$(SSL).res "; }
}
+ chomp($ret); # Does this actually do something? /RL
$ret.="\n\n";
return($ret);
}
$ret.="\n\n";
return($ret);
}
if($parens > 0) {
#Inside a DEPRECATEDIN
$stored_multiline .= $_;
if($parens > 0) {
#Inside a DEPRECATEDIN
$stored_multiline .= $_;
- chomp $stored_multiline;
+ $stored_multiline =~ s|\R$||; # Better chomp
print STDERR "DEBUG: Continuing multiline DEPRECATEDIN: $stored_multiline\n" if $debug;
$parens = count_parens($stored_multiline);
if ($parens == 0) {
print STDERR "DEBUG: Continuing multiline DEPRECATEDIN: $stored_multiline\n" if $debug;
$parens = count_parens($stored_multiline);
if ($parens == 0) {
- chomp; # remove eol
- chop; # remove ending backslash
- $line = $_;
+ $line = $`; # keep what was before the backslash
$cpp++ if /^#\s*if/;
$cpp-- if /^#\s*endif/;
next;
$cpp++ if /^#\s*if/;
$cpp-- if /^#\s*endif/;
next;
$cpp = 1 if /^#.*ifdef.*cplusplus/;
s/{[^{}]*}//gs; # ignore {} blocks
$cpp = 1 if /^#.*ifdef.*cplusplus/;
s/{[^{}]*}//gs; # ignore {} blocks
\@current_algorithms);
} else {
$stored_multiline = $_;
\@current_algorithms);
} else {
$stored_multiline = $_;
- chomp $stored_multiline;
+ $stored_multiline =~ s|\R$||;
print STDERR "DEBUG: Found multiline DEPRECATEDIN starting with: $stored_multiline\n" if $debug;
next;
}
print STDERR "DEBUG: Found multiline DEPRECATEDIN starting with: $stored_multiline\n" if $debug;
next;
}
open(IN,"<$name") || die "unable to open $name:$!\n";
while (<IN>) {
open(IN,"<$name") || die "unable to open $name:$!\n";
while (<IN>) {
+ s|\R$||; # Better chomp
s/#.*$//;
next if /^\s*$/;
@a=split;
s/#.*$//;
next if /^\s*$/;
@a=split;
if (open(IN,"<$cfile")) {
my $line = "";
while (<IN>) {
if (open(IN,"<$cfile")) {
my $line = "";
while (<IN>) {
+ s|\R$||; # Better chomp
$_ = $line . $_;
$line = "";
if (/{ERR_(FUNC|REASON)\(/) {
$_ = $line . $_;
$line = "";
if (/{ERR_(FUNC|REASON)\(/) {
s/#.*//;
if (/^([^\s=]+)\s*=\s*(.*)$/)
{
s/#.*//;
if (/^([^\s=]+)\s*=\s*(.*)$/)
{
$cversion=`$cc --version` if $cversion eq "";
$cversion =~ s/Reading specs.*\n//;
$cversion =~ s/usage.*\n//;
$cversion=`$cc --version` if $cversion eq "";
$cversion =~ s/Reading specs.*\n//;
$cversion =~ s/usage.*\n//;
if (open(IN,"<CHANGES")) {
while(<IN>) {
if (open(IN,"<CHANGES")) {
while(<IN>) {
$header=0 if /^[dr]sa/;
if (/^type/) { $header=0; next; }
next if $header;
$header=0 if /^[dr]sa/;
if (/^type/) { $header=0; next; }
next if $header;
@a=split;
if ($a[0] =~ /^[dr]sa$/)
{
@a=split;
if ($a[0] =~ /^[dr]sa$/)
{