summaryrefslogtreecommitdiffstats
path: root/Configure
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2017-12-01 15:29:05 +0100
committerRichard Levitte <levitte@openssl.org>2017-12-12 17:18:07 +0100
commit3b6c4b07364797566c2c1fd75e499b2d9dd73506 (patch)
treee3b38e114678fc4512900c204aea0eae0fc55dfc /Configure
parentcbade36108267fc551d0ec50d897a954b55672ac (diff)
Configure: Add read_eval_file, a general purpose perl file reader/evaluator
It will return the last expression from the input file. We also use this in read_config, which slightly changes what's expected of Configurations/*.conf. They do not have to assign %targets specifically. On the other hand, the table of configs MUST be the last expression in each of those files. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4840)
Diffstat (limited to 'Configure')
-rwxr-xr-xConfigure35
1 files changed, 24 insertions, 11 deletions
diff --git a/Configure b/Configure
index db191213ad..2c601ad41a 100755
--- a/Configure
+++ b/Configure
@@ -2292,25 +2292,38 @@ sub add {
sub { _add($separator, @_, @x) };
}
+sub read_eval_file {
+ my $fname = shift;
+ my $content;
+ my @result;
+
+ open F, "< $fname" or die "Can't open '$fname': $!\n";
+ {
+ undef local $/;
+ $content = <F>;
+ }
+ close F;
+ {
+ local $@;
+
+ @result = ( eval $content );
+ warn $@ if $@;
+ }
+ return wantarray ? @result : $result[0];
+}
+
# configuration reader, evaluates the input file as a perl script and expects
# it to fill %targets with target configurations. Those are then added to
# %table.
sub read_config {
my $fname = shift;
- open(CONFFILE, "< $fname")
- or die "Can't open configuration file '$fname'!\n";
- my $x = $/;
- undef $/;
- my $content = <CONFFILE>;
- $/ = $x;
- close(CONFFILE);
- my %targets = ();
+ my %targets;
+
{
# Protect certain tables from tampering
- local %table = %::table;
+ local %table = ();
- eval $content;
- warn $@ if $@;
+ %targets = read_eval_file($fname);
}
# For each target, check that it's configured with a hash table.