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;
|
$currentfilename = $fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub open_file( $;$$$ ) {
|
sub open_file( $;$$$ ) {
|
||||||
my ( $fname, $mf, $ca, $nc ) = @_;
|
my ( $fname, $mf, $ca, $nc ) = @_;
|
||||||
|
|
||||||
@ -2018,7 +2019,7 @@ sub open_file( $;$$$ ) {
|
|||||||
$file_format = 1;
|
$file_format = 1;
|
||||||
$max_format = supplied $mf ? $mf : 1;
|
$max_format = supplied $mf ? $mf : 1;
|
||||||
$comments_allowed = supplied $ca ? $ca : 0;
|
$comments_allowed = supplied $ca ? $ca : 0;
|
||||||
$nocomment++ if supplied( $ca ) && no_comment;
|
$nocomment = $nc;
|
||||||
do_open_file $fname;;
|
do_open_file $fname;;
|
||||||
} else {
|
} else {
|
||||||
$ifstack = @ifstack;
|
$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
|
# Pop the include stack
|
||||||
#
|
#
|
||||||
@ -2039,8 +2054,14 @@ sub pop_include() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $arrayref ) {
|
if ( $arrayref ) {
|
||||||
( $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ) = @$arrayref;
|
( $currentfile,
|
||||||
$comment = '' unless @openstack;
|
$currentfilename,
|
||||||
|
$currentlinenumber,
|
||||||
|
$ifstack,
|
||||||
|
$file_format,
|
||||||
|
$max_format,
|
||||||
|
$comment,
|
||||||
|
$nocomment ) = @$arrayref;
|
||||||
} else {
|
} else {
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
$currentlinenumber = 'EOF';
|
$currentlinenumber = 'EOF';
|
||||||
@ -2433,7 +2454,7 @@ sub copy1( $ ) {
|
|||||||
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||||
|
|
||||||
if ( -s _ ) {
|
if ( -s _ ) {
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ];
|
push_include;
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
do_open_file $filename;
|
do_open_file $filename;
|
||||||
} else {
|
} else {
|
||||||
@ -2571,7 +2592,7 @@ EOF
|
|||||||
#
|
#
|
||||||
sub push_open( $;$$$ ) {
|
sub push_open( $;$$$ ) {
|
||||||
my ( $file, $max , $ca, $nc ) = @_;
|
my ( $file, $max , $ca, $nc ) = @_;
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ] if $currentfile;
|
push_include;
|
||||||
my @a = @includestack;
|
my @a = @includestack;
|
||||||
push @openstack, \@a;
|
push @openstack, \@a;
|
||||||
@includestack = ();
|
@includestack = ();
|
||||||
@ -2654,7 +2675,7 @@ sub embedded_shell( $ ) {
|
|||||||
|
|
||||||
$command .= q(');
|
$command .= q(');
|
||||||
|
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack , $file_format, $max_format, $nocomment ];
|
push_include;
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
||||||
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
||||||
@ -2716,7 +2737,7 @@ sub embedded_perl( $ ) {
|
|||||||
|
|
||||||
$perlscript = undef;
|
$perlscript = undef;
|
||||||
|
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack , $file_format, $max_format, $nocomment ];
|
push_include;
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
|
|
||||||
open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname";
|
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 _;
|
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||||
|
|
||||||
if ( -s _ ) {
|
if ( -s _ ) {
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack , $file_format, $max_format, $nocomment ];
|
push_include;
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
do_open_file $filename;
|
do_open_file $filename;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1639,7 +1639,7 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$) {
|
|||||||
|
|
||||||
progress_message "..Expanding Macro $macrofile...";
|
progress_message "..Expanding Macro $macrofile...";
|
||||||
|
|
||||||
push_open $macrofile, 2, 1, 1;
|
push_open $macrofile, 2, 1, no_comment;
|
||||||
|
|
||||||
macro_comment $macro;
|
macro_comment $macro;
|
||||||
|
|
||||||
@ -1767,9 +1767,9 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
|
|||||||
|
|
||||||
progress_message "..Expanding inline action $inlinefile...";
|
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 ) ) {
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
my ( $mtarget,
|
my ( $mtarget,
|
||||||
@ -1855,6 +1855,8 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
|
|||||||
progress_message " Rule \"$currentline\" $done";
|
progress_message " Rule \"$currentline\" $done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pop_comment;
|
||||||
|
|
||||||
pop_open;
|
pop_open;
|
||||||
|
|
||||||
progress_message "..End inline action $inlinefile";
|
progress_message "..End inline action $inlinefile";
|
||||||
|
Loading…
Reference in New Issue
Block a user