doc: remove duplicate entry for the "error" warning class
[nasm/nasm.git] / syncfiles.pl
blob9596923107d6f86891d11978b29d96025297b161
1 #!/usr/bin/perl
3 # Sync the output file list between Makefiles
4 # Use the mkdep.pl parameters to get the filename syntax
6 # The first file is the source file; the other ones target.
8 %def_hints = ('object-ending' => '.o',
9 'path-separator' => '/',
10 'continuation' => "\\");
12 sub do_transform($$) {
13 my($l, $h) = @_;
14 my($ps) = $$h{'path-separator'};
16 $l =~ s/\x01/$$h{'object-ending'}/g;
17 $l =~ s/\x03/$$h{'continuation'}/g;
19 if ($ps eq '') {
20 # Remove the path separator and the preceeding directory
21 $l =~ s/[^\s\=]*\x02//g;
22 } else {
23 # Convert the path separator
24 $l =~ s/\x02/$ps/g;
27 return $l;
30 @file_list = ();
32 $first = 1;
33 $first_file = $ARGV[0];
34 die unless (defined($first_file));
36 foreach $file (@ARGV) {
37 open(FILE, "< $file\0") or die;
39 # First, read the syntax hints
40 %hints = %def_hints;
41 while (defined($line = <FILE>)) {
42 if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
43 $hints{$1} = $2;
47 # Read and process the file
48 seek(FILE,0,0);
49 @lines = ();
50 $processing = 0;
51 while (defined($line = <FILE>)) {
52 chomp $line;
53 if ($processing) {
54 if ($line eq '#-- End File Lists --#') {
55 push(@lines, $line."\n");
56 $processing = 0;
57 } elsif ($first) {
58 my $xl = $line;
59 my $oe = "\Q$hints{'object-ending'}";
60 my $ps = "\Q$hints{'path-separator'}";
61 my $cn = "\Q$hints{'continuation'}";
63 $xl =~ s/${oe}(\s|$)/\x01$1/g;
64 $xl =~ s/${ps}/\x02/g;
65 $xl =~ s/${cn}$/\x03/;
66 push(@file_list, $xl);
67 push(@lines, $line);
69 } else {
70 push(@lines, $line."\n");
71 if ($line eq '#-- Begin File Lists --#') {
72 $processing = 1;
73 if (!$first) {
74 push(@lines, "# Edit in $first_file, not here!\n");
75 foreach $l (@file_list) {
76 push(@lines, do_transform($l, \%hints)."\n");
82 close(FILE);
84 # Write the file back out
85 if (!$first) {
86 open(FILE, "> $file\0") or die;
87 print FILE @lines;
88 close(FILE);
91 undef @lines;
92 $first = 0;