2007-09-23 13:02:34 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
2008-05-24 07:59:59 +08:00
|
|
|
# Re-align the columns in insns.dat, and enforce case conventions
|
2007-09-23 13:02:34 +08:00
|
|
|
#
|
|
|
|
|
2008-05-21 02:04:26 +08:00
|
|
|
@cols = (0, 16, 48, 96);
|
2007-09-23 13:02:34 +08:00
|
|
|
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
chomp $line;
|
|
|
|
if ($line !~ /^\s*(\;.*|)$/) {
|
|
|
|
($ln = $line) =~ s/\s+$//;
|
2008-05-24 07:59:59 +08:00
|
|
|
if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
|
|
|
|
@fields = ($1, $2, $3, $4);
|
|
|
|
$fields[0] = "\U$fields[0]" unless ($fields[0] =~ /^[^a-z]+cc$/);
|
|
|
|
$fields[3] =~ s/\,+$//;
|
|
|
|
$fields[3] = "\U$fields[3]" unless ($fields[3] eq 'ignore');
|
2007-09-23 13:02:34 +08:00
|
|
|
$c = 0;
|
|
|
|
$line = '';
|
|
|
|
for ($i = 0; $i < scalar(@fields); $i++) {
|
|
|
|
if ($i > 0 && $c >= $cols[$i]) {
|
|
|
|
$line .= ' ';
|
|
|
|
$c++;
|
2008-05-24 07:59:59 +08:00
|
|
|
}
|
2007-09-23 13:02:34 +08:00
|
|
|
while ($c < $cols[$i]) {
|
|
|
|
$line .= "\t";
|
2008-05-24 07:59:59 +08:00
|
|
|
$c = ($c+8) & ~7;
|
2007-09-23 13:02:34 +08:00
|
|
|
}
|
|
|
|
$line .= $fields[$i];
|
2008-05-24 07:59:59 +08:00
|
|
|
for ($j = 0; $j < length($fields[$i]); $j++) {
|
|
|
|
if (substr($fields[$i], $j, 1) eq "\t") {
|
|
|
|
$c = ($c+8) & ~7;
|
|
|
|
} else {
|
|
|
|
$c++;
|
|
|
|
}
|
|
|
|
}
|
2007-09-23 13:02:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print $line, "\n";
|
|
|
|
}
|