aboutsummaryrefslogtreecommitdiff
path: root/scripts/guile-doc-snarf
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-01-10 13:48:50 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-01-10 13:48:50 +0000
commitdae948f2bfc04ad3896a22a40beeaf8f5bc090e6 (patch)
treece6d95863cef0fc5786a6ce974dbbd895afe2ee4 /scripts/guile-doc-snarf
parent35e5bf866c64563bcde636548de4e56677b3cf53 (diff)
downloadgamma-dae948f2bfc04ad3896a22a40beeaf8f5bc090e6.tar.gz
gamma-dae948f2bfc04ad3896a22a40beeaf8f5bc090e6.tar.bz2
Updated for guile >= 1.6
Diffstat (limited to 'scripts/guile-doc-snarf')
-rwxr-xr-xscripts/guile-doc-snarf113
1 files changed, 64 insertions, 49 deletions
diff --git a/scripts/guile-doc-snarf b/scripts/guile-doc-snarf
index 16f739c..8b3aae4 100755
--- a/scripts/guile-doc-snarf
+++ b/scripts/guile-doc-snarf
@@ -1,57 +1,72 @@
#! /bin/sh
-# Extract the initialization actions for builtin things.
+# Copyright (C) 2002 Sergey Poznyakoff
#
-# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# 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, or (at your option)
-# any later version.
+# 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 software; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-# Boston, MA 02111-1307 USA
-#
-## For some obscure reason, the original guile-doc-snarf distributed
-## with guile up to version 1.4, passes guile-func-name-check
-## to awk without absolute path spec. Consequently the script bails
-## out unless guile-func-name-check is in the current directory.
-## This version assumes that both scripts live in the same directory
-## and deduces the path to guile-func-name-check from the own pathname.
-## --gray
-
-fullfilename=$1; shift
-
-# strip path to source directory
-filename=`basename $fullfilename`
-
-# we need to be sure that the .x file exists
-# since the .c/.cc file may include it
-# (the old guile-snarf did not have this problem
-# because the makefile redirects output to the .x file
-# which creates the file before the inclusion occurs)
-# --12/12/99 gjb
-no_ext=`echo $filename | sed 's/\.[^.]*$//g'`
-dot_doc=${no_ext}.doc
-
-temp="/tmp/snarf.$$"
-trap "rm -f $temp" 0 1 2 15
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-## Let the user override the preprocessor & awk autoconf found.
+OUTFILE=/dev/tty
+DOCFILE=0
+BASEDIR=`dirname $0`
test -n "${CPP+set}" || CPP="gcc -E"
-test -n "${AWK+set}" || AWK="gawk"
+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
+}
-## Must run guile-func-name-check on the unpreprocessed source
-${AWK} -f `dirname $0`/guile-func-name-check "$fullfilename"
+case "$DOCFILE" in
+ 0) snarf_x $INFILE "$@" > $OUTFILE;;
+ 1) snarf_doc $INFILE "$@" > $OUTFILE;;
+esac
-## We must use a temporary file here, instead of a pipe, because we
-## need to know if CPP exits with a non-zero status.
-${CPP} -DSCM_MAGIC_SNARFER "$@" > ${temp} || exit $?
-cat ${temp} | sed 's/^\(.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}\).*/\1/g' | \
-${AWK} -f `dirname $0`/guile-snarf.awk `basename ${dot_doc}`
+if [ $cpp_exit -ne 0 ]; then
+ [ "$OUTFILE" != "/dev/tty" ] && rm $OUTFILE
+fi
+exit $cpp_exit

Return to:

Send suggestions and report system problems to the System administrator.