#! /bin/sh # Copyright (C) 2002 Sergey Poznyakoff # # This is a snarfer for guile version 1.6 # # 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. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. OUTFILE=/dev/tty DOCFILE=0 BASEDIR=`dirname $0` test -n "${CPP+set}" || CPP="gcc -E" test -n "${AWK+set}" || AWK=awk temp=/tmp/snarf.$$ trap "rm -f $temp" 0 1 2 15 # process aruments while [ $# -gt 0 ]; do case $1 in -o) OUTFILE=$2; shift 2;; -d) DOCFILE=1; shift;; *) break;; esac done INFILE=$1; shift cpp_exit=1 snarf_x() { echo "/* source: $INFILE */" ; echo "/* cpp arguments: $@ */" ; $CPP -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp} cpp_exit=$? grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//" -e "s/\^\ *:\ *\^.*/;/" } snarf_doc() { $CPP -DSCM_MAGIC_SNARF_DOCS "$@" > ${temp} cpp_exit=$? $AWK ' NF<2 {next} state == 0 && /\^\^ {/ { state = 1; print; next } state == 0 && /\^\^/ { print } state == 1 && /\^\^ }/ { state = 0; print; next } state == 1 { print } state == 0 { next }' $temp |\ tr -d '\n' | tr '^' '\n' |\ awk -f $BASEDIR/guile-doc-snarf.awk > $OUTFILE } case "$DOCFILE" in 0) snarf_x $INFILE "$@" > $OUTFILE;; 1) snarf_doc $INFILE "$@" > $OUTFILE;; esac if [ $cpp_exit -ne 0 ]; then [ "$OUTFILE" != "/dev/tty" ] && rm $OUTFILE fi exit $cpp_exit