1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-22 21:57:32 +02:00
eda-tools/schhist/subschname2file
Werner Almesberger 553514cc67 schhist/subschname2file: search a subsheet name in the top-level sheet and
print the name of the subsheet file
2010-09-22 06:42:06 -03:00

37 lines
870 B
Perl
Executable File

#!/usr/bin/perl
#
# subschname2file - Translate a subsheet's name to sheet file's name
#
# Written 2010 by Werner Almesberger
# Copyright 2010 Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
sub usage
{
print STDERR "usage: $0 toplevel.sch subsheet-name\n";
exit(1);
}
($top, $name) = @ARGV;
&usage if $#ARGV != 1;
open(FILE, $top) || die "$top: $!";
while (<FILE>) {
$sheet = 1 if /^\$Sheet/;
$sheet = 0 if /^\$EndSheet/;
next unless $sheet;
$f0 = $1 if /^F0 "(.*)" /;
next unless /^F1 "(.*)" /;
next unless $f0 eq $name;
print "$1\n";
exit(0);
}
print STDERR "\"$name\" not found in $top\n";
exit(1);