compile: make the parse a function instead of inline
Again, prep for delegation, when we'll be reading fragments of config rules from various files and tacking them onto the %repos hash. note: this patch best viewed with "git diff -w", clicking "Ignore space change" in gitk, or eqvt :-)
This commit is contained in:
parent
3267c3f4be
commit
34a6f89c26
|
@ -119,13 +119,16 @@ sub expand_list
|
||||||
# "compile" GL conf
|
# "compile" GL conf
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
my $conf_fh = wrap_open( "<", $GL_CONF );
|
sub parse_conf_file
|
||||||
|
|
||||||
# the syntax is fairly simple, so we parse it inline
|
|
||||||
|
|
||||||
my @repos;
|
|
||||||
while (<$conf_fh>)
|
|
||||||
{
|
{
|
||||||
|
my ($conffile) = @_;
|
||||||
|
my $conf_fh = wrap_open( "<", $conffile );
|
||||||
|
|
||||||
|
# the syntax is fairly simple, so we parse it inline
|
||||||
|
|
||||||
|
my @repos;
|
||||||
|
while (<$conf_fh>)
|
||||||
|
{
|
||||||
# normalise whitespace; keeps later regexes very simple
|
# normalise whitespace; keeps later regexes very simple
|
||||||
s/=/ = /;
|
s/=/ = /;
|
||||||
s/\s+/ /g;
|
s/\s+/ /g;
|
||||||
|
@ -191,8 +194,11 @@ while (<$conf_fh>)
|
||||||
{
|
{
|
||||||
die "$ATTN can't make head or tail of '$_'\n";
|
die "$ATTN can't make head or tail of '$_'\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parse_conf_file($GL_CONF);
|
||||||
|
|
||||||
my $compiled_fh = wrap_open( ">", $GL_CONF_COMPILED );
|
my $compiled_fh = wrap_open( ">", $GL_CONF_COMPILED );
|
||||||
print $compiled_fh Data::Dumper->Dump([\%repos], [qw(*repos)]);
|
print $compiled_fh Data::Dumper->Dump([\%repos], [qw(*repos)]);
|
||||||
close $compiled_fh or die "$ATTN close compiled-conf failed: $!\n";
|
close $compiled_fh or die "$ATTN close compiled-conf failed: $!\n";
|
||||||
|
|
Loading…
Reference in a new issue