mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-24 07:08:53 +01:00
Check for conditional directives prior to continuation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
41dcd5826f
commit
9869420106
@ -1652,8 +1652,14 @@ sub have_capability( $ );
|
|||||||
|
|
||||||
sub process_conditional( $$$ ) {
|
sub process_conditional( $$$ ) {
|
||||||
my ( $omitting, $line, $linenumber ) = @_;
|
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)(.*)$/;
|
fatal_error "Invalid compiler directive ($line)" unless $line =~ /^\s*\?(IF\s+|ELSE|ENDIF)(.*)$/;
|
||||||
|
|
||||||
@ -1705,6 +1711,10 @@ sub process_conditional( $$$ ) {
|
|||||||
$omitting = $prioromit;
|
$omitting = $prioromit;
|
||||||
pop @ifstack;
|
pop @ifstack;
|
||||||
}
|
}
|
||||||
|
#
|
||||||
|
# Restore $currentlinenumber
|
||||||
|
#
|
||||||
|
$currentlinenumber = $save_currentlinenumber;
|
||||||
|
|
||||||
$omitting;
|
$omitting;
|
||||||
}
|
}
|
||||||
@ -2264,10 +2274,21 @@ sub read_a_line($) {
|
|||||||
$currentlinenumber = 0;
|
$currentlinenumber = 0;
|
||||||
|
|
||||||
while ( <$currentfile> ) {
|
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;
|
$currentlinenumber = $. unless $currentlinenumber;
|
||||||
|
|
||||||
chomp;
|
|
||||||
#
|
#
|
||||||
# Suppress leading whitespace in certain continuation lines
|
# Suppress leading whitespace in certain continuation lines
|
||||||
#
|
#
|
||||||
@ -2282,21 +2303,6 @@ sub read_a_line($) {
|
|||||||
#
|
#
|
||||||
chop $currentline, next if ($currentline .= $_) =~ /\\$/;
|
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
|
# Must check for shell/perl before doing variable expansion
|
||||||
#
|
#
|
||||||
if ( $options & EMBEDDED_ENABLED ) {
|
if ( $options & EMBEDDED_ENABLED ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user