r5861 - trunk/eda/boom
werner at docs.openmoko.org
werner at docs.openmoko.org
Wed Mar 31 20:18:37 CEST 2010
Author: werner
Date: 2010-03-31 20:18:37 +0200 (Wed, 31 Mar 2010)
New Revision: 5861
Modified:
trunk/eda/boom/parser.pl
Log:
When parting the KiCad BOM or .inv or .equ files, convert special characters in
part names/numbers to underscores. This avoids situations where we end up with
meta-characters in part names and then have to use wildcards to still match
them.
Modified: trunk/eda/boom/parser.pl
===================================================================
--- trunk/eda/boom/parser.pl 2010-03-31 18:17:01 UTC (rev 5860)
+++ trunk/eda/boom/parser.pl 2010-03-31 18:18:37 UTC (rev 5861)
@@ -3,6 +3,22 @@
use re 'eval';
+#
+# "sanitize" converts all "special" characters to underscores. This is used to
+# avoid part names that could conflict with other uses of meta-characters, such
+# as spaces or hash signs.
+#
+
+sub sanitize
+{
+ local (*s) = @_;
+ my $ok = '[^-a-zA-Z0-9._%,:()=+\/]';
+
+ print STDERR "converting special character(s) in $s\n" if $s =~ /$ok/;
+ $s =~ s/$ok/_/g;
+}
+
+
sub skip
{
# do nothing
@@ -28,6 +44,9 @@
my $ref = $1;
my @f = split(/\s*;\s*/, $');
next if $f[0] eq "NC";
+ for (@f) {
+ &sanitize(\$_);
+ }
$cmp{$ref} = [ @f ];
}
@@ -46,6 +65,8 @@
sub equ
{
my @f = split(/\s+/);
+ &sanitize(\$f[1]);
+ &sanitize(\$f[3]);
my $a = "$f[0] $f[1]";
my $b = "$f[2] $f[3]";
$id{$f[1]} = $a;
@@ -72,6 +93,7 @@
sub inv
{
my @f = split(/\s+/);
+ &sanitize(\$f[1]);
my $id = "$f[0] $f[1]";
shift @f;
my $ref = shift @f;
More information about the commitlog
mailing list