Fix Dynamic engine loading so that the call to ENGINE_load_builtin_engines() is perfo...
[openssl.git] / crypto / pariscid.pl
index 47fdce9513b80a5a9563c9fdb1dcb5c3d4bea94d..c8ee8bdb0a4cdd739eddb950404dec8e0a21ff76 100644 (file)
@@ -7,9 +7,12 @@
 # https://www.openssl.org/source/license.html
 
 
-$flavour = shift;
-$output = shift;
-open STDOUT,">$output";
+# $output is the last argument if it looks like a file (it has an extension)
+# $flavour is the first argument if it doesn't look like a file
+$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
+
+$output and open STDOUT,">$output";
 
 if ($flavour =~ /64/) {
        $LEVEL          ="2.0W";
@@ -272,5 +275,5 @@ foreach(split("\n",$code)) {
 
        print $_,"\n";
 }
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";