diff options
author | H. Peter Anvin <hpa@zytor.com> | 2017-04-03 10:45:33 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2017-04-03 11:10:31 -0700 |
commit | 2956abbbf9274cb1fcec2da4250297fff792530e (patch) | |
tree | 0aa8de646d35831674213c1c68de9e297f10dd85 /tools | |
parent | 526a6c73904e9f07ee63dd76db06bd6687c4c849 (diff) | |
download | nasm-2956abbbf9274cb1fcec2da4250297fff792530e.tar.gz |
syncfiles.pl: allow for multiple synced sections
Allow for multiple sections of Makefiles to be synchronized; the
intent is to use this to synchronize the Perl file generation rules.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/syncfiles.pl | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/tools/syncfiles.pl b/tools/syncfiles.pl index b93e3ed2..38524a82 100755 --- a/tools/syncfiles.pl +++ b/tools/syncfiles.pl @@ -60,7 +60,7 @@ sub do_transform($$) { return $l; } -@file_list = (); +undef %line_lists; $first = 1; $first_file = $ARGV[0]; @@ -80,13 +80,16 @@ foreach $file (@ARGV) { # Read and process the file seek(FILE,0,0); @lines = (); - $processing = 0; + undef $processing; while (defined($line = <FILE>)) { chomp $line; - if ($processing) { - if ($line eq '#-- End File Lists --#') { + if (defined($processing)) { + if ($line =~ /^\#-- End ([^-\#]*[^-#\s]) --\#$/) { + if ($1 ne $processing) { + die "$0: $file: Mismatched Begin and End lines (\"$processing\" -> \"$1\"\n"; + } push(@lines, $line."\n"); - $processing = 0; + undef $processing; } elsif ($first) { my $xl = $line; my $oe = "\Q$hints{'object-ending'}"; @@ -96,16 +99,24 @@ foreach $file (@ARGV) { $xl =~ s/${oe}(\s|$)/\x01$1/g; $xl =~ s/${ps}/\x02/g; $xl =~ s/${cn}$/\x03/; - push(@file_list, $xl); + push(@{$line_lists{$processing}}, $xl); push(@lines, $line); } } else { push(@lines, $line."\n"); - if ($line eq '#-- Begin File Lists --#') { - $processing = 1; - if (!$first) { + if ($line =~ '#-- Begin ([^-\#]*[^-#\s]) --#') { + $processing = $1; + if ($first) { + if (defined($line_lists{$processing})) { + die "$0: $file: Repeated Begin block: $processing\n"; + } + $line_lists{$processing} = []; + } elsif (!$first) { + if (!defined($line_lists{$processing})) { + die "$0: $file: Begin block without template\n"; + } push(@lines, "# Edit in $first_file, not here!\n"); - foreach $l (@file_list) { + foreach $l (@{$line_lists{$processing}}) { push(@lines, do_transform($l, \%hints)."\n"); } } |