diff --git a/sch2fig/sch2pdf b/sch2fig/sch2pdf index 5a7504d..f15e0c6 100755 --- a/sch2fig/sch2pdf +++ b/sch2fig/sch2pdf @@ -32,12 +32,30 @@ while [ "$2" ]; do libs="$libs $1" shift done -cmd= + first=true -for n in `sed '/\$Sheet/,/\$EndSheet/p;d' "$1" | - sed '/F1 "\([^"]*\)" .*/s//\1/p;d'`; do - $quiet || echo "$n" 1>&2 - ./sch2fig $template $libs `dirname "$1"`/$n | fig2dev -L pdf >_tmp.pdf +sheet=false +while read line; do + if ! $sheet; then + [ "${line#\$Sheet}" != "$line" ] && sheet=true + continue + else + if [ "${line#\$EndSheet}" != "$line" ]; then + sheet=false + continue + fi + fi + if [ "${line#F0 \"}" != "$line" ]; then + name=${line#F0 \"} + name=${name%%\"*} + fi + [ "${line#F1 \"}" = "$line" ] && continue + file=${line#F1 \"} + file=${file%%\"*} + + $quiet || echo "$file" 1>&2 + ./sch2fig "-DTITLE=$name" $template $libs `dirname "$1"`/$file | + fig2dev -L pdf >_tmp.pdf if $first; then mv _tmp.pdf "$out" first=false @@ -45,4 +63,5 @@ for n in `sed '/\$Sheet/,/\$EndSheet/p;d' "$1" | pdfunite "$out" _tmp.pdf _tmp2.pdf mv _tmp2.pdf "$out" fi -done +done <"$1" +exit