#! /usr/bin/perl
use strict;
my @flags_str2int = (
{ str => 'hole', int => 0x00000008 },
{ str => 'clearpoly', int => 0x00000010 },
{ str => 'clearline', int => 0x00000020 },
{ str => 'auto', int => 0x00000080 },
{ str => 'onsolder', int => 0x00000080 },
{ str => 'square', int => 0x00000100 },
{ str => 'rubberend', int => 0x00000200 },
{ str => 'edge2', int => 0x00004000 },
{ str => 'thermal(1)', int => 0x00030000 },
);
sub flag_str2int {
my $strs_str = shift;
my $int = 0;
my @strs = split( /[ ,]/, $strs_str );
foreach my $str (@strs) {
foreach my $i_str2int (@flags_str2int) {
my $i_str = $i_str2int->{str};
my $i_int = $i_str2int->{int};
if( $str eq $i_str ) {
$int |= $i_int;
}
}
}
return $int;
}
my $section = '';
my $line;
while( $line = <> ) {
chomp $line;
chomp $line;
# global section
if( $section eq '' ) {
# add indicator to pcb release comment
if( $line =~ /^# release: (.*)$/ ) {
print( "# release: $1 - pcb_old2new.pl\n" );
# reformat Grid
} elsif( $line =~ /^Grid\[([0-9.]+) ([0-9]+ [0-9]+ [0-9]+)\]$/ ) {
printf( "Grid[%.8f %s]\n", $1, $2 );
# remove PolyAera
} elsif( $line =~ /^PolyArea\[[0-9.]*\]$/ ) {