projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Perl's chop / chomp considered bad, use a regexp instead
[openssl.git]
/
util
/
files.pl
diff --git
a/util/files.pl
b/util/files.pl
index 41f033e3b9aa409dba89c65bc9481e6be5d0a8ae..d984196616053efd2d73e23f4b07ac049ea41f66 100755
(executable)
--- a/
util/files.pl
+++ b/
util/files.pl
@@
-4,12
+4,18
@@
# It is basically a list of all variables from the passed makefile
#
# It is basically a list of all variables from the passed makefile
#
+while ($ARGV[0] =~ /^([^\s=]+)\s*=\s*(.*)$/)
+ {
+ $sym{$1} = $2;
+ shift;
+ }
+
$s="";
while (<>)
{
$s="";
while (<>)
{
-
chop
;
+
s|\R$||
;
s/#.*//;
s/#.*//;
- if (/^(
\S
+)\s*=\s*(.*)$/)
+ if (/^(
[^\s=]
+)\s*=\s*(.*)$/)
{
$o="";
($s,$b)=($1,$2);
{
$o="";
($s,$b)=($1,$2);
@@
-17,10
+23,10
@@
while (<>)
{
if ($b =~ /\\$/)
{
{
if ($b =~ /\\$/)
{
- chop($b);
+ $b=$`; # Keep what is before the backslash
$o.=$b." ";
$b=<>;
$o.=$b." ";
$b=<>;
- chop($b);
+ $b =~ s|\R$||; # Better chomp
}
else
{
}
else
{
@@
-33,11
+39,11
@@
while (<>)
$o =~ s/\s+/ /g;
$o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
$o =~ s/\s+/ /g;
$o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
- $sym{$s}=$o;
+ $sym{$s}=$o
if !exists $sym{$s}
;
}
}
}
}
-$pwd=`pwd`;
chop($pwd)
;
+$pwd=`pwd`;
$pwd =~ s|\R$||
;
if ($sym{'TOP'} eq ".")
{
if ($sym{'TOP'} eq ".")
{
@@
-49,7
+55,7
@@
else {
@_=split(/\//,$pwd);
$z=$#_-$n+1;
foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
@_=split(/\//,$pwd);
$z=$#_-$n+1;
foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
- chop($dir);
+ chop($dir);
# Remove the last slash
}
print "RELATIVE_DIRECTORY=$dir\n";
}
print "RELATIVE_DIRECTORY=$dir\n";