1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 20:53:21 +02:00
eda-tools/schhist/subschname2file

37 lines
870 B
Plaintext
Raw Normal View History

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