summaryrefslogtreecommitdiff
path: root/fixpp
blob: f75a175fb1acc643f8229a333b10e9b7b6ac7e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl

@lines = <>;
for (@lines) {
    $line++;

    if (/^PP\(pp_(\w+)/) { $newname = $1; $fixed = 1; $mark = 0; next; }
    if (/^}/) { $fixed{$newname} = $fixed; $mark{$newname} = $mark; $newname=''}

    next unless $fixed;

    if (/^#ifdef NOTDEF/) { $fixed = 0; }
    if (/MSP;/) { $mark = 1; }

    if (/\bMEXTEND/ && $mark == 0) { warn "Inconsistent mark line $line\n"; }
    if (/\bMXPUSH/ && $mark == 0) { warn "Inconsistent mark line $line\n"; }
    if (/\bMRETURN/ && $mark == 0) { warn "Inconsistent mark line $line\n"; }

    if (/\bEXTEND/ && $mark == 1) { warn "Inconsistent mark line $line\n"; }
    if (/\bXPUSH/ && $mark == 1) { warn "Inconsistent mark line $line\n"; }
    if (/\bRETURN/ && $mark == 1) { warn "Inconsistent mark line $line\n"; }

}

for (@lines) {
    if (m#^	0, /\* pp_(\w+)#) {
	$_ = "	pp_$1,\n" if $fixed{$1};
    }
    elsif (m#^	[01], /\* (\w+)[^,]#) {
	s/\d/$mark{$1} + 0/e;
    }
    last if /^PP/;
}

print @lines;