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., 51 Franklin Street, Fifth Floor, Boston,
18 #------------------------------------------------------------------
19 #--------------------------------JM Routoure-----------------------
20 #---------------------------------28/02/2000-----------------------
21 #------------------------------------------------------------------
24 echo "No sch file indicated"
27 echo " file is generated by gschem"
31 # create a secure temp directory
32 tmpd
=${TMP:-/tmp}/annotate.$$
35 if test $rc -ne 0 ; then
38 $0: ERROR -- failed to securily create ${tmpd}
39 Check to make sure that the directory does not already
40 exist and that you have sufficient permissions to create it.
48 # Determine the different refdes=?
50 list
=`@AWK@ '/^refdes=[A-Z]+\?/ {
51 A=$1; gsub(/refdes=/,"",A)
53 print A}' $1 | sort | @AWK@ 'BEGIN {if (NR==1) {A=$1} }{if (A !=$1) print ; A=$1}' - `
56 if [ -z "$list" ]; then
57 echo "No new devices found!"
61 # make a copy of the current schematics
65 # Replace the ? by a number
69 # creation du script gawk 1
70 echo "BEGIN {R=0}" >${sc}
71 echo "/^refdes=$f[0-9]+/ {B=\$1" >>${sc}
72 echo "gsub(/refdes=[A-Z]+/,\"\",B)" >>${sc}
73 echo "if (B>R) {R=B}" >>${sc}
75 echo "END {printf(\"%d\",R)}" >>${sc}
76 # execution des scripts
78 IMAX
=`@AWK@ -f ${sc} $1`
79 echo "Numbering of $f will start at $IMAX"
81 # creation du script gawk 2
83 echo "BEGIN {R=MAX} ">${sc}
84 echo "{if (match(\$1,/^refdes=$f\?/)!=0) {" >>${sc}
86 echo "sub(/\?/,R,\$1)" >>${sc}
87 echo "print \$1 } " >>${sc}
88 echo "else {print \$0}}">>${sc}
91 #echo "LL=NR}" >>${sc}
93 #echo "if ((OK==1)&&(NR==LL+1)) {print \$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" \"1\" \"\$7\" \"\$8 }" >>${sc}
94 #echo "if (NR==LL+2) {OK=0} " >>${sc}
95 #echo "if (OK==0) {print \$0} " >>${sc}
98 #execute the second script
100 cat $1 | @AWK@
-v MAX
=$IMAX -f ${sc} - > $1.tmp