mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-18 04:11:22 +01:00
More comment handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
1c212e878f
commit
575020c851
@ -2006,6 +2006,7 @@ sub do_open_file( $ ) {
|
||||
$currentfilename = $fname;
|
||||
}
|
||||
|
||||
|
||||
sub open_file( $;$$$ ) {
|
||||
my ( $fname, $mf, $ca, $nc ) = @_;
|
||||
|
||||
@ -2018,7 +2019,7 @@ sub open_file( $;$$$ ) {
|
||||
$file_format = 1;
|
||||
$max_format = supplied $mf ? $mf : 1;
|
||||
$comments_allowed = supplied $ca ? $ca : 0;
|
||||
$nocomment++ if supplied( $ca ) && no_comment;
|
||||
$nocomment = $nc;
|
||||
do_open_file $fname;;
|
||||
} else {
|
||||
$ifstack = @ifstack;
|
||||
@ -2026,6 +2027,20 @@ sub open_file( $;$$$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Push open-specific globals onto the include stack
|
||||
#
|
||||
sub push_include() {
|
||||
push @includestack, [ $currentfile,
|
||||
$currentfilename,
|
||||
$currentlinenumber,
|
||||
$ifstack,
|
||||
$file_format,
|
||||
$max_format,
|
||||
$comment,
|
||||
$nocomment ];
|
||||
}
|
||||
|
||||
#
|
||||
# Pop the include stack
|
||||
#
|
||||
@ -2039,8 +2054,14 @@ sub pop_include() {
|
||||
}
|
||||
|
||||
if ( $arrayref ) {
|
||||
( $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ) = @$arrayref;
|
||||
$comment = '' unless @openstack;
|
||||
( $currentfile,
|
||||
$currentfilename,
|
||||
$currentlinenumber,
|
||||
$ifstack,
|
||||
$file_format,
|
||||
$max_format,
|
||||
$comment,
|
||||
$nocomment ) = @$arrayref;
|
||||
} else {
|
||||
$currentfile = undef;
|
||||
$currentlinenumber = 'EOF';
|
||||
@ -2433,7 +2454,7 @@ sub copy1( $ ) {
|
||||
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||
|
||||
if ( -s _ ) {
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ];
|
||||
push_include;
|
||||
$currentfile = undef;
|
||||
do_open_file $filename;
|
||||
} else {
|
||||
@ -2571,7 +2592,7 @@ EOF
|
||||
#
|
||||
sub push_open( $;$$$ ) {
|
||||
my ( $file, $max , $ca, $nc ) = @_;
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ] if $currentfile;
|
||||
push_include;
|
||||
my @a = @includestack;
|
||||
push @openstack, \@a;
|
||||
@includestack = ();
|
||||
@ -2654,7 +2675,7 @@ sub embedded_shell( $ ) {
|
||||
|
||||
$command .= q(');
|
||||
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack , $file_format, $max_format, $nocomment ];
|
||||
push_include;
|
||||
$currentfile = undef;
|
||||
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
||||
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
||||
@ -2716,7 +2737,7 @@ sub embedded_perl( $ ) {
|
||||
|
||||
$perlscript = undef;
|
||||
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack , $file_format, $max_format, $nocomment ];
|
||||
push_include;
|
||||
$currentfile = undef;
|
||||
|
||||
open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname";
|
||||
@ -3003,7 +3024,7 @@ sub read_a_line($) {
|
||||
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||
|
||||
if ( -s _ ) {
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack , $file_format, $max_format, $nocomment ];
|
||||
push_include;
|
||||
$currentfile = undef;
|
||||
do_open_file $filename;
|
||||
} else {
|
||||
|
@ -1639,7 +1639,7 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
progress_message "..Expanding Macro $macrofile...";
|
||||
|
||||
push_open $macrofile, 2, 1, 1;
|
||||
push_open $macrofile, 2, 1, no_comment;
|
||||
|
||||
macro_comment $macro;
|
||||
|
||||
@ -1767,9 +1767,9 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
progress_message "..Expanding inline action $inlinefile...";
|
||||
|
||||
push_open $inlinefile, 2, 1, 1;
|
||||
push_open $inlinefile, 2, 1;
|
||||
|
||||
macro_comment $inline;
|
||||
push_comment('');
|
||||
|
||||
while ( read_a_line( NORMAL_READ ) ) {
|
||||
my ( $mtarget,
|
||||
@ -1855,6 +1855,8 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
|
||||
progress_message " Rule \"$currentline\" $done";
|
||||
}
|
||||
|
||||
pop_comment;
|
||||
|
||||
pop_open;
|
||||
|
||||
progress_message "..End inline action $inlinefile";
|
||||
|
Loading…
Reference in New Issue
Block a user