forked from extern/shorewall_code
Check for conditional directives prior to continuation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
121d34aed0
commit
39b3a0da65
@ -1657,8 +1657,14 @@ sub have_capability( $ );
|
||||
|
||||
sub process_conditional( $$$ ) {
|
||||
my ( $omitting, $line, $linenumber ) = @_;
|
||||
#
|
||||
# Save/set $currentlinenumber so that fatal_error will report correct line number
|
||||
#
|
||||
my $save_currentlinenumber = $currentlinenumber;
|
||||
|
||||
print "CD===> $currentline\n" if $debug;
|
||||
$currentlinenumber = $linenumber;
|
||||
|
||||
print "CD===> $line\n" if $debug;
|
||||
|
||||
fatal_error "Invalid compiler directive ($line)" unless $line =~ /^\s*\?(IF\s+|ELSE|ENDIF)(.*)$/;
|
||||
|
||||
@ -1710,6 +1716,10 @@ sub process_conditional( $$$ ) {
|
||||
$omitting = $prioromit;
|
||||
pop @ifstack;
|
||||
}
|
||||
#
|
||||
# Restore $currentlinenumber
|
||||
#
|
||||
$currentlinenumber = $save_currentlinenumber;
|
||||
|
||||
$omitting;
|
||||
}
|
||||
@ -2269,10 +2279,21 @@ sub read_a_line($) {
|
||||
$currentlinenumber = 0;
|
||||
|
||||
while ( <$currentfile> ) {
|
||||
chomp;
|
||||
#
|
||||
# Handle conditionals
|
||||
#
|
||||
if ( /^\s*\?(?:IF|ELSE|ENDIF)/ ) {
|
||||
$omitting = process_conditional( $omitting, $_, $. );
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $omitting ) {
|
||||
print "OMIT=> $_\n" if $debug;
|
||||
next;
|
||||
}
|
||||
|
||||
$currentlinenumber = $. unless $currentlinenumber;
|
||||
|
||||
chomp;
|
||||
#
|
||||
# Suppress leading whitespace in certain continuation lines
|
||||
#
|
||||
@ -2287,21 +2308,6 @@ sub read_a_line($) {
|
||||
#
|
||||
chop $currentline, next if ($currentline .= $_) =~ /\\$/;
|
||||
#
|
||||
# Handle conditionals
|
||||
#
|
||||
if ( $currentline =~ /^\s*\?(?:IF|ELSE|ENDIF)/ ) {
|
||||
$omitting = process_conditional( $omitting, $currentline, $currentlinenumber );
|
||||
$currentline='';
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $omitting ) {
|
||||
print "OMIT=> $currentline\n" if $debug;
|
||||
$currentline='';
|
||||
$currentlinenumber = 0;
|
||||
next;
|
||||
}
|
||||
#
|
||||
# Must check for shell/perl before doing variable expansion
|
||||
#
|
||||
if ( $options & EMBEDDED_ENABLED ) {
|
||||
|
Loading…
Reference in New Issue
Block a user