3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 #------------------------------------------------------------------
18 #--------------------------------JM Routoure-----------------------
19 #---------------------------------28/02/2000-----------------------
20 #------------------------------------------------------------------
23 echo "No sch file indicated"
26 echo " file is generated by gschem"
30 # create a secure temp directory
31 tmpd
=${TMP:-/tmp}/annotate.$$
34 if test $rc -ne 0 ; then
37 $0: ERROR -- failed to securily create ${tmpd}
38 Check to make sure that the directory does not already
39 exist and that you have sufficient permissions to create it.
47 # Determine the different refdes=?
49 list
=`@AWK@ '/^refdes=[A-Z]+\?/ {
50 A=$1; gsub(/refdes=/,"",A)
52 print A}' $1 | sort | @AWK@ 'BEGIN {if (NR==1) {A=$1} }{if (A !=$1) print ; A=$1}' - `
55 if [ -z "$list" ]; then
56 echo "No new devices found!"
60 # make a copy of the current schematics
64 # Replace the ? by a number
68 # creation du script gawk 1
69 echo "BEGIN {R=0}" >${sc}
70 echo "/^refdes=$f[0-9]+/ {B=\$1" >>${sc}
71 echo "gsub(/refdes=[A-Z]+/,\"\",B)" >>${sc}
72 echo "if (B>R) {R=B}" >>${sc}
74 echo "END {printf(\"%d\",R)}" >>${sc}
75 # execution des scripts
77 IMAX
=`@AWK@ -f ${sc} $1`
78 echo "Numbering of $f will start at $IMAX"
80 # creation du script gawk 2
82 echo "BEGIN {R=MAX} ">${sc}
83 echo "{if (match(\$1,/^refdes=$f\?/)!=0) {" >>${sc}
85 echo "sub(/\?/,R,\$1)" >>${sc}
86 echo "print \$1 } " >>${sc}
87 echo "else {print \$0}}">>${sc}
90 #echo "LL=NR}" >>${sc}
92 #echo "if ((OK==1)&&(NR==LL+1)) {print \$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" \"1\" \"\$7\" \"\$8 }" >>${sc}
93 #echo "if (NR==LL+2) {OK=0} " >>${sc}
94 #echo "if (OK==0) {print \$0} " >>${sc}
97 #execute the second script
99 cat $1 | @AWK@
-v MAX
=$IMAX -f ${sc} - > $1.tmp