3 # gEDA - GPL Electronic Design Automation
4 # gsymupdate - gEDA Symbol Update
5 # Copyright (C) 2002 Ales V. Hvezda
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # This program takes a schematic filename on the command line and outputs an
24 # update schematic to stdout.
26 # This program only changes the label= attribute on nets to netname=
28 # Right now this program should only be run against schematics which are
29 # either version 20020527 or earlier.
32 print "gEDA/gschupdate version 0.2\n";
33 print "gEDA/gschupdate comes with ABSOLUTELY NO WARRANTY; see COPYING for more details\n";
34 print "This is free software, and you are welcome to redistribute it under certain\n";
35 print "conditions; please see the COPYING file for more details.\n\n";
37 $numArgs = $#ARGV + 1;
39 print "Usage: gschupdate filename1 filename2 ... filenameN\n";
44 foreach $filename (@ARGV) {
46 if (-r
"$filename.old") {
47 print "Found backup file: $filename.old. Not gschUpdating $filename\n";
49 rename ($filename, "$filename.old");
50 print "gschUpdating: $filename (backup: $filename.old)\n";
53 open (FILE
, "$filename.old") || die "Cannot open input file: $filename.old Exiting.\n";
54 open (NEWFILE
, ">$filename") || die "Cannot open output file: $filename Exiting.\n";
66 # are we dealing with an attribute?
67 if ($textline =~ /=/) {
69 # Break the attribute up into name=value
70 @attrib = split(/=/,$textline,2);
74 if ($name =~ /^label/) {
76 # It is a label attribute
77 print NEWFILE
$textcmd;
78 print NEWFILE
"netname=$value";
80 } elsif ($name =~ /^uref/) {
82 # It is a uref= attribute, convert to refdes=
83 print NEWFILE
$textcmd;
84 print NEWFILE
"refdes=$value";
87 # none of the above, just pass it through
88 print NEWFILE
$textcmd;
89 print NEWFILE
$textline;
94 print NEWFILE
$textcmd;
95 print NEWFILE
$textline;
99 # It is not a text, so pass it through
107 # Load and Save the file using gschlas
108 # This updates the file to be absolutely current
109 system("gschlas $filename");
110 @args = ("gschlas", "$filename");
111 system(@args) == 0 || die "system @args failed: $?"