#!/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;