mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-27 08:10:07 +08:00
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>
This commit is contained in:
parent
526a6c7390
commit
2956abbbf9
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user