Merge branch 'maint'
[paraslash.git] / error2.pl
1 #!/usr/bin/env perl
2
3 use warnings;
4 use strict;
5
6 my %matrix;
7 my @executables;
8 my %objects;
9
10 sub make_matrix
11 {
12 my ($line, $e, @fields, $field);
13
14 while (defined($line = <>)) {
15 chomp($line);
16 if ($line =~ "^ *\$") {
17 next;
18 }
19 @fields = split(" ", $line);
20 while (defined(($field = shift(@fields)))) {
21 if ($field =~ ":\$") {
22 $field =~ s/://;
23 $e = $field;
24 push(@executables, $e);
25 next;
26 }
27 $matrix{$e . ">" . $field} = 1;
28 $objects{$field} = 1;
29 }
30 }
31 }
32
33 sub print_safe_objects
34 {
35 my @objs = keys(%objects);
36 my ($o1, $o2, $e);
37
38 foreach $o1 (@objs) {
39 print("#ifdef MAIN_INPUT_FILE_IS_$o1\n");
40 O2: foreach $o2 (@objs) {
41 foreach $e (@executables) {
42 if (!defined($matrix{$e . ">" . $o1})) {
43 next;
44 }
45 if (defined($matrix{$e . ">" . $o2})) {
46 next;
47 }
48 next O2;
49 }
50 $_ = $o2;
51 tr/a-z/A-Z/;
52 printf("SS_ENUM(%s);\n", $_);
53 }
54 print("#endif\n");
55 }
56 }
57 make_matrix;
58 print_safe_objects;