summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--support/Makefile.in88
-rw-r--r--support/SYMLINKS18
-rw-r--r--support/bash.pc.in28
-rw-r--r--support/bash.xbm60
-rw-r--r--support/bashbug.sh272
-rw-r--r--support/bashbug.sh.in272
-rw-r--r--support/bashversion.c148
-rwxr-xr-xsupport/checkbashisms170
-rwxr-xr-xsupport/config.guess1486
-rwxr-xr-xsupport/config.rpath684
-rwxr-xr-xsupport/config.sub1790
-rwxr-xr-xsupport/fixlinks89
-rwxr-xr-xsupport/install.sh247
-rw-r--r--support/man2html.c4088
-rwxr-xr-xsupport/missing187
-rwxr-xr-xsupport/mkclone122
-rwxr-xr-xsupport/mkconffiles79
-rwxr-xr-xsupport/mkdirs47
-rwxr-xr-xsupport/mkinstalldirs111
-rw-r--r--support/mksignames.c111
-rwxr-xr-xsupport/mkversion.sh168
-rw-r--r--support/printenv.c72
-rwxr-xr-xsupport/printenv.sh27
-rw-r--r--support/recho.c67
-rwxr-xr-xsupport/rlvers.sh113
-rwxr-xr-xsupport/shobj-conf594
-rw-r--r--support/signames.c401
-rwxr-xr-xsupport/texi2dvi1944
-rwxr-xr-xsupport/texi2html5428
-rw-r--r--support/xcase.c98
-rwxr-xr-xsupport/xenix-link.sh84
-rw-r--r--support/zecho.c43
32 files changed, 19136 insertions, 0 deletions
diff --git a/support/Makefile.in b/support/Makefile.in
new file mode 100644
index 0000000..0289e0a
--- /dev/null
+++ b/support/Makefile.in
@@ -0,0 +1,88 @@
+#
+# Simple Makefile for the support programs.
+#
+# documentation support: man2html
+# testing support: printenv recho zecho xcase
+#
+# bashbug.sh lives here (created by configure), but bashbug is created by
+# the top-level makefile
+#
+# Currently only man2html is built
+#
+# Copyright (C) 1998-2018 Free Software Foundation, Inc.
+
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#
+# Boilerplate
+#
+topdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+BUILD_DIR = @BUILD_DIR@
+
+RM = rm -f
+SHELL = @MAKE_SHELL@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+
+EXEEXT = @EXEEXT@
+
+#
+# Compiler options:
+#
+PROFILE_FLAGS = @PROFILE_FLAGS@
+
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+LOCAL_CFLAGS = @LOCAL_CFLAGS@
+DEFS = @DEFS@
+LOCAL_DEFS = @LOCAL_DEFS@
+
+LIBS = @LIBS@
+LIBS_FOR_BUILD = ${LIBS} # XXX
+
+LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
+LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
+LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
+
+INCLUDES = -I${BUILD_DIR} -I${topdir}
+
+BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
+ ${INCLUDES} $(LOCAL_CFLAGS)
+
+CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
+CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+
+SRC1 = man2html.c
+OBJ1 = man2html.o
+
+.c.o:
+ $(RM) $@
+ $(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
+
+all: man2html$(EXEEXT)
+
+man2html$(EXEEXT): $(OBJ1)
+ $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) $(OBJ1) -o $@ ${LIBS_FOR_BUILD}
+
+clean:
+ $(RM) man2html$(EXEEXT) $(OBJ1)
+
+distclean maintainer-clean mostlyclean: clean
+ $(RM) bash.pc bashbug.sh
+
+man2html.o: man2html.c
diff --git a/support/SYMLINKS b/support/SYMLINKS
new file mode 100644
index 0000000..06bbed7
--- /dev/null
+++ b/support/SYMLINKS
@@ -0,0 +1,18 @@
+#
+# symlink map for bash source tree
+#
+# link name link target
+#
+lib/readline/tilde.c ../tilde/tilde.c
+lib/readline/tilde.h ../tilde/tilde.h
+#
+lib/readline/ansi_stdlib.h ../../include/ansi_stdlib.h
+lib/readline/posixdir.h ../../include/posixdir.h
+lib/readline/posixjmp.h ../../include/posixjmp.h
+lib/readline/posixselect.h ../../include/posixselect.h
+lib/readline/posixstat.h ../../include/posixstat.h
+#lib/readline/rlstdc.h ../../include/stdc.h
+#lib/readline/xmalloc.c ../malloc/xmalloc.c
+#
+#lib/tilde/memalloc.h ../../include/memalloc.h
+#
diff --git a/support/bash.pc.in b/support/bash.pc.in
new file mode 100644
index 0000000..6009659
--- /dev/null
+++ b/support/bash.pc.in
@@ -0,0 +1,28 @@
+# bash.pc.in
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+loadablesdir=@loadablesdir@
+headersdir=${includedir}/@PACKAGE_NAME@
+
+LOCAL_CFLAGS = @LOCAL_CFLAGS@
+LOCAL_DEFS = @LOCAL_DEFS@
+CCFLAGS = ${LOCAL_DEFS} ${LOCAL_CFLAGS}
+
+CC = @CC@
+SHOBJ_CC = @SHOBJ_CC@
+SHOBJ_CFLAGS = @SHOBJ_CFLAGS@
+SHOBJ_LD = @SHOBJ_LD@
+SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
+SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
+SHOBJ_LIBS = @SHOBJ_LIBS@
+
+Name: @PACKAGE_NAME@
+Description: Bash headers for bash loadable builtins
+Version: @PACKAGE_VERSION@
+Url: @PACKAGE_URL@
+Libs: ${SHOBJ_LIBS}
+Cflags: ${SHOBJ_CFLAGS} ${CCFLAGS} -I${headersdir} -I${headersdir}/builtins -I${headersdir}/include
diff --git a/support/bash.xbm b/support/bash.xbm
new file mode 100644
index 0000000..14bbe6a
--- /dev/null
+++ b/support/bash.xbm
@@ -0,0 +1,60 @@
+From: Simon Marshall <sm2@sequent.cc.hull.ac.uk>
+Date: Wed, 8 May 91 17:15:58 +0100
+To: bug-bash@ai.mit.edu
+Subject: X bitmap for bash
+
+ Since other GNU software comes with its very own X bitmap, I
+ thought it was about time bash had one too & here it is! To use,
+ stick the stuff after my signature in a file <path>/bash.xbm. If
+ using a twm window manager, insert the lines:
+
+IconDirectory "<path>"
+Icons {
+ "<xterm title>" "bash.xbm"
+}
+ in your ~/.twmrc file. The <xterm title> can be a prefix, so if
+ you have titles "bash@machine", the prefix "bash" will do. I'm not
+ familiar enough with other window managers, but they should be
+ similar.
+
+ If you like it, you're welcome to it...
+
+ Simon.
+
+Copyright (C) 1992 Simon Marshall
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#define bash_width 64
+#define bash_height 48
+static char bash_bits[] = {
+ 0x00, 0x60, 0x06, 0x30, 0x04, 0x00, 0x00, 0x00, 0x60, 0x98, 0x01, 0x40,
+ 0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0xa0, 0x80, 0x80, 0xff, 0x00, 0x00,
+ 0x06, 0x00, 0x1c, 0x03, 0xe1, 0x5f, 0x03, 0x00, 0x02, 0x00, 0x22, 0x0c,
+ 0x5d, 0xf4, 0x0e, 0x00, 0xe1, 0x02, 0x09, 0x19, 0x17, 0x91, 0x3d, 0x00,
+ 0xf8, 0x87, 0x40, 0x90, 0x88, 0x88, 0x6e, 0x00, 0x8e, 0x9b, 0x04, 0x62,
+ 0x22, 0x22, 0xd6, 0x00, 0x02, 0xee, 0x4c, 0x68, 0x44, 0x44, 0x6c, 0x01,
+ 0x02, 0xf8, 0xa1, 0x4a, 0x11, 0x11, 0xb1, 0x02, 0x05, 0xa0, 0x22, 0xe0,
+ 0x88, 0x88, 0x68, 0x03, 0x42, 0x50, 0x5d, 0x40, 0x22, 0x22, 0xa2, 0x05,
+ 0x11, 0x81, 0x00, 0x44, 0x44, 0x44, 0x44, 0x07, 0x02, 0x20, 0x84, 0x60,
+ 0x11, 0x11, 0xd1, 0x0d, 0x02, 0x0a, 0x02, 0xc0, 0x88, 0x88, 0x48, 0x0b,
+ 0x44, 0x40, 0x00, 0x42, 0x22, 0x22, 0xa2, 0x1d, 0x24, 0x08, 0x02, 0x64,
+ 0x44, 0x44, 0xc4, 0x1a, 0x08, 0x00, 0x20, 0x20, 0x11, 0x11, 0x91, 0x15,
+ 0x88, 0x00, 0x00, 0xe1, 0xff, 0xff, 0xff, 0x1a, 0x10, 0x08, 0x22, 0x10,
+ 0x00, 0x00, 0xc0, 0x15, 0x31, 0x40, 0x00, 0xf2, 0x03, 0xc0, 0xc1, 0x1a,
+ 0x41, 0x24, 0x48, 0x6c, 0x06, 0x80, 0xc1, 0x15, 0x82, 0x01, 0x00, 0x66,
+ 0x06, 0x80, 0xc1, 0x1a, 0x04, 0x22, 0x12, 0x67, 0x06, 0x80, 0xc1, 0x15,
+ 0x0a, 0x04, 0xe0, 0x66, 0xe6, 0xb8, 0xc7, 0x1a, 0x09, 0xf0, 0x17, 0xee,
+ 0xb3, 0xa5, 0xcf, 0x15, 0x30, 0x00, 0x00, 0x6e, 0x86, 0x8d, 0xcd, 0x1a,
+ 0x00, 0x01, 0x80, 0x67, 0xe6, 0xbd, 0xcd, 0x15, 0x00, 0x46, 0x40, 0x66,
+ 0xb6, 0xb1, 0xcd, 0x1a, 0x00, 0x38, 0x3c, 0x66, 0xb6, 0xa5, 0xcd, 0x15,
+ 0x00, 0x00, 0x02, 0xf6, 0xe3, 0x9d, 0xdd, 0x1a, 0x00, 0x04, 0x60, 0x06,
+ 0x00, 0x00, 0xc0, 0x15, 0x00, 0x04, 0x40, 0xfe, 0xff, 0xff, 0xff, 0x1a,
+ 0x00, 0x02, 0x80, 0x12, 0x11, 0x11, 0x91, 0x15, 0x00, 0x00, 0x00, 0x8a,
+ 0x88, 0x88, 0x88, 0x1a, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0xa2, 0x15,
+ 0x00, 0x00, 0x00, 0x46, 0x44, 0x44, 0xc4, 0x9a, 0x00, 0x00, 0x00, 0x12,
+ 0x11, 0x11, 0x91, 0xb5, 0x00, 0x00, 0x10, 0x8a, 0x88, 0x88, 0x88, 0xba,
+ 0x00, 0x00, 0x10, 0x22, 0x22, 0x22, 0xa2, 0xd5, 0x00, 0x00, 0x30, 0xc6,
+ 0x44, 0x44, 0xcc, 0xdf, 0x00, 0x20, 0x39, 0x96, 0x15, 0x51, 0x99, 0xf5,
+ 0x80, 0xf2, 0x56, 0x8b, 0x9a, 0xea, 0x9b, 0xff, 0xc1, 0xad, 0x5e, 0xaf,
+ 0xbb, 0xfa, 0xba, 0xdf, 0x22, 0x9b, 0xae, 0xd7, 0x54, 0x5d, 0xd7, 0xbf,
+ 0x3b, 0x32, 0xce, 0xff, 0xff, 0xff, 0xff, 0xab, 0xae, 0x2b, 0x59, 0xaf,
+ 0xd4, 0xae, 0x2e, 0xc3, 0xdd, 0x43, 0xa9, 0xd1, 0xba, 0xae, 0x2c, 0xcd};
diff --git a/support/bashbug.sh b/support/bashbug.sh
new file mode 100644
index 0000000..29ce134
--- /dev/null
+++ b/support/bashbug.sh
@@ -0,0 +1,272 @@
+#!/bin/sh -
+#
+# bashbug - create a bug report and mail it to the bug address
+#
+# The bug address depends on the release status of the shell. Versions
+# with status `devel', `alpha', `beta', or `rc' mail bug reports to
+# chet@cwru.edu and, optionally, to bash-testers@cwru.edu.
+# Other versions send mail to bug-bash@gnu.org.
+#
+# Copyright (C) 1996-2004 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#
+# configuration section:
+# these variables are filled in by the make target in Makefile
+#
+MACHINE="!MACHINE!"
+OS="!OS!"
+CC="!CC!"
+CFLAGS="!CFLAGS!"
+RELEASE="!RELEASE!"
+PATCHLEVEL="!PATCHLEVEL!"
+RELSTATUS="!RELSTATUS!"
+MACHTYPE="!MACHTYPE!"
+
+PATH=/bin:/usr/bin:/usr/local/bin:$PATH
+export PATH
+
+# Check if TMPDIR is set, default to /tmp
+: ${TMPDIR:=/tmp}
+
+#Securely create a temporary directory for the temporary files
+TEMPDIR=$TMPDIR/bbug.$$
+(umask 077 && mkdir $TEMPDIR) || {
+ echo "$0: could not create temporary directory" >&2
+ exit 1
+}
+
+TEMPFILE1=$TEMPDIR/bbug1
+TEMPFILE2=$TEMPDIR/bbug2
+
+USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"
+VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
+
+do_help= do_version=
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help) shift ; do_help=y ;;
+ --version) shift ; do_version=y ;;
+ --) shift ; break ;;
+ -*) echo "bashbug: ${1}: invalid option" >&2
+ echo "$USAGE" >&2
+ exit 2 ;;
+ *) break ;;
+ esac
+done
+
+if [ -n "$do_version" ]; then
+ echo "${VERSTR}"
+ exit 0
+fi
+
+if [ -n "$do_help" ]; then
+ echo "${VERSTR}"
+ echo "${USAGE}"
+ echo
+ cat << HERE_EOF
+Bashbug is used to send mail to the Bash maintainers
+for when Bash doesn't behave like you'd like, or expect.
+
+Bashbug will start up your editor (as defined by the shell's
+EDITOR environment variable) with a preformatted bug report
+template for you to fill in. The report will be mailed to the
+bug-bash mailing list by default. See the manual for details.
+
+If you invoke bashbug by accident, just quit your editor without
+saving any changes to the template, and no bug report will be sent.
+HERE_EOF
+ exit 0
+fi
+
+# Figure out how to echo a string without a trailing newline
+N=`echo 'hi there\c'`
+case "$N" in
+*c) n=-n c= ;;
+*) n= c='\c' ;;
+esac
+
+BASHTESTERS="bash-testers@cwru.edu"
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*) BUGBASH=chet@cwru.edu ;;
+*) BUGBASH=bug-bash@gnu.org ;;
+esac
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*)
+ echo "$0: This is a testing release. Would you like your bug report"
+ echo "$0: to be sent to the bash-testers mailing list?"
+ echo $n "$0: Send to bash-testers? $c"
+ read ans
+ case "$ans" in
+ y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
+ esac ;;
+esac
+
+BUGADDR="${1-$BUGBASH}"
+
+if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
+ if [ -x /usr/bin/editor ]; then
+ DEFEDITOR=editor
+ elif [ -x /usr/local/bin/ce ]; then
+ DEFEDITOR=ce
+ elif [ -x /usr/local/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/contrib/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/xemacs ]; then
+ DEFEDITOR=xemacs
+ elif [ -x /usr/contrib/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/local/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/bin/vi ]; then
+ DEFEDITOR=vi
+ else
+ echo "$0: No default editor found: attempting to use vi" >&2
+ DEFEDITOR=vi
+ fi
+fi
+
+
+: ${EDITOR=$DEFEDITOR}
+
+: ${USER=${LOGNAME-`whoami`}}
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15
+trap 'rm -rf "$TEMPDIR"' 0
+
+UN=
+if (uname) >/dev/null 2>&1; then
+ UN=`uname -a`
+fi
+
+if [ -f /usr/lib/sendmail ] ; then
+ RMAIL="/usr/lib/sendmail"
+ SMARGS="-i -t"
+elif [ -f /usr/sbin/sendmail ] ; then
+ RMAIL="/usr/sbin/sendmail"
+ SMARGS="-i -t"
+else
+ RMAIL=rmail
+ SMARGS="$BUGADDR"
+fi
+
+INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'
+
+cat > "$TEMPFILE1" <<EOF
+From: ${USER}
+To: ${BUGADDR}
+Subject: ${INITIAL_SUBJECT}
+
+Configuration Information [Automatically generated, do not change]:
+Machine: $MACHINE
+OS: $OS
+Compiler: $CC
+Compilation CFLAGS: $CFLAGS
+uname output: $UN
+Machine Type: $MACHTYPE
+
+Bash Version: $RELEASE
+Patch Level: $PATCHLEVEL
+Release Status: $RELSTATUS
+
+Description:
+ [Detailed description of the problem, suggestion, or complaint.]
+
+Repeat-By:
+ [Describe the sequence of events that causes the problem
+ to occur.]
+
+Fix:
+ [Description of how to fix the problem. If you don't know a
+ fix for the problem, don't include this section.]
+EOF
+
+cp "$TEMPFILE1" "$TEMPFILE2"
+chmod u+w "$TEMPFILE1"
+
+trap '' 2 # ignore interrupts while in editor
+
+edstat=1
+while [ $edstat -ne 0 ]; do
+ $EDITOR "$TEMPFILE1"
+ edstat=$?
+
+ if [ $edstat -ne 0 ]; then
+ echo "$0: editor \`$EDITOR' exited with nonzero status."
+ echo "$0: Perhaps it was interrupted."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ continue
+ fi
+
+ # find the subject from the temp file and see if it's been changed
+ CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
+
+ case "$CURR_SUB" in
+ "${INITIAL_SUBJECT}")
+ echo
+ echo "$0: You have not changed the subject from the default."
+ echo "$0: Please use a more descriptive subject header."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ echo "$0: The editor will be restarted in five seconds."
+ sleep 5
+ edstat=1
+ ;;
+ esac
+
+done
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 2 # restore trap on SIGINT
+
+if cmp -s "$TEMPFILE1" "$TEMPFILE2"
+then
+ echo "File not changed, no bug report submitted."
+ exit
+fi
+
+echo $n "Send bug report to ${BUGADDR}? [y/n] $c"
+read ans
+case "$ans" in
+[Nn]*) exit 0 ;;
+esac
+
+${RMAIL} $SMARGS < "$TEMPFILE1" || {
+ cat "$TEMPFILE1" >> $HOME/dead.bashbug
+ echo "$0: mail to ${BUGADDR} failed: report saved in $HOME/dead.bashbug" >&2
+ echo "$0: please send it manually to ${BUGADDR}" >&2
+}
+
+exit 0
diff --git a/support/bashbug.sh.in b/support/bashbug.sh.in
new file mode 100644
index 0000000..5e92b99
--- /dev/null
+++ b/support/bashbug.sh.in
@@ -0,0 +1,272 @@
+#!/bin/sh -
+#
+# bashbug - create a bug report and mail it to the bug address
+#
+# The bug address depends on the release status of the shell. Versions
+# with status `devel', `alpha', `beta', or `rc' mail bug reports to
+# chet@cwru.edu and, optionally, to bash-testers@cwru.edu.
+# Other versions send mail to bug-bash@gnu.org.
+#
+# Copyright (C) 1996-2004 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#
+# configuration section:
+# these variables are filled in by the make target in Makefile
+#
+MACHINE="@host_cpu@"
+OS="@host_os@"
+CC="@CC@"
+CFLAGS="@CFLAGS@"
+RELEASE="@BASHVERS@"
+PATCHLEVEL="!PATCHLEVEL!"
+RELSTATUS="@RELSTATUS@"
+MACHTYPE="@host@"
+
+PATH=/bin:/usr/bin:/usr/local/bin:$PATH
+export PATH
+
+# Check if TMPDIR is set, default to /tmp
+: ${TMPDIR:=/tmp}
+
+#Securely create a temporary directory for the temporary files
+TEMPDIR=$TMPDIR/bbug.$$
+(umask 077 && mkdir $TEMPDIR) || {
+ echo "$0: could not create temporary directory" >&2
+ exit 1
+}
+
+TEMPFILE1=$TEMPDIR/bbug1
+TEMPFILE2=$TEMPDIR/bbug2
+
+USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"
+VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
+
+do_help= do_version=
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help) shift ; do_help=y ;;
+ --version) shift ; do_version=y ;;
+ --) shift ; break ;;
+ -*) echo "bashbug: ${1}: invalid option" >&2
+ echo "$USAGE" >&2
+ exit 2 ;;
+ *) break ;;
+ esac
+done
+
+if [ -n "$do_version" ]; then
+ echo "${VERSTR}"
+ exit 0
+fi
+
+if [ -n "$do_help" ]; then
+ echo "${VERSTR}"
+ echo "${USAGE}"
+ echo
+ cat << HERE_EOF
+Bashbug is used to send mail to the Bash maintainers
+for when Bash doesn't behave like you'd like, or expect.
+
+Bashbug will start up your editor (as defined by the shell's
+EDITOR environment variable) with a preformatted bug report
+template for you to fill in. The report will be mailed to the
+bug-bash mailing list by default. See the manual for details.
+
+If you invoke bashbug by accident, just quit your editor without
+saving any changes to the template, and no bug report will be sent.
+HERE_EOF
+ exit 0
+fi
+
+# Figure out how to echo a string without a trailing newline
+N=`echo 'hi there\c'`
+case "$N" in
+*c) n=-n c= ;;
+*) n= c='\c' ;;
+esac
+
+BASHTESTERS="bash-testers@cwru.edu"
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*) BUGBASH=chet@cwru.edu ;;
+*) BUGBASH=bug-bash@gnu.org ;;
+esac
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*)
+ echo "$0: This is a testing release. Would you like your bug report"
+ echo "$0: to be sent to the bash-testers mailing list?"
+ echo $n "$0: Send to bash-testers? $c"
+ read ans
+ case "$ans" in
+ y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
+ esac ;;
+esac
+
+BUGADDR="${1-$BUGBASH}"
+
+if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
+ if [ -x /usr/bin/editor ]; then
+ DEFEDITOR=editor
+ elif [ -x /usr/local/bin/ce ]; then
+ DEFEDITOR=ce
+ elif [ -x /usr/local/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/contrib/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/xemacs ]; then
+ DEFEDITOR=xemacs
+ elif [ -x /usr/contrib/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/local/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/bin/vi ]; then
+ DEFEDITOR=vi
+ else
+ echo "$0: No default editor found: attempting to use vi" >&2
+ DEFEDITOR=vi
+ fi
+fi
+
+
+: ${EDITOR=$DEFEDITOR}
+
+: ${USER=${LOGNAME-`whoami`}}
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15
+trap 'rm -rf "$TEMPDIR"' 0
+
+UN=
+if (uname) >/dev/null 2>&1; then
+ UN=`uname -a`
+fi
+
+if [ -f /usr/lib/sendmail ] ; then
+ RMAIL="/usr/lib/sendmail"
+ SMARGS="-i -t"
+elif [ -f /usr/sbin/sendmail ] ; then
+ RMAIL="/usr/sbin/sendmail"
+ SMARGS="-i -t"
+else
+ RMAIL=rmail
+ SMARGS="$BUGADDR"
+fi
+
+INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'
+
+cat > "$TEMPFILE1" <<EOF
+From: ${USER}
+To: ${BUGADDR}
+Subject: ${INITIAL_SUBJECT}
+
+Configuration Information [Automatically generated, do not change]:
+Machine: $MACHINE
+OS: $OS
+Compiler: $CC
+Compilation CFLAGS: $CFLAGS
+uname output: $UN
+Machine Type: $MACHTYPE
+
+Bash Version: $RELEASE
+Patch Level: $PATCHLEVEL
+Release Status: $RELSTATUS
+
+Description:
+ [Detailed description of the problem, suggestion, or complaint.]
+
+Repeat-By:
+ [Describe the sequence of events that causes the problem
+ to occur.]
+
+Fix:
+ [Description of how to fix the problem. If you don't know a
+ fix for the problem, don't include this section.]
+EOF
+
+cp "$TEMPFILE1" "$TEMPFILE2"
+chmod u+w "$TEMPFILE1"
+
+trap '' 2 # ignore interrupts while in editor
+
+edstat=1
+while [ $edstat -ne 0 ]; do
+ $EDITOR "$TEMPFILE1"
+ edstat=$?
+
+ if [ $edstat -ne 0 ]; then
+ echo "$0: editor \`$EDITOR' exited with nonzero status."
+ echo "$0: Perhaps it was interrupted."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ continue
+ fi
+
+ # find the subject from the temp file and see if it's been changed
+ CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
+
+ case "$CURR_SUB" in
+ "${INITIAL_SUBJECT}")
+ echo
+ echo "$0: You have not changed the subject from the default."
+ echo "$0: Please use a more descriptive subject header."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ echo "$0: The editor will be restarted in five seconds."
+ sleep 5
+ edstat=1
+ ;;
+ esac
+
+done
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 2 # restore trap on SIGINT
+
+if cmp -s "$TEMPFILE1" "$TEMPFILE2"
+then
+ echo "File not changed, no bug report submitted."
+ exit
+fi
+
+echo $n "Send bug report to ${BUGADDR}? [y/n] $c"
+read ans
+case "$ans" in
+[Nn]*) exit 0 ;;
+esac
+
+${RMAIL} $SMARGS < "$TEMPFILE1" || {
+ cat "$TEMPFILE1" >> $HOME/dead.bashbug
+ echo "$0: mail to ${BUGADDR} failed: report saved in $HOME/dead.bashbug" >&2
+ echo "$0: please send it manually to ${BUGADDR}" >&2
+}
+
+exit 0
diff --git a/support/bashversion.c b/support/bashversion.c
new file mode 100644
index 0000000..59c2321
--- /dev/null
+++ b/support/bashversion.c
@@ -0,0 +1,148 @@
+/* bashversion.c -- Display bash version information. */
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#include "stdc.h"
+
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include "bashansi.h"
+
+#include "version.h"
+#include "conftypes.h"
+
+#define RFLAG 0x0001
+#define VFLAG 0x0002
+#define MFLAG 0x0004
+#define PFLAG 0x0008
+#define SFLAG 0x0010
+#define LFLAG 0x0020
+#define XFLAG 0x0040
+
+extern int optind;
+extern char *optarg;
+
+extern char *dist_version;
+extern int patch_level;
+
+extern char *shell_version_string __P((void));
+extern void show_shell_version __P((int));
+
+char *shell_name = "bash";
+char *progname;
+
+static void
+usage()
+{
+ fprintf(stderr, "%s: usage: %s [-hrvpmlsx]\n", progname, progname);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int opt, oflags;
+ char dv[128], *rv;
+
+ if (progname = strrchr (argv[0], '/'))
+ progname++;
+ else
+ progname = argv[0];
+
+ oflags = 0;
+ while ((opt = getopt(argc, argv, "hrvmpslx")) != EOF)
+ {
+ switch (opt)
+ {
+ case 'h':
+ usage ();
+ exit (0);
+ case 'r':
+ oflags |= RFLAG; /* release */
+ break;
+ case 'v':
+ oflags |= VFLAG; /* version */
+ break;
+ case 'm':
+ oflags |= MFLAG; /* machtype */
+ break;
+ case 'p':
+ oflags |= PFLAG; /* patchlevel */
+ break;
+ case 's': /* short version string */
+ oflags |= SFLAG;
+ break;
+ case 'l': /* long version string */
+ oflags |= LFLAG;
+ break;
+ case 'x': /* extended version information */
+ oflags |= XFLAG;
+ break;
+ default:
+ usage ();
+ exit (2);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ {
+ usage ();
+ exit (2);
+ }
+
+ /* default behavior */
+ if (oflags == 0)
+ oflags = SFLAG;
+
+ if (oflags & (RFLAG|VFLAG))
+ {
+ strcpy (dv, dist_version);
+ rv = strchr (dv, '.');
+ if (rv)
+ *rv++ = '\0';
+ else
+ rv = "00";
+ }
+ if (oflags & RFLAG)
+ printf ("%s\n", dv);
+ else if (oflags & VFLAG)
+ printf ("%s\n", rv);
+ else if (oflags & MFLAG)
+ printf ("%s\n", MACHTYPE);
+ else if (oflags & PFLAG)
+ printf ("%d\n", patch_level);
+ else if (oflags & SFLAG)
+ printf ("%s\n", shell_version_string ());
+ else if (oflags & LFLAG)
+ show_shell_version (0);
+ else if (oflags & XFLAG)
+ show_shell_version (1);
+
+ exit (0);
+}
diff --git a/support/checkbashisms b/support/checkbashisms
new file mode 100755
index 0000000..ea6cc14
--- /dev/null
+++ b/support/checkbashisms
@@ -0,0 +1,170 @@
+#! /usr/bin/perl -w
+
+# This script is essentially copied from /usr/share/lintian/checks/scripts,
+# which is:
+# Copyright (C) 1998 Richard Braakman
+# Copyright (C) 2002 Josip Rodin
+# This version is
+# Copyright (C) 2003 Julian Gilbey
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+use strict;
+
+(my $progname = $0) =~ s|.*/||;
+
+my $usage = <<"EOF";
+Usage: $progname [-n] script ...
+ or: $progname --help
+ or: $progname --version
+This script performs basic checks for the presence of bashisms
+in /bin/sh scripts.
+EOF
+
+my $version = <<"EOF";
+This is $progname, from the Debian devscripts package, version 2.10.7ubuntu5
+This code is copyright 2003 by Julian Gilbey <jdg\@debian.org>,
+based on original code which is copyright 1998 by Richard Braakman
+and copyright 2002 by Josip Rodin.
+This program comes with ABSOLUTELY NO WARRANTY.
+You are free to redistribute this code under the terms of the
+GNU General Public License, version 3, or (at your option) any later version.
+EOF
+
+my $opt_echo = 0;
+
+##
+## handle command-line options
+##
+if (int(@ARGV) == 0 or $ARGV[0] =~ /^(--help|-h)$/) { print $usage; exit 0; }
+if (@ARGV and $ARGV[0] =~ /^(--version|-v)$/) { print $version; exit 0; }
+if (@ARGV and $ARGV[0] =~ /^(--newline|-n)$/) { $opt_echo = 1; }
+
+
+my $status = 0;
+
+foreach my $filename (@ARGV) {
+ if ($filename eq '-n' or $filename eq '--newline') {
+ next;
+ }
+ unless (open C, "$filename") {
+ warn "cannot open script $filename for reading: $!\n";
+ $status |= 2;
+ next;
+ }
+
+ my $cat_string = "";
+
+ while (<C>) {
+ if ($. == 1) { # This should be an interpreter line
+ if (m,^\#!\s*(\S+),) {
+ my $interpreter = $1;
+ if ($interpreter =~ m,/bash$,) {
+ warn "script $filename is already a bash script; skipping\n";
+ $status |= 2;
+ last; # end this file
+ }
+ elsif ($interpreter !~ m,/(sh|ash|dash)$,) {
+ warn "script $filename does not appear to be a /bin/sh script; skipping\n";
+ $status |= 2;
+ last;
+ }
+ } else {
+ warn "script $filename does not appear to have a \#! interpreter line;\nyou may get strange results\n";
+ }
+ }
+
+ next if m,^\s*\#,; # skip comment lines
+ chomp;
+ my $orig_line = $_;
+
+ s/(?<!\\)\#.*$//; # eat comments
+
+ if (m/(?:^|\s+)cat\s*\<\<\s*(\w+)/) {
+ $cat_string = $1;
+ }
+ elsif ($cat_string ne "" and m/^$cat_string/) {
+ $cat_string = "";
+ }
+ my $within_another_shell = 0;
+ if (m,(^|\s+)((/usr)?/bin/)?((b|d)?a|k|z|t?c)sh\s+-c\s*.+,) {
+ $within_another_shell = 1;
+ }
+ # if cat_string is set, we are in a HERE document and need not
+ # check for things
+ if ($cat_string eq "" and !$within_another_shell) {
+ my $found = 0;
+ my $match = '';
+ my $explanation = '';
+ my %bashisms = (
+ '(?:^|\s+)function\s+\w+' => q<'function' is useless>,
+ '(?:^|\s+)select\s+\w+' => q<'select' is not POSIX>,
+ '(?:^|\s+)source\s+(?:\.\/|\/|\$)[^\s]+' =>
+ q<should be '.', not 'source'>,
+ '(\[|test|-o|-a)\s*[^\s]+\s+==\s' =>
+ q<should be 'b = a'>,
+ '\s\|\&' => q<pipelining is not POSIX>,
+ '\$\[\w+\]' => q<arithmetic not allowed>,
+ '\$\{\w+\:\d+(?::\d+)?\}' => q<${foo:3[:1]}>,
+ '\$\{!\w+[@*]\}' => q<${!prefix[*|@]>,
+ '\$\{!\w+\}' => q<${!name}>,
+ '\$\{\w+(/.+?){1,2}\}' => q<${parm/?/pat[/str]}>,
+ '[^\\\]\{([^\s]+?,)+[^\\\}\s]+\}' =>
+ q<brace expansion>,
+ '(?:^|\s+)\w+\[\d+\]=' => q<bash arrays, H[0]>,
+ '\$\{\#?\w+\[[0-9\*\@]+\]\}' => q<bash arrays, ${name[0|*|@]}>,
+ '(?:^|\s+)(read\s*(?:;|$))' => q<read without variable>,
+ '\$\(\([A-Za-z]' => q<cnt=$((cnt + 1)) does not work in dash>,
+ 'echo\s+-[e]' => q<echo -e>,
+ 'exec\s+-[acl]' => q<exec -c/-l/-a name>,
+ '\blet\s' => q<let ...>,
+ '\$RANDOM\b' => q<$RANDOM>,
+ '(?<!\$)\(\(' => q<'((' should be '$(('>,
+ );
+
+ if ($opt_echo) {
+ $bashisms{'echo\s+-[n]'} = 'q<echo -n>';
+ }
+
+ while (my ($re,$expl) = each %bashisms) {
+ if (m/($re)/) {
+ $found = 1;
+ $match = $1;
+ $explanation = $expl;
+ last;
+ }
+ }
+ # since this test is ugly, I have to do it by itself
+ # detect source (.) trying to pass args to the command it runs
+ if (not $found and m/^\s*(\.\s+[^\s]+\s+([^\s]+))/) {
+ if ($2 eq '&&' || $2 eq '||') {
+ # everything is ok
+ ;
+ } else {
+ $found = 1;
+ $match = $1;
+ }
+ }
+ unless ($found == 0) {
+ warn "possible bashism in $filename line $. ($explanation):\n$orig_line\n";
+ $status |= 1;
+ }
+ }
+ }
+
+ close C;
+}
+
+exit $status;
diff --git a/support/config.guess b/support/config.guess
new file mode 100755
index 0000000..18f8edc
--- /dev/null
+++ b/support/config.guess
@@ -0,0 +1,1486 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright 1992-2018 Free Software Foundation, Inc.
+
+timestamp='2018-08-29'
+
+# This file 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 3 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, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
+#
+# You can get the latest version of this script from:
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+#
+# Please send patches to <config-patches@gnu.org>.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Options:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2018 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+tmp=
+# shellcheck disable=SC2172
+trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
+trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
+
+set_cc_for_build() {
+ : "${TMPDIR=/tmp}"
+ # shellcheck disable=SC2039
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
+ dummy=$tmp/dummy
+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
+ ,,) echo "int x;" > "$dummy.c"
+ for driver in cc gcc c89 c99 ; do
+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$driver"
+ break
+ fi
+ done
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+ esac
+}
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if test -f /.attbin/uname ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "$UNAME_SYSTEM" in
+Linux|GNU|GNU/*)
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ LIBC=gnu
+
+ set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #else
+ LIBC=gnu
+ #endif
+ EOF
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+ # If ldd exists, use it to detect musl libc.
+ if command -v ldd >/dev/null && \
+ ldd --version 2>&1 | grep -q ^musl
+ then
+ LIBC=musl
+ fi
+ ;;
+esac
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+ "/sbin/$sysctl" 2>/dev/null || \
+ "/usr/sbin/$sysctl" 2>/dev/null || \
+ echo unknown)`
+ case "$UNAME_MACHINE_ARCH" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ earmv*)
+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
+ machine="${arch}${endian}"-unknown
+ ;;
+ *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently (or will in the future) and ABI.
+ case "$UNAME_MACHINE_ARCH" in
+ earm*)
+ os=netbsdelf
+ ;;
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ELF__
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # Determine ABI tags.
+ case "$UNAME_MACHINE_ARCH" in
+ earm*)
+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "$UNAME_VERSION" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "$machine-${os}${release}${abi-}"
+ exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
+ exit ;;
+ *:LibertyBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
+ echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
+ exit ;;
+ *:MidnightBSD:*:*)
+ echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
+ exit ;;
+ *:SolidBSD:*:*)
+ echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
+ exit ;;
+ *:MirBSD:*:*)
+ echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
+ exit ;;
+ *:Sortix:*:*)
+ echo "$UNAME_MACHINE"-unknown-sortix
+ exit ;;
+ *:Redox:*:*)
+ echo "$UNAME_MACHINE"-unknown-redox
+ exit ;;
+ mips:OSF1:*.*)
+ echo mips-dec-osf1
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE=alpha ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE=alpha ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE=alpha ;;
+ "EV5 (21164)")
+ UNAME_MACHINE=alphaev5 ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE=alphaev56 ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE=alphapca56 ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE=alphapca57 ;;
+ "EV6 (21264)")
+ UNAME_MACHINE=alphaev6 ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE=alphaev67 ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE=alphaev68 ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE=alphaev69 ;;
+ "EV7 (21364)")
+ UNAME_MACHINE=alphaev7 ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE=alphaev79 ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo "$UNAME_MACHINE"-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo "$UNAME_MACHINE"-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix"$UNAME_RELEASE"
+ exit ;;
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ s390x:SunOS:*:*)
+ echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
+ exit ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
+ exit ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ echo i386-pc-auroraux"$UNAME_RELEASE"
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
+ case `isainfo -b` in
+ 32)
+ echo i386-pc-solaris2"$UNAME_REL"
+ ;;
+ 64)
+ echo x86_64-pc-solaris2"$UNAME_REL"
+ ;;
+ esac
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos"$UNAME_RELEASE"
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos"$UNAME_RELEASE"
+ ;;
+ sun4)
+ echo sparc-sun-sunos"$UNAME_RELEASE"
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos"$UNAME_RELEASE"
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint"$UNAME_RELEASE"
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint"$UNAME_RELEASE"
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint"$UNAME_RELEASE"
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint"$UNAME_RELEASE"
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint"$UNAME_RELEASE"
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint"$UNAME_RELEASE"
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten"$UNAME_RELEASE"
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten"$UNAME_RELEASE"
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix"$UNAME_RELEASE"
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix"$UNAME_RELEASE"
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix"$UNAME_RELEASE"
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos"$UNAME_RELEASE"
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
+ then
+ if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
+ [ "$TARGET_BINARY_INTERFACE"x = x ]
+ then
+ echo m88k-dg-dgux"$UNAME_RELEASE"
+ else
+ echo m88k-dg-dguxbcs"$UNAME_RELEASE"
+ fi
+ else
+ echo i586-dg-dgux"$UNAME_RELEASE"
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ fi
+ echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[4567])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/lslpp ] ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
+ else
+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ fi
+ echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+ case "$UNAME_MACHINE" in
+ 9000/31?) HP_ARCH=m68000 ;;
+ 9000/[34]??) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "$sc_cpu_version" in
+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "$sc_kernel_bits" in
+ 32) HP_ARCH=hppa2.0n ;;
+ 64) HP_ARCH=hppa2.0w ;;
+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "$HP_ARCH" = "" ]; then
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ "$HP_ARCH" = hppa2.0w ]
+ then
+ set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
+ then
+ HP_ARCH=hppa2.0w
+ else
+ HP_ARCH=hppa64
+ fi
+ fi
+ echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux"$HPUX_REV"
+ exit ;;
+ 3050*:HI-UX:*:*)
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo "$UNAME_MACHINE"-unknown-osf1mk
+ else
+ echo "$UNAME_MACHINE"-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi"$UNAME_RELEASE"
+ exit ;;
+ *:BSD/OS:*:*)
+ echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
+ exit ;;
+ arm:FreeBSD:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ set_cc_for_build
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
+ else
+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
+ fi
+ exit ;;
+ *:FreeBSD:*:*)
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ case "$UNAME_PROCESSOR" in
+ amd64)
+ UNAME_PROCESSOR=x86_64 ;;
+ i386)
+ UNAME_PROCESSOR=i586 ;;
+ esac
+ echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
+ exit ;;
+ i*:CYGWIN*:*)
+ echo "$UNAME_MACHINE"-pc-cygwin
+ exit ;;
+ *:MINGW64*:*)
+ echo "$UNAME_MACHINE"-pc-mingw64
+ exit ;;
+ *:MINGW*:*)
+ echo "$UNAME_MACHINE"-pc-mingw32
+ exit ;;
+ *:MSYS*:*)
+ echo "$UNAME_MACHINE"-pc-msys
+ exit ;;
+ i*:PW*:*)
+ echo "$UNAME_MACHINE"-pc-pw32
+ exit ;;
+ *:Interix*:*)
+ case "$UNAME_MACHINE" in
+ x86)
+ echo i586-pc-interix"$UNAME_RELEASE"
+ exit ;;
+ authenticamd | genuineintel | EM64T)
+ echo x86_64-unknown-interix"$UNAME_RELEASE"
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix"$UNAME_RELEASE"
+ exit ;;
+ esac ;;
+ i*:UWIN*:*)
+ echo "$UNAME_MACHINE"-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-pc-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
+ exit ;;
+ *:Minix:*:*)
+ echo "$UNAME_MACHINE"-unknown-minix
+ exit ;;
+ aarch64:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ arm*:Linux:*:*)
+ set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
+ else
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
+ fi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ cris:Linux:*:*)
+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
+ exit ;;
+ crisv32:Linux:*:*)
+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
+ exit ;;
+ e2k:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ frv:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ hexagon:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ i*86:Linux:*:*)
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
+ exit ;;
+ ia64:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ k1om:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ m32r*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ m68*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ set_cc_for_build
+ sed 's/^ //' << EOF > "$dummy.c"
+ #undef CPU
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=${UNAME_MACHINE}el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=${UNAME_MACHINE}
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
+ test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
+ ;;
+ mips64el:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ openrisc*:Linux:*:*)
+ echo or1k-unknown-linux-"$LIBC"
+ exit ;;
+ or32:Linux:*:* | or1k*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-"$LIBC"
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-"$LIBC"
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
+ PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
+ *) echo hppa-unknown-linux-"$LIBC" ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-"$LIBC"
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-"$LIBC"
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-"$LIBC"
+ exit ;;
+ ppcle:Linux:*:*)
+ echo powerpcle-unknown-linux-"$LIBC"
+ exit ;;
+ riscv32:Linux:*:* | riscv64:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
+ exit ;;
+ sh64*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ sh*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ tile*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ vax:Linux:*:*)
+ echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
+ exit ;;
+ x86_64:Linux:*:*)
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo "$UNAME_MACHINE"-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo "$UNAME_MACHINE"-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo "$UNAME_MACHINE"-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo "$UNAME_MACHINE"-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ echo i386-unknown-lynxos"$UNAME_RELEASE"
+ exit ;;
+ i*86:*DOS:*:*)
+ echo "$UNAME_MACHINE"-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:*)
+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
+ else
+ echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
+ else
+ echo "$UNAME_MACHINE"-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configure will decide that
+ # this is a cross-build.
+ echo i586-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos"$UNAME_RELEASE"
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos"$UNAME_RELEASE"
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos"$UNAME_RELEASE"
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ echo powerpc-unknown-lynxos"$UNAME_RELEASE"
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv"$UNAME_RELEASE"
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo "$UNAME_MACHINE"-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo "$UNAME_MACHINE"-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux"$UNAME_RELEASE"
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv"$UNAME_RELEASE"
+ else
+ echo mips-unknown-sysv"$UNAME_RELEASE"
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ SX-ACE:SUPER-UX:*:*)
+ echo sxace-nec-superux"$UNAME_RELEASE"
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody"$UNAME_RELEASE"
+ exit ;;
+ *:Rhapsody:*:*)
+ echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ set_cc_for_build
+ if test "$UNAME_PROCESSOR" = unknown ; then
+ UNAME_PROCESSOR=powerpc
+ fi
+ if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
+ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_PPC >/dev/null
+ then
+ UNAME_PROCESSOR=powerpc
+ fi
+ fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # Avoid executing cc on OS X 10.9, as it ships with a stub
+ # that puts up a graphical alert prompting to install
+ # developer tools. Any system running Mac OS X 10.7 or
+ # later (Darwin 11 and later) is required to have a 64-bit
+ # processor. This is not true of the ARM version of Darwin
+ # that Apple uses in portable devices.
+ UNAME_PROCESSOR=x86_64
+ fi
+ echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = x86; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NEO-*:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSE-*:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSR-*:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSV-*:NONSTOP_KERNEL:*:*)
+ echo nsv-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSX-*:NONSTOP_KERNEL:*:*)
+ echo nsx-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ # shellcheck disable=SC2154
+ if test "$cputype" = 386; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo "$UNAME_MACHINE"-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux"$UNAME_RELEASE"
+ exit ;;
+ *:DragonFly:*:*)
+ echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "$UNAME_MACHINE" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
+ exit ;;
+ i*86:rdos:*:*)
+ echo "$UNAME_MACHINE"-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo "$UNAME_MACHINE"-pc-aros
+ exit ;;
+ x86_64:VMkernel:*:*)
+ echo "$UNAME_MACHINE"-unknown-esx
+ exit ;;
+ amd64:Isilon\ OneFS:*:*)
+ echo x86_64-unknown-onefs
+ exit ;;
+esac
+
+echo "$0: unable to guess system type" >&2
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+ mips:Linux | mips64:Linux)
+ # If we got here on MIPS GNU/Linux, output extra information.
+ cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+ ;;
+esac
+
+cat >&2 <<EOF
+
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
+
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+and
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = "$UNAME_MACHINE"
+UNAME_RELEASE = "$UNAME_RELEASE"
+UNAME_SYSTEM = "$UNAME_SYSTEM"
+UNAME_VERSION = "$UNAME_VERSION"
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/support/config.rpath b/support/config.rpath
new file mode 100755
index 0000000..fc5913d
--- /dev/null
+++ b/support/config.rpath
@@ -0,0 +1,684 @@
+#! /bin/sh
+# Output a system dependent set of variables, describing how to set the
+# run time search path of shared libraries in an executable.
+#
+# Copyright 1996-2018 Free Software Foundation, Inc.
+# Taken from GNU libtool, 2001
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# The first argument passed to this file is the canonical host specification,
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# should be set by the caller.
+#
+# The set of defined variables is at the end of this script.
+
+# Known limitations:
+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
+# than 256 bytes, otherwise the compiler driver will dump core. The only
+# known workaround is to choose shorter directory names for the build
+# directory and/or the installation directory.
+
+# All known linkers require a '.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+shrext=.so
+
+host="$1"
+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# Code taken from libtool.m4's _LT_CC_BASENAME.
+
+for cc_temp in $CC""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
+
+# Code taken from libtool.m4's _LT_COMPILER_PIC.
+
+wl=
+if test "$GCC" = yes; then
+ wl='-Wl,'
+else
+ case "$host_os" in
+ aix*)
+ wl='-Wl,'
+ ;;
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ wl='-Wl,'
+ ;;
+ irix5* | irix6* | nonstopux*)
+ wl='-Wl,'
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ ecc*)
+ wl='-Wl,'
+ ;;
+ icc* | ifort*)
+ wl='-Wl,'
+ ;;
+ lf95*)
+ wl='-Wl,'
+ ;;
+ nagfor*)
+ wl='-Wl,-Wl,,'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+ wl='-Wl,'
+ ;;
+ ccc*)
+ wl='-Wl,'
+ ;;
+ xl* | bgxl* | bgf* | mpixl*)
+ wl='-Wl,'
+ ;;
+ como)
+ wl='-lopt='
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ F* | *Sun*Fortran*)
+ wl=
+ ;;
+ *Sun\ C*)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ newsos6)
+ ;;
+ *nto* | *qnx*)
+ ;;
+ osf3* | osf4* | osf5*)
+ wl='-Wl,'
+ ;;
+ rdos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+ wl='-Qoption ld '
+ ;;
+ *)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ sunos4*)
+ wl='-Qoption ld '
+ ;;
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ wl='-Wl,'
+ ;;
+ sysv4*MP*)
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ wl='-Wl,'
+ ;;
+ unicos*)
+ wl='-Wl,'
+ ;;
+ uts4*)
+ ;;
+ esac
+fi
+
+# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
+
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+
+case "$host_os" in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ # Unlike libtool, we use -rpath here, not --rpath, since the documented
+ # option of GNU ld is called -rpath, not --rpath.
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ case "$host_os" in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ fi
+ ;;
+ amigaos*)
+ case "$host_cpu" in
+ powerpc)
+ ;;
+ m68k)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ cygwin* | mingw* | pw32* | cegcc*)
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ haiku*)
+ ;;
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ netbsd*)
+ ;;
+ solaris*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+ sunos4*)
+ hardcode_direct=yes
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ if test "$ld_shlibs" = no; then
+ hardcode_libdir_flag_spec=
+ fi
+else
+ case "$host_os" in
+ aix3*)
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ else
+ aix_use_runtimelinking=no
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+ fi
+ hardcode_direct=yes
+ hardcode_libdir_separator=':'
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ fi
+ # Begin _LT_AC_SYS_LIBPATH_AIX.
+ echo 'int main () { return 0; }' > conftest.c
+ ${CC} ${LDFLAGS} conftest.c -o conftest
+ aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ fi
+ if test -z "$aix_libpath"; then
+ aix_libpath="/usr/lib:/lib"
+ fi
+ rm -f conftest.c conftest
+ # End _LT_AC_SYS_LIBPATH_AIX.
+ if test "$aix_use_runtimelinking" = yes; then
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ else
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ fi
+ fi
+ ;;
+ amigaos*)
+ case "$host_cpu" in
+ powerpc)
+ ;;
+ m68k)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+ bsdi[45]*)
+ ;;
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ libext=lib
+ ;;
+ darwin* | rhapsody*)
+ hardcode_direct=no
+ if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ dgux*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ freebsd2.[01]*)
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ freebsd* | dragonfly*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ hpux9*)
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ hpux10*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+ hpux11*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ ;;
+ *)
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+ irix5* | irix6* | nonstopux*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ netbsd*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ newsos6)
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ *nto* | *qnx*)
+ ;;
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ else
+ case "$host_os" in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ osf3*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ osf4* | osf5*)
+ if test "$GCC" = yes; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ # Both cc and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ hardcode_libdir_separator=:
+ ;;
+ solaris*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ sunos4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ sysv4)
+ case $host_vendor in
+ sni)
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ hardcode_direct=no
+ ;;
+ motorola)
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ ;;
+ sysv4.3*)
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ ld_shlibs=yes
+ fi
+ ;;
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ ;;
+ sysv5* | sco3.2v5* | sco5v6*)
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+ hardcode_libdir_separator=':'
+ ;;
+ uts4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+fi
+
+# Check dynamic linker characteristics
+# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
+# Unlike libtool.m4, here we don't care about _all_ names of the library, but
+# only about the one the linker finds when passed -lNAME. This is the last
+# element of library_names_spec in libtool.m4, or possibly two of them if the
+# linker has special search rules.
+library_names_spec= # the last element of library_names_spec in libtool.m4
+libname_spec='lib$name'
+case "$host_os" in
+ aix3*)
+ library_names_spec='$libname.a'
+ ;;
+ aix[4-9]*)
+ library_names_spec='$libname$shrext'
+ ;;
+ amigaos*)
+ case "$host_cpu" in
+ powerpc*)
+ library_names_spec='$libname$shrext' ;;
+ m68k)
+ library_names_spec='$libname.a' ;;
+ esac
+ ;;
+ beos*)
+ library_names_spec='$libname$shrext'
+ ;;
+ bsdi[45]*)
+ library_names_spec='$libname$shrext'
+ ;;
+ cygwin* | mingw* | pw32* | cegcc*)
+ shrext=.dll
+ library_names_spec='$libname.dll.a $libname.lib'
+ ;;
+ darwin* | rhapsody*)
+ shrext=.dylib
+ library_names_spec='$libname$shrext'
+ ;;
+ dgux*)
+ library_names_spec='$libname$shrext'
+ ;;
+ freebsd[23].*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
+ freebsd* | dragonfly*)
+ library_names_spec='$libname$shrext'
+ ;;
+ gnu*)
+ library_names_spec='$libname$shrext'
+ ;;
+ haiku*)
+ library_names_spec='$libname$shrext'
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $host_cpu in
+ ia64*)
+ shrext=.so
+ ;;
+ hppa*64*)
+ shrext=.sl
+ ;;
+ *)
+ shrext=.sl
+ ;;
+ esac
+ library_names_spec='$libname$shrext'
+ ;;
+ interix[3-9]*)
+ library_names_spec='$libname$shrext'
+ ;;
+ irix5* | irix6* | nonstopux*)
+ library_names_spec='$libname$shrext'
+ case "$host_os" in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
+ *) libsuff= shlibsuff= ;;
+ esac
+ ;;
+ esac
+ ;;
+ linux*oldld* | linux*aout* | linux*coff*)
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ library_names_spec='$libname$shrext'
+ ;;
+ knetbsd*-gnu)
+ library_names_spec='$libname$shrext'
+ ;;
+ netbsd*)
+ library_names_spec='$libname$shrext'
+ ;;
+ newsos6)
+ library_names_spec='$libname$shrext'
+ ;;
+ *nto* | *qnx*)
+ library_names_spec='$libname$shrext'
+ ;;
+ openbsd*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
+ os2*)
+ libname_spec='$name'
+ shrext=.dll
+ library_names_spec='$libname.a'
+ ;;
+ osf3* | osf4* | osf5*)
+ library_names_spec='$libname$shrext'
+ ;;
+ rdos*)
+ ;;
+ solaris*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sunos4*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
+ sysv4 | sysv4.3*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sysv4*MP*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ library_names_spec='$libname$shrext'
+ ;;
+ tpf*)
+ library_names_spec='$libname$shrext'
+ ;;
+ uts4*)
+ library_names_spec='$libname$shrext'
+ ;;
+esac
+
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+
+LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
+
+# How to pass a linker flag through the compiler.
+wl="$escaped_wl"
+
+# Static library suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally "so").
+shlibext="$shlibext"
+
+# Format of library name prefix.
+libname_spec="$escaped_libname_spec"
+
+# Library names that the linker finds when passed -lNAME.
+library_names_spec="$escaped_library_names_spec"
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator="$hardcode_libdir_separator"
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct="$hardcode_direct"
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L="$hardcode_minus_L"
+
+EOF
diff --git a/support/config.sub b/support/config.sub
new file mode 100755
index 0000000..f208558
--- /dev/null
+++ b/support/config.sub
@@ -0,0 +1,1790 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright 1992-2018 Free Software Foundation, Inc.
+
+timestamp='2018-08-29'
+
+# This file 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 3 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, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
+
+Canonicalize a configuration name.
+
+Options:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2018 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo "$1"
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Split fields of configuration type
+IFS="-" read -r field1 field2 field3 field4 <<EOF
+$1
+EOF
+
+# Separate into logical components for further validation
+case $1 in
+ *-*-*-*-*)
+ echo Invalid configuration \`"$1"\': more than four components >&2
+ exit 1
+ ;;
+ *-*-*-*)
+ basic_machine=$field1-$field2
+ os=$field3-$field4
+ ;;
+ *-*-*)
+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
+ # parts
+ maybe_os=$field2-$field3
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
+ | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
+ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
+ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
+ | storm-chaos* | os2-emx* | rtmk-nova*)
+ basic_machine=$field1
+ os=$maybe_os
+ ;;
+ android-linux)
+ basic_machine=$field1-unknown
+ os=linux-android
+ ;;
+ *)
+ basic_machine=$field1-$field2
+ os=$field3
+ ;;
+ esac
+ ;;
+ *-*)
+ # A lone config we happen to match not fitting any pattern
+ case $field1-$field2 in
+ decstation-3100)
+ basic_machine=mips-dec
+ os=
+ ;;
+ *-*)
+ # Second component is usually, but not always the OS
+ case $field2 in
+ # Prevent following clause from handling this valid os
+ sun*os*)
+ basic_machine=$field1
+ os=$field2
+ ;;
+ # Manufacturers
+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \
+ | convergent* | ncr* | news | 32* | 3600* | 3100* \
+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
+ | ultra | tti* | harris | dolphin | highlevel | gould \
+ | cbm | ns | masscomp | apple | axis | knuth | cray \
+ | microblaze* | sim | cisco \
+ | oki | wec | wrs | winbond)
+ basic_machine=$field1-$field2
+ os=
+ ;;
+ *)
+ basic_machine=$field1
+ os=$field2
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ *)
+ # Convert single-component short-hands not valid as part of
+ # multi-component configurations.
+ case $field1 in
+ 386bsd)
+ basic_machine=i386-pc
+ os=bsd
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=scout
+ ;;
+ alliant)
+ basic_machine=fx80-alliant
+ os=
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ os=
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=sysv
+ ;;
+ amiga)
+ basic_machine=m68k-unknown
+ os=
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=linux
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=bsd
+ ;;
+ cray)
+ basic_machine=j90-cray
+ os=unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ os=
+ ;;
+ da30)
+ basic_machine=m68k-da30
+ os=
+ ;;
+ decstation | pmax | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ os=
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=msdosdjgpp
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=ebmon
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=ose
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=go32
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=sysv3
+ ;;
+ hp300)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=hpux
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=proelf
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=mach
+ ;;
+ vsta)
+ basic_machine=i386-pc
+ os=vsta
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=linux
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=sysv
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=mingw64
+ ;;
+ mingw32)
+ basic_machine=i686-pc
+ os=mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=mingw32ce
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=morphos
+ ;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=moxiebox
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=msdos
+ ;;
+ msys)
+ basic_machine=i686-pc
+ os=msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ os=nacl
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-pc
+ os=netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=sysv
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=nonstopux
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=os68k
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=linux
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=pw32
+ ;;
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=rdos
+ ;;
+ rdos32)
+ basic_machine=i386-pc
+ os=rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=coff
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ os=
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=sysv2
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ os=
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ os=
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=sunos4
+ ;;
+ sun3)
+ basic_machine=m68k-sun
+ os=
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=sunos4
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ os=
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=solaris2
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ os=
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=unicos
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=tops20
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=vms
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=vxworks
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=mingw32
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=unicos
+ ;;
+ *)
+ basic_machine=$1
+ os=
+ ;;
+ esac
+ ;;
+esac
+
+# Decode 1-component or ad-hoc basic machines
+case $basic_machine in
+ # Here we handle the default manufacturer of certain CPU types. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ cpu=hppa1.1
+ vendor=winbond
+ ;;
+ op50n)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ op60c)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ ibm*)
+ cpu=i370
+ vendor=ibm
+ ;;
+ orion105)
+ cpu=clipper
+ vendor=highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ cpu=m68k
+ vendor=apple
+ ;;
+ pmac | pmac-mpw)
+ cpu=powerpc
+ vendor=apple
+ ;;
+
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ cpu=m68000
+ vendor=att
+ ;;
+ 3b*)
+ cpu=we32k
+ vendor=att
+ ;;
+ bluegene*)
+ cpu=powerpc
+ vendor=ibm
+ os=cnk
+ ;;
+ decsystem10* | dec10*)
+ cpu=pdp10
+ vendor=dec
+ os=tops10
+ ;;
+ decsystem20* | dec20*)
+ cpu=pdp10
+ vendor=dec
+ os=tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ cpu=m68k
+ vendor=motorola
+ ;;
+ dpx2*)
+ cpu=m68k
+ vendor=bull
+ os=sysv3
+ ;;
+ encore | umax | mmax)
+ cpu=ns32k
+ vendor=encore
+ ;;
+ elxsi)
+ cpu=elxsi
+ vendor=elxsi
+ os=${os:-bsd}
+ ;;
+ fx2800)
+ cpu=i860
+ vendor=alliant
+ ;;
+ genix)
+ cpu=ns32k
+ vendor=ns
+ ;;
+ h3050r* | hiux*)
+ cpu=hppa1.1
+ vendor=hitachi
+ os=hiuxwe2
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ cpu=m68000
+ vendor=hp
+ ;;
+ hp9k3[2-9][0-9])
+ cpu=m68k
+ vendor=hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ i*86v32)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv32
+ ;;
+ i*86v4*)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv4
+ ;;
+ i*86v)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv
+ ;;
+ i*86sol2)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=solaris2
+ ;;
+ j90 | j90-cray)
+ cpu=j90
+ vendor=cray
+ os=${os:-unicos}
+ ;;
+ iris | iris4d)
+ cpu=mips
+ vendor=sgi
+ case $os in
+ irix*)
+ ;;
+ *)
+ os=irix4
+ ;;
+ esac
+ ;;
+ miniframe)
+ cpu=m68000
+ vendor=convergent
+ ;;
+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ cpu=m68k
+ vendor=atari
+ os=mint
+ ;;
+ news-3600 | risc-news)
+ cpu=mips
+ vendor=sony
+ os=newsos
+ ;;
+ next | m*-next)
+ cpu=m68k
+ vendor=next
+ case $os in
+ nextstep* )
+ ;;
+ ns2*)
+ os=nextstep2
+ ;;
+ *)
+ os=nextstep3
+ ;;
+ esac
+ ;;
+ np1)
+ cpu=np1
+ vendor=gould
+ ;;
+ op50n-* | op60c-*)
+ cpu=hppa1.1
+ vendor=oki
+ os=proelf
+ ;;
+ pa-hitachi)
+ cpu=hppa1.1
+ vendor=hitachi
+ os=hiuxwe2
+ ;;
+ pbd)
+ cpu=sparc
+ vendor=tti
+ ;;
+ pbb)
+ cpu=m68k
+ vendor=tti
+ ;;
+ pc532)
+ cpu=ns32k
+ vendor=pc532
+ ;;
+ pn)
+ cpu=pn
+ vendor=gould
+ ;;
+ power)
+ cpu=power
+ vendor=ibm
+ ;;
+ ps2)
+ cpu=i386
+ vendor=ibm
+ ;;
+ rm[46]00)
+ cpu=mips
+ vendor=siemens
+ ;;
+ rtpc | rtpc-*)
+ cpu=romp
+ vendor=ibm
+ ;;
+ sde)
+ cpu=mipsisa32
+ vendor=sde
+ os=${os:-elf}
+ ;;
+ simso-wrs)
+ cpu=sparclite
+ vendor=wrs
+ os=vxworks
+ ;;
+ tower | tower-32)
+ cpu=m68k
+ vendor=ncr
+ ;;
+ vpp*|vx|vx-*)
+ cpu=f301
+ vendor=fujitsu
+ ;;
+ w65)
+ cpu=w65
+ vendor=wdc
+ ;;
+ w89k-*)
+ cpu=hppa1.1
+ vendor=winbond
+ os=proelf
+ ;;
+ none)
+ cpu=none
+ vendor=none
+ ;;
+ leon|leon[3-9])
+ cpu=sparc
+ vendor=$basic_machine
+ ;;
+ leon-*|leon[3-9]-*)
+ cpu=sparc
+ vendor=`echo "$basic_machine" | sed 's/-.*//'`
+ ;;
+
+ *-*)
+ IFS="-" read -r cpu vendor <<EOF
+$basic_machine
+EOF
+ ;;
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ cpu=$basic_machine
+ vendor=pc
+ ;;
+ # These rules are duplicated from below for sake of the special case above;
+ # i.e. things that normalized to x86 arches should also default to "pc"
+ pc98)
+ cpu=i386
+ vendor=pc
+ ;;
+ x64 | amd64)
+ cpu=x86_64
+ vendor=pc
+ ;;
+ # Recognize the basic CPU types without company name.
+ *)
+ cpu=$basic_machine
+ vendor=unknown
+ ;;
+esac
+
+unset -v basic_machine
+
+# Decode basic machines in the full and proper CPU-Company form.
+case $cpu-$vendor in
+ # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ craynv-unknown)
+ vendor=cray
+ os=${os:-unicosmp}
+ ;;
+ c90-unknown | c90-cray)
+ vendor=cray
+ os=${os:-unicos}
+ ;;
+ fx80-unknown)
+ vendor=alliant
+ ;;
+ romp-unknown)
+ vendor=ibm
+ ;;
+ mmix-unknown)
+ vendor=knuth
+ ;;
+ microblaze-unknown | microblazeel-unknown)
+ vendor=xilinx
+ ;;
+ rs6000-unknown)
+ vendor=ibm
+ ;;
+ vax-unknown)
+ vendor=dec
+ ;;
+ pdp11-unknown)
+ vendor=dec
+ ;;
+ we32k-unknown)
+ vendor=att
+ ;;
+ cydra-unknown)
+ vendor=cydrome
+ ;;
+ i370-ibm*)
+ vendor=ibm
+ ;;
+ orion-unknown)
+ vendor=highlevel
+ ;;
+ xps-unknown | xps100-unknown)
+ cpu=xps100
+ vendor=honeywell
+ ;;
+
+ # Here we normalize CPU types with a missing or matching vendor
+ dpx20-unknown | dpx20-bull)
+ cpu=rs6000
+ vendor=bull
+ os=${os:-bosx}
+ ;;
+
+ # Here we normalize CPU types irrespective of the vendor
+ amd64-*)
+ cpu=x86_64
+ ;;
+ blackfin-*)
+ cpu=bfin
+ os=linux
+ ;;
+ c54x-*)
+ cpu=tic54x
+ ;;
+ c55x-*)
+ cpu=tic55x
+ ;;
+ c6x-*)
+ cpu=tic6x
+ ;;
+ e500v[12]-*)
+ cpu=powerpc
+ os=$os"spe"
+ ;;
+ mips3*-*)
+ cpu=mips64
+ ;;
+ ms1-*)
+ cpu=mt
+ ;;
+ m68knommu-*)
+ cpu=m68k
+ os=linux
+ ;;
+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+ cpu=s12z
+ ;;
+ openrisc-*)
+ cpu=or32
+ ;;
+ parisc-*)
+ cpu=hppa
+ os=linux
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ cpu=i586
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+ cpu=i686
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ cpu=i686
+ ;;
+ pentium4-*)
+ cpu=i786
+ ;;
+ pc98-*)
+ cpu=i386
+ ;;
+ ppc-* | ppcbe-*)
+ cpu=powerpc
+ ;;
+ ppcle-* | powerpclittle-*)
+ cpu=powerpcle
+ ;;
+ ppc64-*)
+ cpu=powerpc64
+ ;;
+ ppc64le-* | powerpc64little-*)
+ cpu=powerpc64le
+ ;;
+ sb1-*)
+ cpu=mipsisa64sb1
+ ;;
+ sb1el-*)
+ cpu=mipsisa64sb1el
+ ;;
+ sh5e[lb]-*)
+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
+ ;;
+ spur-*)
+ cpu=spur
+ ;;
+ strongarm-* | thumb-*)
+ cpu=arm
+ ;;
+ tx39-*)
+ cpu=mipstx39
+ ;;
+ tx39el-*)
+ cpu=mipstx39el
+ ;;
+ x64-*)
+ cpu=x86_64
+ ;;
+ xscale-* | xscalee[bl]-*)
+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
+ ;;
+
+ # Recognize the canonical CPU Types that limit and/or modify the
+ # company names they are paired with.
+ cr16-*)
+ os=${os:-elf}
+ ;;
+ crisv32-* | etraxfs*-*)
+ cpu=crisv32
+ vendor=axis
+ ;;
+ cris-* | etrax*-*)
+ cpu=cris
+ vendor=axis
+ ;;
+ crx-*)
+ os=${os:-elf}
+ ;;
+ neo-tandem)
+ cpu=neo
+ vendor=tandem
+ ;;
+ nse-tandem)
+ cpu=nse
+ vendor=tandem
+ ;;
+ nsr-tandem)
+ cpu=nsr
+ vendor=tandem
+ ;;
+ nsv-tandem)
+ cpu=nsv
+ vendor=tandem
+ ;;
+ nsx-tandem)
+ cpu=nsx
+ vendor=tandem
+ ;;
+ s390-*)
+ cpu=s390
+ vendor=ibm
+ ;;
+ s390x-*)
+ cpu=s390x
+ vendor=ibm
+ ;;
+ tile*-*)
+ os=${os:-linux-gnu}
+ ;;
+
+ *)
+ # Recognize the canonical CPU types that are allowed with any
+ # company name.
+ case $cpu in
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be \
+ | abacus \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
+ | alphapca5[67] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arceb \
+ | arm | arm[lb]e | arme[lb] | armv* \
+ | avr | avr32 \
+ | asmjs \
+ | ba \
+ | be32 | be64 \
+ | bfin | bs2000 \
+ | c[123]* | c30 | [cjt]90 | c4x \
+ | c8051 | clipper | craynv | csky | cydra \
+ | d10v | d30v | dlx | dsp16xx \
+ | e2k | elxsi | epiphany \
+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+ | h8300 | h8500 \
+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \
+ | ip2k | iq2000 \
+ | k1om \
+ | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle \
+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k | v70 | w65 \
+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip \
+ | m88110 | m88k | maxq | mb | mcore | mep | metag \
+ | microblaze | microblazeel \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mmix \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nfp \
+ | nios | nios2 | nios2eb | nios2el \
+ | none | np1 | ns16k | ns32k \
+ | open8 \
+ | or1k* \
+ | or32 \
+ | orion \
+ | pdp10 | pdp11 | pj | pjl | pn | power \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
+ | pru \
+ | pyramid \
+ | riscv | riscv32 | riscv64 \
+ | rl78 | romp | rs6000 | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
+ | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
+ | spu \
+ | tahoe \
+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
+ | tron \
+ | ubicom32 \
+ | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+ | vax \
+ | visium \
+ | wasm32 \
+ | we32k \
+ | x86 | x86_64 | xc16x | xgate | xps100 \
+ | xstormy16 | xtensa* \
+ | ymp \
+ | z8k | z80)
+ ;;
+
+ *)
+ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $vendor in
+ digital*)
+ vendor=dec
+ ;;
+ commodore*)
+ vendor=cbm
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x$os != x ]
+then
+case $os in
+ # First match some system type aliases that might get confused
+ # with valid system types.
+ # solaris* is a basic system type, with this one exception.
+ auroraux)
+ os=auroraux
+ ;;
+ bluegene*)
+ os=cnk
+ ;;
+ solaris1 | solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ solaris)
+ os=solaris2
+ ;;
+ unixware*)
+ os=sysv4.2uw
+ ;;
+ gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # es1800 is here to avoid being matched by es* (a different OS)
+ es1800*)
+ os=ose
+ ;;
+ # Some version numbers need modification
+ chorusos*)
+ os=chorusos
+ ;;
+ isc)
+ os=isc2.2
+ ;;
+ sco6)
+ os=sco5v6
+ ;;
+ sco5)
+ os=sco3.2v5
+ ;;
+ sco4)
+ os=sco3.2v4
+ ;;
+ sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ ;;
+ sco3.2v[4-9]* | sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ ;;
+ scout)
+ # Don't match below
+ ;;
+ sco*)
+ os=sco3.2v2
+ ;;
+ psos*)
+ os=psos
+ ;;
+ # Now accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST end in a * to match a version number.
+ # sysv* is not here because it comes later, after sysvr4.
+ gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
+ | sym* | kopensolaris* | plan9* \
+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
+ | aos* | aros* | cloudabi* | sortix* \
+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
+ | knetbsd* | mirbsd* | netbsd* \
+ | bitrig* | openbsd* | solidbsd* | libertybsd* \
+ | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
+ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
+ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
+ | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
+ | chorusrdb* | cegcc* | glidix* \
+ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
+ | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
+ | linux-newlib* | linux-musl* | linux-uclibc* \
+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \
+ | interix* | uwin* | mks* | rhapsody* | darwin* \
+ | openstep* | oskit* | conix* | pw32* | nonstopux* \
+ | storm-chaos* | tops10* | tenex* | tops20* | its* \
+ | os2* | vos* | palmos* | uclinux* | nucleus* \
+ | morphos* | superux* | rtmk* | windiss* \
+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \
+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+ | midnightbsd*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ qnx*)
+ case $cpu in
+ x86 | i*86)
+ ;;
+ *)
+ os=nto-$os
+ ;;
+ esac
+ ;;
+ hiux*)
+ os=hiuxwe2
+ ;;
+ nto-qnx*)
+ ;;
+ nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ sim | xray | os68k* | v88r* \
+ | windows* | osx | abug | netware* | os9* \
+ | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
+ ;;
+ linux-dietlibc)
+ os=linux-dietlibc
+ ;;
+ linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ lynx*178)
+ os=lynxos178
+ ;;
+ lynx*5)
+ os=lynxos5
+ ;;
+ lynx*)
+ os=lynxos
+ ;;
+ mac*)
+ os=`echo "$os" | sed -e 's|mac|macos|'`
+ ;;
+ opened*)
+ os=openedition
+ ;;
+ os400*)
+ os=os400
+ ;;
+ sunos5*)
+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
+ ;;
+ sunos6*)
+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
+ ;;
+ wince*)
+ os=wince
+ ;;
+ utek*)
+ os=bsd
+ ;;
+ dynix*)
+ os=bsd
+ ;;
+ acis*)
+ os=aos
+ ;;
+ atheos*)
+ os=atheos
+ ;;
+ syllable*)
+ os=syllable
+ ;;
+ 386bsd)
+ os=bsd
+ ;;
+ ctix* | uts*)
+ os=sysv
+ ;;
+ nova*)
+ os=rtmk-nova
+ ;;
+ ns2)
+ os=nextstep2
+ ;;
+ nsk*)
+ os=nsk
+ ;;
+ # Preserve the version number of sinix5.
+ sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ sinix*)
+ os=sysv4
+ ;;
+ tpf*)
+ os=tpf
+ ;;
+ triton*)
+ os=sysv3
+ ;;
+ oss*)
+ os=sysv3
+ ;;
+ svr4*)
+ os=sysv4
+ ;;
+ svr3)
+ os=sysv3
+ ;;
+ sysvr4)
+ os=sysv4
+ ;;
+ # This must come after sysvr4.
+ sysv*)
+ ;;
+ ose*)
+ os=ose
+ ;;
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ os=mint
+ ;;
+ zvmoe)
+ os=zvmoe
+ ;;
+ dicos*)
+ os=dicos
+ ;;
+ pikeos*)
+ # Until real need of OS specific support for
+ # particular features comes up, bare metal
+ # configurations are quite functional.
+ case $cpu in
+ arm*)
+ os=eabi
+ ;;
+ *)
+ os=elf
+ ;;
+ esac
+ ;;
+ nacl*)
+ ;;
+ ios)
+ ;;
+ none)
+ ;;
+ *-eabi)
+ ;;
+ *)
+ echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $cpu-$vendor in
+ score-*)
+ os=elf
+ ;;
+ spu-*)
+ os=elf
+ ;;
+ *-acorn)
+ os=riscix1.2
+ ;;
+ arm*-rebel)
+ os=linux
+ ;;
+ arm*-semi)
+ os=aout
+ ;;
+ c4x-* | tic4x-*)
+ os=coff
+ ;;
+ c8051-*)
+ os=elf
+ ;;
+ clipper-intergraph)
+ os=clix
+ ;;
+ hexagon-*)
+ os=elf
+ ;;
+ tic54x-*)
+ os=coff
+ ;;
+ tic55x-*)
+ os=coff
+ ;;
+ tic6x-*)
+ os=coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=tops20
+ ;;
+ pdp11-*)
+ os=none
+ ;;
+ *-dec | vax-*)
+ os=ultrix4.2
+ ;;
+ m68*-apollo)
+ os=domain
+ ;;
+ i386-sun)
+ os=sunos4.0.2
+ ;;
+ m68000-sun)
+ os=sunos3
+ ;;
+ m68*-cisco)
+ os=aout
+ ;;
+ mep-*)
+ os=elf
+ ;;
+ mips*-cisco)
+ os=elf
+ ;;
+ mips*-*)
+ os=elf
+ ;;
+ or32-*)
+ os=coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=sysv3
+ ;;
+ sparc-* | *-sun)
+ os=sunos4.1.1
+ ;;
+ pru-*)
+ os=elf
+ ;;
+ *-be)
+ os=beos
+ ;;
+ *-ibm)
+ os=aix
+ ;;
+ *-knuth)
+ os=mmixware
+ ;;
+ *-wec)
+ os=proelf
+ ;;
+ *-winbond)
+ os=proelf
+ ;;
+ *-oki)
+ os=proelf
+ ;;
+ *-hp)
+ os=hpux
+ ;;
+ *-hitachi)
+ os=hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=sysv
+ ;;
+ *-cbm)
+ os=amigaos
+ ;;
+ *-dg)
+ os=dgux
+ ;;
+ *-dolphin)
+ os=sysv3
+ ;;
+ m68k-ccur)
+ os=rtu
+ ;;
+ m88k-omron*)
+ os=luna
+ ;;
+ *-next)
+ os=nextstep
+ ;;
+ *-sequent)
+ os=ptx
+ ;;
+ *-crds)
+ os=unos
+ ;;
+ *-ns)
+ os=genix
+ ;;
+ i370-*)
+ os=mvs
+ ;;
+ *-gould)
+ os=sysv
+ ;;
+ *-highlevel)
+ os=bsd
+ ;;
+ *-encore)
+ os=bsd
+ ;;
+ *-sgi)
+ os=irix
+ ;;
+ *-siemens)
+ os=sysv4
+ ;;
+ *-masscomp)
+ os=rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=uxpv
+ ;;
+ *-rom68k)
+ os=coff
+ ;;
+ *-*bug)
+ os=coff
+ ;;
+ *-apple)
+ os=macos
+ ;;
+ *-atari*)
+ os=mint
+ ;;
+ *-wrs)
+ os=vxworks
+ ;;
+ *)
+ os=none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+case $vendor in
+ unknown)
+ case $os in
+ riscix*)
+ vendor=acorn
+ ;;
+ sunos*)
+ vendor=sun
+ ;;
+ cnk*|-aix*)
+ vendor=ibm
+ ;;
+ beos*)
+ vendor=be
+ ;;
+ hpux*)
+ vendor=hp
+ ;;
+ mpeix*)
+ vendor=hp
+ ;;
+ hiux*)
+ vendor=hitachi
+ ;;
+ unos*)
+ vendor=crds
+ ;;
+ dgux*)
+ vendor=dg
+ ;;
+ luna*)
+ vendor=omron
+ ;;
+ genix*)
+ vendor=ns
+ ;;
+ clix*)
+ vendor=intergraph
+ ;;
+ mvs* | opened*)
+ vendor=ibm
+ ;;
+ os400*)
+ vendor=ibm
+ ;;
+ ptx*)
+ vendor=sequent
+ ;;
+ tpf*)
+ vendor=ibm
+ ;;
+ vxsim* | vxworks* | windiss*)
+ vendor=wrs
+ ;;
+ aux*)
+ vendor=apple
+ ;;
+ hms*)
+ vendor=hitachi
+ ;;
+ mpw* | macos*)
+ vendor=apple
+ ;;
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ vendor=atari
+ ;;
+ vos*)
+ vendor=stratus
+ ;;
+ esac
+ ;;
+esac
+
+echo "$cpu-$vendor-$os"
+exit
+
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/support/fixlinks b/support/fixlinks
new file mode 100755
index 0000000..73b0fa3
--- /dev/null
+++ b/support/fixlinks
@@ -0,0 +1,89 @@
+#! /bin/sh
+#
+# fixlinks - make symlinks in the bash source tree so that there is
+# exactly one version of any given source file.
+#
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+SRCDIR=.
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -s) shift; SRCDIR=$1 ;;
+ -u) unfix=yes ;;
+ -h) hardlinks=yes ;;
+ -*) echo "$0: $1: bad option" 1>&2
+ echo "$0: usage: $0 [-hu] [-s srcdir] [linkmap]" 1>&2
+ exit 1;;
+ *) break ;;
+ esac
+ shift
+done
+
+if [ ! -d $SRCDIR/builtins ]; then
+ echo "$0: must be run with valid -s argument or from source directory" 1>&2
+ exit 1
+fi
+
+if [ $# -eq 0 ]; then
+ linkfile=$SRCDIR/support/SYMLINKS
+else
+ linkfile=$1
+fi
+
+if [ ! -f "$linkfile" ]; then
+ echo "$0: symlink map file \`$linkfile' does not exist"
+ exit 1
+fi
+
+rm_ltmp=false
+LINKTEMP=`mktemp -t linktmp.XXXXXXXX 2>/dev/null`
+if [ -z "$LINKTEMP" ]; then
+ : ${TMPDIR:=/tmp}
+ LINKTEMP=${TMPDIR}/linktmp.$$
+ rm_ltmp=true
+fi
+
+$rm_ltmp && rm -f ${LINKTEMP}
+# if the user specified hard links, then do that. otherwise, try to use
+# symlinks if they're present
+if [ -n "$hardlinks" ]; then
+ LN=ln
+elif (ln -s /dev/null ${LINKTEMP}) >/dev/null 2>&1; then
+ LN="ln -s"
+else
+ LN=ln
+fi
+rm -f ${LINKTEMP}
+
+while read name target
+do
+ case "$name" in
+ \#*) continue;;
+ esac
+
+ rm -f $name
+ case "$unfix" in
+ yes) dirname=`expr "$name" ':' '^\(.*\)/[^/]*'`
+ [ -z "$dirname" ] && dirname=.
+ cp $dirname/$target $name
+ echo $target copied to $name ;;
+ *) $LN $target $name ; echo "$name -> $target" ;;
+ esac
+
+done < $linkfile
+
+exit 0
diff --git a/support/install.sh b/support/install.sh
new file mode 100755
index 0000000..0cac004
--- /dev/null
+++ b/support/install.sh
@@ -0,0 +1,247 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+tranformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/support/man2html.c b/support/man2html.c
new file mode 100644
index 0000000..b10cb95
--- /dev/null
+++ b/support/man2html.c
@@ -0,0 +1,4088 @@
+/*
+ * This program was written by Richard Verhoeven (NL:5482ZX35)
+ * at the Eindhoven University of Technology. Email: rcb5@win.tue.nl
+ *
+ * Permission is granted to distribute, modify and use this program as long
+ * as this comment is not removed or changed.
+ *
+ * THIS IS A MODIFIED VERSION. IT WAS MODIFIED BY chet@po.cwru.edu FOR
+ * USE BY BASH.
+ */
+
+/*
+ * man2html will add links to the converted manpages. The function add_links
+ * is used for that. At the moment it will add links as follows, where
+ * indicates what should match to start with:
+ * ^^^
+ * Recognition Item Link
+ * ----------------------------------------------------------
+ * name(*) Manpage ../man?/name.*
+ * ^
+ * name@hostname Email address mailto:name@hostname
+ * ^
+ * method://string URL method://string
+ * ^^^
+ * www.host.name WWW server http://www.host.name
+ * ^^^^
+ * ftp.host.name FTP server ftp://ftp.host.name
+ * ^^^^
+ * <file.h> Include file file:/usr/include/file.h
+ * ^^^
+ *
+ * Since man2html does not check if manpages, hosts or email addresses exist,
+ * some links might not work. For manpages, some extra checks are performed
+ * to make sure not every () pair creates a link. Also out of date pages
+ * might point to incorrect places.
+ *
+ * The program will not allow users to get system specific files, such as
+ * /etc/passwd. It will check that "man" is part of the specified file and
+ * that "/../" isn't. Even if someone manages to get such file, man2html will
+ * handle it like a manpage and will usually not produce any output (or crash).
+ *
+ * If you find any bugs when normal manpages are converted, please report
+ * them to me (rcb5@win.tue.nl) after you have checked that man(1) can handle
+ * the manpage correct.
+ *
+ * Known bugs and missing features:
+ *
+ * * Equations are not converted at all.
+ * * Tables are converted but some features are not possible in html.
+ * * The tabbing environment is converted by counting characters and adding
+ * spaces. This might go wrong (outside <PRE>)
+ * * Some pages look beter if man2html works in troff mode, especially pages
+ * with tables. You can deside at compile time which made you want to use.
+ *
+ * -DNROFF=0 troff mode
+ * -DNROFF=1 nroff mode (default)
+ *
+ * if you install both modes, you should compile with the correct CGIBASE.
+ * * Some manpages rely on the fact that troff/nroff is used to convert
+ * them and use features which are not descripted in the man manpages.
+ * (definitions, calculations, conditionals, requests). I can't guarantee
+ * that all these features work on all manpages. (I didn't have the
+ * time to look through all the available manpages.)
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define NROFF 0
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <time.h>
+#include <sys/time.h>
+#include <errno.h>
+
+#define NULL_TERMINATED(n) ((n) + 1)
+
+#define HUGE_STR_MAX 10000
+#define LARGE_STR_MAX 2000
+#define MED_STR_MAX 500
+#define SMALL_STR_MAX 100
+#define TINY_STR_MAX 10
+
+#define MAX_MAN_PATHS 100 /* Max number of directories */
+#define MAX_ZCATS 10 /* Max number of zcat style programs */
+#define MAX_WORDLIST 100
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+#ifndef EXIT_USAGE
+#define EXIT_USAGE 2
+#endif
+
+static char location_base[NULL_TERMINATED(MED_STR_MAX)] = "";
+
+static char th_page_and_sec[128] = { '\0' };
+static char th_datestr[128] = { '\0' };
+static char th_version[128] = { '\0' };
+
+char *signature = "<HR>\nThis document was created by man2html from %s.<BR>\nTime: %s\n";
+
+/* timeformat for signature */
+#define TIMEFORMAT "%d %B %Y %T %Z"
+
+char *manpage;
+
+/* BSD mandoc Bl/El lists to HTML list types */
+#define BL_DESC_LIST 1
+#define BL_BULLET_LIST 2
+#define BL_ENUM_LIST 4
+
+/* BSD mandoc Bd/Ed example(?) blocks */
+#define BD_LITERAL 1
+#define BD_INDENT 2
+
+#ifndef HAVE_STRERROR
+static char *
+strerror(int e)
+{
+ static char emsg[40];
+
+#if defined (HAVE_SYS_ERRLIST)
+ extern int sys_nerr;
+ extern char *sys_errlist[];
+
+ if (e > 0 && e < sys_nerr)
+ return (sys_errlist[e]);
+ else
+#endif /* HAVE_SYS_ERRLIST */
+ {
+ sprintf(emsg, "Unknown system error %d", e);
+ return (&emsg[0]);
+ }
+}
+#endif /* !HAVE_STRERROR */
+
+static char *
+strgrow(char *old, int len)
+{
+ char *new = realloc(old, (strlen(old) + len + 1) * sizeof(char));
+
+ if (!new) {
+ fprintf(stderr, "man2html: out of memory");
+ exit(EXIT_FAILURE);
+ }
+ return new;
+}
+
+static char *
+stralloc(int len)
+{
+ /* allocate enough for len + NULL */
+ char *new = malloc((len + 1) * sizeof(char));
+
+ if (!new) {
+ fprintf(stderr, "man2html: out of memory");
+ exit(EXIT_FAILURE);
+ }
+ return new;
+}
+
+void *
+xmalloc (size_t size)
+{
+ void *ret;
+
+ ret = malloc (size);
+ if (ret == 0) {
+ fprintf(stderr, "man2html: out of memory");
+ exit(EXIT_FAILURE);
+ }
+ return ret;
+}
+
+/*
+ * Some systems don't have strdup so lets use our own - which can also
+ * check for out of memory.
+ */
+static char *
+strduplicate(char *from)
+{
+ char *new = stralloc(strlen(from));
+
+ strcpy(new, from);
+ return new;
+}
+
+/* Assumes space for n plus a null */
+static char *
+strmaxcpy(char *to, char *from, int n)
+{
+ int len = strlen(from);
+
+ strncpy(to, from, n);
+ to[(len <= n) ? len : n] = '\0';
+ return to;
+}
+
+static char *
+strmaxcat(char *to, char *from, int n)
+{
+ int to_len = strlen(to);
+
+ if (to_len < n) {
+ int from_len = strlen(from);
+ int cp = (to_len + from_len <= n) ? from_len : n - to_len;
+
+ strncpy(to + to_len, from, cp);
+ to[to_len + cp] = '\0';
+ }
+ return to;
+}
+
+/* Assumes space for limit plus a null */
+static char *
+strlimitcpy(char *to, char *from, int n, int limit)
+{
+ int len = n > limit ? limit : n;
+
+ strmaxcpy(to, from, len);
+ to[len] = '\0';
+ return to;
+}
+
+/*
+ * takes string and escapes all metacharacters. should be used before
+ * including string in system() or similar call.
+ */
+static char *
+escape_input(char *str)
+{
+ int i, j = 0;
+ static char new[NULL_TERMINATED(MED_STR_MAX)];
+
+ if (strlen(str) * 2 + 1 > MED_STR_MAX) {
+ fprintf(stderr,
+ "man2html: escape_input - str too long:\n%-80s...\n",
+ str);
+ exit(EXIT_FAILURE);
+ }
+ for (i = 0; i < strlen(str); i++) {
+ if (!(((str[i] >= 'A') && (str[i] <= 'Z')) ||
+ ((str[i] >= 'a') && (str[i] <= 'z')) ||
+ ((str[i] >= '0') && (str[i] <= '9')))) {
+ new[j] = '\\';
+ j++;
+ }
+ new[j] = str[i];
+ j++;
+ }
+ new[j] = '\0';
+ return new;
+}
+
+static void
+usage(void)
+{
+ fprintf(stderr, "man2html: usage: man2html filename\n");
+}
+
+
+
+/*
+ * below this you should not change anything unless you know a lot
+ * about this program or about troff.
+ */
+
+typedef struct STRDEF STRDEF;
+struct STRDEF {
+ int nr, slen;
+ char *st;
+ STRDEF *next;
+};
+
+typedef struct INTDEF INTDEF;
+struct INTDEF {
+ int nr;
+ int val;
+ int incr;
+ INTDEF *next;
+};
+
+static char NEWLINE[2] = "\n";
+static char idxlabel[6] = "ixAAA";
+
+#define INDEXFILE "/tmp/manindex.list"
+
+static char *fname;
+static FILE *idxfile;
+
+static STRDEF *chardef, *strdef, *defdef;
+static INTDEF *intdef;
+
+#define V(A,B) ((A)*256+(B))
+
+static INTDEF standardint[] = {
+ {V('n', ' '), NROFF, 0, NULL},
+ {V('t', ' '), 1 - NROFF, 0, NULL},
+ {V('o', ' '), 1, 0, NULL},
+ {V('e', ' '), 0, 0, NULL},
+ {V('.', 'l'), 70, 0, NULL},
+ {V('.', '$'), 0, 0, NULL},
+ {V('.', 'A'), NROFF, 0, NULL},
+ {V('.', 'T'), 1 - NROFF, 0, NULL},
+ {V('.', 'V'), 1, 0, NULL}, /* the me package tests for this */
+{0, 0, 0, NULL}};
+
+static STRDEF standardstring[] = {
+ {V('R', ' '), 1, "&#174;", NULL},
+ {V('l', 'q'), 2, "``", NULL},
+ {V('r', 'q'), 2, "''", NULL},
+ {0, 0, NULL, NULL}
+};
+
+
+static STRDEF standardchar[] = {
+ {V('*', '*'), 1, "*", NULL},
+ {V('*', 'A'), 1, "A", NULL},
+ {V('*', 'B'), 1, "B", NULL},
+ {V('*', 'C'), 2, "Xi", NULL},
+ {V('*', 'D'), 5, "Delta", NULL},
+ {V('*', 'E'), 1, "E", NULL},
+ {V('*', 'F'), 3, "Phi", NULL},
+ {V('*', 'G'), 5, "Gamma", NULL},
+ {V('*', 'H'), 5, "Theta", NULL},
+ {V('*', 'I'), 1, "I", NULL},
+ {V('*', 'K'), 1, "K", NULL},
+ {V('*', 'L'), 6, "Lambda", NULL},
+ {V('*', 'M'), 1, "M", NULL},
+ {V('*', 'N'), 1, "N", NULL},
+ {V('*', 'O'), 1, "O", NULL},
+ {V('*', 'P'), 2, "Pi", NULL},
+ {V('*', 'Q'), 3, "Psi", NULL},
+ {V('*', 'R'), 1, "P", NULL},
+ {V('*', 'S'), 5, "Sigma", NULL},
+ {V('*', 'T'), 1, "T", NULL},
+ {V('*', 'U'), 1, "Y", NULL},
+ {V('*', 'W'), 5, "Omega", NULL},
+ {V('*', 'X'), 1, "X", NULL},
+ {V('*', 'Y'), 1, "H", NULL},
+ {V('*', 'Z'), 1, "Z", NULL},
+ {V('*', 'a'), 5, "alpha", NULL},
+ {V('*', 'b'), 4, "beta", NULL},
+ {V('*', 'c'), 2, "xi", NULL},
+ {V('*', 'd'), 5, "delta", NULL},
+ {V('*', 'e'), 7, "epsilon", NULL},
+ {V('*', 'f'), 3, "phi", NULL},
+ {V('*', 'g'), 5, "gamma", NULL},
+ {V('*', 'h'), 5, "theta", NULL},
+ {V('*', 'i'), 4, "iota", NULL},
+ {V('*', 'k'), 5, "kappa", NULL},
+ {V('*', 'l'), 6, "lambda", NULL},
+ {V('*', 'm'), 1, "&#181;", NULL},
+ {V('*', 'n'), 2, "nu", NULL},
+ {V('*', 'o'), 1, "o", NULL},
+ {V('*', 'p'), 2, "pi", NULL},
+ {V('*', 'q'), 3, "psi", NULL},
+ {V('*', 'r'), 3, "rho", NULL},
+ {V('*', 's'), 5, "sigma", NULL},
+ {V('*', 't'), 3, "tau", NULL},
+ {V('*', 'u'), 7, "upsilon", NULL},
+ {V('*', 'w'), 5, "omega", NULL},
+ {V('*', 'x'), 3, "chi", NULL},
+ {V('*', 'y'), 3, "eta", NULL},
+ {V('*', 'z'), 4, "zeta", NULL},
+ {V('t', 's'), 5, "sigma", NULL},
+ {V('+', '-'), 1, "&#177;", NULL},
+ {V('1', '2'), 1, "&#189;", NULL},
+ {V('1', '4'), 1, "&#188;", NULL},
+ {V('3', '4'), 1, "&#190;", NULL},
+ {V('F', 'i'), 3, "ffi", NULL},
+ {V('F', 'l'), 3, "ffl", NULL},
+ {V('a', 'a'), 1, "&#180;", NULL},
+ {V('a', 'p'), 1, "~", NULL},
+ {V('b', 'r'), 1, "|", NULL},
+ {V('b', 'u'), 1, "*", NULL},
+ {V('b', 'v'), 1, "|", NULL},
+ {V('c', 'i'), 1, "o", NULL},
+ {V('c', 'o'), 1, "&#169;", NULL},
+ {V('c', 't'), 1, "&#162;", NULL},
+ {V('d', 'e'), 1, "&#176;", NULL},
+ {V('d', 'g'), 1, "+", NULL},
+ {V('d', 'i'), 1, "&#247;", NULL},
+ {V('e', 'm'), 1, "-", NULL},
+ {V('e', 'm'), 3, "---", NULL},
+ {V('e', 'q'), 1, "=", NULL},
+ {V('e', 's'), 1, "&#216;", NULL},
+ {V('f', 'f'), 2, "ff", NULL},
+ {V('f', 'i'), 2, "fi", NULL},
+ {V('f', 'l'), 2, "fl", NULL},
+ {V('f', 'm'), 1, "&#180;", NULL},
+ {V('g', 'a'), 1, "`", NULL},
+ {V('h', 'y'), 1, "-", NULL},
+ {V('l', 'c'), 2, "|&#175;", NULL},
+ {V('l', 'f'), 2, "|_", NULL},
+ {V('l', 'k'), 1, "<FONT SIZE=+2>{</FONT>", NULL},
+ {V('m', 'i'), 1, "-", NULL},
+ {V('m', 'u'), 1, "&#215;", NULL},
+ {V('n', 'o'), 1, "&#172;", NULL},
+ {V('o', 'r'), 1, "|", NULL},
+ {V('p', 'l'), 1, "+", NULL},
+ {V('r', 'c'), 2, "&#175;|", NULL},
+ {V('r', 'f'), 2, "_|", NULL},
+ {V('r', 'g'), 1, "&#174;", NULL},
+ {V('r', 'k'), 1, "<FONT SIZE=+2>}</FONT>", NULL},
+ {V('r', 'n'), 1, "&#175;", NULL},
+ {V('r', 'u'), 1, "_", NULL},
+ {V('s', 'c'), 1, "&#167;", NULL},
+ {V('s', 'l'), 1, "/", NULL},
+ {V('s', 'q'), 2, "[]", NULL},
+ {V('u', 'l'), 1, "_", NULL},
+ {0, 0, NULL, NULL}
+};
+
+/* default: print code */
+
+
+static char eqndelimopen = 0, eqndelimclose = 0;
+static char escapesym = '\\', nobreaksym = '\'', controlsym = '.', fieldsym = 0, padsym = 0;
+
+static char *buffer = NULL;
+static int buffpos = 0, buffmax = 0;
+static int scaninbuff = 0;
+static int itemdepth = 0;
+static int dl_set[20] = {0};
+static int still_dd = 0;
+static int tabstops[20] = {8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96};
+static int maxtstop = 12;
+static int curpos = 0;
+
+static char *scan_troff(char *c, int san, char **result);
+static char *scan_troff_mandoc(char *c, int san, char **result);
+
+static char **argument = NULL;
+
+static char charb[TINY_STR_MAX];
+
+static void
+print_sig(void)
+{
+ char datbuf[NULL_TERMINATED(MED_STR_MAX)];
+ struct tm *timetm;
+ time_t clock;
+
+ datbuf[0] = '\0';
+ clock = time(NULL);
+ timetm = localtime(&clock);
+ strftime(datbuf, MED_STR_MAX, TIMEFORMAT, timetm);
+ printf(signature, manpage, datbuf);
+}
+
+static char *
+expand_char(int nr)
+{
+ STRDEF *h;
+
+ h = chardef;
+ if (!nr)
+ return NULL;
+ while (h)
+ if (h->nr == nr) {
+ curpos += h->slen;
+ return h->st;
+ } else
+ h = h->next;
+ charb[0] = nr / 256;
+ charb[1] = nr % 256;
+ charb[2] = '\0';
+ if (charb[0] == '<') { /* Fix up <= */
+ charb[4] = charb[1];
+ strncpy(charb, "&lt;", 4);
+ charb[5] = '\0';
+ }
+ curpos += 2;
+ return charb;
+}
+
+static char *
+expand_string(int nr)
+{
+ STRDEF *h = strdef;
+
+ if (!nr)
+ return NULL;
+ while (h)
+ if (h->nr == nr) {
+ curpos += h->slen;
+ return h->st;
+ } else
+ h = h->next;
+ return NULL;
+}
+
+static char *
+read_man_page(char *filename)
+{
+ char *man_buf = NULL;
+ int i;
+ FILE *man_stream = NULL;
+ struct stat stbuf;
+ int buf_size;
+
+ if (stat(filename, &stbuf) == -1)
+ return NULL;
+
+ buf_size = stbuf.st_size;
+ man_buf = stralloc(buf_size + 5);
+ man_stream = fopen(filename, "r");
+ if (man_stream) {
+ man_buf[0] = '\n';
+ if (fread(man_buf + 1, 1, buf_size, man_stream) == buf_size) {
+ man_buf[buf_size] = '\n';
+ man_buf[buf_size + 1] = man_buf[buf_size + 2] = '\0';
+ } else {
+ free(man_buf);
+ man_buf = NULL;
+ }
+ fclose(man_stream);
+ }
+ return man_buf;
+}
+
+
+static char outbuffer[NULL_TERMINATED(HUGE_STR_MAX)];
+static int obp = 0;
+static int no_newline_output = 0;
+static int newline_for_fun = 0;
+static int output_possible = 0;
+static int out_length = 0;
+
+/*
+ * Add the links to the output. At the moment the following are
+ * recognized:
+ *
+#if 0
+ * name(*) -> ../man?/name.*
+#endif
+ * method://string -> method://string
+ * www.host.name -> http://www.host.name
+ * ftp.host.name -> ftp://ftp.host.name
+ * name@host -> mailto:name@host
+ * <name.h> -> file:/usr/include/name.h (guess)
+ *
+ * Other possible links to add in the future:
+ *
+ * /dir/dir/file -> file:/dir/dir/file
+ */
+static void
+add_links(char *c)
+{
+ int i, j, nr;
+ char *f, *g, *h;
+ char *idtest[6]; /* url, mailto, www, ftp, manpage */
+
+ out_length += strlen(c);
+ /* search for (section) */
+ nr = 0;
+ idtest[0] = strstr(c + 1, "://");
+ idtest[1] = strchr(c + 1, '@');
+ idtest[2] = strstr(c, "www.");
+ idtest[3] = strstr(c, "ftp.");
+#if 0
+ idtest[4] = strchr(c + 1, '(');
+#else
+ idtest[4] = 0;
+#endif
+ idtest[5] = strstr(c + 1, ".h&gt;");
+ for (i = 0; i < 6; i++)
+ nr += (idtest[i] != NULL);
+ while (nr) {
+ j = -1;
+ for (i = 0; i < 6; i++)
+ if (idtest[i] && (j < 0 || idtest[i] < idtest[j]))
+ j = i;
+ switch (j) {
+ case 5: /* <name.h> */
+ f = idtest[5];
+ h = f + 2;
+ g = f;
+ while (g > c && g[-1] != ';')
+ g--;
+ if (g != c) {
+ char t;
+
+ t = *g;
+ *g = '\0';
+ fputs(c, stdout);
+ *g = t;
+ *h = '\0';
+ printf("<A HREF=\"file:/usr/include/%s\">%s</A>&gt;", g, g);
+ c = f + 6;
+ } else {
+ f[5] = '\0';
+ fputs(c, stdout);
+ f[5] = ';';
+ c = f + 5;
+ }
+ break;
+ case 4: /* manpage */
+#if 0
+ f = idtest[j];
+ /* check section */
+ g = strchr(f, ')');
+ if (g && f - g < 6 && (isalnum(f[-1]) || f[-1] == '>') &&
+ ((isdigit(f[1]) && f[1] != '0' &&
+ (f[2] == ')' || (isalpha(f[2]) && f[3] == ')') || f[2] == 'X')) ||
+ (f[2] == ')' && (f[1] == 'n' || f[1] == 'l')))) {
+ /* this might be a link */
+ h = f - 1;
+ /* skip html makeup */
+ while (h > c && *h == '>') {
+ while (h != c && *h != '<')
+ h--;
+ if (h != c)
+ h--;
+ }
+ if (isalnum(*h)) {
+ char t, sec, subsec, *e;
+
+ e = h + 1;
+ sec = f[1];
+ subsec = f[2];
+ if ((subsec == 'X' && f[3] != ')') || subsec == ')')
+ subsec = '\0';
+ while (h > c && (isalnum(h[-1]) || h[-1] == '_' ||
+ h[-1] == '-' || h[-1] == '.'))
+ h--;
+ t = *h;
+ *h = '\0';
+ fputs(c, stdout);
+ *h = t;
+ t = *e;
+ *e = '\0';
+ if (subsec)
+ printf("<A HREF=\""
+ CGIBASE
+ "?man%c/%s.%c%c\">%s</A>",
+ sec, h, sec, tolower(subsec), h);
+ else
+ printf("<A HREF=\""
+ CGIBASE
+ "?man%c/%s.%c\">%s</A>",
+ sec, h, sec, h);
+ *e = t;
+ c = e;
+ }
+ }
+ *f = '\0';
+ fputs(c, stdout);
+ *f = '(';
+ idtest[4] = f - 1;
+ c = f;
+#endif
+ break; /* manpage */
+ case 3: /* ftp */
+ case 2: /* www */
+ g = f = idtest[j];
+ while (*g && (isalnum(*g) || *g == '_' || *g == '-' || *g == '+' ||
+ *g == '.'))
+ g++;
+ if (g[-1] == '.')
+ g--;
+ if (g - f > 4) {
+ char t;
+
+ t = *f;
+ *f = '\0';
+ fputs(c, stdout);
+ *f = t;
+ t = *g;
+ *g = '\0';
+ printf("<A HREF=\"%s://%s\">%s</A>", (j == 3 ? "ftp" : "http"),
+ f, f);
+ *g = t;
+ c = g;
+ } else {
+ f[3] = '\0';
+ fputs(c, stdout);
+ c = f + 3;
+ f[3] = '.';
+ }
+ break;
+ case 1: /* mailto */
+ g = f = idtest[1];
+ while (g > c && (isalnum(g[-1]) || g[-1] == '_' || g[-1] == '-' ||
+ g[-1] == '+' || g[-1] == '.' || g[-1] == '%'))
+ g--;
+ h = f + 1;
+ while (*h && (isalnum(*h) || *h == '_' || *h == '-' || *h == '+' ||
+ *h == '.'))
+ h++;
+ if (*h == '.')
+ h--;
+ if (h - f > 4 && f - g > 1) {
+ char t;
+
+ t = *g;
+ *g = '\0';
+ fputs(c, stdout);
+ *g = t;
+ t = *h;
+ *h = '\0';
+ printf("<A HREF=\"mailto:%s\">%s</A>", g, g);
+ *h = t;
+ c = h;
+ } else {
+ *f = '\0';
+ fputs(c, stdout);
+ *f = '@';
+ idtest[1] = c;
+ c = f;
+ }
+ break;
+ case 0: /* url */
+ g = f = idtest[0];
+ while (g > c && isalpha(g[-1]) && islower(g[-1]))
+ g--;
+ h = f + 3;
+ while (*h && !isspace(*h) && *h != '<' && *h != '>' && *h != '"' &&
+ *h != '&')
+ h++;
+ if (f - g > 2 && f - g < 7 && h - f > 3) {
+ char t;
+
+ t = *g;
+ *g = '\0';
+ fputs(c, stdout);
+ *g = t;
+ t = *h;
+ *h = '\0';
+ printf("<A HREF=\"%s\">%s</A>", g, g);
+ *h = t;
+ c = h;
+ } else {
+ f[1] = '\0';
+ fputs(c, stdout);
+ f[1] = '/';
+ c = f + 1;
+ }
+ break;
+ default:
+ break;
+ }
+ nr = 0;
+ if (idtest[0] && idtest[0] < c)
+ idtest[0] = strstr(c + 1, "://");
+ if (idtest[1] && idtest[1] < c)
+ idtest[1] = strchr(c + 1, '@');
+ if (idtest[2] && idtest[2] < c)
+ idtest[2] = strstr(c, "www.");
+ if (idtest[3] && idtest[3] < c)
+ idtest[3] = strstr(c, "ftp.");
+ if (idtest[4] && idtest[4] < c)
+ idtest[4] = strchr(c + 1, '(');
+ if (idtest[5] && idtest[5] < c)
+ idtest[5] = strstr(c + 1, ".h&gt;");
+ for (i = 0; i < 6; i++)
+ nr += (idtest[i] != NULL);
+ }
+ fputs(c, stdout);
+}
+
+static int current_font = 0;
+static int current_size = 0;
+static int fillout = 1;
+
+static void
+out_html(char *c)
+{
+ if (!c)
+ return;
+ if (no_newline_output) {
+ int i = 0;
+
+ no_newline_output = 1;
+ while (c[i]) {
+ if (!no_newline_output)
+ c[i - 1] = c[i];
+ if (c[i] == '\n')
+ no_newline_output = 1;
+ i++;
+ }
+ if (!no_newline_output)
+ c[i - 1] = 0;
+ }
+ if (scaninbuff) {
+ while (*c) {
+ if (buffpos >= buffmax) {
+ char *h;
+
+ h = realloc(buffer, buffmax * 2);
+ if (!h)
+ return;
+ buffer = h;
+ buffmax *= 2;
+ }
+ buffer[buffpos++] = *c++;
+ }
+ } else if (output_possible) {
+ while (*c) {
+ outbuffer[obp++] = *c;
+ if (*c == '\n' || obp > HUGE_STR_MAX) {
+ outbuffer[obp] = '\0';
+ add_links(outbuffer);
+ obp = 0;
+ }
+ c++;
+ }
+ }
+}
+
+#define FO0 ""
+#define FC0 ""
+#define FO1 "<I>"
+#define FC1 "</I>"
+#define FO2 "<B>"
+#define FC2 "</B>"
+#define FO3 "<TT>"
+#define FC3 "</TT>"
+
+static char *switchfont[16] = {
+ "", FC0 FO1, FC0 FO2, FC0 FO3,
+ FC1 FO0, "", FC1 FO2, FC1 FO3,
+ FC2 FO0, FC2 FO1, "", FC2 FO3,
+ FC3 FO0, FC3 FO1, FC3 FO2, ""
+};
+
+static char *
+change_to_font(int nr)
+{
+ int i;
+
+ switch (nr) {
+ case '0':
+ nr++;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ nr = nr - '1';
+ break;
+ case V('C', 'W'):
+ nr = 3;
+ break;
+ case 'L':
+ nr = 3;
+ break;
+ case 'B':
+ nr = 2;
+ break;
+ case 'I':
+ nr = 1;
+ break;
+ case 'P':
+ case 'R':
+ nr = 0;
+ break;
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ break;
+ default:
+ nr = 0;
+ break;
+ }
+ i = current_font * 4 + nr % 4;
+ current_font = nr % 4;
+ return switchfont[i];
+}
+
+static char sizebuf[200];
+
+static char *
+change_to_size(int nr)
+{
+ int i;
+
+ switch (nr) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ nr = nr - '0';
+ break;
+ case '\0':
+ break;
+ default:
+ nr = current_size + nr;
+ if (nr > 9)
+ nr = 9;
+ if (nr < -9)
+ nr = -9;
+ break;
+ }
+ if (nr == current_size)
+ return "";
+ i = current_font;
+ sizebuf[0] = '\0';
+ strcat(sizebuf, change_to_font(0));
+ if (current_size)
+ strcat(sizebuf, "</FONT>");
+ current_size = nr;
+ if (nr) {
+ int l;
+
+ strcat(sizebuf, "<FONT SIZE=");
+ l = strlen(sizebuf);
+ if (nr > 0)
+ sizebuf[l++] = '+';
+ else
+ sizebuf[l++] = '-', nr = -nr;
+ sizebuf[l++] = nr + '0';
+ sizebuf[l++] = '>';
+ sizebuf[l] = '\0';
+ }
+ strcat(sizebuf, change_to_font(i));
+ return sizebuf;
+}
+
+static int asint = 0;
+static int intresult = 0;
+
+#define SKIPEOL while (*c && *c++!='\n')
+
+static int skip_escape = 0;
+static int single_escape = 0;
+
+static char *
+scan_escape(char *c)
+{
+ char *h = NULL;
+ char b[5];
+ INTDEF *intd;
+ int exoutputp, exskipescape;
+ int i, j;
+
+ intresult = 0;
+ switch (*c) {
+ case 'e':
+ h = "\\";
+ curpos++;
+ break;
+ case '0':
+ case ' ':
+ h = "&nbsp;";
+ curpos++;
+ break;
+ case '|':
+ h = "";
+ break;
+ case '"':
+ SKIPEOL;
+ c--;
+ h = "";
+ break;
+ case '$':
+ if (argument) {
+ c++;
+ i = (*c - '1');
+ if (!(h = argument[i]))
+ h = "";
+ }
+ break;
+ case 'z':
+ c++;
+ if (*c == '\\') {
+ c = scan_escape(c + 1);
+ c--;
+ h = "";
+ } else {
+ b[0] = *c;
+ b[1] = '\0';
+ h = "";
+ }
+ break;
+ case 'k':
+ c++;
+ if (*c == '(')
+ c += 2;
+ case '^':
+ case '!':
+ case '%':
+ case 'a':
+ case 'd':
+ case 'r':
+ case 'u':
+ case '\n':
+ case '&':
+ h = "";
+ break;
+ case '(':
+ c++;
+ i = c[0] * 256 + c[1];
+ c++;
+ h = expand_char(i);
+ break;
+ case '*':
+ c++;
+ if (*c == '(') {
+ c++;
+ i = c[0] * 256 + c[1];
+ c++;
+ } else
+ i = *c * 256 + ' ';
+ h = expand_string(i);
+ break;
+ case 'f':
+ c++;
+ if (*c == '\\') {
+ c++;
+ c = scan_escape(c);
+ c--;
+ i = intresult;
+ } else if (*c != '(')
+ i = *c;
+ else {
+ c++;
+ i = c[0] * 256 + c[1];
+ c++;
+ }
+ if (!skip_escape)
+ h = change_to_font(i);
+ else
+ h = "";
+ break;
+ case 's':
+ c++;
+ j = 0;
+ i = 0;
+ if (*c == '-') {
+ j = -1;
+ c++;
+ } else if (*c == '+') {
+ j = 1;
+ c++;
+ }
+ if (*c == '0')
+ c++;
+ else if (*c == '\\') {
+ c++;
+ c = scan_escape(c);
+ i = intresult;
+ if (!j)
+ j = 1;
+ } else
+ while (isdigit(*c) && (!i || (!j && i < 4)))
+ i = i * 10 + (*c++) - '0';
+ if (!j) {
+ j = 1;
+ if (i)
+ i = i - 10;
+ }
+ if (!skip_escape)
+ h = change_to_size(i * j);
+ else
+ h = "";
+ c--;
+ break;
+ case 'n':
+ c++;
+ j = 0;
+ switch (*c) {
+ case '+':
+ j = 1;
+ c++;
+ break;
+ case '-':
+ j = -1;
+ c++;
+ break;
+ default:
+ break;
+ }
+ if (*c == '(') {
+ c++;
+ i = V(c[0], c[1]);
+ c = c + 1;
+ } else {
+ i = V(c[0], ' ');
+ }
+ intd = intdef;
+ while (intd && intd->nr != i)
+ intd = intd->next;
+ if (intd) {
+ intd->val = intd->val + j * intd->incr;
+ intresult = intd->val;
+ } else {
+ switch (i) {
+ case V('.', 's'):
+ intresult = current_size;
+ break;
+ case V('.', 'f'):
+ intresult = current_font;
+ break;
+ default:
+ intresult = 0;
+ break;
+ }
+ }
+ h = "";
+ break;
+ case 'w':
+ c++;
+ i = *c;
+ c++;
+ exoutputp = output_possible;
+ exskipescape = skip_escape;
+ output_possible = 0;
+ skip_escape = 1;
+ j = 0;
+ while (*c != i) {
+ j++;
+ if (*c == escapesym)
+ c = scan_escape(c + 1);
+ else
+ c++;
+ }
+ output_possible = exoutputp;
+ skip_escape = exskipescape;
+ intresult = j;
+ break;
+ case 'l':
+ h = "<HR>";
+ curpos = 0;
+ case 'b':
+ case 'v':
+ case 'x':
+ case 'o':
+ case 'L':
+ case 'h':
+ c++;
+ i = *c;
+ c++;
+ exoutputp = output_possible;
+ exskipescape = skip_escape;
+ output_possible = 0;
+ skip_escape = 1;
+ while (*c != i)
+ if (*c == escapesym)
+ c = scan_escape(c + 1);
+ else
+ c++;
+ output_possible = exoutputp;
+ skip_escape = exskipescape;
+ break;
+ case 'c':
+ no_newline_output = 1;
+ break;
+ case '{':
+ newline_for_fun++;
+ h = "";
+ break;
+ case '}':
+ if (newline_for_fun)
+ newline_for_fun--;
+ h = "";
+ break;
+ case 'p':
+ h = "<BR>\n";
+ curpos = 0;
+ break;
+ case 't':
+ h = "\t";
+ curpos = (curpos + 8) & 0xfff8;
+ break;
+ case '<':
+ h = "&lt;";
+ curpos++;
+ break;
+ case '>':
+ h = "&gt;";
+ curpos++;
+ break;
+ case '\\':
+ if (single_escape) {
+ c--;
+ break;
+ }
+ default:
+ b[0] = *c;
+ b[1] = 0;
+ h = b;
+ curpos++;
+ break;
+ }
+ c++;
+ if (!skip_escape)
+ out_html(h);
+ return c;
+}
+
+typedef struct TABLEITEM TABLEITEM;
+
+struct TABLEITEM {
+ char *contents;
+ int size, align, valign, colspan, rowspan, font, vleft, vright, space,
+ width;
+ TABLEITEM *next;
+};
+
+static TABLEITEM emptyfield = {NULL, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, NULL};
+
+typedef struct TABLEROW TABLEROW;
+
+struct TABLEROW {
+ TABLEITEM *first;
+ TABLEROW *prev, *next;
+};
+
+static char *tableopt[] = {
+ "center", "expand", "box", "allbox", "doublebox",
+ "tab", "linesize", "delim", NULL
+};
+static int tableoptl[] = {6, 6, 3, 6, 9, 3, 8, 5, 0};
+
+static void
+clear_table(TABLEROW * table)
+{
+ TABLEROW *tr1, *tr2;
+ TABLEITEM *ti1, *ti2;
+
+ tr1 = table;
+ while (tr1->prev)
+ tr1 = tr1->prev;
+ while (tr1) {
+ ti1 = tr1->first;
+ while (ti1) {
+ ti2 = ti1->next;
+ if (ti1->contents)
+ free(ti1->contents);
+ free(ti1);
+ ti1 = ti2;
+ }
+ tr2 = tr1;
+ tr1 = tr1->next;
+ free(tr2);
+ }
+}
+
+static char *scan_expression(char *c, int *result);
+
+static char *
+scan_format(char *c, TABLEROW ** result, int *maxcol)
+{
+ TABLEROW *layout, *currow;
+ TABLEITEM *curfield;
+ int i, j;
+
+ if (*result) {
+ clear_table(*result);
+ }
+ layout = currow = (TABLEROW *) xmalloc(sizeof(TABLEROW));
+ currow->next = currow->prev = NULL;
+ currow->first = curfield = (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ *curfield = emptyfield;
+ while (*c && *c != '.') {
+ switch (*c) {
+ case 'C':
+ case 'c':
+ case 'N':
+ case 'n':
+ case 'R':
+ case 'r':
+ case 'A':
+ case 'a':
+ case 'L':
+ case 'l':
+ case 'S':
+ case 's':
+ case '^':
+ case '_':
+ if (curfield->align) {
+ curfield->next = (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ curfield = curfield->next;
+ *curfield = emptyfield;
+ }
+ curfield->align = toupper(*c);
+ c++;
+ break;
+ case 'i':
+ case 'I':
+ case 'B':
+ case 'b':
+ curfield->font = toupper(*c);
+ c++;
+ break;
+ case 'f':
+ case 'F':
+ c++;
+ curfield->font = toupper(*c);
+ c++;
+ if (!isspace(*c))
+ c++;
+ break;
+ case 't':
+ case 'T':
+ curfield->valign = 't';
+ c++;
+ break;
+ case 'p':
+ case 'P':
+ c++;
+ i = j = 0;
+ if (*c == '+') {
+ j = 1;
+ c++;
+ }
+ if (*c == '-') {
+ j = -1;
+ c++;
+ }
+ while (isdigit(*c))
+ i = i * 10 + (*c++) - '0';
+ if (j)
+ curfield->size = i * j;
+ else
+ curfield->size = j - 10;
+ break;
+ case 'v':
+ case 'V':
+ case 'w':
+ case 'W':
+ c = scan_expression(c + 2, &curfield->width);
+ break;
+ case '|':
+ if (curfield->align)
+ curfield->vleft++;
+ else
+ curfield->vright++;
+ c++;
+ break;
+ case 'e':
+ case 'E':
+ c++;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ i = 0;
+ while (isdigit(*c))
+ i = i * 10 + (*c++) - '0';
+ curfield->space = i;
+ break;
+ case ',':
+ case '\n':
+ currow->next = (TABLEROW *) xmalloc(sizeof(TABLEROW));
+ currow->next->prev = currow;
+ currow = currow->next;
+ currow->next = NULL;
+ curfield = currow->first = (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ *curfield = emptyfield;
+ c++;
+ break;
+ default:
+ c++;
+ break;
+ }
+ }
+ if (*c == '.')
+ while (*c++ != '\n');
+ *maxcol = 0;
+ currow = layout;
+ while (currow) {
+ curfield = layout->first;
+ i = 0;
+ while (curfield) {
+ i++;
+ curfield = curfield->next;
+ }
+ if (i > *maxcol)
+ *maxcol = i;
+ currow = currow->next;
+ }
+ *result = layout;
+ return c;
+}
+
+static TABLEROW *
+next_row(TABLEROW * tr)
+{
+ if (tr->next) {
+ tr = tr->next;
+ if (!tr->next)
+ next_row(tr);
+ return tr;
+ } else {
+ TABLEITEM *ti, *ti2;
+
+ tr->next = (TABLEROW *) xmalloc(sizeof(TABLEROW));
+ tr->next->prev = tr;
+ ti = tr->first;
+ tr = tr->next;
+ tr->next = NULL;
+ if (ti)
+ tr->first = ti2 = (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ else
+ tr->first = ti2 = NULL;
+ while (ti != ti2) {
+ *ti2 = *ti;
+ ti2->contents = NULL;
+ if ((ti = ti->next)) {
+ ti2->next = (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ }
+ ti2 = ti2->next;
+ }
+ return tr;
+ }
+}
+
+static char itemreset[20] = "\\fR\\s0";
+
+static char *
+scan_table(char *c)
+{
+ char *t, *h, *g;
+ int center = 0, expand = 0, box = 0, border = 0, linesize = 1;
+ int i, j, maxcol = 0, finished = 0;
+ int oldfont, oldsize, oldfillout;
+ char itemsep = '\t';
+ TABLEROW *layout = NULL, *currow, *ftable;
+ TABLEITEM *curfield;
+
+ while (*c++ != '\n');
+ h = c;
+ if (*h == '.')
+ return c - 1;
+ oldfont = current_font;
+ oldsize = current_size;
+ oldfillout = fillout;
+ out_html(change_to_font(0));
+ out_html(change_to_size(0));
+ if (!fillout) {
+ fillout = 1;
+ out_html("</PRE>");
+ }
+ while (*h && *h != '\n')
+ h++;
+ if (h[-1] == ';') {
+ /* scan table options */
+ while (c < h) {
+ while (isspace(*c))
+ c++;
+ for (i = 0; tableopt[i] && strncmp(tableopt[i], c, tableoptl[i]); i++);
+ c = c + tableoptl[i];
+ switch (i) {
+ case 0:
+ center = 1;
+ break;
+ case 1:
+ expand = 1;
+ break;
+ case 2:
+ box = 1;
+ break;
+ case 3:
+ border = 1;
+ break;
+ case 4:
+ box = 2;
+ break;
+ case 5:
+ while (*c++ != '(');
+ itemsep = *c++;
+ break;
+ case 6:
+ while (*c++ != '(');
+ linesize = 0;
+ while (isdigit(*c))
+ linesize = linesize * 10 + (*c++) - '0';
+ break;
+ case 7:
+ while (*c != ')')
+ c++;
+ default:
+ break;
+ }
+ c++;
+ }
+ c = h + 1;
+ }
+ /* scan layout */
+ c = scan_format(c, &layout, &maxcol);
+ currow = layout;
+ next_row(currow);
+ curfield = layout->first;
+ i = 0;
+ while (!finished) {
+ /* search item */
+ h = c;
+ if ((*c == '_' || *c == '=') && (c[1] == itemsep || c[1] == '\n')) {
+ if (c[-1] == '\n' && c[1] == '\n') {
+ if (currow->prev) {
+ currow->prev->next = (TABLEROW *) xmalloc(sizeof(TABLEROW));
+ currow->prev->next->next = currow;
+ currow->prev->next->prev = currow->prev;
+ currow->prev = currow->prev->next;
+ } else {
+ currow->prev = layout = (TABLEROW *) xmalloc(sizeof(TABLEROW));
+ currow->prev->prev = NULL;
+ currow->prev->next = currow;
+ }
+ curfield = currow->prev->first =
+ (TABLEITEM *) xmalloc(sizeof(TABLEITEM));
+ *curfield = emptyfield;
+ curfield->align = *c;
+ curfield->colspan = maxcol;
+ curfield = currow->first;
+ c = c + 2;
+ } else {
+ if (curfield) {
+ curfield->align = *c;
+ do {
+ curfield = curfield->next;
+ } while (curfield && curfield->align == 'S');
+ }
+ if (c[1] == '\n') {
+ currow = next_row(currow);
+ curfield = currow->first;
+ }
+ c = c + 2;
+ }
+ } else if (*c == 'T' && c[1] == '{') {
+ h = c + 2;
+ c = strstr(h, "\nT}");
+ c++;
+ *c = '\0';
+ g = NULL;
+ scan_troff(h, 0, &g);
+ scan_troff(itemreset, 0, &g);
+ *c = 'T';
+ c += 3;
+ if (curfield) {
+ curfield->contents = g;
+ do {
+ curfield = curfield->next;
+ } while (curfield && curfield->align == 'S');
+ } else if (g)
+ free(g);
+ if (c[-1] == '\n') {
+ currow = next_row(currow);
+ curfield = currow->first;
+ }
+ } else if (*c == '.' && c[1] == 'T' && c[2] == '&' && c[-1] == '\n') {
+ TABLEROW *hr;
+
+ while (*c++ != '\n');
+ hr = currow;
+ currow = currow->prev;
+ hr->prev = NULL;
+ c = scan_format(c, &hr, &i);
+ hr->prev = currow;
+ currow->next = hr;
+ currow = hr;
+ next_row(currow);
+ curfield = currow->first;
+ } else if (*c == '.' && c[1] == 'T' && c[2] == 'E' && c[-1] == '\n') {
+ finished = 1;
+ while (*c++ != '\n');
+ if (currow->prev)
+ currow->prev->next = NULL;
+ currow->prev = NULL;
+ clear_table(currow);
+ } else if (*c == '.' && c[-1] == '\n' && !isdigit(c[1])) {
+ /*
+ * skip troff request inside table (usually only .sp
+ * )
+ */
+ while (*c++ != '\n');
+ } else {
+ h = c;
+ while (*c && (*c != itemsep || c[-1] == '\\') &&
+ (*c != '\n' || c[-1] == '\\'))
+ c++;
+ i = 0;
+ if (*c == itemsep) {
+ i = 1;
+ *c = '\n';
+ }
+ if (h[0] == '\\' && h[2] == '\n' &&
+ (h[1] == '_' || h[1] == '^')) {
+ if (curfield) {
+ curfield->align = h[1];
+ do {
+ curfield = curfield->next;
+ } while (curfield && curfield->align == 'S');
+ }
+ h = h + 3;
+ } else {
+ g = NULL;
+ h = scan_troff(h, 1, &g);
+ scan_troff(itemreset, 0, &g);
+ if (curfield) {
+ curfield->contents = g;
+ do {
+ curfield = curfield->next;
+ } while (curfield && curfield->align == 'S');
+ } else if (g)
+ free(g);
+ }
+ if (i)
+ *c = itemsep;
+ c = h;
+ if (c[-1] == '\n') {
+ currow = next_row(currow);
+ curfield = currow->first;
+ }
+ }
+ }
+ /* calculate colspan and rowspan */
+ currow = layout;
+ while (currow->next)
+ currow = currow->next;
+ while (currow) {
+ TABLEITEM *ti, *ti1 = NULL, *ti2 = NULL;
+
+ ti = currow->first;
+ if (currow->prev)
+ ti1 = currow->prev->first;
+ while (ti) {
+ switch (ti->align) {
+ case 'S':
+ if (ti2) {
+ ti2->colspan++;
+ if (ti2->rowspan < ti->rowspan)
+ ti2->rowspan = ti->rowspan;
+ }
+ break;
+ case '^':
+ if (ti1)
+ ti1->rowspan++;
+ default:
+ if (!ti2)
+ ti2 = ti;
+ else {
+ do {
+ ti2 = ti2->next;
+ } while (ti2 && curfield->align == 'S');
+ }
+ break;
+ }
+ ti = ti->next;
+ if (ti1)
+ ti1 = ti1->next;
+ }
+ currow = currow->prev;
+ }
+ /* produce html output */
+ if (center)
+ out_html("<CENTER>");
+ if (box == 2)
+ out_html("<TABLE BORDER><TR><TD>");
+ out_html("<TABLE");
+ if (box || border) {
+ out_html(" BORDER");
+ if (!border)
+ out_html("><TR><TD><TABLE");
+ if (expand)
+ out_html(" WIDTH=100%");
+ }
+ out_html(">\n");
+ currow = layout;
+ while (currow) {
+ j = 0;
+ out_html("<TR VALIGN=top>");
+ curfield = currow->first;
+ while (curfield) {
+ if (curfield->align != 'S' && curfield->align != '^') {
+ out_html("<TD");
+ switch (curfield->align) {
+ case 'N':
+ curfield->space += 4;
+ case 'R':
+ out_html(" ALIGN=right");
+ break;
+ case 'C':
+ out_html(" ALIGN=center");
+ default:
+ break;
+ }
+ if (!curfield->valign && curfield->rowspan > 1)
+ out_html(" VALIGN=center");
+ if (curfield->colspan > 1) {
+ char buf[5];
+
+ out_html(" COLSPAN=");
+ sprintf(buf, "%i", curfield->colspan);
+ out_html(buf);
+ }
+ if (curfield->rowspan > 1) {
+ char buf[5];
+
+ out_html(" ROWSPAN=");
+ sprintf(buf, "%i", curfield->rowspan);
+ out_html(buf);
+ }
+ j = j + curfield->colspan;
+ out_html(">");
+ if (curfield->size)
+ out_html(change_to_size(curfield->size));
+ if (curfield->font)
+ out_html(change_to_font(curfield->font));
+ switch (curfield->align) {
+ case '=':
+ out_html("<HR><HR>");
+ break;
+ case '_':
+ out_html("<HR>");
+ break;
+ default:
+ if (curfield->contents)
+ out_html(curfield->contents);
+ break;
+ }
+ if (curfield->space)
+ for (i = 0; i < curfield->space; i++)
+ out_html("&nbsp;");
+ if (curfield->font)
+ out_html(change_to_font(0));
+ if (curfield->size)
+ out_html(change_to_size(0));
+ if (j >= maxcol && curfield->align > '@' && curfield->align != '_')
+ out_html("<BR>");
+ out_html("</TD>");
+ }
+ curfield = curfield->next;
+ }
+ out_html("</TR>\n");
+ currow = currow->next;
+ }
+ if (box && !border)
+ out_html("</TABLE>");
+ out_html("</TABLE>");
+ if (box == 2)
+ out_html("</TABLE>");
+ if (center)
+ out_html("</CENTER>\n");
+ else
+ out_html("\n");
+ if (!oldfillout)
+ out_html("<PRE>");
+ fillout = oldfillout;
+ out_html(change_to_size(oldsize));
+ out_html(change_to_font(oldfont));
+ return c;
+}
+
+static char *
+scan_expression(char *c, int *result)
+{
+ int value = 0, value2, j = 0, sign = 1, opex = 0;
+ char oper = 'c';
+
+ if (*c == '!') {
+ c = scan_expression(c + 1, &value);
+ value = (!value);
+ } else if (*c == 'n') {
+ c++;
+ value = NROFF;
+ } else if (*c == 't') {
+ c++;
+ value = 1 - NROFF;
+ } else if (*c == '\'' || *c == '"' || *c < ' ' || (*c == '\\' && c[1] == '(')) {
+ /*
+ * ?string1?string2? test if string1 equals string2.
+ */
+ char *st1 = NULL, *st2 = NULL, *h;
+ char *tcmp = NULL;
+ char sep;
+
+ sep = *c;
+ if (sep == '\\') {
+ tcmp = c;
+ c = c + 3;
+ }
+ c++;
+ h = c;
+ while (*c != sep && (!tcmp || strncmp(c, tcmp, 4)))
+ c++;
+ *c = '\n';
+ scan_troff(h, 1, &st1);
+ *c = sep;
+ if (tcmp)
+ c = c + 3;
+ c++;
+ h = c;
+ while (*c != sep && (!tcmp || strncmp(c, tcmp, 4)))
+ c++;
+ *c = '\n';
+ scan_troff(h, 1, &st2);
+ *c = sep;
+ if (!st1 && !st2)
+ value = 1;
+ else if (!st1 || !st2)
+ value = 0;
+ else
+ value = (!strcmp(st1, st2));
+ if (st1)
+ free(st1);
+ if (st2)
+ free(st2);
+ if (tcmp)
+ c = c + 3;
+ c++;
+ } else {
+ while (*c && !isspace(*c) && *c != ')') {
+ opex = 0;
+ switch (*c) {
+ case '(':
+ c = scan_expression(c + 1, &value2);
+ value2 = sign * value2;
+ opex = 1;
+ break;
+ case '.':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':{
+ int num = 0, denum = 1;
+
+ value2 = 0;
+ while (isdigit(*c))
+ value2 = value2 * 10 + ((*c++) - '0');
+ if (*c == '.') {
+ c++;
+ while (isdigit(*c)) {
+ num = num * 10 + ((*c++) - '0');
+ denum = denum * 10;
+ }
+ }
+ if (isalpha(*c)) {
+ /* scale indicator */
+ switch (*c) {
+ case 'i': /* inch -> 10pt */
+ value2 = value2 * 10 + (num * 10 + denum / 2) / denum;
+ num = 0;
+ break;
+ default:
+ break;
+ }
+ c++;
+ }
+ value2 = value2 + (num + denum / 2) / denum;
+ value2 = sign * value2;
+ opex = 1;
+ break;
+ }
+ case '\\':
+ c = scan_escape(c + 1);
+ value2 = intresult * sign;
+ if (isalpha(*c))
+ c++; /* scale indicator */
+ opex = 1;
+ break;
+ case '-':
+ if (oper) {
+ sign = -1;
+ c++;
+ break;
+ }
+ case '>':
+ case '<':
+ case '+':
+ case '/':
+ case '*':
+ case '%':
+ case '&':
+ case '=':
+ case ':':
+ if (c[1] == '=')
+ oper = (*c++) + 16;
+ else
+ oper = *c;
+ c++;
+ break;
+ default:
+ c++;
+ break;
+ }
+ if (opex) {
+ sign = 1;
+ switch (oper) {
+ case 'c':
+ value = value2;
+ break;
+ case '-':
+ value = value - value2;
+ break;
+ case '+':
+ value = value + value2;
+ break;
+ case '*':
+ value = value * value2;
+ break;
+ case '/':
+ if (value2)
+ value = value / value2;
+ break;
+ case '%':
+ if (value2)
+ value = value % value2;
+ break;
+ case '<':
+ value = (value < value2);
+ break;
+ case '>':
+ value = (value > value2);
+ break;
+ case '>' + 16:
+ value = (value >= value2);
+ break;
+ case '<' + 16:
+ value = (value <= value2);
+ break;
+ case '=':
+ case '=' + 16:
+ value = (value == value2);
+ break;
+ case '&':
+ value = (value && value2);
+ break;
+ case ':':
+ value = (value || value2);
+ break;
+ default:
+ fprintf(stderr, "man2html: unknown operator %c.\n", oper);
+ }
+ oper = 0;
+ }
+ }
+ if (*c == ')')
+ c++;
+ }
+ *result = value;
+ return c;
+}
+
+static void
+trans_char(char *c, char s, char t)
+{
+ char *sl = c;
+ int slash = 0;
+
+ while (*sl != '\n' || slash) {
+ if (!slash) {
+ if (*sl == escapesym)
+ slash = 1;
+ else if (*sl == s)
+ *sl = t;
+ } else
+ slash = 0;
+ sl++;
+ }
+}
+
+/* Remove \a from C in place. Return modified C. */
+static char *
+unescape (char *c)
+{
+ int i, l;
+
+ l = strlen (c);
+ i = 0;
+ while (i < l && c[i]) {
+ if (c[i] == '\a') {
+ if (c[i+1])
+ memmove (c + i, c + i + 1, l - i);
+ else {
+ c[i] = '\0';
+ break;
+ }
+ }
+ i++;
+ }
+ return c;
+}
+
+static char *
+fill_words(char *c, char *words[], int *n)
+{
+ char *sl = c;
+ int slash = 0;
+ int skipspace = 0;
+
+ *n = 0;
+ words[*n] = sl;
+ while (*sl && (*sl != '\n' || slash)) {
+ if (!slash) {
+ if (*sl == '"') {
+ *sl = '\a';
+ skipspace = !skipspace;
+ } else if (*sl == '\a') {
+ /* handle already-translated " */
+ skipspace = !skipspace;
+ } else if (*sl == escapesym)
+ slash = 1;
+ else if ((*sl == ' ' || *sl == '\t') && !skipspace) {
+ *sl = '\n';
+ if (words[*n] != sl)
+ (*n)++;
+ words[*n] = sl + 1;
+ }
+ } else {
+ if (*sl == '"') {
+ sl--;
+ *sl = '\n';
+ if (words[*n] != sl)
+ (*n)++;
+ sl++;
+ while (*sl && *sl != '\n')
+ sl++;
+ words[*n] = sl;
+ sl--;
+ }
+ slash = 0;
+ }
+ sl++;
+ }
+ if (sl != words[*n])
+ (*n)++;
+ return sl;
+}
+
+static char *abbrev_list[] = {
+ "GSBG", "Getting Started ",
+ "SUBG", "Customizing SunOS",
+ "SHBG", "Basic Troubleshooting",
+ "SVBG", "SunView User's Guide",
+ "MMBG", "Mail and Messages",
+ "DMBG", "Doing More with SunOS",
+ "UNBG", "Using the Network",
+ "GDBG", "Games, Demos &amp; Other Pursuits",
+ "CHANGE", "SunOS 4.1 Release Manual",
+ "INSTALL", "Installing SunOS 4.1",
+ "ADMIN", "System and Network Administration",
+ "SECUR", "Security Features Guide",
+ "PROM", "PROM User's Manual",
+ "DIAG", "Sun System Diagnostics",
+ "SUNDIAG", "Sundiag User's Guide",
+ "MANPAGES", "SunOS Reference Manual",
+ "REFMAN", "SunOS Reference Manual",
+ "SSI", "Sun System Introduction",
+ "SSO", "System Services Overview",
+ "TEXT", "Editing Text Files",
+ "DOCS", "Formatting Documents",
+ "TROFF", "Using <B>nroff</B> and <B>troff</B>",
+ "INDEX", "Global Index",
+ "CPG", "C Programmer's Guide",
+ "CREF", "C Reference Manual",
+ "ASSY", "Assembly Language Reference",
+ "PUL", "Programming Utilities and Libraries",
+ "DEBUG", "Debugging Tools",
+ "NETP", "Network Programming",
+ "DRIVER", "Writing Device Drivers",
+ "STREAMS", "STREAMS Programming",
+ "SBDK", "SBus Developer's Kit",
+ "WDDS", "Writing Device Drivers for the SBus",
+ "FPOINT", "Floating-Point Programmer's Guide",
+ "SVPG", "SunView 1 Programmer's Guide",
+ "SVSPG", "SunView 1 System Programmer's Guide",
+ "PIXRCT", "Pixrect Reference Manual",
+ "CGI", "SunCGI Reference Manual",
+ "CORE", "SunCore Reference Manual",
+ "4ASSY", "Sun-4 Assembly Language Reference",
+ "SARCH", "<FONT SIZE=-1>SPARC</FONT> Architecture Manual",
+ "KR", "The C Programming Language",
+NULL, NULL};
+
+static char *
+lookup_abbrev(char *c)
+{
+ int i = 0;
+
+ if (!c)
+ return "";
+ while (abbrev_list[i] && strcmp(c, abbrev_list[i]))
+ i = i + 2;
+ if (abbrev_list[i])
+ return abbrev_list[i + 1];
+ else
+ return c;
+}
+
+static char manidx[NULL_TERMINATED(HUGE_STR_MAX)];
+static int subs = 0;
+static int mip = 0;
+static char label[5] = "lbAA";
+
+static void
+add_to_index(int level, char *item)
+{
+ char *c = NULL;
+
+ label[3]++;
+ if (label[3] > 'Z') {
+ label[3] = 'A';
+ label[2]++;
+ }
+ if (level != subs) {
+ if (subs) {
+ strmaxcpy(manidx + mip, "</DL>\n", HUGE_STR_MAX - mip);
+ mip += 6;
+ } else {
+ strmaxcpy(manidx + mip, "<DL>\n", HUGE_STR_MAX - mip);
+ mip += 5;
+ }
+ }
+ subs = level;
+ scan_troff(item, 1, &c);
+ sprintf(manidx + mip, "<DT><A HREF=\"#%s\">%s</A><DD>\n", label, c);
+ if (c)
+ free(c);
+ while (manidx[mip])
+ mip++;
+}
+
+static char *
+skip_till_newline(char *c)
+{
+ int lvl = 0;
+
+ while (*c && *c != '\n' || lvl > 0) {
+ if (*c == '\\') {
+ c++;
+ if (*c == '}')
+ lvl--;
+ else if (*c == '{')
+ lvl++;
+ }
+ c++;
+ }
+ c++;
+ if (lvl < 0 && newline_for_fun) {
+ newline_for_fun = newline_for_fun + lvl;
+ if (newline_for_fun < 0)
+ newline_for_fun = 0;
+ }
+ return c;
+}
+
+static void
+outputPageHeader(char *l, char *c, char *r)
+{
+ out_html("<TABLE WIDTH=100%>\n<TR>\n");
+ out_html("<TH ALIGN=LEFT width=33%>");
+ out_html(l);
+ out_html("<TH ALIGN=CENTER width=33%>");
+ out_html(c);
+ out_html("<TH ALIGN=RIGHT width=33%>");
+ out_html(r);
+ out_html("\n</TR>\n</TABLE>\n");
+}
+
+static void
+outputPageFooter(char *l, char *c, char *r)
+{
+ out_html("<HR>\n");
+ outputPageHeader(l, c, r);
+}
+
+static int ifelseval = 0;
+
+static char *
+scan_request(char *c)
+{
+ /* BSD Mandoc stuff */
+ static int mandoc_synopsis = 0; /* True if we are in the synopsis
+ * section */
+ static int mandoc_command = 0; /* True if this is mandoc page */
+ static int mandoc_bd_options; /* Only copes with non-nested Bd's */
+
+ int i, j, mode = 0;
+ char *h;
+ char *wordlist[MAX_WORDLIST];
+ int words;
+ char *sl;
+ STRDEF *owndef;
+
+ while (*c == ' ' || *c == '\t')
+ c++;
+ if (c[0] == '\n')
+ return c + 1;
+ if (c[1] == '\n')
+ j = 1;
+ else
+ j = 2;
+ while (c[j] == ' ' || c[j] == '\t')
+ j++;
+ if (c[0] == escapesym) {
+ /* some pages use .\" .\$1 .\} */
+ /* .\$1 is too difficult/stupid */
+ if (c[1] == '$')
+ c = skip_till_newline(c);
+ else
+ c = scan_escape(c + 1);
+ } else {
+ i = V(c[0], c[1]);
+ switch (i) {
+ case V('a', 'b'):
+ h = c + j;
+ while (*h && *h != '\n')
+ h++;
+ *h = '\0';
+ if (scaninbuff && buffpos) {
+ buffer[buffpos] = '\0';
+ puts(buffer);
+ }
+ /* fprintf(stderr, "%s\n", c+2); */
+ exit(0);
+ break;
+ case V('d', 'i'):
+ {
+ STRDEF *de;
+ int oldcurpos = curpos;
+
+ c = c + j;
+ i = V(c[0], c[1]);
+ if (*c == '\n') {
+ c++;
+ break;
+ }
+ while (*c && *c != '\n')
+ c++;
+ c++;
+ h = c;
+ while (*c && strncmp(c, ".di", 3))
+ while (*c && *c++ != '\n');
+ *c = '\0';
+ de = strdef;
+ while (de && de->nr != i)
+ de = de->next;
+ if (!de) {
+ de = (STRDEF *) xmalloc(sizeof(STRDEF));
+ de->nr = i;
+ de->slen = 0;
+ de->next = strdef;
+ de->st = NULL;
+ strdef = de;
+ } else {
+ if (de->st)
+ free(de->st);
+ de->slen = 0;
+ de->st = NULL;
+ }
+ scan_troff(h, 0, &de->st);
+ *c = '.';
+ while (*c && *c++ != '\n');
+ break;
+ }
+ case V('d', 's'):
+ mode = 1;
+ case V('a', 's'):
+ {
+ STRDEF *de;
+ int oldcurpos = curpos;
+
+ c = c + j;
+ i = V(c[0], c[1]);
+ j = 0;
+ while (c[j] && c[j] != '\n')
+ j++;
+ if (j < 3) {
+ c = c + j;
+ break;
+ }
+ if (c[1] == ' ')
+ c = c + 1;
+ else
+ c = c + 2;
+ while (isspace(*c))
+ c++;
+ if (*c == '"')
+ c++;
+ de = strdef;
+ while (de && de->nr != i)
+ de = de->next;
+ single_escape = 1;
+ curpos = 0;
+ if (!de) {
+ char *h;
+
+ de = (STRDEF *) xmalloc(sizeof(STRDEF));
+ de->nr = i;
+ de->slen = 0;
+ de->next = strdef;
+ de->st = NULL;
+ strdef = de;
+ h = NULL;
+ c = scan_troff(c, 1, &h);
+ de->st = h;
+ de->slen = curpos;
+ } else {
+ if (mode) {
+ char *h = NULL;
+
+ c = scan_troff(c, 1, &h);
+ free(de->st);
+ de->slen = 0;
+ de->st = h;
+ } else
+ c = scan_troff(c, 1, &de->st);
+ de->slen += curpos;
+ }
+ single_escape = 0;
+ curpos = oldcurpos;
+ }
+ break;
+ case V('b', 'r'):
+ if (still_dd)
+ out_html("<DD>");
+ else
+ out_html("<BR>\n");
+ curpos = 0;
+ c = c + j;
+ if (c[0] == escapesym) {
+ c = scan_escape(c + 1);
+ }
+ c = skip_till_newline(c);
+ break;
+ case V('c', '2'):
+ c = c + j;
+ if (*c != '\n') {
+ nobreaksym = *c;
+ } else
+ nobreaksym = '\'';
+ c = skip_till_newline(c);
+ break;
+ case V('c', 'c'):
+ c = c + j;
+ if (*c != '\n') {
+ controlsym = *c;
+ } else
+ controlsym = '.';
+ c = skip_till_newline(c);
+ break;
+ case V('c', 'e'):
+ c = c + j;
+ if (*c == '\n') {
+ i = 1;
+ } else {
+ i = 0;
+ while ('0' <= *c && *c <= '9') {
+ i = i * 10 + *c - '0';
+ c++;
+ }
+ }
+ c = skip_till_newline(c);
+ /* center next i lines */
+ if (i > 0) {
+ out_html("<CENTER>\n");
+ while (i && *c) {
+ char *line = NULL;
+
+ c = scan_troff(c, 1, &line);
+ if (line && strncmp(line, "<BR>", 4)) {
+ out_html(line);
+ out_html("<BR>\n");
+ i--;
+ }
+ }
+ out_html("</CENTER>\n");
+ curpos = 0;
+ }
+ break;
+ case V('e', 'c'):
+ c = c + j;
+ if (*c != '\n') {
+ escapesym = *c;
+ } else
+ escapesym = '\\';
+ break;
+ c = skip_till_newline(c);
+ case V('e', 'o'):
+ escapesym = '\0';
+ c = skip_till_newline(c);
+ break;
+ case V('e', 'x'):
+ exit(0);
+ break;
+ case V('f', 'c'):
+ c = c + j;
+ if (*c == '\n') {
+ fieldsym = padsym = '\0';
+ } else {
+ fieldsym = c[0];
+ padsym = c[1];
+ }
+ c = skip_till_newline(c);
+ break;
+ case V('f', 'i'):
+ if (!fillout) {
+ out_html(change_to_font(0));
+ out_html(change_to_size('0'));
+ out_html("</PRE>\n");
+ }
+ curpos = 0;
+ fillout = 1;
+ c = skip_till_newline(c);
+ break;
+ case V('f', 't'):
+ c = c + j;
+ if (*c == '\n') {
+ out_html(change_to_font(0));
+ } else {
+ if (*c == escapesym) {
+ int fn;
+
+ c = scan_expression(c, &fn);
+ c--;
+ out_html(change_to_font(fn));
+ } else {
+ out_html(change_to_font(*c));
+ c++;
+ }
+ }
+ c = skip_till_newline(c);
+ break;
+ case V('e', 'l'):
+ /* .el anything : else part of if else */
+ if (ifelseval) {
+ c = c + j;
+ c[-1] = '\n';
+ c = scan_troff(c, 1, NULL);
+ } else
+ c = skip_till_newline(c + j);
+ break;
+ case V('i', 'e'):
+ /* .ie c anything : then part of if else */
+ case V('i', 'f'):
+ /*
+ * .if c anything .if !c anything .if N anything .if
+ * !N anything .if 'string1'string2' anything .if
+ * !'string1'string2' anything
+ */
+ c = c + j;
+ c = scan_expression(c, &i);
+ ifelseval = !i;
+ if (i) {
+ *c = '\n';
+ c++;
+ c = scan_troff(c, 1, NULL);
+ } else
+ c = skip_till_newline(c);
+ break;
+ case V('i', 'g'):
+ {
+ char *endwith = "..\n";
+
+ i = 3;
+ c = c + j;
+ if (*c != '\n') {
+ endwith = c - 1;
+ i = 1;
+ c[-1] = '.';
+ while (*c && *c != '\n')
+ c++, i++;
+ }
+ c++;
+ while (*c && strncmp(c, endwith, i))
+ while (*c++ != '\n');
+ while (*c++ != '\n');
+ break;
+ }
+ case V('n', 'f'):
+ if (fillout) {
+ out_html(change_to_font(0));
+ out_html(change_to_size('0'));
+ out_html("<PRE>\n");
+ }
+ curpos = 0;
+ fillout = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('p', 's'):
+ c = c + j;
+ if (*c == '\n') {
+ out_html(change_to_size('0'));
+ } else {
+ j = 0;
+ i = 0;
+ if (*c == '-') {
+ j = -1;
+ c++;
+ } else if (*c == '+') {
+ j = 1;
+ c++;
+ }
+ c = scan_expression(c, &i);
+ if (!j) {
+ j = 1;
+ if (i > 5)
+ i = i - 10;
+ }
+ out_html(change_to_size(i * j));
+ }
+ c = skip_till_newline(c);
+ break;
+ case V('s', 'p'):
+ c = c + j;
+ if (fillout)
+ out_html("<P>");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('s', 'o'):
+ {
+ FILE *f;
+ struct stat stbuf;
+ int l = 0;
+ char *buf;
+ char *name = NULL;
+
+ curpos = 0;
+ c = c + j;
+ if (*c == '/') {
+ h = c;
+ } else {
+ h = c - 3;
+ h[0] = '.';
+ h[1] = '.';
+ h[2] = '/';
+ }
+ while (*c != '\n')
+ c++;
+ *c = '\0';
+ scan_troff(h, 1, &name);
+ if (name[3] == '/')
+ h = name + 3;
+ else
+ h = name;
+ if (stat(h, &stbuf) != -1)
+ l = stbuf.st_size;
+#if NOCGI
+ if (!out_length) {
+ char *t, *s;
+
+ t = strrchr(fname, '/');
+ if (!t)
+ t = fname;
+ fprintf(stderr, "ln -s %s.html %s.html\n", h, t);
+ s = strrchr(t, '.');
+ if (!s)
+ s = t;
+ printf("<HTML><HEAD><TITLE> Manpage of %s</TITLE>\n"
+ "</HEAD><BODY>\n"
+ "See the manpage for <A HREF=\"%s.html\">%s</A>.\n"
+ "</BODY></HTML>\n",
+ s, h, h);
+ } else
+#endif
+ {
+ /*
+ * this works alright, except for
+ * section 3
+ */
+ buf = read_man_page(h);
+ if (!buf) {
+
+ fprintf(stderr, "man2html: unable to open or read file %s.\n",
+ h);
+ out_html("<BLOCKQUOTE>"
+ "man2html: unable to open or read file.\n");
+ out_html(h);
+ out_html("</BLOCKQUOTE>\n");
+ } else {
+ buf[0] = buf[l] = '\n';
+ buf[l + 1] = buf[l + 2] = '\0';
+ scan_troff(buf + 1, 0, NULL);
+ }
+ if (buf)
+ free(buf);
+ }
+ *c++ = '\n';
+ break;
+ }
+ case V('t', 'a'):
+ c = c + j;
+ j = 0;
+ while (*c != '\n') {
+ sl = scan_expression(c, &tabstops[j]);
+ if (*c == '-' || *c == '+')
+ tabstops[j] += tabstops[j - 1];
+ c = sl;
+ while (*c == ' ' || *c == '\t')
+ c++;
+ j++;
+ }
+ maxtstop = j;
+ curpos = 0;
+ break;
+ case V('t', 'i'):
+ /*
+ * while (itemdepth || dl_set[itemdepth]) {
+ * out_html("</DL>\n"); if (dl_set[itemdepth])
+ * dl_set[itemdepth]=0; else itemdepth--; }
+ */
+ out_html("<BR>\n");
+ c = c + j;
+ c = scan_expression(c, &j);
+ for (i = 0; i < j; i++)
+ out_html("&nbsp;");
+ curpos = j;
+ c = skip_till_newline(c);
+ break;
+ case V('t', 'm'):
+ c = c + j;
+ h = c;
+ while (*c != '\n')
+ c++;
+ *c = '\0';
+ /* fprintf(stderr,"%s\n", h); */
+ *c = '\n';
+ break;
+ case V('B', ' '):
+ case V('B', '\n'):
+ case V('I', ' '):
+ case V('I', '\n'):
+ /* parse one line in a certain font */
+ out_html(change_to_font(*c));
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('O', 'P'): /* groff manpages use this
+ * construction */
+ /* .OP a b : [ <B>a</B> <I>b</I> ] */
+ mode = 1;
+ c[0] = 'B';
+ c[1] = 'I';
+ out_html(change_to_font('R'));
+ out_html("[");
+ curpos++;
+ case V('B', 'R'):
+ case V('B', 'I'):
+ case V('I', 'B'):
+ case V('I', 'R'):
+ case V('R', 'B'):
+ case V('R', 'I'):
+ {
+ char font[2];
+
+ font[0] = c[0];
+ font[1] = c[1];
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ sl = fill_words(c, wordlist, &words);
+ c = sl + 1;
+ /*
+ * .BR name (section) indicates a link. It
+ * will be added in the output routine.
+ */
+ for (i = 0; i < words; i++) {
+ if (mode) {
+ out_html(" ");
+ curpos++;
+ }
+ wordlist[i][-1] = ' ';
+ out_html(change_to_font(font[i & 1]));
+ scan_troff(wordlist[i], 1, NULL);
+ }
+ out_html(change_to_font('R'));
+ if (mode) {
+ out_html(" ]");
+ curpos++;
+ }
+ out_html(NEWLINE);
+ if (!fillout)
+ curpos = 0;
+ else
+ curpos++;
+ }
+ break;
+ case V('D', 'T'):
+ for (j = 0; j < 20; j++)
+ tabstops[j] = (j + 1) * 8;
+ maxtstop = 20;
+ c = skip_till_newline(c);
+ break;
+ case V('I', 'P'):
+ sl = fill_words(c + j, wordlist, &words);
+ c = sl + 1;
+ if (!dl_set[itemdepth]) {
+ out_html("<DL COMPACT>\n");
+ dl_set[itemdepth] = 1;
+ }
+ out_html("<DT>");
+ if (words) {
+ scan_troff(wordlist[0], 1, NULL);
+ }
+ out_html("<DD>");
+ curpos = 0;
+ break;
+ case V('T', 'P'):
+ if (!dl_set[itemdepth]) {
+ out_html("<DL COMPACT>\n");
+ dl_set[itemdepth] = 1;
+ }
+ out_html("<DT>");
+ c = skip_till_newline(c);
+ /* somewhere a definition ends with '.TP' */
+ if (!*c)
+ still_dd = 1;
+ else {
+ c = scan_troff(c, 1, NULL);
+ out_html("<DD>");
+ }
+ curpos = 0;
+ break;
+ case V('I', 'X'):
+ /* general index */
+ sl = fill_words(c + j, wordlist, &words);
+ c = sl + 1;
+ j = 4;
+ while (idxlabel[j] == 'Z')
+ idxlabel[j--] = 'A';
+ idxlabel[j]++;
+#ifdef MAKEINDEX
+ fprintf(idxfile, "%s@%s@", fname, idxlabel);
+ for (j = 0; j < words; j++) {
+ h = NULL;
+ scan_troff(wordlist[j], 1, &h);
+ fprintf(idxfile, "_\b@%s", h);
+ free(h);
+ }
+ fprintf(idxfile, "\n");
+#endif
+ out_html("<A NAME=\"");
+ out_html(idxlabel);
+ /*
+ * this will not work in mosaic (due to a bug).
+ * Adding '&nbsp;' between '>' and '<' solves it, but
+ * creates some space. A normal space does not work.
+ */
+ out_html("\"></A>");
+ break;
+ case V('L', 'P'):
+ case V('P', 'P'):
+ if (dl_set[itemdepth]) {
+ out_html("</DL>\n");
+ dl_set[itemdepth] = 0;
+ }
+ if (fillout)
+ out_html("<P>\n");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('H', 'P'):
+ if (!dl_set[itemdepth]) {
+ out_html("<DL COMPACT>");
+ dl_set[itemdepth] = 1;
+ }
+ out_html("<DT>\n");
+ still_dd = 1;
+ c = skip_till_newline(c);
+ curpos = 0;
+ break;
+ case V('P', 'D'):
+ c = skip_till_newline(c);
+ break;
+ case V('R', 's'): /* BSD mandoc */
+ case V('R', 'S'):
+ sl = fill_words(c + j, wordlist, &words);
+ j = 1;
+ if (words > 0)
+ scan_expression(wordlist[0], &j);
+ if (j >= 0) {
+ itemdepth++;
+ dl_set[itemdepth] = 0;
+ out_html("<DL COMPACT><DT><DD>");
+ c = skip_till_newline(c);
+ curpos = 0;
+ break;
+ }
+ case V('R', 'e'): /* BSD mandoc */
+ case V('R', 'E'):
+ if (itemdepth > 0) {
+ if (dl_set[itemdepth])
+ out_html("</DL>");
+ out_html("</DL>\n");
+ itemdepth--;
+ }
+ c = skip_till_newline(c);
+ curpos = 0;
+ break;
+ case V('S', 'B'):
+ out_html(change_to_size(-1));
+ out_html(change_to_font('B'));
+ c = scan_troff(c + j, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html(change_to_size('0'));
+ break;
+ case V('S', 'M'):
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html(change_to_size(-1));
+ trans_char(c, '"', '\a');
+ c = scan_troff(c, 1, NULL);
+ out_html(change_to_size('0'));
+ break;
+ case V('S', 's'): /* BSD mandoc */
+ mandoc_command = 1;
+ case V('S', 'S'):
+ mode = 1;
+ case V('S', 'h'): /* BSD mandoc */
+ /* hack for fallthru from above */
+ mandoc_command = !mode || mandoc_command;
+ case V('S', 'H'):
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ while (itemdepth || dl_set[itemdepth]) {
+ out_html("</DL>\n");
+ if (dl_set[itemdepth])
+ dl_set[itemdepth] = 0;
+ else if (itemdepth > 0)
+ itemdepth--;
+ }
+ out_html(change_to_font(0));
+ out_html(change_to_size(0));
+ if (!fillout) {
+ fillout = 1;
+ out_html("</PRE>");
+ }
+ trans_char(c, '"', '\a');
+ add_to_index(mode, c);
+ out_html("<A NAME=\"");
+ out_html(label);
+ /* &nbsp; for mosaic users */
+ if (mode)
+ out_html("\">&nbsp;</A>\n<H4>");
+ else
+ out_html("\">&nbsp;</A>\n<H3>");
+ mandoc_synopsis = strncmp(c, "SYNOPSIS", 8) == 0;
+ c = mandoc_command ? scan_troff_mandoc(c, 1, NULL) : scan_troff(c, 1, NULL);
+ if (mode)
+ out_html("</H4>\n");
+ else
+ out_html("</H3>\n");
+ curpos = 0;
+ break;
+ case V('T', 'S'):
+ c = scan_table(c);
+ break;
+ case V('D', 't'): /* BSD mandoc */
+ mandoc_command = 1;
+ case V('T', 'H'):
+ if (!output_possible) {
+ sl = fill_words(c + j, wordlist, &words);
+ if (words > 1) {
+ char *t;
+ for (i = 1; i < words; i++)
+ wordlist[i][-1] = '\0';
+ *sl = '\0';
+ output_possible = 1;
+ sprintf(th_page_and_sec, "%s(%s)", wordlist[0], wordlist[1]);
+ if (words > 2) {
+ t = unescape(wordlist[2]);
+ strncpy(th_datestr, t, sizeof(th_datestr));
+ th_datestr[sizeof(th_datestr) - 1] = '\0';
+ } else
+ th_datestr[0] = '\0';
+ if (words > 3) {
+ t = unescape(wordlist[3]);
+ strncpy(th_version, t, sizeof(th_version));
+ th_version[sizeof(th_version) - 1] = '\0';
+ } else
+ th_version[0] = '\0';
+ out_html("<HTML><HEAD>\n<TITLE>");
+ out_html(th_page_and_sec);
+ out_html(" Manual Page");
+ out_html("</TITLE>\n</HEAD>\n<BODY>");
+
+ outputPageHeader(th_page_and_sec, th_datestr, th_page_and_sec);
+
+ out_html("<BR><A HREF=\"#index\">Index</A>\n");
+ *sl = '\n';
+ out_html("<HR>\n");
+ if (mandoc_command)
+ out_html("<BR>BSD mandoc<BR>");
+ }
+ c = sl + 1;
+ } else
+ c = skip_till_newline(c);
+ curpos = 0;
+ break;
+ case V('T', 'X'):
+ sl = fill_words(c + j, wordlist, &words);
+ *sl = '\0';
+ out_html(change_to_font('I'));
+ if (words > 1)
+ wordlist[1][-1] = '\0';
+ c = lookup_abbrev(wordlist[0]);
+ curpos += strlen(c);
+ out_html(c);
+ out_html(change_to_font('R'));
+ if (words > 1)
+ out_html(wordlist[1]);
+ *sl = '\n';
+ c = sl + 1;
+ break;
+ case V('r', 'm'):
+ /* .rm xx : Remove request, macro or string */
+ case V('r', 'n'):
+ /*
+ * .rn xx yy : Rename request, macro or string xx to
+ * yy
+ */
+ {
+ STRDEF *de;
+
+ c = c + j;
+ i = V(c[0], c[1]);
+ c = c + 2;
+ while (isspace(*c) && *c != '\n')
+ c++;
+ j = V(c[0], c[1]);
+ while (*c && *c != '\n')
+ c++;
+ c++;
+ de = strdef;
+ while (de && de->nr != j)
+ de = de->next;
+ if (de) {
+ if (de->st)
+ free(de->st);
+ de->nr = 0;
+ }
+ de = strdef;
+ while (de && de->nr != i)
+ de = de->next;
+ if (de)
+ de->nr = j;
+ break;
+ }
+ case V('n', 'x'):
+ /* .nx filename : next file. */
+ case V('i', 'n'):
+ /* .in +-N : Indent */
+ c = skip_till_newline(c);
+ break;
+ case V('n', 'r'):
+ /*
+ * .nr R +-N M: define and set number register R by
+ * +-N; auto-increment by M
+ */
+ {
+ INTDEF *intd;
+
+ c = c + j;
+ i = V(c[0], c[1]);
+ c = c + 2;
+ intd = intdef;
+ while (intd && intd->nr != i)
+ intd = intd->next;
+ if (!intd) {
+ intd = (INTDEF *) xmalloc(sizeof(INTDEF));
+ intd->nr = i;
+ intd->val = 0;
+ intd->incr = 0;
+ intd->next = intdef;
+ intdef = intd;
+ }
+ while (*c == ' ' || *c == '\t')
+ c++;
+ c = scan_expression(c, &intd->val);
+ if (*c != '\n') {
+ while (*c == ' ' || *c == '\t')
+ c++;
+ c = scan_expression(c, &intd->incr);
+ }
+ c = skip_till_newline(c);
+ break;
+ }
+ case V('a', 'm'):
+ /* .am xx yy : append to a macro. */
+ /* define or handle as .ig yy */
+ mode = 1;
+ case V('d', 'e'):
+ /*
+ * .de xx yy : define or redefine macro xx; end at
+ * .yy (..)
+ */
+ /* define or handle as .ig yy */
+ {
+ STRDEF *de;
+ int olen = 0;
+
+ c = c + j;
+ sl = fill_words(c, wordlist, &words);
+ i = V(c[0], c[1]);
+ j = 2;
+ if (words == 1)
+ wordlist[1] = "..";
+ else {
+ wordlist[1]--;
+ wordlist[1][0] = '.';
+ j = 3;
+ }
+ c = sl + 1;
+ sl = c;
+ while (*c && strncmp(c, wordlist[1], j))
+ c = skip_till_newline(c);
+ de = defdef;
+ while (de && de->nr != i)
+ de = de->next;
+ if (mode && de)
+ olen = strlen(de->st);
+ j = olen + c - sl;
+ h = stralloc(j * 2 + 4);
+ if (h) {
+ for (j = 0; j < olen; j++)
+ h[j] = de->st[j];
+ if (!j || h[j - 1] != '\n')
+ h[j++] = '\n';
+ while (sl != c) {
+ if (sl[0] == '\\' && sl[1] == '\\') {
+ h[j++] = '\\';
+ sl++;
+ } else
+ h[j++] = *sl;
+ sl++;
+ }
+ h[j] = '\0';
+ if (de) {
+ if (de->st)
+ free(de->st);
+ de->st = h;
+ } else {
+ de = (STRDEF *) xmalloc(sizeof(STRDEF));
+ de->nr = i;
+ de->next = defdef;
+ de->st = h;
+ defdef = de;
+ }
+ }
+ }
+ c = skip_till_newline(c);
+ break;
+ case V('B', 'l'): /* BSD mandoc */
+ {
+ char list_options[NULL_TERMINATED(MED_STR_MAX)];
+ char *nl = strchr(c, '\n');
+
+ c = c + j;
+ if (dl_set[itemdepth]) { /* These things can
+ * nest. */
+ itemdepth++;
+ }
+ if (nl) { /* Parse list options */
+ strlimitcpy(list_options, c, nl - c, MED_STR_MAX);
+ }
+ if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */
+ dl_set[itemdepth] = BL_BULLET_LIST;
+ out_html("<UL>\n");
+ } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */
+ dl_set[itemdepth] = BL_ENUM_LIST;
+ out_html("<OL>\n");
+ } else { /* HTML Descriptive List */
+ dl_set[itemdepth] = BL_DESC_LIST;
+ out_html("<DL COMPACT>\n");
+ }
+ if (fillout)
+ out_html("<P>\n");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ }
+ case V('E', 'l'): /* BSD mandoc */
+ c = c + j;
+ if (dl_set[itemdepth] & BL_DESC_LIST) {
+ out_html("</DL>\n");
+ } else if (dl_set[itemdepth] & BL_BULLET_LIST) {
+ out_html("</UL>\n");
+ } else if (dl_set[itemdepth] & BL_ENUM_LIST) {
+ out_html("</OL>\n");
+ }
+ dl_set[itemdepth] = 0;
+ if (itemdepth > 0)
+ itemdepth--;
+ if (fillout)
+ out_html("<P>\n");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('I', 't'): /* BSD mandoc */
+ c = c + j;
+ if (strncmp(c, "Xo", 2) == 0 && isspace(*(c + 2))) {
+ c = skip_till_newline(c);
+ }
+ if (dl_set[itemdepth] & BL_DESC_LIST) {
+ out_html("<DT>");
+ out_html(change_to_font('B'));
+ if (*c == '\n') { /* Don't allow embedded
+ * comms after a newline */
+ c++;
+ c = scan_troff(c, 1, NULL);
+ } else { /* Do allow embedded comms on
+ * the same line. */
+ c = scan_troff_mandoc(c, 1, NULL);
+ }
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ out_html("<DD>");
+ } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) {
+ out_html("<LI>");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(NEWLINE);
+ }
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('B', 'k'): /* BSD mandoc */
+ case V('E', 'k'): /* BSD mandoc */
+ case V('D', 'd'): /* BSD mandoc */
+ case V('O', 's'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('B', 't'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ out_html(" is currently in beta test.");
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('B', 'x'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html("BSD ");
+ c = scan_troff_mandoc(c, 1, NULL);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('D', 'l'): /* BSD mandoc */
+ c = c + j;
+ out_html(NEWLINE);
+ out_html("<BLOCKQUOTE>");
+ out_html(change_to_font('L'));
+ if (*c == '\n')
+ c++;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html("</BLOCKQUOTE>");
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('B', 'd'): /* BSD mandoc */
+ { /* Seems like a kind of example/literal mode */
+ char bd_options[NULL_TERMINATED(MED_STR_MAX)];
+ char *nl = strchr(c, '\n');
+
+ c = c + j;
+ if (nl) {
+ strlimitcpy(bd_options, c, nl - c, MED_STR_MAX);
+ }
+ out_html(NEWLINE);
+ mandoc_bd_options = 0; /* Remember options for
+ * terminating Bl */
+ if (strstr(bd_options, "-offset indent")) {
+ mandoc_bd_options |= BD_INDENT;
+ out_html("<BLOCKQUOTE>\n");
+ }
+ if (strstr(bd_options, "-literal")
+ || strstr(bd_options, "-unfilled")) {
+ if (fillout) {
+ mandoc_bd_options |= BD_LITERAL;
+ out_html(change_to_font(0));
+ out_html(change_to_size('0'));
+ out_html("<PRE>\n");
+ }
+ curpos = 0;
+ fillout = 0;
+ }
+ c = skip_till_newline(c);
+ break;
+ }
+ case V('E', 'd'): /* BSD mandoc */
+ if (mandoc_bd_options & BD_LITERAL) {
+ if (!fillout) {
+ out_html(change_to_font(0));
+ out_html(change_to_size('0'));
+ out_html("</PRE>\n");
+ }
+ }
+ if (mandoc_bd_options & BD_INDENT)
+ out_html("</BLOCKQUOTE>\n");
+ curpos = 0;
+ fillout = 1;
+ c = skip_till_newline(c);
+ break;
+ case V('B', 'e'): /* BSD mandoc */
+ c = c + j;
+ if (fillout)
+ out_html("<P>");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('X', 'r'): /* BSD mandoc */
+ {
+ /*
+ * Translate xyz 1 to xyz(1) Allow for
+ * multiple spaces. Allow the section to be
+ * missing.
+ */
+ char buff[NULL_TERMINATED(MED_STR_MAX)];
+ char *bufptr;
+
+ trans_char(c, '"', '\a');
+ bufptr = buff;
+ c = c + j;
+ if (*c == '\n')
+ c++; /* Skip spaces */
+ while (isspace(*c) && *c != '\n')
+ c++;
+ while (isalnum(*c)) { /* Copy the xyz part */
+ *bufptr = *c;
+ bufptr++;
+ if (bufptr >= buff + MED_STR_MAX)
+ break;
+ c++;
+ }
+ while (isspace(*c) && *c != '\n')
+ c++; /* Skip spaces */
+ if (isdigit(*c)) { /* Convert the number if
+ * there is one */
+ *bufptr = '(';
+ bufptr++;
+ if (bufptr < buff + MED_STR_MAX) {
+ while (isalnum(*c)) {
+ *bufptr = *c;
+ bufptr++;
+ if (bufptr >= buff + MED_STR_MAX)
+ break;
+ c++;
+ }
+ if (bufptr < buff + MED_STR_MAX) {
+ *bufptr = ')';
+ bufptr++;
+ }
+ }
+ }
+ while (*c != '\n') { /* Copy the remainder */
+ if (!isspace(*c)) {
+ *bufptr = *c;
+ bufptr++;
+ if (bufptr >= buff + MED_STR_MAX)
+ break;
+ }
+ c++;
+ }
+ *bufptr = '\n';
+ scan_troff_mandoc(buff, 1, NULL);
+
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ }
+ break;
+ case V('F', 'l'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ out_html("-");
+ if (*c != '\n') {
+ out_html(change_to_font('B'));
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ }
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('P', 'a'): /* BSD mandoc */
+ case V('P', 'f'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('P', 'p'): /* BSD mandoc */
+ if (fillout)
+ out_html("<P>\n");
+ else {
+ out_html(NEWLINE);
+ NEWLINE[0] = '\n';
+ }
+ curpos = 0;
+ c = skip_till_newline(c);
+ break;
+ case V('D', 'q'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html("``");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html("''");
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('O', 'p'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html(change_to_font('R'));
+ out_html("[");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html("]");
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('O', 'o'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html(change_to_font('R'));
+ out_html("[");
+ c = scan_troff_mandoc(c, 1, NULL);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('O', 'c'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html("]");
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('P', 'q'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html("(");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(")");
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('Q', 'l'): /* BSD mandoc */
+ { /* Single quote first word in the line */
+ char *sp;
+
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ sp = c;
+ do { /* Find first whitespace after the
+ * first word that isn't a mandoc
+ * macro */
+ while (*sp && isspace(*sp))
+ sp++;
+ while (*sp && !isspace(*sp))
+ sp++;
+ } while (*sp && isupper(*(sp - 2)) && islower(*(sp - 1)));
+
+ /*
+ * Use a newline to mark the end of text to
+ * be quoted
+ */
+ if (*sp)
+ *sp = '\n';
+ out_html("`"); /* Quote the text */
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html("'");
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ }
+ case V('S', 'q'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html("`");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html("'");
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('A', 'r'): /* BSD mandoc */
+ /* parse one line in italics */
+ out_html(change_to_font('I'));
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n') { /* An empty Ar means "file
+ * ..." */
+ out_html("file ...");
+ } else {
+ c = scan_troff_mandoc(c, 1, NULL);
+ }
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('A', 'd'): /* BSD mandoc */
+ case V('E', 'm'): /* BSD mandoc */
+ case V('V', 'a'): /* BSD mandoc */
+ case V('X', 'c'): /* BSD mandoc */
+ /* parse one line in italics */
+ out_html(change_to_font('I'));
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('N', 'd'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html(" - ");
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('N', 'm'): /* BSD mandoc */
+ {
+ static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = "";
+
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (mandoc_synopsis) { /* Break lines only in
+ * the Synopsis. The
+ * Synopsis section
+ * seems to be treated
+ * as a special case -
+ * Bummer! */
+ static int count = 0; /* Don't break on the
+ * first Nm */
+
+ if (count) {
+ out_html("<BR>");
+ } else {
+ char *end = strchr(c, '\n');
+
+ if (end) { /* Remember the name for
+ * later. */
+ strlimitcpy(mandoc_name, c, end - c, SMALL_STR_MAX);
+ }
+ }
+ count++;
+ }
+ out_html(change_to_font('B'));
+ while (*c == ' ' || *c == '\t')
+ c++;
+ if (*c == '\n') { /* If Nm has no
+ * argument, use one
+ * from an earlier Nm
+ * command that did have
+ * one. Hope there
+ * aren't too many
+ * commands that do
+ * this. */
+ out_html(mandoc_name);
+ } else {
+ c = scan_troff_mandoc(c, 1, NULL);
+ }
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ }
+ case V('C', 'd'): /* BSD mandoc */
+ case V('C', 'm'): /* BSD mandoc */
+ case V('I', 'c'): /* BSD mandoc */
+ case V('M', 's'): /* BSD mandoc */
+ case V('O', 'r'): /* BSD mandoc */
+ case V('S', 'y'): /* BSD mandoc */
+ /* parse one line in bold */
+ out_html(change_to_font('B'));
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('D', 'v'): /* BSD mandoc */
+ case V('E', 'v'): /* BSD mandoc */
+ case V('F', 'r'): /* BSD mandoc */
+ case V('L', 'i'): /* BSD mandoc */
+ case V('N', 'o'): /* BSD mandoc */
+ case V('N', 's'): /* BSD mandoc */
+ case V('T', 'n'): /* BSD mandoc */
+ case V('n', 'N'): /* BSD mandoc */
+ trans_char(c, '"', '\a');
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ out_html(change_to_font('B'));
+ c = scan_troff_mandoc(c, 1, NULL);
+ out_html(change_to_font('R'));
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('%', 'A'): /* BSD mandoc biblio stuff */
+ case V('%', 'D'):
+ case V('%', 'N'):
+ case V('%', 'O'):
+ case V('%', 'P'):
+ case V('%', 'Q'):
+ case V('%', 'V'):
+ c = c + j;
+ if (*c == '\n')
+ c++;
+ c = scan_troff(c, 1, NULL); /* Don't allow embedded
+ * mandoc coms */
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ case V('%', 'B'):
+ case V('%', 'J'):
+ case V('%', 'R'):
+ case V('%', 'T'):
+ c = c + j;
+ out_html(change_to_font('I'));
+ if (*c == '\n')
+ c++;
+ c = scan_troff(c, 1, NULL); /* Don't allow embedded
+ * mandoc coms */
+ out_html(change_to_font('R'));
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ break;
+ default:
+ /* search macro database of self-defined macros */
+ owndef = defdef;
+ while (owndef && owndef->nr != i)
+ owndef = owndef->next;
+ if (owndef) {
+ char **oldargument;
+ int deflen;
+ int onff;
+
+ sl = fill_words(c + j, wordlist, &words);
+ c = sl + 1;
+ *sl = '\0';
+ for (i = 1; i < words; i++)
+ wordlist[i][-1] = '\0';
+ for (i = 0; i < words; i++) {
+ char *h = NULL;
+
+ if (mandoc_command) {
+ scan_troff_mandoc(wordlist[i], 1, &h);
+ } else {
+ scan_troff(wordlist[i], 1, &h);
+ }
+ wordlist[i] = h;
+ }
+ for (i = words; i < 20; i++)
+ wordlist[i] = NULL;
+ deflen = strlen(owndef->st);
+ for (i = 0; owndef->st[deflen + 2 + i] = owndef->st[i]; i++);
+ oldargument = argument;
+ argument = wordlist;
+ onff = newline_for_fun;
+ if (mandoc_command) {
+ scan_troff_mandoc(owndef->st + deflen + 2, 0, NULL);
+ } else {
+ scan_troff(owndef->st + deflen + 2, 0, NULL);
+ }
+ newline_for_fun = onff;
+ argument = oldargument;
+ for (i = 0; i < words; i++)
+ if (wordlist[i])
+ free(wordlist[i]);
+ *sl = '\n';
+ } else if (mandoc_command &&
+ ((isupper(*c) && islower(*(c + 1)))
+ || (islower(*c) && isupper(*(c + 1))))
+ ) { /* Let through any BSD mandoc
+ * commands that haven't been delt
+ * with. I don't want to miss
+ * anything out of the text. */
+ char buf[4];
+
+ strncpy(buf, c, 2);
+ buf[2] = ' ';
+ buf[3] = '\0';
+ out_html(buf); /* Print the command (it
+ * might just be text). */
+ c = c + j;
+ trans_char(c, '"', '\a');
+ if (*c == '\n')
+ c++;
+ out_html(change_to_font('R'));
+ c = scan_troff(c, 1, NULL);
+ out_html(NEWLINE);
+ if (fillout)
+ curpos++;
+ else
+ curpos = 0;
+ } else {
+ c = skip_till_newline(c);
+ }
+ break;
+ }
+ }
+ if (fillout) {
+ out_html(NEWLINE);
+ curpos++;
+ }
+ NEWLINE[0] = '\n';
+ return c;
+}
+
+static void
+flush(void)
+{
+}
+
+static int contained_tab = 0;
+static int mandoc_line = 0; /* Signals whether to look for embedded
+ * mandoc commands. */
+
+/* san : stop at newline */
+static char *
+scan_troff(char *c, int san, char **result)
+{
+ char *h;
+ char intbuff[NULL_TERMINATED(MED_STR_MAX)];
+ int ibp = 0;
+ int i;
+ char *exbuffer;
+ int exbuffpos, exbuffmax, exscaninbuff, exnewline_for_fun;
+ int usenbsp = 0;
+
+#define FLUSHIBP if (ibp) { intbuff[ibp]=0; out_html(intbuff); ibp=0; }
+
+ exbuffer = buffer;
+ exbuffpos = buffpos;
+ exbuffmax = buffmax;
+ exnewline_for_fun = newline_for_fun;
+ exscaninbuff = scaninbuff;
+ newline_for_fun = 0;
+ if (result) {
+ if (*result) {
+ buffer = *result;
+ buffpos = strlen(buffer);
+ buffmax = buffpos;
+ } else {
+ buffer = stralloc(LARGE_STR_MAX);
+ buffpos = 0;
+ buffmax = LARGE_STR_MAX;
+ }
+ scaninbuff = 1;
+ }
+ h = c;
+ /* start scanning */
+
+ while (*h && (!san || newline_for_fun || *h != '\n')) {
+
+ if (*h == escapesym) {
+ h++;
+ FLUSHIBP;
+ h = scan_escape(h);
+ } else if (*h == controlsym && h[-1] == '\n') {
+ h++;
+ FLUSHIBP;
+ h = scan_request(h);
+ if (san && h[-1] == '\n')
+ h--;
+ } else if (mandoc_line
+ && *(h) && isupper(*(h))
+ && *(h + 1) && islower(*(h + 1))
+ && *(h + 2) && isspace(*(h + 2))) {
+ /*
+ * BSD imbedded command eg ".It Fl Ar arg1 Fl Ar
+ * arg2"
+ */
+ FLUSHIBP;
+ h = scan_request(h);
+ if (san && h[-1] == '\n')
+ h--;
+ } else if (*h == nobreaksym && h[-1] == '\n') {
+ h++;
+ FLUSHIBP;
+ h = scan_request(h);
+ if (san && h[-1] == '\n')
+ h--;
+ } else {
+ int mx;
+
+ if (h[-1] == '\n' && still_dd && isalnum(*h)) {
+ /*
+ * sometimes a .HP request is not followed by
+ * a .br request
+ */
+ FLUSHIBP;
+ out_html("<DD>");
+ curpos = 0;
+ still_dd = 0;
+ }
+ switch (*h) {
+ case '&':
+ intbuff[ibp++] = '&';
+ intbuff[ibp++] = 'a';
+ intbuff[ibp++] = 'm';
+ intbuff[ibp++] = 'p';
+ intbuff[ibp++] = ';';
+ curpos++;
+ break;
+ case '<':
+ intbuff[ibp++] = '&';
+ intbuff[ibp++] = 'l';
+ intbuff[ibp++] = 't';
+ intbuff[ibp++] = ';';
+ curpos++;
+ break;
+ case '>':
+ intbuff[ibp++] = '&';
+ intbuff[ibp++] = 'g';
+ intbuff[ibp++] = 't';
+ intbuff[ibp++] = ';';
+ curpos++;
+ break;
+ case '"':
+ intbuff[ibp++] = '&';
+ intbuff[ibp++] = 'q';
+ intbuff[ibp++] = 'u';
+ intbuff[ibp++] = 'o';
+ intbuff[ibp++] = 't';
+ intbuff[ibp++] = ';';
+ curpos++;
+ break;
+ case '\n':
+ if (h[-1] == '\n' && fillout) {
+ intbuff[ibp++] = '<';
+ intbuff[ibp++] = 'P';
+ intbuff[ibp++] = '>';
+ }
+ if (contained_tab && fillout) {
+ intbuff[ibp++] = '<';
+ intbuff[ibp++] = 'B';
+ intbuff[ibp++] = 'R';
+ intbuff[ibp++] = '>';
+ }
+ contained_tab = 0;
+ curpos = 0;
+ usenbsp = 0;
+ intbuff[ibp++] = '\n';
+ break;
+ case '\t':
+ {
+ int curtab = 0;
+
+ contained_tab = 1;
+ FLUSHIBP;
+ /* like a typewriter, not like TeX */
+ tabstops[19] = curpos + 1;
+ while (curtab < maxtstop && tabstops[curtab] <= curpos)
+ curtab++;
+ if (curtab < maxtstop) {
+ if (!fillout) {
+ while (curpos < tabstops[curtab]) {
+ intbuff[ibp++] = ' ';
+ if (ibp > 480) {
+ FLUSHIBP;
+ }
+ curpos++;
+ }
+ } else {
+ out_html("<TT>");
+ while (curpos < tabstops[curtab]) {
+ out_html("&nbsp;");
+ curpos++;
+ }
+ out_html("</TT>");
+ }
+ }
+ }
+ break;
+ default:
+ if (*h == ' ' && (h[-1] == '\n' || usenbsp)) {
+ FLUSHIBP;
+ if (!usenbsp && fillout) {
+ out_html("<BR>");
+ curpos = 0;
+ }
+ usenbsp = fillout;
+ if (usenbsp)
+ out_html("&nbsp;");
+ else
+ intbuff[ibp++] = ' ';
+ } else if (*h > 31 && *h < 127)
+ intbuff[ibp++] = *h;
+ else if (((unsigned char) (*h)) > 127) {
+ intbuff[ibp++] = '&';
+ intbuff[ibp++] = '#';
+ intbuff[ibp++] = '0' + ((unsigned char) (*h)) / 100;
+ intbuff[ibp++] = '0' + (((unsigned char) (*h)) % 100) / 10;
+ intbuff[ibp++] = '0' + ((unsigned char) (*h)) % 10;
+ intbuff[ibp++] = ';';
+ }
+ curpos++;
+ break;
+ }
+ if (ibp > (MED_STR_MAX - 20))
+ FLUSHIBP;
+ h++;
+ }
+ }
+ FLUSHIBP;
+ if (buffer)
+ buffer[buffpos] = '\0';
+ if (san && *h)
+ h++;
+ newline_for_fun = exnewline_for_fun;
+ if (result) {
+ *result = buffer;
+ buffer = exbuffer;
+ buffpos = exbuffpos;
+ buffmax = exbuffmax;
+ scaninbuff = exscaninbuff;
+ }
+ return h;
+}
+
+
+static char *
+scan_troff_mandoc(char *c, int san, char **result)
+{
+ char *ret, *end = c;
+ int oldval = mandoc_line;
+
+ mandoc_line = 1;
+ while (*end && *end != '\n') {
+ end++;
+ }
+
+ if (end > c + 2
+ && ispunct(*(end - 1))
+ && isspace(*(end - 2)) && *(end - 2) != '\n') {
+ /*
+ * Don't format lonely punctuation E.g. in "xyz ," format the
+ * xyz and then append the comma removing the space.
+ */
+ *(end - 2) = '\n';
+ ret = scan_troff(c, san, result);
+ *(end - 2) = *(end - 1);
+ *(end - 1) = ' ';
+ } else {
+ ret = scan_troff(c, san, result);
+ }
+ mandoc_line = oldval;
+ return ret;
+}
+
+int
+main(int argc, char **argv)
+{
+ FILE *f;
+ char *t;
+ int l, i;
+ char *buf;
+ char *h, *fullname;
+ STRDEF *stdf;
+
+ t = NULL;
+ while ((i = getopt(argc, argv, "")) != EOF) {
+ switch (i) {
+ default:
+ usage();
+ exit(EXIT_USAGE);
+ }
+ }
+
+ if (argc != 2) {
+ usage();
+ exit(EXIT_USAGE);
+ }
+ manpage = h = t = argv[1];
+ i = 0;
+
+ buf = read_man_page(h);
+ if (!buf) {
+ fprintf(stderr, "man2html: cannot read %s: %s\n", h, strerror(errno));
+ exit(1);
+ }
+#ifdef MAKEINDEX
+ idxfile = fopen(INDEXFILE, "a");
+#endif
+ stdf = &standardchar[0];
+ i = 0;
+ while (stdf->nr) {
+ stdf->next = &standardchar[i];
+ stdf = stdf->next;
+ i++;
+ }
+ chardef = &standardchar[0];
+
+ stdf = &standardstring[0];
+ i = 0;
+ while (stdf->nr) {
+ stdf->next = &standardstring[i];
+ stdf = stdf->next;
+ i++;
+ }
+ strdef = &standardstring[0];
+
+ intdef = &standardint[0];
+ i = 0;
+ while (intdef->nr) {
+ intdef->next = &standardint[i];
+ intdef = intdef->next;
+ i++;
+ }
+ intdef = &standardint[0];
+
+ defdef = NULL;
+
+ scan_troff(buf + 1, 0, NULL);
+
+ while (itemdepth || dl_set[itemdepth]) {
+ out_html("</DL>\n");
+ if (dl_set[itemdepth])
+ dl_set[itemdepth] = 0;
+ else if (itemdepth > 0)
+ itemdepth--;
+ }
+
+ out_html(change_to_font(0));
+ out_html(change_to_size(0));
+ if (!fillout) {
+ fillout = 1;
+ out_html("</PRE>");
+ }
+ out_html(NEWLINE);
+
+ if (output_possible) {
+ outputPageFooter(th_version, th_datestr, th_page_and_sec);
+ /* &nbsp; for mosaic users */
+ fputs("<HR>\n<A NAME=\"index\">&nbsp;</A><H2>Index</H2>\n<DL>\n", stdout);
+ manidx[mip] = 0;
+ fputs(manidx, stdout);
+ if (subs)
+ fputs("</DL>\n", stdout);
+ fputs("</DL>\n", stdout);
+ print_sig();
+ fputs("</BODY>\n</HTML>\n", stdout);
+ } else
+ fprintf(stderr, "man2html: no output produced\n");
+#ifdef MAKEINDEX
+ if (idxfile)
+ fclose(idxfile);
+#endif
+ exit(EXIT_SUCCESS);
+}
diff --git a/support/missing b/support/missing
new file mode 100755
index 0000000..31977a1
--- /dev/null
+++ b/support/missing
@@ -0,0 +1,187 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing - GNU libit 0.0"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`configure.in'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`configure.in'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`configure.in'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER([^):]*:\([^)]*\)).*/\1/p' configure.in`
+ if test -z "$files"; then
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^):]*\)).*/\1/p' configure.in`
+ test -z "$files" || files="$files.in"
+ else
+ files=`echo "$files" | sed -e 's/:/ /g'`
+ fi
+ test -z "$files" && files="config.h.in"
+ touch $files
+ ;;
+
+ automake)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print \
+ | sed 's/^\(.*\).am$/touch \1.in/' \
+ | sh
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/support/mkclone b/support/mkclone
new file mode 100755
index 0000000..1840b03
--- /dev/null
+++ b/support/mkclone
@@ -0,0 +1,122 @@
+#! /bin/bash
+#
+# mkclone - symlink every file appearing in $src/MANIFEST to a corresponding
+# file in the target directory ($1). Directories specified in
+# MANIFEST are created in the target directory
+#
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+prog=`basename $0`
+
+SRCDIR=src
+
+USAGE="usage: $prog [-m manifest] [-s srcdir] [-v] [-d] [-h] target"
+while getopts dhm:s:v opt
+do
+ case "$opt" in
+ m) MANIFEST=$OPTARG ;;
+ s) SRCDIR=$OPTARG ;;
+ v) verbose=y ;;
+ d) ECHO=echo debug=y ;;
+ h) hardlinks=y ;;
+ ?) echo $USAGE >&2
+ exit 2;;
+ esac
+done
+
+: ${MANIFEST:=${SRCDIR}/MANIFEST}
+
+[ -n "$debug" ] && verbose=
+
+shift $(( $OPTIND - 1 ))
+
+if [ $# -lt 1 ]; then
+ echo $USAGE >&2
+ exit 2
+fi
+
+if [ ! -f $MANIFEST ]; then
+ echo "$prog: $MANIFEST: no such file or directory" >&2
+ echo "$prog: must be run with valid -s argument or from source directory" >&2
+ exit 1
+fi
+
+rm_ltmp=false
+LINKTEMP=`mktemp -t linktmp.XXXXXXXX 2>/dev/null`
+if [ -z "$LINKTEMP" ]; then
+ : ${TMPDIR:=/tmp}
+ LINKTEMP=${TMPDIR}/linktmp.$$
+ rm_ltmp=true
+fi
+
+$rm_ltmp && rm -f ${LINKTEMP}
+# if the user specified hard links, then do that. otherwise, try to use
+# symlinks if they're present
+if [ -n "$hardlinks" ]; then
+ LN=ln
+elif (ln -s /dev/null ${LINKTEMP}) >/dev/null 2>&1; then
+ LN="ln -s"
+else
+ LN=ln
+fi
+rm -f ${LINKTEMP}
+
+TARGET=$1
+
+if [ ! -d "$TARGET" ]; then
+ mkdir "$TARGET"
+fi
+
+echo "${prog}: creating clone of bash source tree (from $SRCDIR) in $TARGET"
+
+cd "$TARGET" || { echo "${prog}: cannot cd to $TARGET" >&2 ; exit 1; }
+
+while read fname type mode
+do
+ [ -z "$fname" ] && continue
+
+ case "$fname" in
+ \#*) continue ;;
+ esac
+
+ case "$type" in
+ d) [ -n "$verbose" ] && echo mkdir $fname
+ $ECHO mkdir $fname ;; # already in $TARGET
+ f) fn=${fname##*/}
+ case "$fname" in
+ */*) dn=${fname%/*} ;;
+ *) dn=. ;;
+ esac
+ if [ -n "$verbose" ] || [ -n "$debug" ]; then
+ echo "( cd $dn && $LN $SRCDIR/$fname $fn )"
+ fi
+ [ -z "$debug" ] && ( cd $dn && $LN $SRCDIR/$fname $fn )
+ ;;
+ *) echo "${prog}: ${fname}: unknown file type $type" 1>&2 ;;
+ esac
+done < $MANIFEST
+
+# special
+SPECIAL="parser-built y.tab.c y.tab.h"
+
+rm -f $SPECIAL
+for sf in $SPECIAL
+do
+ [ -n "$verbose" ] && echo cp -p $SRCDIR/$sf $TARGET
+ $ECHO cp -p $SRCDIR/$sf $TARGET
+done
+
+exit 0
diff --git a/support/mkconffiles b/support/mkconffiles
new file mode 100755
index 0000000..59e4c0f
--- /dev/null
+++ b/support/mkconffiles
@@ -0,0 +1,79 @@
+#! /bin/sh
+#
+# mkconffiles - create _distribution and _patchlevel files in preparation
+# for recreating `configure' from `configure.ac'
+#
+# options:
+# -s srcdir directory where `configure' resides (defaults to `.')
+# -d outdir directory where the files should be written (defaults
+# to "$srcdir")
+# -v verbose
+# -n nocreate - don't create the output files
+#
+# Chet Ramey
+# chet@po.cwru.edu
+
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+PROG=`basename $0`
+
+# defaults
+srcdir=.
+
+distname="_distribution"
+patchname="_patchlevel"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -s) shift; srcdir="$1"; shift;;
+ -d) shift; outdir="$1"; shift;;
+ -v) shift; verbose=yes ;;
+ -n) shift; nocreate=yes;;
+ --) shift; break;;
+ *) echo "${PROG}: usage: ${PROG} [-s srcdir] [-d outdir] [-nv]" >&2; exit 2;;
+ esac
+done
+
+if [ ! -f ${srcdir}/configure ]; then
+ echo "${PROG}: ${srcdir}/configure not found" >&2
+ exit 1
+fi
+
+# default output directory to source directory
+if [ -z "$outdir" ]; then
+ outdir=${srcdir}
+fi
+
+DISTRIB=`grep '^BASHVERS' ${srcdir}/configure | sed 's:.*=::'`
+PATCH=`grep '^BASHPATCH' ${srcdir}/configure | sed 's:.*=::'`
+
+if [ -n "$verbose" ]; then
+ echo "${PROG}: creating new distribution files for bash-${DISTRIB}.${PATCH} in ${outdir}"
+fi
+
+distout=${outdir}/${distname}
+patchout=${outdir}/${patchname}
+
+if [ -z "$nocreate" ]; then
+ echo "$DISTRIB" > $distout
+ echo "$PATCH" > $patchout
+fi
+
+if [ -n "$verbose" ]; then
+ echo "${PROG}: created $distout and $patchout"
+fi
+
+exit 0
diff --git a/support/mkdirs b/support/mkdirs
new file mode 100755
index 0000000..46f656e
--- /dev/null
+++ b/support/mkdirs
@@ -0,0 +1,47 @@
+#! /bin/sh
+#
+# mkdirs - a work-alike for `mkdir -p'
+#
+# Chet Ramey
+# chet@po.cwru.edu
+
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+for dir
+do
+
+ test -d "$dir" && continue
+
+ tomake=$dir
+ while test -n "$dir" ; do
+ # dir=${dir%/*}
+ # dir=`expr "$dir" ':' '\(/.*\)/[^/]*'`
+ if dir=`expr "$dir" ':' '\(.*\)/[^/]*'`; then
+ tomake="$dir $tomake"
+ else
+ dir=
+ fi
+ done
+
+ for d in $tomake
+ do
+ test -d "$d" && continue
+ echo mkdir "$d"
+ mkdir "$d"
+ done
+done
+
+exit 0
diff --git a/support/mkinstalldirs b/support/mkinstalldirs
new file mode 100755
index 0000000..d2d5f21
--- /dev/null
+++ b/support/mkinstalldirs
@@ -0,0 +1,111 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ fi
+ ;;
+esac
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# End:
+# mkinstalldirs ends here
diff --git a/support/mksignames.c b/support/mksignames.c
new file mode 100644
index 0000000..5618879
--- /dev/null
+++ b/support/mksignames.c
@@ -0,0 +1,111 @@
+/* mksignames.c -- Create and write `signames.h', which contains an array of
+ signal names. */
+
+/* Copyright (C) 1992-2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <signal.h>
+
+#include <stdio.h>
+#if defined (HAVE_STDLIB_H)
+# include <stdlib.h>
+#else
+# include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+/* Duplicated from signames.c */
+#if !defined (NSIG)
+# define NSIG 64
+#endif
+
+#define LASTSIG NSIG+2
+
+/* Imported from signames.c */
+extern void initialize_signames ();
+extern char *signal_names[];
+
+char *progname;
+
+void
+write_signames (stream)
+ FILE *stream;
+{
+ register int i;
+
+ fprintf (stream, "/* This file was automatically created by %s.\n",
+ progname);
+ fprintf (stream, " Do not edit. Edit support/mksignames.c instead. */\n\n");
+ fprintf (stream,
+ "/* A translation list so we can be polite to our users. */\n");
+#if defined (CROSS_COMPILING)
+ fprintf (stream, "extern char *signal_names[];\n\n");
+ fprintf (stream, "extern void initialize_signames __P((void));\n\n");
+#else
+ fprintf (stream, "char *signal_names[NSIG + 4] = {\n");
+
+ for (i = 0; i <= LASTSIG; i++)
+ fprintf (stream, " \"%s\",\n", signal_names[i]);
+
+ fprintf (stream, " (char *)0x0\n");
+ fprintf (stream, "};\n\n");
+ fprintf (stream, "#define initialize_signames()\n\n");
+#endif
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *stream_name;
+ FILE *stream;
+
+ progname = argv[0];
+
+ if (argc == 1)
+ {
+ stream_name = "stdout";
+ stream = stdout;
+ }
+ else if (argc == 2)
+ {
+ stream_name = argv[1];
+ stream = fopen (stream_name, "w");
+ }
+ else
+ {
+ fprintf (stderr, "Usage: %s [output-file]\n", progname);
+ exit (1);
+ }
+
+ if (!stream)
+ {
+ fprintf (stderr, "%s: %s: cannot open for writing\n",
+ progname, stream_name);
+ exit (2);
+ }
+
+#if !defined (CROSS_COMPILING)
+ initialize_signames ();
+#endif
+ write_signames (stream);
+ exit (0);
+}
diff --git a/support/mkversion.sh b/support/mkversion.sh
new file mode 100755
index 0000000..08a5d98
--- /dev/null
+++ b/support/mkversion.sh
@@ -0,0 +1,168 @@
+#! /bin/sh
+
+# Simple program to make new version numbers for the shell.
+# Big deal, but it was getting out of hand to do everything
+# in the makefile. This creates a file named by the -o option,
+# otherwise everything is echoed to the standard output.
+
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+PROGNAME=`basename $0`
+USAGE="$PROGNAME [-b] [-S srcdir] -d version -p patchlevel [-s status] [-o outfile]"
+
+source_dir="."
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -o) shift; OUTFILE=$1; shift ;;
+ -b) shift; inc_build=yes ;;
+ -s) shift; rel_status=$1; shift ;;
+ -p) shift; patch_level=$1; shift ;;
+ -d) shift; dist_version=$1; shift ;;
+ -S) shift; source_dir="$1"; shift ;;
+ *) echo "$PROGNAME: usage: $USAGE" >&2 ; exit 2 ;;
+ esac
+done
+
+# Required arguments
+if [ -z "$dist_version" ]; then
+ echo "${PROGNAME}: required argument -d missing" >&2
+ echo "$PROGNAME: usage: $USAGE" >&2
+ exit 1
+fi
+
+#if [ -z "$patch_level" ]; then
+# echo "${PROGNAME}: required argument -p missing" >&2
+# echo "$PROGNAME: usage: $USAGE" >&2
+# exit 1
+#fi
+
+# Defaults
+if [ -z "$rel_status" ]; then
+ rel_status="release"
+fi
+
+build_ver=
+if [ -r .build ]; then
+ build_ver=`cat .build`
+fi
+if [ -z "$build_ver" ]; then
+ build_ver=0
+fi
+
+# increment the build version if that's what's required
+
+if [ -n "$inc_build" ]; then
+ build_ver=`expr 1 + $build_ver`
+fi
+
+# what's the patch level?
+if [ -z "$patch_level" ]; then
+ patchlevel_h=$source_dir/patchlevel.h
+ if [ -s $patchlevel_h ]; then
+ patch_level=`cat $patchlevel_h | grep '^#define[ ]*PATCHLEVEL' | awk '{print $NF}'`
+ fi
+fi
+if [ -z "$patch_level" ]; then
+ patch_level=0
+fi
+
+# If we have an output file specified, make it the standard output
+if [ -n "$OUTFILE" ]; then
+ if exec >$OUTFILE; then
+ :
+ else
+ echo "${PROGNAME}: cannot redirect standard output to $OUTFILE" >&2
+ exit 1
+ fi
+fi
+
+# Output the leading comment.
+echo "/* Version control for the shell. This file gets changed when you say"
+echo " \`make version.h' to the Makefile. It is created by mkversion. */"
+
+# Output the distribution version. Single numbers are converted to x.00.
+# Allow, as a special case, `[:digit:].[:digit:][:alpha:]' for
+# intermediate versions (e.g., `2.5a').
+# Any characters other than digits and `.' are invalid.
+case "$dist_version" in
+[0-9].[0-9][a-z]) ;; # special case
+*[!0-9.]*) echo "mkversion.sh: ${dist_version}: bad distribution version" >&2
+ exit 1 ;;
+*.*) ;;
+*) dist_version=${dist_version}.00 ;;
+esac
+
+dist_major=`echo $dist_version | sed 's:\..*$::'`
+[ -z "${dist_major}" ] && dist_major=0
+
+dist_minor=`echo $dist_version | sed 's:^.*\.::'`
+case "$dist_minor" in
+"") dist_minor=0 ;;
+[a-z]) dist_minor=0${dist_minor} ;;
+?) dist_minor=${dist_minor} ;;
+*) ;;
+esac
+
+#float_dist=`echo $dist_version | awk '{printf "%.2f\n", $1}'`
+float_dist=${dist_major}.${dist_minor}
+
+echo
+echo "/* The distribution version number of this shell. */"
+echo "#define DISTVERSION \"${float_dist}\""
+
+# Output the patch level
+#echo
+#echo "/* The patch level of this version of the shell. */"
+#echo "#define PATCHLEVEL ${patch_level}"
+
+# Output the build version
+echo
+echo "/* The last built version of this shell. */"
+echo "#define BUILDVERSION ${build_ver}"
+
+# Output the release status
+echo
+echo "/* The release status of this shell. */"
+echo "#define RELSTATUS \"${rel_status}\""
+
+echo
+echo "/* The default shell compatibility-level (the current version) */"
+echo "#define DEFAULT_COMPAT_LEVEL ${dist_major}${dist_minor}"
+
+# Output the SCCS version string
+sccs_string="${float_dist}.${patch_level}(${build_ver}) ${rel_status} GNU"
+echo
+echo "/* A version string for use by sccs and the what command. */"
+echo "#define SCCSVERSION \"@(#)Bash version ${sccs_string}\""
+
+# extern function declarations
+#echo
+#echo '/* Functions from version.c. */'
+#echo 'extern char *shell_version_string __P((void));'
+#echo 'extern void show_shell_version __P((int));'
+
+if [ -n "$inc_build" ]; then
+ # Make sure we can write to .build
+ if [ -f .build ] && [ ! -w .build ]; then
+ echo "$PROGNAME: cannot write to .build, not incrementing build version" >&2
+ else
+ echo "$build_ver" > .build
+ fi
+fi
+
+exit 0
diff --git a/support/printenv.c b/support/printenv.c
new file mode 100644
index 0000000..154e086
--- /dev/null
+++ b/support/printenv.c
@@ -0,0 +1,72 @@
+/* printenv -- minimal clone of BSD printenv(1).
+
+ usage: printenv [varname]
+
+ Chet Ramey
+ chet@po.cwru.edu
+*/
+
+/* Copyright (C) 1997-2002 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include "bashansi.h"
+#include <stdio.h> /* puts */
+
+extern char **environ;
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ register char **envp, *eval;
+ int len;
+
+ argv++;
+ argc--;
+
+ /* printenv */
+ if (argc == 0)
+ {
+ for (envp = environ; *envp; envp++)
+ puts (*envp);
+ exit (0);
+ }
+
+ /* printenv varname */
+ len = strlen (*argv);
+ for (envp = environ; *envp; envp++)
+ {
+ if (**argv == **envp && strncmp (*envp, *argv, len) == 0)
+ {
+ eval = *envp + len;
+ /* If the environment variable doesn't have an `=', ignore it. */
+ if (*eval == '=')
+ {
+ puts (eval + 1);
+ exit (0);
+ }
+ }
+ }
+ exit (1);
+}
+
diff --git a/support/printenv.sh b/support/printenv.sh
new file mode 100755
index 0000000..32b7ee8
--- /dev/null
+++ b/support/printenv.sh
@@ -0,0 +1,27 @@
+#! /bin/sh -
+
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+if [ $# -eq 0 ]; then
+ env
+ exit
+elif eval [ "\${$1-unset}" = "unset" ]; then
+ exit 1
+else
+ eval echo \$$1
+ exit 0
+fi
diff --git a/support/recho.c b/support/recho.c
new file mode 100644
index 0000000..7e3c6bc
--- /dev/null
+++ b/support/recho.c
@@ -0,0 +1,67 @@
+/*
+ recho -- really echo args, bracketed with <> and with invisible chars
+ made visible.
+
+ Chet Ramey
+ chet@po.cwru.edu
+*/
+
+/* Copyright (C) 2002-2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include "bashansi.h"
+#include <stdio.h>
+
+void strprint();
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+ register int i;
+
+ for (i = 1; i < argc; i++) {
+ printf("argv[%d] = <", i);
+ strprint(argv[i]);
+ printf(">\n");
+ }
+ exit(0);
+}
+
+void
+strprint(str)
+char *str;
+{
+ register unsigned char *s;
+
+ for (s = (unsigned char *)str; s && *s; s++) {
+ if (*s < ' ') {
+ putchar('^');
+ putchar(*s+64);
+ } else if (*s == 127) {
+ putchar('^');
+ putchar('?');
+ } else
+ putchar(*s);
+ }
+}
diff --git a/support/rlvers.sh b/support/rlvers.sh
new file mode 100755
index 0000000..64cadc7
--- /dev/null
+++ b/support/rlvers.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+#
+# rlvers.sh -- run a program that prints out the readline version number
+# using locally-installed readline libraries
+#
+
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+PROGNAME=`basename $0`
+
+: ${TMPDIR:=/tmp}
+TDIR=$TMPDIR/rlvers
+
+# defaults
+CC=cc
+RL_LIBDIR=/usr/local/lib
+RL_INCDIR=/usr/local/include
+
+TERMCAP_LIB="-ltermcap"
+
+# cannot rely on the presence of getopts
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -C) shift ; CC="$1"; shift ;;
+ -I) shift ; RL_INCDIR="$1" ; shift ;;
+ -L) shift ; RL_LIBDIR="$1" ; shift ;;
+ -T) shift ; TERMCAP_LIB="$1" ; shift ;;
+ -v) shift ; verbose=y ;;
+ --) shift ; break ;;
+ *) echo "${PROGNAME}: usage: $PROGNAME [-C compiler] [-L libdir] [-v]" >&2 ; exit 2;;
+ esac
+done
+
+# if someone happened to install examples/rlversion, use it (it's not
+# installed by default)
+if test -f ${RL_LIBDIR}/rlversion ; then
+ if [ -n "$verbose" ]; then
+ echo "${PROGNAME}: using installed rlversion from ${RL_LIBDIR}/rlversion"
+ fi
+ v=`${RL_LIBDIR}/rlversion 2>/dev/null`
+ case "$v" in
+ unknown | "") echo 0 ;;
+ *) echo "$v" ;;
+ esac
+ exit 0
+fi
+
+if [ -n "$verbose" ]; then
+ echo "${PROGNAME}: using ${RL_LIBDIR} to find libreadline"
+ echo "${PROGNAME}: attempting program compilation"
+fi
+
+# make $TDIR mode 0700
+mkdir $TDIR || {
+ echo "${PROGNAME}: ${TDIR}: file exists" >&2
+ echo 0
+ exit 1
+}
+chmod 700 $TDIR
+
+trap 'rm -f $TDIR/rlvers $TDIR/rlvers.? ; rmdir $TDIR' 0 1 2 3 6 15
+
+cat > $TDIR/rlvers.c << EOF
+#include <stdio.h>
+extern char *rl_library_version;
+
+main()
+{
+ printf("%s\n", rl_library_version ? rl_library_version : "0");
+ exit(0);
+}
+EOF
+
+opwd=`pwd`
+
+cd $TDIR || {
+ echo "${PROGNAME}: cannot cd to $TDIR" >&2
+ echo 0
+ exit 1
+}
+
+if eval ${CC} -L${RL_LIBDIR} -I${RL_INCDIR} -o $TDIR/rlvers $TDIR/rlvers.c -lreadline ${TERMCAP_LIB};
+then
+ v=`$TDIR/rlvers`
+else
+ if [ -n "$verbose" ] ; then
+ echo "${PROGNAME}: compilation failed: status $?"
+ echo "${PROGNAME}: using version 0"
+ fi
+ v=0
+fi
+
+case "$v" in
+unknown | "") echo 0 ;;
+*) echo "$v" ;;
+esac
+
+cd $opwd
+exit 0
diff --git a/support/shobj-conf b/support/shobj-conf
new file mode 100755
index 0000000..7920f1b
--- /dev/null
+++ b/support/shobj-conf
@@ -0,0 +1,594 @@
+#! /bin/sh
+#
+# shobj-conf -- output a series of variable assignments to be substituted
+# into a Makefile by configure which specify system-dependent
+# information for creating shared objects that may be loaded
+# into bash with `enable -f'
+#
+# usage: shobj-conf [-C compiler] -c host_cpu -o host_os -v host_vendor
+#
+# Chet Ramey
+# chet@po.cwru.edu
+
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+#
+# This file is part of GNU Bash, the Bourne Again SHell.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# defaults
+#
+SHOBJ_STATUS=supported
+SHLIB_STATUS=supported
+
+SHOBJ_CC=cc
+SHOBJ_CFLAGS=
+SHOBJ_LD=
+SHOBJ_LDFLAGS=
+SHOBJ_XLDFLAGS=
+SHOBJ_LIBS=
+
+SHLIB_XLDFLAGS=
+SHLIB_LIBS=
+
+SHLIB_DOT='.'
+SHLIB_LIBPREF='lib'
+SHLIB_LIBSUFF='so'
+
+SHLIB_LIBVERSION='$(SHLIB_LIBSUFF)'
+SHLIB_DLLVERSION='$(SHLIB_MAJOR)'
+
+PROGNAME=`basename $0`
+USAGE="$PROGNAME [-C compiler] -c host_cpu -o host_os -v host_vendor"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -C) shift; SHOBJ_CC="$1"; shift ;;
+ -c) shift; host_cpu="$1"; shift ;;
+ -o) shift; host_os="$1"; shift ;;
+ -v) shift; host_vendor="$1"; shift ;;
+ *) echo "$USAGE" >&2 ; exit 2;;
+ esac
+done
+
+case "${host_os}-${SHOBJ_CC}-${host_vendor}" in
+nsk-cc-tandem)
+ SHOBJ_CFLAGS=-Wglobalized
+ case `uname -m` in
+ NSR*)
+ SHOBJ_CFLAGS="${SHOBJ_CFLAGS} -Wcall_shared" # default on TNS/E, needed on TNS/R
+ SHOBJ_LD=/usr/bin/ld # for TNS/R
+ ;;
+ NSE*|NEO*)
+ SHOBJ_LD=/usr/bin/eld
+ ;;
+ esac
+ SHOBJ_LDFLAGS='-shared -bglobalized -unres_symbols ignore'
+ ;;
+
+sunos4*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD=/usr/bin/ld
+ SHOBJ_LDFLAGS='-assert pure-text'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+sunos4*)
+ SHOBJ_CFLAGS=-pic
+ SHOBJ_LD=/usr/bin/ld
+ SHOBJ_LDFLAGS='-assert pure-text'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+sunos5*-*gcc*|solaris2*-*gcc*)
+ SHOBJ_LD='${CC}'
+ ld_used=`gcc -print-prog-name=ld`
+ if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then
+ # This line works for the GNU ld
+ SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
+ # http://sourceware.org/ml/binutils/2001-08/msg00361.html
+ SHOBJ_CFLAGS=-fPIC
+ else
+ # This line works for the Solaris linker in /usr/ccs/bin/ld
+ SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
+ SHOBJ_CFLAGS=-fpic
+ fi
+
+# SHLIB_XLDFLAGS='-R $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sunos5*|solaris2*)
+ SHOBJ_CFLAGS='-K pic'
+ SHOBJ_LD=/usr/ccs/bin/ld
+ SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
+
+# SHLIB_XLDFLAGS='-R $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+# All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd.
+linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+freebsd2*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-x -Bshareable'
+
+ SHLIB_XLDFLAGS='-R$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+# FreeBSD-3.x ELF
+freebsd3*|freebsdaout*)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+
+ if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ else
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_XLDFLAGS='-R$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ fi
+ ;;
+
+# FreeBSD-4.x and later have only ELF
+freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+# Darwin/MacOS X
+darwin*)
+ # Common definitions for all darwin/mac os x versions
+ SHOBJ_CFLAGS='-fno-common'
+
+ SHOBJ_LD='${CC}'
+
+ SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
+ SHLIB_LIBSUFF='dylib'
+
+ # unused at this time
+ SHLIB_SONAME='$(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF)'
+
+ case "${host_os}" in
+ # Darwin versions 1, 5, 6, 7 correspond to Mac OS X 10.0, 10.1, 10.2,
+ # and 10.3, respectively.
+ darwin[1-7].*)
+ SHOBJ_STATUS=unsupported
+ SHOBJ_LDFLAGS='-dynamic'
+ SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -v'
+ ;;
+ # Darwin 8 == Mac OS X 10.4; Mac OS X 10.N == Darwin N+4
+ *)
+ case "${host_os}" in
+ darwin[89]*|darwin1[012]*)
+ SHOBJ_ARCHFLAGS='-arch_only `/usr/bin/arch`'
+ ;;
+ *) # Mac OS X 10.9 (Mavericks) and later
+ SHOBJ_ARCHFLAGS=
+ # for 32 and 64bit universal library
+ #SHOBJ_ARCHFLAGS='-arch i386 -arch x86_64'
+ #SHOBJ_CFLAGS=${SHOBJ_CFLAGS}' -arch i386 -arch x86_64'
+ ;;
+ esac
+ SHOBJ_LDFLAGS="-dynamiclib -dynamic -undefined dynamic_lookup ${SHOBJ_ARCHFLAGS}"
+ SHLIB_XLDFLAGS="-dynamiclib ${SHOBJ_ARCHFLAGS}"' -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -v'
+ ;;
+ esac
+
+ SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
+ ;;
+
+openbsd*|netbsd*|mirbsd*)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_XLDFLAGS='-R$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+bsdi2*)
+ SHOBJ_CC=shlicc2
+ SHOBJ_CFLAGS=
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS=-r
+ SHOBJ_LIBS=-lc_s.2.1.0
+
+ # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
+ # the ass -- they require changing {/usr/lib,etc}/shlib.map on
+ # each system, and the library creation process is byzantine
+ SHLIB_STATUS=unsupported
+ ;;
+
+bsdi3*)
+ SHOBJ_CC=shlicc2
+ SHOBJ_CFLAGS=
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS=-r
+ SHOBJ_LIBS=-lc_s.3.0.0
+
+ # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
+ # the ass -- they require changing {/usr/lib,etc}/shlib.map on
+ # each system, and the library creation process is byzantine
+ SHLIB_STATUS=unsupported
+ ;;
+
+bsdi4*)
+ # BSD/OS 4.x now supports ELF and SunOS-style dynamically-linked
+ # shared libraries. gcc 2.x is the standard compiler, and the
+ # `normal' gcc options should work as they do in Linux.
+
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+osf*-*gcc*)
+ # Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-rpath $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+osf*)
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"'
+
+ SHLIB_XLDFLAGS='-rpath $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='ld'
+ SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
+ SHOBJ_XLDFLAGS='-G'
+
+ SHLIB_XLDFLAGS='-bM:SRE'
+ SHLIB_LIBS='-lcurses -lc'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+aix4.[2-9]*|aix[5-9].*)
+ SHOBJ_CFLAGS=-K
+ SHOBJ_LD='ld'
+ SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
+ SHOBJ_XLDFLAGS='-G'
+
+ SHLIB_XLDFLAGS='-bM:SRE'
+ SHLIB_LIBS='-lcurses -lc'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+#
+# THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
+#
+irix[56]*-*gcc*)
+ SHOBJ_CFLAGS='-fpic'
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+irix[56]*)
+ SHOBJ_CFLAGS='-K PIC'
+ SHOBJ_LD=ld
+# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
+# Change from David Kaelbling <drk@sgi.com>. If you have problems,
+# remove the `-no_unresolved'
+ SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
+
+ SHLIB_XLDFLAGS='-rpath $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+hpux9*-*gcc*)
+ # must use gcc; the bundled cc cannot compile PIC code
+ SHOBJ_CFLAGS='-fpic'
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
+
+ SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
+ SHLIB_LIBSUFF='sl'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+hpux9*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+
+ # If you are using the HP ANSI C compiler, you can uncomment and use
+ # this code (I have not tested it)
+# SHOBJ_STATUS=supported
+# SHLIB_STATUS=supported
+#
+# SHOBJ_CFLAGS='+z'
+# SHOBJ_LD='ld'
+# SHOBJ_LDFLAGS='-b +s'
+#
+# SHLIB_XLDFLAGS='+b $(libdir)'
+# SHLIB_LIBSUFF='sl'
+# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+
+ ;;
+
+hpux10*-*gcc*)
+ # must use gcc; the bundled cc cannot compile PIC code
+ SHOBJ_CFLAGS='-fpic'
+ SHOBJ_LD='${CC}'
+ # if you have problems linking here, moving the `-Wl,+h,$@' from
+ # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work
+ SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s'
+
+ SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
+ SHLIB_LIBSUFF='sl'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+hpux10*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+
+ # If you are using the HP ANSI C compiler, you can uncomment and use
+ # this code (I have not tested it)
+# SHOBJ_STATUS=supported
+# SHLIB_STATUS=supported
+#
+# SHOBJ_CFLAGS='+z'
+# SHOBJ_LD='ld'
+# SHOBJ_LDFLAGS='-b +s +h $@'
+#
+# SHLIB_XLDFLAGS='+b $(libdir)'
+# SHLIB_LIBSUFF='sl'
+# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+
+ ;;
+
+hpux11*-*gcc*)
+ # must use gcc; the bundled cc cannot compile PIC code
+ SHOBJ_CFLAGS='-fpic'
+ SHOBJ_LD='${CC}'
+# SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
+ SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
+
+ SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
+ SHLIB_LIBSUFF='sl'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+hpux11*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+
+ # If you are using the HP ANSI C compiler, you can uncomment and use
+ # this code (I have not tested it)
+# SHOBJ_STATUS=supported
+# SHLIB_STATUS=supported
+#
+# SHOBJ_CFLAGS='+z'
+# SHOBJ_LD='ld'
+# SHOBJ_LDFLAGS='-b +s +h $@'
+#
+# SHLIB_XLDFLAGS='+b $(libdir)'
+# SHLIB_LIBSUFF='sl'
+# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+
+ ;;
+
+sysv4*-*gcc*)
+ SHOBJ_CFLAGS=-shared
+ SHOBJ_LDFLAGS='-shared -h $@'
+ SHOBJ_LD='${CC}'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv4*)
+ SHOBJ_CFLAGS='-K PIC'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-dy -z text -G -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sco3.2v5*-*gcc*)
+ SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sco3.2v5*)
+ SHOBJ_CFLAGS='-K pic -b elf'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-G -b elf -dy -z text -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5uw7*-*gcc*)
+ SHOBJ_CFLAGS='-fpic'
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5uw7*)
+ SHOBJ_CFLAGS='-K PIC'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-G -dy -z text -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5UnixWare*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5UnixWare*)
+ SHOBJ_CFLAGS='-K PIC'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-G -dy -z text -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5OpenUNIX*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+sysv5OpenUNIX*)
+ SHOBJ_CFLAGS='-K PIC'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-G -dy -z text -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+dgux*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+dgux*)
+ SHOBJ_CFLAGS='-K pic'
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-G -dy -h $@'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+msdos*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+ ;;
+
+cygwin*)
+ SHOBJ_LD='$(CC)'
+ SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
+ SHLIB_LIBPREF='cyg'
+ SHLIB_LIBSUFF='dll'
+ SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
+ SHLIB_LIBS='$(TERMCAP_LIB)'
+
+ SHLIB_DOT=
+ # For official cygwin releases, DLLVERSION will be defined in the
+ # environment of configure, and will be incremented any time the API
+ # changes in a non-backwards compatible manner. Otherwise, it is just
+ # SHLIB_MAJOR.
+ if [ -n "$DLLVERSION" ] ; then
+ SHLIB_DLLVERSION="$DLLVERSION"
+ fi
+ ;;
+
+mingw*)
+ SHOBJ_LD='$(CC)'
+ SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
+ SHLIB_LIBSUFF='dll'
+ SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
+ SHLIB_LIBS='$(TERMCAP_LIB)'
+
+ SHLIB_DOT=
+ # For official cygwin releases, DLLVERSION will be defined in the
+ # environment of configure, and will be incremented any time the API
+ # changes in a non-backwards compatible manner. Otherwise, it is just
+ # SHLIB_MAJOR.
+ if [ -n "$DLLVERSION" ] ; then
+ SHLIB_DLLVERSION="$DLLVERSION"
+ fi
+ ;;
+
+#
+# Rely on correct gcc configuration for everything else
+#
+*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+ ;;
+
+esac
+
+echo SHOBJ_CC=\'"$SHOBJ_CC"\'
+echo SHOBJ_CFLAGS=\'"$SHOBJ_CFLAGS"\'
+echo SHOBJ_LD=\'"$SHOBJ_LD"\'
+echo SHOBJ_LDFLAGS=\'"$SHOBJ_LDFLAGS"\'
+echo SHOBJ_XLDFLAGS=\'"$SHOBJ_XLDFLAGS"\'
+echo SHOBJ_LIBS=\'"$SHOBJ_LIBS"\'
+
+echo SHLIB_XLDFLAGS=\'"$SHLIB_XLDFLAGS"\'
+echo SHLIB_LIBS=\'"$SHLIB_LIBS"\'
+
+echo SHLIB_DOT=\'"$SHLIB_DOT"\'
+
+echo SHLIB_LIBPREF=\'"$SHLIB_LIBPREF"\'
+echo SHLIB_LIBSUFF=\'"$SHLIB_LIBSUFF"\'
+
+echo SHLIB_LIBVERSION=\'"$SHLIB_LIBVERSION"\'
+echo SHLIB_DLLVERSION=\'"$SHLIB_DLLVERSION"\'
+
+echo SHOBJ_STATUS=\'"$SHOBJ_STATUS"\'
+echo SHLIB_STATUS=\'"$SHLIB_STATUS"\'
+
+exit 0
diff --git a/support/signames.c b/support/signames.c
new file mode 100644
index 0000000..d297808
--- /dev/null
+++ b/support/signames.c
@@ -0,0 +1,401 @@
+/* signames.c -- Create an array of signal names. */
+
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <sys/types.h>
+#include <signal.h>
+
+#if defined (HAVE_STDLIB_H)
+# include <stdlib.h>
+#else
+# include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#if !defined (NSIG)
+# define NSIG 64
+#endif
+
+/*
+ * Special traps:
+ * EXIT == 0
+ * DEBUG == NSIG
+ * ERR == NSIG+1
+ * RETURN == NSIG+2
+ */
+#define LASTSIG NSIG+2
+
+char *signal_names[2 * (LASTSIG)];
+
+#define signal_names_size (sizeof(signal_names)/sizeof(signal_names[0]))
+
+/* AIX 4.3 defines SIGRTMIN and SIGRTMAX as 888 and 999 respectively.
+ I don't want to allocate so much unused space for the intervening signal
+ numbers, so we just punt if SIGRTMAX is past the bounds of the
+ signal_names array (handled in configure). */
+#if defined (SIGRTMAX) && defined (UNUSABLE_RT_SIGNALS)
+# undef SIGRTMAX
+# undef SIGRTMIN
+#endif
+
+#if defined (SIGRTMAX) || defined (SIGRTMIN)
+# define RTLEN 14
+# define RTLIM 256
+#endif
+
+#if defined (BUILDTOOL)
+extern char *progname;
+#endif
+
+void
+initialize_signames ()
+{
+ register int i;
+#if defined (SIGRTMAX) || defined (SIGRTMIN)
+ int rtmin, rtmax, rtcnt;
+#endif
+
+ for (i = 1; i < signal_names_size; i++)
+ signal_names[i] = (char *)NULL;
+
+ /* `signal' 0 is what we do on exit. */
+ signal_names[0] = "EXIT";
+
+ /* Place signal names which can be aliases for more common signal
+ names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
+
+ /* POSIX 1003.1b-1993 real time signals, but take care of incomplete
+ implementations. Acoording to the standard, both, SIGRTMIN and
+ SIGRTMAX must be defined, SIGRTMIN must be strictly less than
+ SIGRTMAX, and the difference must be at least 7, that is, there
+ must be at least eight distinct real time signals. */
+
+ /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ...,
+ SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number
+ of RT signals is odd, there is an extra SIGRTMIN+(x+1).
+ These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */
+
+#if defined (SIGRTMIN)
+ rtmin = SIGRTMIN;
+ signal_names[rtmin] = "SIGRTMIN";
+#endif
+
+#if defined (SIGRTMAX)
+ rtmax = SIGRTMAX;
+ signal_names[rtmax] = "SIGRTMAX";
+#endif
+
+#if defined (SIGRTMAX) && defined (SIGRTMIN)
+ if (rtmax > rtmin)
+ {
+ rtcnt = (rtmax - rtmin - 1) / 2;
+ /* croak if there are too many RT signals */
+ if (rtcnt >= RTLIM/2)
+ {
+ rtcnt = RTLIM/2-1;
+#ifdef BUILDTOOL
+ fprintf(stderr, "%s: error: more than %d real time signals, fix `%s'\n",
+ progname, RTLIM, progname);
+#endif
+ }
+
+ for (i = 1; i <= rtcnt; i++)
+ {
+ signal_names[rtmin+i] = (char *)malloc(RTLEN);
+ if (signal_names[rtmin+i])
+ sprintf (signal_names[rtmin+i], "SIGRTMIN+%d", i);
+ signal_names[rtmax-i] = (char *)malloc(RTLEN);
+ if (signal_names[rtmax-i])
+ sprintf (signal_names[rtmax-i], "SIGRTMAX-%d", i);
+ }
+
+ if (rtcnt < RTLIM/2-1 && rtcnt != (rtmax-rtmin)/2)
+ {
+ /* Need an extra RTMIN signal */
+ signal_names[rtmin+rtcnt+1] = (char *)malloc(RTLEN);
+ if (signal_names[rtmin+rtcnt+1])
+ sprintf (signal_names[rtmin+rtcnt+1], "SIGRTMIN+%d", rtcnt+1);
+ }
+ }
+#endif /* SIGRTMIN && SIGRTMAX */
+
+#if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
+ signal_names[SIGLOST] = "SIGLOST";
+#endif
+
+/* AIX */
+#if defined (SIGMSG) /* HFT input data pending */
+ signal_names[SIGMSG] = "SIGMSG";
+#endif
+
+#if defined (SIGDANGER) /* system crash imminent */
+ signal_names[SIGDANGER] = "SIGDANGER";
+#endif
+
+#if defined (SIGMIGRATE) /* migrate process to another CPU */
+ signal_names[SIGMIGRATE] = "SIGMIGRATE";
+#endif
+
+#if defined (SIGPRE) /* programming error */
+ signal_names[SIGPRE] = "SIGPRE";
+#endif
+
+#if defined (SIGVIRT) /* AIX virtual time alarm */
+ signal_names[SIGVIRT] = "SIGVIRT";
+#endif
+
+#if defined (SIGALRM1) /* m:n condition variables */
+ signal_names[SIGALRM1] = "SIGALRM1";
+#endif
+
+#if defined (SIGWAITING) /* m:n scheduling */
+ signal_names[SIGWAITING] = "SIGWAITING";
+#endif
+
+#if defined (SIGGRANT) /* HFT monitor mode granted */
+ signal_names[SIGGRANT] = "SIGGRANT";
+#endif
+
+#if defined (SIGKAP) /* keep alive poll from native keyboard */
+ signal_names[SIGKAP] = "SIGKAP";
+#endif
+
+#if defined (SIGRETRACT) /* HFT monitor mode retracted */
+ signal_names[SIGRETRACT] = "SIGRETRACT";
+#endif
+
+#if defined (SIGSOUND) /* HFT sound sequence has completed */
+ signal_names[SIGSOUND] = "SIGSOUND";
+#endif
+
+#if defined (SIGSAK) /* Secure Attention Key */
+ signal_names[SIGSAK] = "SIGSAK";
+#endif
+
+/* SunOS5 */
+#if defined (SIGLWP) /* Solaris: special signal used by thread library */
+ signal_names[SIGLWP] = "SIGLWP";
+#endif
+
+#if defined (SIGFREEZE) /* Solaris: special signal used by CPR */
+ signal_names[SIGFREEZE] = "SIGFREEZE";
+#endif
+
+#if defined (SIGTHAW) /* Solaris: special signal used by CPR */
+ signal_names[SIGTHAW] = "SIGTHAW";
+#endif
+
+#if defined (SIGCANCEL) /* Solaris: thread cancellation signal used by libthread */
+ signal_names[SIGCANCEL] = "SIGCANCEL";
+#endif
+
+#if defined (SIGXRES) /* Solaris: resource control exceeded */
+ signal_names[SIGXRES] = "SIGXRES";
+#endif
+
+#if defined (SIGJVM1) /* Solaris: Java Virtual Machine 1 */
+ signal_names[SIGJVM1] = "SIGJVM1";
+#endif
+
+#if defined (SIGJVM2) /* Solaris: Java Virtual Machine 2 */
+ signal_names[SIGJVM2] = "SIGJVM2";
+#endif
+
+/* HP-UX */
+#if defined (SIGDIL) /* DIL signal (?) */
+ signal_names[SIGDIL] = "SIGDIL";
+#endif
+
+/* System V */
+#if defined (SIGCLD) /* Like SIGCHLD. */
+ signal_names[SIGCLD] = "SIGCLD";
+#endif
+
+#if defined (SIGPWR) /* power state indication */
+ signal_names[SIGPWR] = "SIGPWR";
+#endif
+
+#if defined (SIGPOLL) /* Pollable event (for streams) */
+ signal_names[SIGPOLL] = "SIGPOLL";
+#endif
+
+/* Unknown */
+#if defined (SIGWINDOW)
+ signal_names[SIGWINDOW] = "SIGWINDOW";
+#endif
+
+/* Linux */
+#if defined (SIGSTKFLT)
+ signal_names[SIGSTKFLT] = "SIGSTKFLT";
+#endif
+
+/* FreeBSD */
+#if defined (SIGTHR) /* thread interrupt */
+ signal_names[SIGTHR] = "SIGTHR";
+#endif
+
+/* Common */
+#if defined (SIGHUP) /* hangup */
+ signal_names[SIGHUP] = "SIGHUP";
+#endif
+
+#if defined (SIGINT) /* interrupt */
+ signal_names[SIGINT] = "SIGINT";
+#endif
+
+#if defined (SIGQUIT) /* quit */
+ signal_names[SIGQUIT] = "SIGQUIT";
+#endif
+
+#if defined (SIGILL) /* illegal instruction (not reset when caught) */
+ signal_names[SIGILL] = "SIGILL";
+#endif
+
+#if defined (SIGTRAP) /* trace trap (not reset when caught) */
+ signal_names[SIGTRAP] = "SIGTRAP";
+#endif
+
+#if defined (SIGIOT) /* IOT instruction */
+ signal_names[SIGIOT] = "SIGIOT";
+#endif
+
+#if defined (SIGABRT) /* Cause current process to dump core. */
+ signal_names[SIGABRT] = "SIGABRT";
+#endif
+
+#if defined (SIGEMT) /* EMT instruction */
+ signal_names[SIGEMT] = "SIGEMT";
+#endif
+
+#if defined (SIGFPE) /* floating point exception */
+ signal_names[SIGFPE] = "SIGFPE";
+#endif
+
+#if defined (SIGKILL) /* kill (cannot be caught or ignored) */
+ signal_names[SIGKILL] = "SIGKILL";
+#endif
+
+#if defined (SIGBUS) /* bus error */
+ signal_names[SIGBUS] = "SIGBUS";
+#endif
+
+#if defined (SIGSEGV) /* segmentation violation */
+ signal_names[SIGSEGV] = "SIGSEGV";
+#endif
+
+#if defined (SIGSYS) /* bad argument to system call */
+ signal_names[SIGSYS] = "SIGSYS";
+#endif
+
+#if defined (SIGPIPE) /* write on a pipe with no one to read it */
+ signal_names[SIGPIPE] = "SIGPIPE";
+#endif
+
+#if defined (SIGALRM) /* alarm clock */
+ signal_names[SIGALRM] = "SIGALRM";
+#endif
+
+#if defined (SIGTERM) /* software termination signal from kill */
+ signal_names[SIGTERM] = "SIGTERM";
+#endif
+
+#if defined (SIGURG) /* urgent condition on IO channel */
+ signal_names[SIGURG] = "SIGURG";
+#endif
+
+#if defined (SIGSTOP) /* sendable stop signal not from tty */
+ signal_names[SIGSTOP] = "SIGSTOP";
+#endif
+
+#if defined (SIGTSTP) /* stop signal from tty */
+ signal_names[SIGTSTP] = "SIGTSTP";
+#endif
+
+#if defined (SIGCONT) /* continue a stopped process */
+ signal_names[SIGCONT] = "SIGCONT";
+#endif
+
+#if defined (SIGCHLD) /* to parent on child stop or exit */
+ signal_names[SIGCHLD] = "SIGCHLD";
+#endif
+
+#if defined (SIGTTIN) /* to readers pgrp upon background tty read */
+ signal_names[SIGTTIN] = "SIGTTIN";
+#endif
+
+#if defined (SIGTTOU) /* like TTIN for output if (tp->t_local&LTOSTOP) */
+ signal_names[SIGTTOU] = "SIGTTOU";
+#endif
+
+#if defined (SIGIO) /* input/output possible signal */
+ signal_names[SIGIO] = "SIGIO";
+#endif
+
+#if defined (SIGXCPU) /* exceeded CPU time limit */
+ signal_names[SIGXCPU] = "SIGXCPU";
+#endif
+
+#if defined (SIGXFSZ) /* exceeded file size limit */
+ signal_names[SIGXFSZ] = "SIGXFSZ";
+#endif
+
+#if defined (SIGVTALRM) /* virtual time alarm */
+ signal_names[SIGVTALRM] = "SIGVTALRM";
+#endif
+
+#if defined (SIGPROF) /* profiling time alarm */
+ signal_names[SIGPROF] = "SIGPROF";
+#endif
+
+#if defined (SIGWINCH) /* window changed */
+ signal_names[SIGWINCH] = "SIGWINCH";
+#endif
+
+/* 4.4 BSD */
+#if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */
+ signal_names[SIGINFO] = "SIGINFO";
+#endif
+
+#if defined (SIGUSR1) /* user defined signal 1 */
+ signal_names[SIGUSR1] = "SIGUSR1";
+#endif
+
+#if defined (SIGUSR2) /* user defined signal 2 */
+ signal_names[SIGUSR2] = "SIGUSR2";
+#endif
+
+#if defined (SIGKILLTHR) /* BeOS: Kill Thread */
+ signal_names[SIGKILLTHR] = "SIGKILLTHR";
+#endif
+
+ for (i = 0; i < NSIG; i++)
+ if (signal_names[i] == (char *)NULL)
+ {
+ signal_names[i] = (char *)malloc (18);
+ if (signal_names[i])
+ sprintf (signal_names[i], "SIGJUNK(%d)", i);
+ }
+
+ signal_names[NSIG] = "DEBUG";
+ signal_names[NSIG+1] = "ERR";
+ signal_names[NSIG+2] = "RETURN";
+}
diff --git a/support/texi2dvi b/support/texi2dvi
new file mode 100755
index 0000000..173e8ab
--- /dev/null
+++ b/support/texi2dvi
@@ -0,0 +1,1944 @@
+#! /bin/sh
+# texi2dvi --- produce DVI (or PDF) files from Texinfo (or (La)TeX) sources.
+# $Id: texi2dvi 5704 2014-07-07 17:45:16Z karl $
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
+# Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# Originally written by Noah Friedman.
+#
+# Please send bug reports, etc. to bug-texinfo@gnu.org.
+# If possible, please send a copy of the output of the script called with
+# the `--debug' option when making a bug report.
+
+test -f /bin/ksh && test -z "$RUNNING_KSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
+unset RUNNING_KSH
+
+# No failure shall remain unpunished.
+set -e
+
+# In case the default sed doesn't suffice.
+: ${SED=sed}
+
+# This string is expanded automatically when this file is checked out.
+rcs_revision='$Revision: 5704 $'
+rcs_version=`set - $rcs_revision; echo $2`
+program=`echo $0 | $SED -e 's!.*/!!'`
+
+build_mode=${TEXI2DVI_BUILD_MODE:-local}
+build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
+
+# Initialize variables for option overriding and otherwise.
+# Don't use `unset' since old bourne shells don't have this command.
+# Instead, assign them an empty value.
+action=compile
+batch=false # interact normally
+catcode_special=maybe
+debug=false
+escape="\\"
+expand=false # true for expansion via makeinfo
+includes=
+line_error=true # pass --file-line-error to TeX
+max_iters=7 # when to quit
+oname= # --output
+out_lang=dvi
+quiet=false # let the tools' message be displayed
+set_language=
+src_specials=
+shell_escape=
+latex2html=hevea # or set to tex4ht
+textra= # Extra TeX commands to insert in the input file.
+txiprereq=19990129 # minimum texinfo.tex version with macro expansion
+verb=false # true for verbose mode
+translate_file= # name of charset translation file
+
+orig_pwd=`pwd`
+
+# We have to initialize IFS to space tab newline since we save and
+# restore IFS and apparently POSIX allows stupid/broken behavior with
+# empty-but-set IFS.
+# http://lists.gnu.org/archive/html/automake-patches/2006-05/msg00008.html
+# We need space, tab and new line, in precisely that order. And don't leave
+# trailing blanks.
+space=' '
+tab=' '
+newline='
+'
+IFS="$space$tab$newline"
+
+# In case someone pedantic insists on using grep -E.
+: ${EGREP=egrep}
+
+# Systems which define $COMSPEC or $ComSpec use semicolons to separate
+# directories in TEXINPUTS -- except for Cygwin et al., where COMSPEC
+# might be inherited, but : is used.
+if test -n "$COMSPEC$ComSpec" \
+ && uname | $EGREP -iv 'cygwin|mingw|djgpp' >/dev/null; then
+ path_sep=";"
+else
+ path_sep=":"
+fi
+
+# Pacify verbose cds.
+CDPATH=${ZSH_VERSION+.}$path_sep
+
+# If $TEX is set to a directory, don't use it.
+test -n "$TEX" && test -d "$TEX" && unset TEX
+
+#
+## --------------------- ##
+## Auxiliary functions. ##
+## --------------------- ##
+
+# In case `local' is not supported by the shell, provide a function
+# that simulates it by simply performing the assignments. This means
+# that we must not expect `local' to work, i.e., we must not (i) rely
+# on it during recursion, and (ii) have two local declarations of the
+# same variable. (ii) is easy to check statically, and our test suite
+# does make sure there is never twice a static local declaration of a
+# variable. (i) cannot be checked easily, so just be careful.
+#
+# Note that since we might use a function simulating `local', we can
+# no longer rely on the fact that no IFS-splitting is performed. So,
+# while
+#
+# foo=$bar
+#
+# is fine (no IFS-splitting), never write
+#
+# local foo=$bar
+#
+# but rather
+#
+# local foo="$bar"
+(
+ foo=bar
+ test_local () {
+ local foo=foo
+ }
+ test_local >/dev/null 2>&1
+ test $foo = bar
+) || eval '
+local () {
+ case $1 in
+ *=*) eval "$1";;
+ esac
+}
+'
+
+
+# cd_orig
+# -------
+# Return to the original directory.
+cd_orig ()
+{
+ # In case $orig_pwd is on a different drive (for DOS).
+ cd /
+
+ # Return to the original directory so that
+ # - the next file is processed in correct conditions
+ # - the temporary file can be removed
+ cd "$orig_pwd" || exit 1
+}
+
+# func_dirname FILE
+# -----------------
+# Return the directory part of FILE.
+func_dirname ()
+{
+ dirname "$1" 2>/dev/null \
+ || { echo "$1" | $SED 's!/[^/]*$!!;s!^$!.!'; }
+}
+
+
+# noexit FILE
+# -----------
+# Return FILE with one extension remove. foo.bar.baz -> foo.bar.
+noext ()
+{
+ echo "$1" | $SED -e 's/\.[^/.][^/.]*$//'
+}
+
+
+# absolute NAME -> ABS-NAME
+# -------------------------
+# Return an absolute path to NAME.
+absolute ()
+{
+ case $1 in
+ [\\/]* | ?:[\\/]*)
+ # Absolute paths don't need to be expanded.
+ echo "$1"
+ ;;
+ *) local slashes
+ slashes=`echo "$1" | $SED -n 's,.*[^/]\(/*\)$,\1,p'`
+ local rel
+ rel=$orig_pwd/`func_dirname "$1"`
+ if test -d "$rel"; then
+ (cd "$rel" 2>/dev/null \
+ && local n
+ n=`pwd`/`basename "$1"`"$slashes"
+ echo "$n")
+ else
+ error 1 "not a directory: $rel"
+ fi
+ ;;
+ esac
+}
+
+
+# ensure_dir DIR1 DIR2...
+# -----------------------
+# Make sure the directories exist.
+ensure_dir ()
+{
+ for dir
+ do
+ # Beware that in parallel builds we may have several concurrent
+ # attempts to create the directory. So fail only if "mkdir"
+ # failed *and* the directory still does not exist.
+ test -d "$dir" \
+ || mkdir "$dir" \
+ || test -d "$dir" \
+ || error 1 "cannot create directory: $dir"
+ done
+}
+
+
+# error EXIT_STATUS LINE1 LINE2...
+# --------------------------------
+# Report an error and exit with failure if EXIT_STATUS is non-null.
+error ()
+{
+ local s="$1"
+ shift
+ report "$@"
+ if test "$s" != 0; then
+ exit $s
+ fi
+}
+
+
+# findprog PROG
+# -------------
+# Return true if PROG is somewhere in PATH, else false.
+findprog ()
+{
+ local saveIFS="$IFS"
+ IFS=$path_sep # break path components at the path separator
+ for dir in $PATH; do
+ IFS=$saveIFS
+ # The basic test for an executable is `test -f $f && test -x $f'.
+ # (`test -x' is not enough, because it can also be true for directories.)
+ # We have to try this both for $1 and $1.exe.
+ #
+ # Note: On Cygwin and DJGPP, `test -x' also looks for .exe. On Cygwin,
+ # also `test -f' has this enhancement, but not on DJGPP. (Both are
+ # design decisions, so there is little chance to make them consistent.)
+ # Thusly, it seems to be difficult to make use of these enhancements.
+ #
+ if { test -f "$dir/$1" && test -x "$dir/$1"; } \
+ || { test -f "$dir/$1.exe" && test -x "$dir/$1.exe"; }; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+# report LINE1 LINE2...
+# ---------------------
+# Report some information on stderr.
+report ()
+{
+ for i in "$@"
+ do
+ echo >&2 "$0: $i"
+ done
+}
+
+
+# run COMMAND-LINE
+# ----------------
+# Run the COMMAND-LINE verbosely, and catching errors as failures.
+run ()
+{
+ verbose "Running $@"
+ "$@" 2>&5 1>&2 \
+ || error 1 "$1 failed"
+}
+
+
+# usage
+# -----
+# Display usage and exit successfully.
+usage ()
+{
+ # We used to simply have `echo "$usage"', but coping with the
+ # changing behavior of `echo' is much harder than simply using a
+ # here-doc.
+ #
+ # echo '\noto' echo '\\noto' echo -e '\\noto'
+ # bash 3.1 \noto \\noto \noto
+ # bash 3.2 %oto \noto -e \noto
+ #
+ # where % denotes the eol character.
+ cat <<EOF
+Usage: $program [OPTION]... FILE...
+ or: texi2pdf [OPTION]... FILE...
+ or: pdftexi2dvi [OPTION]... FILE...
+
+Run each Texinfo or (La)TeX FILE through TeX in turn until all
+cross-references are resolved, building all indices. The directory
+containing each FILE is searched for included files. The suffix of FILE
+is used to determine its language ((La)TeX or Texinfo). To process
+(e)plain TeX files, set the environment variable LATEX=tex.
+
+In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX,
+the FILE may also be composed of the following simple TeX commands.
+ \`\\input{FILE}' the actual file to compile
+ \`\\nonstopmode' same as --batch
+
+When invoked as \`texi2pdf' or \`pdftexi2dvi', or given the option --pdf
+or --dvipdf, generate PDF output. Otherwise, generate DVI.
+
+General options:
+ -b, --batch no interaction
+ -D, --debug turn on shell debugging (set -x)
+ -h, --help display this help and exit successfully
+ -o, --output=OFILE leave output in OFILE; only one input FILE is allowed
+ -q, --quiet no output unless errors (implies --batch)
+ -s, --silent same as --quiet
+ -v, --version display version information and exit successfully
+ -V, --verbose report on what is done
+
+Output format:
+ --dvi output a DVI file [default]
+ --dvipdf output a PDF file via DVI (using a dvi-to-pdf program)
+ --html output an HTML file from LaTeX, using HeVeA
+ --info output an Info file from LaTeX, using HeVeA
+ -p, --pdf use pdftex or pdflatex for processing
+ --ps output a PostScript file via DVI (using dvips)
+ --text output a plain text file from LaTeX, using HeVeA
+
+TeX tuning:
+ -@ use @input instead of \input for preloaded Texinfo
+ -e, -E, --expand force macro expansion using makeinfo
+ -I DIR search DIR for Texinfo files
+ -l, --language=LANG specify LANG for FILE, either latex or texinfo
+ --no-line-error do not pass --file-line-error to TeX
+ --shell-escape pass --shell-escape to TeX
+ --src-specials pass --src-specials to TeX
+ -t, --command=CMD insert CMD in copy of input file
+ or --texinfo=CMD multiple values accumulate
+ --translate-file=FILE use given charset translation file for TeX
+
+Build modes:
+ --build=MODE specify the treatment of auxiliary files [$build_mode]
+ --tidy same as --build=tidy
+ -c, --clean same as --build=clean
+ --build-dir=DIR specify where the tidy compilation is performed;
+ implies --tidy;
+ defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
+ --mostly-clean remove the auxiliary files and directories
+ but not the output
+ --max-iterations=N don't process files more than N times [$max_iters]
+
+The MODE specifies where the TeX compilation takes place, and, as a
+consequence, how auxiliary files are treated. The build mode
+can also be set using the environment variable TEXI2DVI_BUILD_MODE.
+
+Valid MODEs are:
+ \`local' compile in the current directory, leaving all the auxiliary
+ files around. This is the traditional TeX use.
+ \`tidy' compile in a local *.t2d directory, where the auxiliary files
+ are left. Output files are copied back to the original file.
+ \`clean' same as \`tidy', but remove the auxiliary directory afterwards.
+ Every compilation therefore requires the full cycle.
+
+Using the \`tidy' mode brings several advantages:
+ - the current directory is not cluttered with plethora of temporary files.
+ - clutter can be even further reduced using --build-dir=dir: all the *.t2d
+ directories are stored there.
+ - clutter can be reduced to zero using, e.g., --build-dir=/tmp/\$USER.t2d
+ or --build-dir=\$HOME/.t2d.
+ - the output file is updated after every successful TeX run, for
+ sake of concurrent visualization of the output. In a \`local' build
+ the viewer stops during the whole TeX run.
+ - if the compilation fails, the previous state of the output file
+ is preserved.
+ - PDF and DVI compilation are kept in separate subdirectories
+ preventing any possibility of auxiliary file incompatibility.
+
+On the other hand, because \`tidy' compilation takes place in another
+directory, occasionally TeX won't be able to find some files (e.g., when
+using \\graphicspath): in that case, use -I to specify the additional
+directories to consider.
+
+The values of the BIBER, BIBTEX, DVIPDF, DVIPS, HEVEA, LATEX, MAKEINDEX,
+MAKEINFO, PDFLATEX, PDFTEX, SED, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF_CMD
+environment variables are used to run those commands, if they are set.
+
+Regarding --dvipdf, if DVIPDF is not set in the environment, the
+following programs are looked for (in this order): dvipdfmx dvipdfm
+dvipdf dvi2pdf dvitopdf.
+
+Any CMD strings are added after @setfilename for Texinfo input, or in
+the first line for LaTeX input.
+
+Report bugs to bug-texinfo@gnu.org,
+general questions and discussion to help-texinfo@gnu.org.
+GNU Texinfo home page: <http://www.gnu.org/software/texinfo/>
+General help using GNU software: <http://www.gnu.org/gethelp/>
+EOF
+ exit 0
+}
+
+
+# verbose WORD1 WORD2
+# -------------------
+# Report some verbose information.
+verbose ()
+{
+ if $verb; then
+ echo >&2 "$0: $@"
+ fi
+}
+
+
+# version
+# -------
+# Display version info and exit successfully.
+version ()
+{
+ cat <<EOF
+texi2dvi (GNU Texinfo 5.2) $rcs_version
+
+Copyright (C) 2014 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+EOF
+ exit 0
+}
+
+
+## ---------------- ##
+## Handling lists. ##
+## ---------------- ##
+
+
+# list_append LIST-NAME ELEM
+# --------------------------
+# Set LIST-NAME to its former contents, with ELEM appended.
+list_append ()
+{
+ local la_l="$1"
+ shift
+ eval set X \$$la_l "$@"
+ shift
+ eval $la_l=\""$@"\"
+}
+
+
+# list_concat_dirs LIST-NAME DIR-LIST
+# -----------------------------------
+# Append to LIST-NAME all the components (included empty) from
+# the $path_sep separated list DIR-LIST. Make the paths absolute.
+list_concat_dirs ()
+{
+ local lcd_list="$1"
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
+ local replace_EMPTY="-e 's/^$path_sep/EMPTY$path_sep/g' \
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ save_IFS=$IFS
+ IFS=$path_sep
+ set x `echo "$2" | eval $SED $replace_EMPTY`; shift
+ IFS=$save_IFS
+ local dir
+ for dir
+ do
+ case $dir in
+ EMPTY)
+ list_append $lcd_list ""
+ ;;
+ *)
+ if test -d $dir; then
+ dir=`absolute "$dir"`
+ list_append $lcd_list "$dir"
+ fi
+ ;;
+ esac
+ done
+}
+
+
+# list_prefix LIST-NAME SEP -> STRING
+# -----------------------------------
+# Return a string that is composed of the LIST-NAME with each item
+# preceded by SEP.
+list_prefix ()
+{
+ local lp_p="$2"
+ eval set X \$$1
+ shift
+ local lp_res
+ for i
+ do
+ lp_res="$lp_res \"$lp_p\" \"$i\""
+ done
+ echo "$lp_res"
+}
+
+# list_infix LIST-NAME SEP -> STRING
+# ----------------------------------
+# Same as list_prefix, but a separator.
+list_infix ()
+{
+ eval set X \$$1
+ shift
+ local la_IFS="$IFS"
+ IFS=$path_sep
+ echo "$*"
+ IFS=$la_IFS
+}
+
+# list_dir_to_abs LIST-NAME
+# -------------------------
+# Convert the list to using only absolute dir names.
+# Currently unused, but should replace absolute_filenames some day.
+list_dir_to_abs ()
+{
+ local ld_l="$1"
+ eval set X \$$ld_l
+ shift
+ local ld_res
+ for dir
+ do
+ dir=`absolute "$dir"`
+ test -d "$dir" || continue
+ ld_res="$ld_res \"$dir\""
+ done
+ set X $ld_res; shift
+ eval $ld_l=\"$@\"
+}
+
+
+## ------------------------------ ##
+## Language auxiliary functions. ##
+## ------------------------------ ##
+
+
+# out_lang_set LANG
+# -----------------
+out_lang_set ()
+{
+ case $1 in
+ dvi|dvipdf|html|info|pdf|ps|text) out_lang=$1;;
+ *) error 1 "invalid output format: $1";;
+ esac
+}
+
+
+# out_lang_tex
+# ------------
+# Return the tex output language (DVI or PDF) for $OUT_LANG.
+out_lang_tex ()
+{
+ case $out_lang in
+ dvi | ps | dvipdf ) echo dvi;;
+ pdf ) echo $out_lang;;
+ html | info | text ) echo $out_lang;;
+ *) error 1 "invalid out_lang: $1";;
+ esac
+}
+
+
+# out_lang_ext
+# ------------
+# Return the extension for $OUT_LANG.
+out_lang_ext ()
+{
+ case $out_lang in
+ dvipdf ) echo pdf;;
+ dvi | html | info | pdf | ps | text ) echo $out_lang;;
+ *) error 1 "invalid out_lang: $1";;
+ esac
+}
+
+
+## ------------------------- ##
+## TeX auxiliary functions. ##
+## ------------------------- ##
+
+# Save TEXINPUTS so we can construct a new TEXINPUTS path for each file.
+# Likewise for bibtex and makeindex.
+tex_envvars="BIBINPUTS BSTINPUTS DVIPSHEADERS INDEXSTYLE MFINPUTS MPINPUTS \
+TEXINPUTS TFMFONTS"
+for var in $tex_envvars; do
+ eval ${var}_orig=\$$var
+ export $var
+done
+
+
+# absolute_filenames TEX-PATH -> TEX-PATH
+# ---------------------------------------
+# Convert relative paths to absolute paths, so we can run in another
+# directory (e.g., in tidy build mode, or during the macro-support
+# detection). Prepend ".".
+absolute_filenames ()
+{
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
+ local replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ local res
+ res=`echo "$1" | eval $SED $replace_empty`
+ save_IFS=$IFS
+ IFS=$path_sep
+ set x $res; shift
+ res=.
+ for dir
+ do
+ case $dir in
+ EMPTY)
+ res=$res$path_sep
+ ;;
+ *)
+ if test -d "$dir"; then
+ res=$res$path_sep`absolute "$dir"`
+ else
+ # Even if $dir is not a directory, preserve it in the path.
+ # It might contain metacharacters that TeX will expand in
+ # turn, e.g., /some/path/{a,b,c}. This will not get the
+ # implicit absolutification of the path, but we can't help that.
+ res=$res$path_sep$dir
+ fi
+ ;;
+ esac
+ done
+ echo "$res"
+}
+
+
+# output_base_name FILE
+# ---------------------
+# The name of FILE, possibly renamed to satisfy --output.
+# FILE is local, there is no directory part.
+output_base_name ()
+{
+ case $oname in
+ '') echo "$1";;
+ *) local out_noext
+ out_noext=`noext "$oname"`
+ local file_ext
+ file_ext=`echo "$1" | $SED 's/^.*\.//'`
+ echo "$out_noext.$file_ext"
+ ;;
+ esac
+}
+
+
+# destdir
+# -------
+# Return the name of the directory where the output is expected.
+destdir ()
+{
+ case $oname in
+ '') echo "$orig_pwd";;
+ *) dirname "$oname";;
+ esac
+}
+
+
+# move_to_dest FILE...
+# --------------------
+# Move FILE to the place where the user expects it. Truly move it, that
+# is, it must not remain in its build location unless that is also the
+# output location. (Otherwise it might appear as an extra file in make
+# distcheck.)
+#
+# FILE can be the principal output (in which case -o directly applies), or
+# an auxiliary file with the same base name.
+move_to_dest ()
+{
+# echo "move_to_dest $*, tidy=$tidy, oname=$oname"
+
+ # If we built in place and have no output name, there is nothing to
+ # do, so just return.
+ case $tidy:$oname in
+ false:) return;;
+ esac
+
+ local destfile
+ local destdir
+ local destbase
+ local sourcedir
+ local sourcebase
+
+ for file
+ do
+ test -f "$file" \
+ || error 1 "no such file or directory: $file"
+ case $tidy:$oname in
+ true:) destdir=$orig_pwd
+ destfile=$destdir/$file;;
+ true:*) destfile=`output_base_name "$file"`
+ destdir=`dirname "$destfile"`;;
+ false:*) destfile=$oname
+ destdir=`dirname "$destfile"`;;
+ esac
+
+ # We want to compare the source location and the output location,
+ # and if they are different, do the move. But if they are the
+ # same, we must preserve the source. Since we can't assume
+ # stat(1) or test -ef is available, resort to comparing the
+ # directory names, canonicalized with pwd. We can't use cmp -s
+ # since the output file might not actually change from run to run;
+ # e.g., TeX DVI output is timestamped to only the nearest minute.
+ destdir=`cd "$destdir" && pwd`
+ destbase=`basename "$destfile"`
+
+ sourcedir=`dirname "$file"`
+ sourcedir=`cd "$sourcedir" && pwd`
+ sourcebase=`basename "$file"`
+
+ if test "$sourcedir/$sourcebase" != "$destdir/$destbase"; then
+ verbose "Moving $file to $destfile"
+ rm -f "$destfile"
+ mv "$file" "$destfile"
+ fi
+ done
+}
+
+
+## --------------------- ##
+## Managing xref files. ##
+## --------------------- ##
+
+# aux_file_p FILE
+# ---------------
+# Return with success if FILE is an aux file.
+aux_file_p ()
+{
+ test -f "$1" || return 1
+ case $1 in
+ *.aux) return 0;;
+ *) return 1;;
+ esac
+}
+
+# bibaux_file_p FILE
+# ------------------
+# Return with success if FILE is an aux file containing citation
+# requests.
+bibaux_file_p ()
+{
+ test -s "$1" || return 1
+ if (grep '^\\bibstyle[{]' "$1" \
+ && grep '^\\bibdata[{]' "$1" \
+ ## The following line is suspicious: fails when there
+ ## are citations in sub aux files. We need to be
+ ## smarter in this case.
+ ## && grep '^\\citation[{]' "$f"
+ ) >&6 2>&1;
+ then
+ return 0
+ fi
+ return 1
+}
+
+# index_file_p FILE
+# -----------------
+# Return with success if FILE is an index file.
+index_file_p ()
+{
+ test -f "$1" || return 1
+ case $in_lang:$latex2html:`out_lang_tex`:`$SED '1q' "$1"` in
+ # When working with TeX4HT, *.idx are created by LaTeX. They must
+ # be processed to produce *.4ix, *.4dx files. The *.4dx file is
+ # passed to makeindex to produce the *.ind file. This sequence is
+ # handled by run_index, so we are only interested in the *.idx
+ # files, which have each "\indexentry" preceded by a
+ # "\beforeentry".
+ latex:tex4ht:html:"\\beforeentry {"*) return 0;;
+
+ # When index.sty is used, there is a space before the brace.
+ latex:*:*:"\\indexentry{"*|latex:*:*:"\\indexentry {"*) return 0;;
+
+ texinfo:*:*:"\\entry{"*) return 0;;
+
+ *) return 1;;
+ esac
+}
+
+# xref_file_p FILE
+# ----------------
+# Return with success if FILE is an xref file (indexes, tables and lists).
+xref_file_p ()
+{
+ test -f "$1" || return 1
+ # If the file is not suitable to be an index or xref file, don't
+ # process it. It's suitable if the first character is a
+ # backslash or right quote or at, as long as the first line isn't
+ # \input texinfo.
+ case `$SED '1q' "$1"` in
+ "\\input texinfo"*) return 1;;
+ [\\''@]*) return 0;;
+ *) return 1;;
+ esac
+}
+
+
+# generated_files_get FILENAME-NOEXT [PREDICATE-FILTER]
+# -----------------------------------------------------
+# Return the list of files generated by the TeX compilation of FILENAME-NOEXT.
+generated_files_get ()
+{
+ local filter=true
+ if test -n "$2"; then
+ filter=$2
+ fi
+
+ # Gather the files created by TeX.
+ (
+ if test -f "$1.log"; then
+ $SED -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
+ fi
+ echo "$1.log"
+ ) |
+ # Depending on these files, infer outputs from other tools.
+ while read file; do
+ echo $file
+ case $in_lang in
+ texinfo)
+ # texindex: texinfo.cp -> texinfo.cps
+ if index_file_p $file; then
+ echo ${file}s
+ fi
+ ;;
+ latex)
+ if aux_file_p $file; then
+ # bibtex: *.aux -> *.bbl and *.blg.
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.bbl/'
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.blg/'
+ # -recorder: .fls
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.fls/'
+ fi
+ ;;
+ esac
+ done |
+ # Filter existing files matching the criterion.
+ #
+ # With an input file name containing a space, this produces a
+ # "command not found" message (and filtering is ineffective).
+ # The situation with a newline is presumably even worse.
+ while read file; do
+ if $filter "$file"; then
+ echo $file
+ fi
+ done |
+ sort |
+ # Some files are opened several times, e.g., listings.sty's *.vrb.
+ uniq
+}
+
+
+# xref_files_save
+# ---------------
+# Save the xref files.
+xref_files_save ()
+{
+ # Save copies of auxiliary files for later comparison.
+ xref_files_orig=`generated_files_get "$in_noext" xref_file_p`
+ if test -n "$xref_files_orig"; then
+ verbose "Backing up xref files: $xref_files_orig"
+ # The following line improves `cp $xref_files_orig "$work_bak"'
+ # by preserving the directory parts. Think of
+ # cp chap1/main.aux chap2/main.aux $work_bak.
+ #
+ # Users may have, e.g., --keep-old-files. Don't let this interfere.
+ # (Don't use unset for the sake of ancient shells.)
+ TAR_OPTIONS=; export TAR_OPTIONS
+ tar cf - $xref_files_orig | (cd "$work_bak" && tar xf -)
+ fi
+}
+
+
+# xref_files_changed
+# ------------------
+# Whether the xref files were changed since the previous run.
+xref_files_changed ()
+{
+ # LaTeX (and the package changebar) report in the LOG file if it
+ # should be rerun. This is needed for files included from
+ # subdirs, since texi2dvi does not try to compare xref files in
+ # subdirs. Performing xref files test is still good since LaTeX
+ # does not report changes in xref files.
+ if grep "Rerun to get" "$in_noext.log" >&6 2>&1; then
+ return 0
+ fi
+ # biblatex report of whether rerunning is needed.
+ if grep "biblatex.*(re)run" "$in_noext.log" >&6 2>&1; then
+ return 0
+ fi
+
+ # If old and new lists don't have the same file list,
+ # then something has definitely changed.
+ xref_files_new=`generated_files_get "$in_noext" xref_file_p`
+ verbose "Original xref files = $xref_files_orig"
+ verbose "New xref files = $xref_files_new"
+ if test "x$xref_files_orig" != "x$xref_files_new"; then
+ return 0
+ fi
+
+ # Compare each file until we find a difference.
+ for this_file in $xref_files_new; do
+ verbose "Comparing xref file `echo $this_file | $SED 's|\./||g'` ..."
+ # cmp -s returns nonzero exit status if files differ.
+ if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
+ verbose "xref file `echo $this_file | $SED 's|\./||g'` differed ..."
+ if $debug; then
+ diff -u "$work_bak/$this_file" "$this_file"
+ fi
+ return 0
+ fi
+ done
+
+ # No change.
+ return 1
+}
+
+
+
+## ----------------------- ##
+## Running the TeX suite. ##
+## ----------------------- ##
+
+
+
+# run_tex ()
+# ----------
+# Run TeX as "$tex $in_input", taking care of errors and logs.
+run_tex ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:*:dvi|latex:tex4ht:html)
+ tex=${LATEX:-latex};;
+ latex:*:pdf)
+ tex=${PDFLATEX:-pdflatex};;
+ texinfo:*:dvi)
+ # MetaPost also uses the TEX environment variable. If the user
+ # has set TEX=latex for that reason, don't bomb out.
+ case $TEX in
+ *latex) tex=tex;; # don't bother trying to find etex
+ *) tex=$TEX
+ esac;;
+ texinfo:*:pdf) tex=$PDFTEX;;
+
+ *) error 1 "$out_lang not supported for $in_lang";;
+ esac
+
+ # do the special catcode trick for ~ in filenames only for Texinfo,
+ # not LaTeX.
+ if test x"$in_lang" = xtexinfo && test $catcode_special = maybe; then
+ catcode_special=true
+ else
+ catcode_special=false
+ fi
+
+ # Beware of aux files in subdirectories that require the
+ # subdirectory to exist.
+ case $in_lang:$tidy in
+ latex:true)
+ $SED -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
+ sort -u |
+ while read d
+ do
+ ensure_dir "$work_build/$d"
+ done
+ ;;
+ esac
+
+ # Note that this will be used via an eval: quote properly.
+ local cmd="$tex"
+
+ # If possible, make TeX report error locations in GNU format.
+ if $line_error; then
+ if test "${tex_help:+set}" != set; then
+ # Go to a temporary directory to try --help, since old versions that
+ # don't accept --help will generate a texput.log.
+ tex_help_dir=$t2ddir/tex_help
+ ensure_dir "$tex_help_dir"
+ tex_help=`cd "$tex_help_dir" >&6 && $tex --help </dev/null 2>&1 || true`
+ fi
+ # The mk program and perhaps others want to parse TeX's
+ # original error messages.
+ case $tex_help in
+ *file-line-error*) cmd="$cmd --file-line-error";;
+ esac
+ fi
+
+ # Tell TeX about TCX file, if specified.
+ test -n "$translate_file" && cmd="$cmd --translate-file=$translate_file"
+
+ # Tell TeX to make source specials (for backtracking from output to
+ # source, given a sufficiently smart editor), if specified.
+ test -n "$src_specials" && cmd="$cmd $src_specials"
+
+ # Tell TeX to allow running external executables
+ test -n "$shell_escape" && cmd="$cmd $shell_escape"
+
+ # Tell TeX to be batch if requested.
+ if $batch; then
+ # \batchmode does not show terminal output at all, so we don't
+ # want that. And even in batch mode, TeX insists on having input
+ # from the user. Close its stdin to make it impossible.
+ cmd="$cmd </dev/null '${escape}nonstopmode'"
+ fi
+
+ # we'd like to handle arbitrary input file names, especially
+ # foo~bar/a~b.tex, since Debian likes ~ characters.
+ if $catcode_special; then
+ # $normaltilde is just to reduce line length in this source file.
+ # The idea is to define \normaltilde as a catcode other ~ character,
+ # then make the active ~ be equivalent to that, instead of the plain
+ # TeX tie. Then when the active ~ appears in the filename, it will
+ # be expanded to itself, as far as \input will see. (This is the
+ # same thing that texinfo.tex does in general, BTW.)
+ normaltilde="${escape}catcode126=12 ${escape}def${escape}normaltilde{~}"
+ cmd="$cmd '$normaltilde${escape}catcode126=13 ${escape}let~\normaltilde '"
+ fi
+ # Other special (non-active) characters could be supported by
+ # resetting their catcodes to other on the command line and changing
+ # texinfo.tex to initialize everything to plain catcodes. Maybe someday.
+
+ # append the \input command.
+ cmd="$cmd '${escape}input'"
+
+ # TeX's \input does not (easily or reliably) support whitespace
+ # characters or other special characters in file names. Our intensive
+ # use of absolute file names makes this worse: the enclosing directory
+ # names may include white spaces. Improve the situation using a
+ # symbolic link to the filename in the current directory, in tidy mode
+ # only. Do not alter in_input.
+ #
+ # The filename is almost always tokenized using plain TeX conventions
+ # (the exception would be if the user made a texinfo.fmt file). Not
+ # all the plain TeX special characters cause trouble, but there's no
+ # harm in making the link.
+ #
+ case $tidy:`func_dirname "$in_input"` in
+ true:*["$space$tab$newline\"#\$%\\^_{}~"]*)
+ _run_tex_file_name=`basename "$in_input"`
+ if test ! -f "$_run_tex_file_name"; then
+ # It might not be a file, clear it.
+ run rm -f "$_run_tex_file_name"
+ run ln -s "$in_input"
+ fi
+ cmd="$cmd '$_run_tex_file_name'"
+ ;;
+
+ *)
+ cmd="$cmd '$in_input'"
+ ;;
+ esac
+
+ verbose "$0: Running $cmd ..."
+ if eval "$cmd" >&5; then
+ case $out_lang in
+ dvi | pdf ) move_to_dest "$in_noext.$out_lang";;
+ esac
+ else
+ error 1 "$tex exited with bad status, quitting."
+ fi
+}
+
+# run_bibtex ()
+# -------------
+# Run bibtex on (or biber) current file.
+# - If its input (AUX) exists.
+# - If some citations are missing (LOG contains `Citation').
+# or the LOG complains of a missing .bbl
+#
+# Don't try to be too smart:
+# 1. Running bibtex only if the bbl file exists and is older than
+# the LaTeX file is wrong, since the document might include files
+# that have changed.
+#
+# 3. Because there can be several AUX (if there are \include's),
+# but a single LOG, looking for missing citations in LOG is
+# easier, though we take the risk of matching false messages.
+run_bibtex ()
+{
+ case $in_lang in
+ latex) bibtex=${BIBTEX:-bibtex};;
+ texinfo) return;;
+ esac
+
+ # "Citation undefined" is for LaTeX, "Undefined citation" for btxmac.tex.
+ # The no .aux && \bibdata test is also for btxmac, in case it was the
+ # first run of a bibtex-using document. Otherwise, it's possible that
+ # bibtex would never be run.
+ if test -r "$in_noext.aux" \
+ && test -r "$in_noext.log" \
+ && ( (grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
+ || grep '.*Undefined citation' "$in_noext.log" \
+ || grep 'No file .*\.bbl\.' "$in_noext.log") \
+ || (grep 'No \.aux file' "$in_noext.log" \
+ && grep '^\\bibdata' "$in_noext.aux") ) \
+ >&6 2>&1; \
+ then
+ bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
+ for f in $bibtex_aux; do
+ run $bibtex "$f"
+ done
+ fi
+
+ # biber(+biblatex) check.
+ if test -r "$in_noext.bcf" \
+ && grep '</bcf:controlfile>' "$in_noext.bcf" >/dev/null; then
+ run ${BIBER:-biber} "$in_noext"
+ fi
+}
+
+# run_index ()
+# ------------
+# Run texindex (or makeindex or texindy) on current index files. If
+# they already exist, and after running TeX a first time the index
+# files don't change, then there's no reason to run TeX again. But we
+# won't know that if the index files are out of date or nonexistent.
+run_index ()
+{
+ local index_files
+ index_files=`generated_files_get $in_noext index_file_p`
+ test -n "$index_files" \
+ || return 0
+
+ : ${MAKEINDEX:=makeindex}
+ : ${TEXINDEX:=texindex}
+ : ${TEXINDY:=texindy}
+
+ local index_file
+ local index_noext
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ for index_file in $index_files
+ do
+ index_noext=`noext "$index_file"`
+ run tex \
+ '\def\filename{{'"$index_noext"'}{idx}{4dx}{ind}}
+ \input idxmake.4ht'
+ run $MAKEINDEX -o $index_noext.ind $index_noext.4dx
+ done
+ ;;
+
+ latex:*)
+ if $TEXINDY --version >&6 2>&1; then
+ run $TEXINDY $index_files
+ else
+ run $MAKEINDEX $index_files
+ fi
+ ;;
+
+ texinfo:*)
+ run $TEXINDEX $index_files
+ ;;
+ esac
+}
+
+
+# run_tex4ht ()
+# -------------
+# Run the last two phases of TeX4HT: tex4ht extracts the HTML from the
+# instrumented DVI file, and t4ht converts the figures and installs
+# the files when given -d.
+#
+# Because knowing exactly which files are created is complex (in
+# addition the names are not simple to compute), which makes it
+# difficult to install the output files in a second step, it is much
+# simpler to install directly the output files.
+run_tex4ht ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ : ${TEX4HT:=tex4ht} ${T4HT:=t4ht}
+ run "$TEX4HT" "-f/$in_noext"
+ # Do not remove the / after the destdir.
+ run "$T4HT" "-d`destdir`/" "-f/$in_noext"
+ ;;
+ esac
+}
+
+
+# run_thumbpdf ()
+# ---------------
+run_thumbpdf ()
+{
+ if test `out_lang_tex` = pdf \
+ && test -r "$in_noext.log" \
+ && grep 'thumbpdf\.sty' "$in_noext.log" >&6 2>&1; \
+ then
+ thumbpdf=${THUMBPDF_CMD:-thumbpdf}
+ thumbcmd="$thumbpdf $in_dir/$in_noext"
+ verbose "Running $thumbcmd ..."
+ if $thumbcmd >&5; then
+ run_tex
+ else
+ report "$thumbpdf exited with bad status." \
+ "Ignoring its output."
+ fi
+ fi
+}
+
+
+# run_dvipdf FILE.dvi
+# -------------------
+# Convert FILE.dvi to FILE.pdf.
+run_dvipdf ()
+{
+ # Find which dvi->pdf program is available.
+ if test -z "$dvipdf"; then
+ for i in "$DVIPDF" dvipdfmx dvipdfm dvipdf dvi2pdf dvitopdf; do
+ if findprog $i; then
+ dvipdf=$i
+ fi
+ done
+ fi
+ # These tools have varying interfaces, some 'input output', others
+ # 'input -o output'. They all seem to accept 'input' only,
+ # outputting using the expected file name.
+ run $dvipdf "$1"
+ if test ! -f `echo "$1" | $SED -e 's/\.dvi$/.pdf/'`; then
+ error 1 "cannot find output file"
+ fi
+}
+
+# run_tex_suite ()
+# ----------------
+# Run the TeX tools until a fix point is reached.
+run_tex_suite ()
+{
+ # Move to the working directory.
+ if $tidy; then
+ verbose "cd $work_build"
+ cd "$work_build" || exit 1
+ fi
+
+ # Count the number of cycles.
+ local cycle=0
+
+ while :; do
+ # check for probably LaTeX loop (e.g. varioref)
+ if test $cycle -eq "$max_iters"; then
+ error 0 "Maximum of $max_iters cycles exceeded"
+ break
+ fi
+
+ # report progress
+ cycle=`expr $cycle + 1`
+ verbose "Cycle $cycle for $command_line_filename"
+
+ xref_files_save
+
+ # We run bibtex first, because it's more likely for the indexes
+ # to change after bibtex is run than the reverse, though either
+ # would be rare.
+ run_bibtex
+ run_index
+ run_core_conversion
+
+ xref_files_changed || break
+ done
+
+ # If we were using thumbpdf and producing PDF, then run thumbpdf
+ # and TeX one last time.
+ run_thumbpdf
+
+ # If we are using tex4ht, call it.
+ run_tex4ht
+
+ # Install the result if we didn't already (i.e., if the output is
+ # dvipdf or ps).
+ case $latex2html:$out_lang in
+ *:dvipdf)
+ run_dvipdf "$in_noext.`out_lang_tex`"
+ move_to_dest "$in_noext.`out_lang_ext`"
+ ;;
+ *:ps)
+ : ${DVIPS:=dvips}
+ run $DVIPS -o "$in_noext.`out_lang_ext`" "$in_noext.`out_lang_tex`"
+ move_to_dest "$in_noext.`out_lang_ext`"
+ ;;
+ esac
+
+ cd_orig
+}
+
+## -------------------------------- ##
+## TeX processing auxiliary tools. ##
+## -------------------------------- ##
+
+
+# A sed script that preprocesses Texinfo sources in order to keep the
+# iftex sections only. We want to remove non-TeX sections, and comment
+# (with `@c _texi2dvi') TeX sections so that makeinfo does not try to
+# parse them. Nevertheless, while commenting TeX sections, don't
+# comment @macro/@end macro so that makeinfo does propagate them.
+# Unfortunately makeinfo --iftex --no-ifinfo doesn't work well enough
+# (yet), makeinfo can't parse the TeX commands, so work around with sed.
+#
+# We assume that `@c _texi2dvi' starting a line is not present in the
+# document.
+#
+comment_iftex=\
+'/^@tex/,/^@end tex/{
+ s/^/@c _texi2dvi/
+}
+/^@iftex/,/^@end iftex/{
+ s/^/@c _texi2dvi/
+ /^@c _texi2dvi@macro/,/^@c _texi2dvi@end macro/{
+ s/^@c _texi2dvi//
+ }
+}
+/^@ifnottex/,/^@end ifnottex/{
+ s/^/@c (_texi2dvi)/
+}
+/^@ifinfo/,/^@end ifinfo/{
+ /^@node/p
+ /^@menu/,/^@end menu/p
+ t
+ s/^/@c (_texi2dvi)/
+}
+s/^@ifnotinfo/@c _texi2dvi@ifnotinfo/
+s/^@end ifnotinfo/@c _texi2dvi@end ifnotinfo/'
+
+# Uncommenting is simpler: remove any leading `@c texi2dvi'; repeated
+# copies can sneak in via macro invocations.
+uncomment_iftex='s/^@c _texi2dvi\(@c _texi2dvi\)*//'
+
+
+# run_makeinfo ()
+# ---------------
+# Expand macro commands in the original source file using Makeinfo.
+# Always use `end' footnote style, since the `separate' style
+# generates different output (arguably this is a bug in -E). Discard
+# main info output, the user asked to run TeX, not makeinfo.
+run_makeinfo ()
+{
+ test $in_lang = texinfo \
+ || return 0
+
+ # Unless required by the user, makeinfo expansion is wanted only
+ # if texinfo.tex is too old.
+ if $expand; then
+ makeinfo=${MAKEINFO:-makeinfo}
+ else
+ # Check if texinfo.tex performs macro expansion by looking for
+ # its version. The version is a date of the form YEAR-MO-DA.
+ # We don't need to use [0-9] to match the digits since anyway
+ # the comparison with $txiprereq, a number, will fail with non-digits.
+ # Run in a temporary directory to avoid leaving files.
+ version_test_dir=$t2ddir/version_test
+ ensure_dir "$version_test_dir"
+ if (
+ cd "$version_test_dir"
+ echo '\input texinfo.tex @bye' >txiversion.tex
+ # Be sure that if tex wants to fail, it is not interactive:
+ # close stdin.
+ $TEX txiversion.tex </dev/null >txiversion.out 2>txiversion.err
+ ); then :; else
+ report "texinfo.tex appears to be broken.
+This may be due to the environment variable TEX set to something
+other than (plain) tex, a corrupt texinfo.tex file, or
+to tex itself simply not working."
+ cat "$version_test_dir/txiversion.out"
+ cat "$version_test_dir/txiversion.err" >&2
+ error 1 "quitting."
+ fi
+ eval `$SED -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
+ verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
+ if test "$txiprereq" -le "$txiversion" >&6 2>&1; then
+ makeinfo=
+ else
+ makeinfo=${MAKEINFO:-makeinfo}
+ fi
+ # If TeX is preloaded, offer the user this convenience:
+ if test "$txiformat" = Texinfo; then
+ escape=@
+ fi
+ fi
+
+ if test -n "$makeinfo"; then
+ # in_src: the file with macros expanded.
+ # Use the same basename to generate the same aux file names.
+ work_src=$workdir/src
+ ensure_dir "$work_src"
+ in_src=$work_src/$in_base
+ local miincludes
+ miincludes=`list_prefix includes -I`
+ verbose "Macro-expanding $command_line_filename to $in_src ..."
+ # eval $makeinfo because it might be defined as something complex
+ # (running missing) and then we end up with things like '"-I"',
+ # and "-I" (including the quotes) is not an option name. This
+ # happens with gettext 0.14.5, at least.
+ $SED "$comment_iftex" "$command_line_filename" \
+ | eval $makeinfo --footnote-style=end -I "$in_dir" $miincludes \
+ -o /dev/null --macro-expand=- \
+ | $SED "$uncomment_iftex" >"$in_src"
+ # Continue only if everything succeeded.
+ if test $? -ne 0 \
+ || test ! -r "$in_src"; then
+ verbose "Expansion failed, ignored...";
+ else
+ in_input=$in_src
+ fi
+ fi
+}
+
+# insert_commands ()
+# ------------------
+# Used most commonly for @finalout, @smallbook, etc.
+insert_commands ()
+{
+ if test -n "$textra"; then
+ # _xtr. The file with the user's extra commands.
+ work_xtr=$workdir/xtr
+ in_xtr=$work_xtr/$in_base
+ ensure_dir "$work_xtr"
+ verbose "Inserting extra commands: $textra"
+ local textra_cmd
+ case $in_lang in
+ latex) textra_cmd=1i;;
+ texinfo) textra_cmd='/^@setfilename/a';;
+ *) error 1 "internal error, unknown language: $in_lang";;
+ esac
+ $SED "$textra_cmd\\
+$textra" "$in_input" >"$in_xtr"
+ in_input=$in_xtr
+ fi
+
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ # _tex4ht. The file with the added \usepackage{tex4ht}.
+ work_tex4ht=$workdir/tex4ht
+ in_tex4ht=$work_tex4ht/$in_base
+ ensure_dir "$work_tex4ht"
+ verbose "Inserting \\usepackage{tex4ht}"
+ perl -pe 's<\\documentclass(?:\[.*\])?{.*}>
+ <$&\\usepackage[xhtml]{tex4ht}>' \
+ "$in_input" >"$in_tex4ht"
+ in_input=$in_tex4ht
+ ;;
+ esac
+}
+
+# compute_language FILENAME
+# -------------------------
+# Return the short string describing the language in which FILENAME
+# is written: `texinfo' or `latex'.
+compute_language ()
+{
+ # If the user explicitly specified the language, use that.
+ # Otherwise, if the first line is \input texinfo, assume it's texinfo.
+ # Otherwise, guess from the file extension.
+ if test -n "$set_language"; then
+ echo $set_language
+ elif $SED 1q "$1" | grep 'input texinfo' >&6; then
+ echo texinfo
+ else
+ # Get the type of the file (latex or texinfo) from the given language
+ # we just guessed, or from the file extension if not set yet.
+ case $1 in
+ *.ltx | *.tex | *.drv | *.dtx) echo latex;;
+ *) echo texinfo;;
+ esac
+ fi
+}
+
+
+# run_hevea (MODE)
+# ----------------
+# Convert to HTML/INFO/TEXT.
+#
+# Don't pass `-noiso' to hevea: it's useless in HTML since anyway the
+# charset is set to latin1, and troublesome in other modes since
+# accented characters loose their accents.
+#
+# Don't pass `-o DEST' to hevea because in that case it leaves all its
+# auxiliary files there too... Too bad, because it means we will need
+# to handle images some day.
+run_hevea ()
+{
+ local hevea="${HEVEA:-hevea}"
+ local run_hevea="$hevea"
+
+ case $1 in
+ html) ;;
+ text|info) run_hevea="$run_hevea -$1";;
+ *) error 1 "run_hevea: invalid argument: $1";;
+ esac
+
+ # Compiling to the tmp directory enables to preserve a previous
+ # successful compilation.
+ run_hevea="$run_hevea -fix -O -o '$out_base'"
+ run_hevea="$run_hevea `list_prefix includes -I` -I '$orig_pwd' "
+ run_hevea="$run_hevea '$in_input'"
+
+ if $debug; then
+ run_hevea="$run_hevea -v -v"
+ fi
+
+ verbose "running $run_hevea"
+ if eval "$run_hevea" >&5; then
+ # hevea leaves trailing white spaces, this is annoying.
+ case $1 in text|info)
+ perl -pi -e 's/[ \t]+$//g' "$out_base"*;;
+ esac
+ case $1 in
+ html|text) move_to_dest "$out_base";;
+ info) # There can be foo.info-1, foo.info-2 etc.
+ move_to_dest "$out_base"*;;
+ esac
+ else
+ error 1 "$hevea exited with bad status, quitting."
+ fi
+}
+
+
+# run_core_conversion ()
+# ----------------------
+# Run the TeX (or HeVeA).
+run_core_conversion ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ *:dvi|*:pdf|latex:tex4ht:html)
+ run_tex;;
+ latex:*:html|latex:*:text|latex:*:info)
+ run_hevea $out_lang;;
+ *)
+ error 1 "invalid input/output combination: $in_lang/$out_lang";;
+ esac
+}
+
+
+# compile ()
+# ----------
+# Run the full compilation chain, from pre-processing to installation
+# of the output at its expected location.
+compile ()
+{
+ # Source file might include additional sources.
+ # We want `.:$orig_pwd' before anything else. (We'll add `.:' later
+ # after all other directories have been turned into absolute paths.)
+ # `.' goes first to ensure that any old .aux, .cps,
+ # etc. files in ${directory} don't get used in preference to fresher
+ # files in `.'. Include orig_pwd in case we are in clean build mode, where
+ # we have cd'd to a temp directory.
+ common="$orig_pwd$path_sep$in_dir$path_sep"
+ #
+ # If we have any includes, put those at the end.
+ # Keep a final path_sep to get the default (system) TeX directories included.
+ txincludes=`list_infix includes $path_sep`
+ test -n "$txincludes" && common="$common$txincludes$path_sep"
+ #
+ for var in $tex_envvars; do
+ eval val="\$common\$${var}_orig"
+ # Convert relative paths to absolute paths, so we can run in another
+ # directory (e.g., in clean build mode, or during the macro-support
+ # detection). ".:" is added here.
+ val=`absolute_filenames "$val"`
+ eval $var="\"$val\""
+ export $var
+ eval verbose \"$var=\'\$${var}\'\"
+ done
+
+ # --expand
+ run_makeinfo
+
+ # --command, --texinfo
+ insert_commands
+
+ # Run until a fix point is reached.
+ run_tex_suite
+}
+
+
+# remove FILES
+# ------------
+remove ()
+{
+ verbose "Removing" "$@"
+ rm -rf "$@"
+}
+
+
+# mostly_clean
+# ------------
+# Remove auxiliary files and directories. Changes the current directory.
+mostly_clean ()
+{
+ cd_orig
+ set X "$t2ddir"
+ shift
+ $tidy || {
+ local log="$work_build/$in_noext.log"
+ set X ${1+"$@"} "$log" `generated_files_get "$work_build/$in_noext"`
+ shift
+ }
+ remove ${1+"$@"}
+}
+
+
+# cleanup ()
+# ----------
+# Remove what should be removed according to options.
+# Called at the end of each compilation cycle, and at the end of
+# the script. Changes the current directory.
+cleanup ()
+{
+ case $build_mode in
+ local) cd_orig; remove "$t2ddir";;
+ clean) mostly_clean;;
+ tidy) ;;
+ esac
+}
+
+
+
+## ---------------------- ##
+## Command line parsing. ##
+## ---------------------- ##
+
+# Push a token among the arguments that will be used to notice when we
+# ended options/arguments parsing.
+# Use "set dummy ...; shift" rather than 'set - ..." because on
+# Solaris set - turns off set -x (but keeps set -e).
+# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
+# still expand "$@" to a single argument (the empty string) rather
+# than nothing at all.
+arg_sep="$$--$$"
+set dummy ${1+"$@"} "$arg_sep"; shift
+
+#
+# Parse command line arguments.
+while test x"$1" != x"$arg_sep"; do
+
+ # Handle --option=value by splitting apart and putting back on argv.
+ case "$1" in
+ --*=*)
+ opt=`echo "$1" | $SED -e 's/=.*//'`
+ val=`echo "$1" | $SED -e 's/[^=]*=//'`
+ shift
+ set dummy "$opt" "$val" ${1+"$@"}; shift
+ ;;
+ esac
+
+ case "$1" in
+ -@ ) escape=@;;
+ -~ ) catcode_special=false;;
+ # Silently and without documentation accept -b and --b[atch] as synonyms.
+ -b | --batch) batch=true;;
+ --build) shift; build_mode=$1;;
+ --build-dir) shift; build_dir=$1; build_mode=tidy;;
+ -c | --clean) build_mode=clean;;
+ -D | --debug) debug=true;;
+ -e | -E | --expand) expand=true;;
+ -h | --help) usage;;
+ -I) shift; list_concat_dirs includes "$1";;
+ -l | --lang | --language) shift; set_language=$1;;
+ --mostly-clean) action=mostly-clean;;
+ --no-line-error) line_error=false;;
+ --max-iterations) shift; max_iters=$1;;
+ -o | --out | --output)
+ shift
+ # Make it absolute, just in case we also have --clean, or whatever.
+ oname=`absolute "$1"`;;
+
+ # Output formats.
+ -O|--output-format) shift; out_lang_set "$1";;
+ --dvi|--dvipdf|--html|--info|--pdf|--ps|--text)
+ out_lang_set `echo "x$1" | $SED 's/^x--//'`;;
+
+ -p) out_lang_set pdf;;
+ -q | -s | --quiet | --silent) quiet=true; batch=true;;
+ --src-specials) src_specials=--src-specials;;
+ --shell-escape) shell_escape=--shell-escape;;
+ --tex4ht) latex2html=tex4ht;;
+ -t | --texinfo | --command ) shift; textra="$textra\\
+"`echo "$1" | $SED 's/\\\\/\\\\\\\\/g'`;;
+ --translate-file ) shift; translate_file="$1";;
+ --tidy) build_mode=tidy;;
+ -v | --vers*) version;;
+ -V | --verb*) verb=true;;
+ --) # What remains are not options.
+ shift
+ while test x"$1" != x"$arg_sep"; do
+ set dummy ${1+"$@"} "$1"; shift
+ shift
+ done
+ break;;
+ -*)
+ error 1 "Unknown or ambiguous option \`$1'." \
+ "Try \`--help' for more information."
+ ;;
+ *) set dummy ${1+"$@"} "$1"; shift;;
+ esac
+ shift
+done
+# Pop the token
+shift
+
+# $tidy: compile in a t2d directory.
+# $clean: remove all the aux files.
+case $build_mode in
+ local) clean=false; tidy=false;;
+ tidy) clean=false; tidy=true;;
+ clean) clean=true; tidy=true;;
+ *) error 1 "invalid build mode: $build_mode";;
+esac
+
+# Interpret remaining command line args as filenames.
+case $# in
+ 0)
+ error 2 "Missing file arguments." "Try \`--help' for more information."
+ ;;
+ 1) ;;
+ *)
+ if test -n "$oname"; then
+ error 2 "Can't use option \`--output' with more than one argument."
+ fi
+ ;;
+esac
+
+
+# We can't do much without tex.
+#
+if findprog ${TEX:-tex}; then :; else cat <<EOM
+You don't have a working TeX binary (${TEX:-tex}) installed anywhere in
+your PATH, and texi2dvi cannot proceed without one. If you want to use
+this script, you'll need to install TeX (if you don't have it) or change
+your PATH or TEX environment variable (if you do). See the --help
+output for more details.
+
+For information about obtaining TeX, please see http://tug.org/texlive,
+or do a web search for TeX and your operating system or distro.
+EOM
+ exit 1
+fi
+
+
+# We want to use etex (or pdftex) if they are available, and the user
+# didn't explicitly specify. We don't check for elatex and pdfelatex
+# because (as of 2003), the LaTeX team has asked that new distributions
+# use etex by default anyway.
+#
+# End up with the TEX and PDFTEX variables set to what we are going to use.
+if test -z "$TEX"; then
+ if findprog etex; then TEX=etex; else TEX=tex; fi
+fi
+#
+if test -z "$PDFTEX"; then
+ if findprog pdfetex; then PDFTEX=pdfetex; else PDFTEX=pdftex; fi
+fi
+
+
+# File descriptor usage:
+# 0 standard input
+# 1 standard output (--verbose messages)
+# 2 standard error
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 5 tools output (turned off by --quiet)
+# 6 tracing/debugging (set -x output, etc.)
+
+
+# Main tools' output (TeX, etc.) that TeX users are used to seeing.
+#
+# If quiet, discard, else redirect to the message flow.
+if $quiet; then
+ exec 5>/dev/null
+else
+ exec 5>&1
+fi
+
+
+# Enable tracing, and auxiliary tools output.
+#
+# This fd should be used where you'd typically use /dev/null to throw
+# output away. But sometimes it is convenient to see that output (e.g.,
+# from a grep) to aid debugging. Especially debugging at distance, via
+# the user.
+#
+if $debug; then
+ exec 6>&1
+ set -vx
+else
+ exec 6>/dev/null
+fi
+
+#
+
+# input_file_name_decode
+# ----------------------
+# Decode COMMAND_LINE_FILENAME, and compute:
+# - COMMAND_LINE_FILENAME clean of TeX commands
+# - IN_DIR
+# The directory to the input file, possibly absolute if needed.
+# - IN_DIR_ABS
+# The absolute directory of the input file.
+# - IN_BASE
+# The input file base name (no directory part).
+# - IN_NOEXT
+# The input file name without extensions (nor directory part).
+# - IN_INPUT
+# Defaults to COMMAND_LINE_FILENAME, but might change if the
+# input is preprocessed. With directory, possibly absolute.
+input_file_name_decode ()
+{
+ # See if we are run from within AUC-Tex, in which case we are
+ # passed `\input{FOO.tex}' or even `\nonstopmode\input{FOO.tex}'.
+ case $command_line_filename in
+ *\\nonstopmode*)
+ batch=true;;
+ esac
+ case $command_line_filename in
+ *\\input{*}*)
+ # Let AUC-TeX error parser deal with line numbers.
+ line_error=false
+ command_line_filename=`\
+ expr X"$command_line_filename" : X'.*input{\([^}]*\)}'`
+ ;;
+ esac
+
+ # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
+ # prepend `./' in order to avoid that the tools take it as an option.
+ echo "$command_line_filename" | LC_ALL=C $EGREP '^(/|[A-Za-z]:/)' >&6 \
+ || command_line_filename="./$command_line_filename"
+
+ # See if the file exists. If it doesn't we're in trouble since, even
+ # though the user may be able to reenter a valid filename at the tex
+ # prompt (assuming they're attending the terminal), this script won't
+ # be able to find the right xref files and so forth.
+ test -r "$command_line_filename" \
+ || error 1 "cannot read $command_line_filename, skipping."
+
+ # Get the name of the current directory.
+ in_dir=`func_dirname "$command_line_filename"`
+ in_dir_abs=`absolute "$in_dir"`
+ # In a clean build, we `cd', so get an absolute file name.
+ if $tidy; then
+ in_dir=$in_dir_abs
+ fi
+
+ # Strip directory part but leave extension.
+ in_base=`basename "$command_line_filename"`
+ # Strip extension.
+ in_noext=`noext "$in_base"`
+
+ # The normalized file name to compile. Must always point to the
+ # file to actually compile (in case of recoding, macro-expansion etc.).
+ in_input=$in_dir/$in_base
+
+
+ # Compute the output file name.
+ if test x"$oname" != x; then
+ out_name=$oname
+ else
+ out_name=$in_noext.`out_lang_ext`
+ fi
+ out_dir=`func_dirname "$out_name"`
+ out_dir_abs=`absolute "$out_dir"`
+ out_base=`basename "$out_name"`
+ out_noext=`noext "$out_base"`
+}
+
+
+## -------------- ##
+## TeXify files. ##
+## -------------- ##
+
+for command_line_filename
+do
+ verbose "Processing $command_line_filename ..."
+
+ input_file_name_decode
+
+ # `texinfo' or `latex'?
+ in_lang=`compute_language "$command_line_filename"`
+
+ # An auxiliary directory used for all the auxiliary tasks involved
+ # in compiling this document.
+ case $build_dir in
+ '' | . ) t2ddir=$out_noext.t2d ;;
+ *) # Avoid collisions between multiple occurrences of the same
+ # file, so depend on the output path. Remove leading `./',
+ # at least to avoid creating a file starting with `.!', i.e.,
+ # an invisible file. The sed expression is fragile if the cwd
+ # has active characters. Transform / into ! so that we don't
+ # need `mkdir -p'. It might be something to reconsider.
+ t2ddir=$build_dir/`echo "$out_dir_abs/$out_noext.t2d" |
+ $SED "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
+ esac
+ # Remove it at exit if clean mode.
+ trap "cleanup" 0 1 2 15
+
+ ensure_dir "$build_dir" "$t2ddir"
+
+ # We will change directory, better work with an absolute path...
+ t2ddir=`absolute "$t2ddir"`
+ # Sometimes there are incompatibilities between auxiliary files for
+ # DVI and PDF. The contents can also change whether we work on PDF
+ # and/or DVI. So keep separate spaces for each.
+ workdir=$t2ddir/`out_lang_tex`
+ ensure_dir "$workdir"
+
+ # _build. In a tidy build, where the auxiliary files are output.
+ if $tidy; then
+ work_build=$workdir/build
+ else
+ work_build=.
+ fi
+
+ # _bak. Copies of the previous auxiliary files (another round is
+ # run if they differ from the new ones).
+ work_bak=$workdir/bak
+
+ # Make those directories.
+ ensure_dir "$work_build" "$work_bak"
+
+ case $action in
+ compile)
+ # Compile the document.
+ compile
+ cleanup
+ ;;
+
+ mostly-clean)
+ mostly_clean
+ ;;
+ esac
+done
+
+verbose "done."
+exit 0 # exit successfully, not however we ended the loop.
diff --git a/support/texi2html b/support/texi2html
new file mode 100755
index 0000000..13b5588
--- /dev/null
+++ b/support/texi2html
@@ -0,0 +1,5428 @@
+#! /usr/bin/perl
+'di ';
+'ig 00 ';
+#+##############################################################################
+#
+# texi2html: Program to transform Texinfo documents to HTML
+#
+# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+#-##############################################################################
+
+# This requires perl version 5 or higher
+require 5.0;
+
+#++##############################################################################
+#
+# NOTE FOR DEBUGGING THIS SCRIPT:
+# You can run 'perl texi2html.pl' directly, provided you have
+# the environment variable T2H_HOME set to the directory containing
+# the texi2html.init file
+#
+#--##############################################################################
+
+# CVS version:
+# $Id: texi2html.pl,v 1.55 2000/07/27 14:39:41 obachman Exp $
+
+# Homepage:
+$T2H_HOMEPAGE = <<EOT;
+http://www.mathematik.uni-kl.de/~obachman/Texi2html
+EOT
+
+# Authors:
+$T2H_AUTHORS = <<EOT;
+Written by: Lionel Cons <Lionel.Cons\@cern.ch> (original author)
+ Karl Berry <karl\@freefriends.org>
+ Olaf Bachmann <obachman\@mathematik.uni-kl.de>
+ and many others.
+Maintained by: Olaf Bachmann <obachman\@mathematik.uni-kl.de>
+Send bugs and suggestions to <texi2html\@mathematik.uni-kl.de>
+EOT
+
+# Version: set in configure.in
+$THISVERSION = '1.64';
+$THISPROG = "texi2html $THISVERSION"; # program name and version
+
+# The man page for this program is included at the end of this file and can be
+# viewed using the command 'nroff -man texi2html'.
+
+# Identity:
+
+$T2H_TODAY = &pretty_date; # like "20 September 1993"
+# the eval prevents this from breaking on system which do not have
+# a proper getpwuid implemented
+eval { ($T2H_USER = (getpwuid ($<))[6]) =~ s/,.*//;}; # Who am i
+
+#+++############################################################################
+# #
+# Initialization #
+# Pasted content of File $(srcdir)/texi2html.init: Default initializations #
+# #
+#---############################################################################
+
+# leave this within comments, and keep the require statement
+# This way, you can directly run texi2html.pl, if $ENV{T2H_HOME}/texi2html.init
+# exists.
+
+#
+# -*-perl-*-
+######################################################################
+# File: texi2html.init
+#
+# Sets default values for command-line arguments and for various customizable
+# procedures
+#
+# A copy of this file is pasted into the beginning of texi2html by
+# 'make texi2html'
+#
+# Copy this file and make changes to it, if you like.
+# Afterwards, either, load it with command-line option -init_file <your_init_file>
+#
+# $Id: texi2html.init,v 1.34 2000/07/27 14:09:02 obachman Exp $
+
+######################################################################
+# stuff which can also be set by command-line options
+#
+#
+# Note: values set here, overwrite values set by the command-line
+# options before -init_file and might still be overwritten by
+# command-line arguments following the -init_file option
+#
+
+# T2H_OPTIONS is a hash whose keys are the (long) names of valid
+# command-line options and whose values are a hash with the following keys:
+# type ==> one of !|=i|:i|=s|:s (see GetOpt::Long for more info)
+# linkage ==> ref to scalar, array, or subroutine (see GetOpt::Long for more info)
+# verbose ==> short description of option (displayed by -h)
+# noHelp ==> if 1 -> for "not so important options": only print description on -h 1
+# 2 -> for obsolete options: only print description on -h 2
+
+$T2H_DEBUG = 0;
+$T2H_OPTIONS -> {debug} =
+{
+ type => '=i',
+ linkage => \$main::T2H_DEBUG,
+ verbose => 'output HTML with debuging information',
+};
+
+$T2H_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
+$T2H_OPTIONS -> {doctype} =
+{
+ type => '=s',
+ linkage => \$main::T2H_DOCTYPE,
+ verbose => 'document type which is output in header of HTML files',
+ noHelp => 1
+};
+
+$T2H_CHECK = 0;
+$T2H_OPTIONS -> {check} =
+{
+ type => '!',
+ linkage => \$main::T2H_CHECK,
+ verbose => 'if set, only check files and output all things that may be Texinfo commands',
+ noHelp => 1
+};
+
+# -expand
+# if set to "tex" (or, "info") expand @iftex and @tex (or, @ifinfo) sections
+# else, neither expand @iftex, @tex, nor @ifinfo sections
+$T2H_EXPAND = "info";
+$T2H_OPTIONS -> {expand} =
+{
+ type => '=s',
+ linkage => \$T2H_EXPAND,
+ verbose => 'Expand info|tex|none section of texinfo source',
+};
+
+# - glossary
+#if set, uses section named `Footnotes' for glossary
+$T2H_USE_GLOSSARY = 0;
+T2H_OPTIONS -> {glossary} =
+{
+ type => '!',
+ linkage => \$T2H_USE_GLOSSARY,
+ verbose => "if set, uses section named `Footnotes' for glossary",
+ noHelp => 1,
+};
+
+
+# -invisible
+# $T2H_INVISIBLE_MARK is the text used to create invisible destination
+# anchors for index links (you can for instance use the invisible.xbm
+# file shipped with this program). This is a workaround for a known
+# bug of many WWW browsers, including netscape.
+# For me, it works fine without it -- on the contrary: if there, it
+# inserts space between headers and start of text (obachman 3/99)
+$T2H_INVISIBLE_MARK = '';
+# $T2H_INVISIBLE_MARK = '&#160;';
+$T2H_OPTIONS -> {invisible} =
+{
+ type => '=s',
+ linkage => \$T2H_INVISIBLE_MARK,
+ verbose => 'use text in invisble anchot',
+ noHelp => 1,
+};
+
+# -iso
+# if set, ISO8879 characters are used for special symbols (like copyright, etc)
+$T2H_USE_ISO = 0;
+$T2H_OPTIONS -> {iso} =
+{
+ type => 'iso',
+ linkage => \$T2H_USE_ISO,
+ verbose => 'if set, ISO8879 characters are used for special symbols (like copyright, etc)',
+ noHelp => 1,
+};
+
+# -I
+# list directories where @include files are searched for (besides the
+# directory of the doc file) additional '-I' args add to this list
+@T2H_INCLUDE_DIRS = (".");
+$T2H_OPTIONS -> {I} =
+{
+ type => '=s',
+ linkage => \@T2H_INCLUDE_DIRS,
+ verbose => 'append $s to the @include search path',
+};
+
+# -top_file
+# uses file of this name for top-level file
+# extension is manipulated appropriately, if necessary.
+# If empty, <basename of document>.html is used
+# Typically, you would set this to "index.html".
+$T2H_TOP_FILE = '';
+$T2H_OPTIONS -> {top_file} =
+{
+ type => '=s',
+ linkage => \$T2H_TOP_FILE,
+ verbose => 'use $s as top file, instead of <docname>.html',
+};
+
+
+# -toc_file
+# uses file of this name for table of contents file
+# extension is manipulated appropriately, if necessary.
+# If empty, <basename of document>_toc.html is used
+$T2H_TOC_FILE = '';
+$T2H_OPTIONS -> {toc_file} =
+{
+ type => '=s',
+ linkage => \$T2H_TOC_FILE,
+ verbose => 'use $s as ToC file, instead of <docname>_toc.html',
+};
+
+# -frames
+# if set, output two additional files which use HTML 4.0 "frames".
+$T2H_FRAMES = 0;
+$T2H_OPTIONS -> {frames} =
+{
+ type => '!',
+ linkage => \$T2H_FRAMES,
+ verbose => 'output files which use HTML 4.0 frames (experimental)',
+ noHelp => 1,
+};
+
+
+# -menu | -nomenu
+# if set, show the Texinfo menus
+$T2H_SHOW_MENU = 1;
+$T2H_OPTIONS -> {menu} =
+{
+ type => '!',
+ linkage => \$T2H_SHOW_MENU,
+ verbose => 'ouput Texinfo menus',
+};
+
+# -number | -nonumber
+# if set, number sections and show section names and numbers in references
+# and menus
+$T2H_NUMBER_SECTIONS = 1;
+$T2H_OPTIONS -> {number} =
+{
+ type => '!',
+ linkage => \$T2H_NUMBER_SECTIONS,
+ verbose => 'use numbered sections'
+};
+
+# if set, and T2H_NUMBER_SECTIONS is set, then use node names in menu
+# entries, instead of section names
+$T2H_NODE_NAME_IN_MENU = 0;
+
+# if set and menu entry equals menu descr, then do not print menu descr.
+# Likewise, if node name equals entry name, do not print entry name.
+$T2H_AVOID_MENU_REDUNDANCY = 1;
+
+# -split section|chapter|none
+# if set to 'section' (resp. 'chapter') create one html file per (sub)section
+# (resp. chapter) and separate pages for Top, ToC, Overview, Index,
+# Glossary, About.
+# otherwise, create monolithic html file which contains whole document
+#$T2H_SPLIT = 'section';
+$T2H_SPLIT = '';
+$T2H_OPTIONS -> {split} =
+{
+ type => '=s',
+ linkage => \$T2H_SPLIT,
+ verbose => 'split document on section|chapter else no splitting',
+};
+
+# -section_navigation|-no-section_navigation
+# if set, then navigation panels are printed at the beginning of each section
+# and, possibly at the end (depending on whether or not there were more than
+# $T2H_WORDS_IN_PAGE words on page
+# This is most useful if you do not want to have section navigation
+# on -split chapter
+$T2H_SECTION_NAVIGATION = 1;
+$T2H_OPTIONS -> {sec_nav} =
+{
+ type => '!',
+ linkage => \$T2H_SECTION_NAVIGATION,
+ verbose => 'output navigation panels for each section',
+};
+
+# -subdir
+# if set put result files in this directory
+# if not set result files are put into current directory
+#$T2H_SUBDIR = 'html';
+$T2H_SUBDIR = '';
+$T2H_OPTIONS -> {subdir} =
+{
+ type => '=s',
+ linkage => \$T2H_SUBDIR,
+ verbose => 'put HTML files in directory $s, instead of $cwd',
+};
+
+# -short_extn
+# If this is set all HTML file will have extension ".htm" instead of
+# ".html". This is helpful when shipping the document to PC systems.
+$T2H_SHORTEXTN = 0;
+$T2H_OPTIONS -> {short_ext} =
+{
+ type => '!',
+ linkage => \$T2H_SHORTEXTN,
+ verbose => 'use "htm" extension for output HTML files',
+};
+
+
+# -prefix
+# Set the output file prefix, prepended to all .html, .gif and .pl files.
+# By default, this is the basename of the document
+$T2H_PREFIX = '';
+$T2H_OPTIONS -> {prefix} =
+{
+ type => '=s',
+ linkage => \$T2H_PREFIX,
+ verbose => 'use as prefix for output files, instead of <docname>',
+};
+
+# -o filename
+# If set, generate monolithic document output html into $filename
+$T2H_OUT = '';
+$T2H_OPTIONS -> {out_file} =
+{
+ type => '=s',
+ linkage => sub {$main::T2H_OUT = @_[1]; $T2H_SPLIT = '';},
+ verbose => 'if set, all HTML output goes into file $s',
+};
+
+# -short_ref
+#if set cross-references are given without section numbers
+$T2H_SHORT_REF = '';
+$T2H_OPTIONS -> {short_ref} =
+{
+ type => '!',
+ linkage => \$T2H_SHORT_REF,
+ verbose => 'if set, references are without section numbers',
+};
+
+# -idx_sum
+# if value is set, then for each @prinindex $what
+# $docu_name_$what.idx is created which contains lines of the form
+# $key\t$ref sorted alphabetically (case matters)
+$T2H_IDX_SUMMARY = 0;
+$T2H_OPTIONS -> {idx_sum} =
+{
+ type => '!',
+ linkage => \$T2H_IDX_SUMMARY,
+ verbose => 'if set, also output index summary',
+ noHelp => 1,
+};
+
+# -verbose
+# if set, chatter about what we are doing
+$T2H_VERBOSE = '';
+$T2H_OPTIONS -> {Verbose} =
+{
+ type => '!',
+ linkage => \$T2H_VERBOSE,
+ verbose => 'print progress info to stdout',
+};
+
+# -lang
+# For page titles use $T2H_WORDS->{$T2H_LANG}->{...} as title.
+# To add a new language, supply list of titles (see $T2H_WORDS below).
+# and use ISO 639 language codes (see e.g. perl module Locale-Codes-1.02
+# for definitions)
+# Default's to 'en' if not set or no @documentlanguage is specified
+$T2H_LANG = '';
+$T2H_OPTIONS -> {lang} =
+{
+ type => '=s',
+ linkage => sub {SetDocumentLanguage($_[1])},
+ verbose => 'use $s as document language (ISO 639 encoding)',
+};
+
+# -l2h
+# if set, uses latex2html for generation of math content
+$T2H_L2H = '';
+$T2H_OPTIONS -> {l2h} =
+{
+ type => '!',
+ linkage => \$T2H_L2H,
+ verbose => 'if set, uses latex2html for @math and @tex',
+};
+
+######################
+# The following options are only relevant if $T2H_L2H is set
+#
+# -l2h_l2h
+# name/location of latex2html progam
+$T2H_L2H_L2H = "latex2html";
+$T2H_OPTIONS -> {l2h_l2h} =
+{
+ type => '=s',
+ linkage => \$T2H_L2H_L2H,
+ verbose => 'program to use for latex2html translation',
+ noHelp => 1,
+};
+
+# -l2h_skip
+# if set, skips actual call to latex2html tries to reuse previously generated
+# content, instead
+$T2H_L2H_SKIP = '';
+$T2H_OPTIONS -> {l2h_skip} =
+{
+ type => '!',
+ linkage => \$T2H_L2H_SKIP,
+ verbose => 'if set, tries to reuse previously latex2html output',
+ noHelp => 1,
+};
+
+# -l2h_tmp
+# if set, l2h uses this directory for temporarary files. The path
+# leading to this directory may not contain a dot (i.e., a "."),
+# otherwise, l2h will fail
+$T2H_L2H_TMP = '';
+$T2H_OPTIONS -> {l2h_tmp} =
+{
+ type => '=s',
+ linkage => \$T2H_L2H_TMP,
+ verbose => 'if set, uses $s as temporary latex2html directory',
+ noHelp => 1,
+};
+
+# if set, cleans intermediate files (they all have the prefix $doc_l2h_)
+# of l2h
+$T2H_L2H_CLEAN = 1;
+$T2H_OPTIONS -> {l2h_clean} =
+{
+ type => '!',
+ linkage => \$T2H_L2H_CLEAN,
+ verbose => 'if set, do not keep intermediate latex2html files for later reuse',
+ noHelp => 1,
+};
+
+$T2H_OPTIONS -> {D} =
+{
+ type => '=s',
+ linkage => sub {$main::value{@_[1]} = 1;},
+ verbose => 'equivalent to Texinfo "@set $s 1"',
+ noHelp => 1,
+};
+
+$T2H_OPTIONS -> {init_file} =
+{
+ type => '=s',
+ linkage => \&LoadInitFile,
+ verbose => 'load init file $s'
+};
+
+
+##############################################################################
+#
+# The following can only be set in the init file
+#
+##############################################################################
+
+# if set, center @image by default
+# otherwise, do not center by default
+$T2H_CENTER_IMAGE = 1;
+
+# used as identation for block enclosing command @example, etc
+# If not empty, must be enclosed in <td></td>
+$T2H_EXAMPLE_INDENT_CELL = '<td>&nbsp;</td>';
+# same as above, only for @small
+$T2H_SMALL_EXAMPLE_INDENT_CELL = '<td>&nbsp;</td>';
+# font size for @small
+$T2H_SMALL_FONT_SIZE = '-1';
+
+# if non-empty, and no @..heading appeared in Top node, then
+# use this as header for top node/section, otherwise use value of
+# @settitle or @shorttitle (in that order)
+$T2H_TOP_HEADING = '';
+
+# if set, use this chapter for 'Index' button, else
+# use first chapter whose name matches 'index' (case insensitive)
+$T2H_INDEX_CHAPTER = '';
+
+# if set and $T2H_SPLIT is set, then split index pages at the next letter
+# after they have more than that many entries
+$T2H_SPLIT_INDEX = 100;
+
+# if set (e.g., to index.html) replace hrefs to this file
+# (i.e., to index.html) by ./
+$T2H_HREF_DIR_INSTEAD_FILE = '';
+
+########################################################################
+# Language dependencies:
+# To add a new language extend T2H_WORDS hash and create $T2H_<...>_WORDS hash
+# To redefine one word, simply do:
+# $T2H_WORDS->{<language>}->{<word>} = 'whatever' in your personal init file.
+#
+$T2H_WORDS_EN =
+{
+ # titles of pages
+ 'ToC_Title' => 'Table of Contents',
+ 'Overview_Title' => 'Short Table of Contents',
+ 'Index_Title' => 'Index',
+ 'About_Title' => 'About this document',
+ 'Footnotes_Title' => 'Footnotes',
+ 'See' => 'See',
+ 'see' => 'see',
+ 'section' => 'section',
+# If necessary, we could extend this as follows:
+# # text for buttons
+# 'Top_Button' => 'Top',
+# 'ToC_Button' => 'Contents',
+# 'Overview_Button' => 'Overview',
+# 'Index_button' => 'Index',
+# 'Back_Button' => 'Back',
+# 'FastBack_Button' => 'FastBack',
+# 'Prev_Button' => 'Prev',
+# 'Up_Button' => 'Up',
+# 'Next_Button' => 'Next',
+# 'Forward_Button' =>'Forward',
+# 'FastWorward_Button' => 'FastForward',
+# 'First_Button' => 'First',
+# 'Last_Button' => 'Last',
+# 'About_Button' => 'About'
+};
+
+$T2H_WORD_DE =
+{
+ 'ToC_Title' => 'Inhaltsverzeichniss',
+ 'Overview_Title' => 'Kurzes Inhaltsverzeichniss',
+ 'Index_Title' => 'Index',
+ 'About_Title' => '&Uuml;ber dieses Dokument',
+ 'Footnotes_Title' => 'Fu&szlig;noten',
+ 'See' => 'Siehe',
+ 'see' => 'siehe',
+ 'section' => 'Abschnitt',
+};
+
+$T2H_WORD_NL =
+{
+ 'ToC_Title' => 'Inhoudsopgave',
+ 'Overview_Title' => 'Korte inhoudsopgave',
+ 'Index_Title' => 'Index', #Not sure ;-)
+ 'About_Title' => 'No translation available!', #No translation available!
+ 'Footnotes_Title' => 'No translation available!', #No translation available!
+ 'See' => 'Zie',
+ 'see' => 'zie',
+ 'section' => 'sectie',
+};
+
+$T2H_WORD_ES =
+{
+ 'ToC_Title' => '&iacute;ndice General',
+ 'Overview_Title' => 'Resumen del Contenido',
+ 'Index_Title' => 'Index', #Not sure ;-)
+ 'About_Title' => 'No translation available!', #No translation available!
+ 'Footnotes_Title' => 'Fu&szlig;noten',
+ 'See' => 'V&eacute;ase',
+ 'see' => 'v&eacute;ase',
+ 'section' => 'secci&oacute;n',
+};
+
+$T2H_WORD_NO =
+{
+ 'ToC_Title' => 'Innholdsfortegnelse',
+ 'Overview_Title' => 'Kort innholdsfortegnelse',
+ 'Index_Title' => 'Indeks', #Not sure ;-)
+ 'About_Title' => 'No translation available!', #No translation available!
+ 'Footnotes_Title' => 'No translation available!',
+ 'See' => 'Se',
+ 'see' => 'se',
+ 'section' => 'avsnitt',
+};
+
+$T2H_WORD_PT =
+{
+ 'ToC_Title' => 'Sum&aacute;rio',
+ 'Overview_Title' => 'Breve Sum&aacute;rio',
+ 'Index_Title' => '&Iacute;ndice', #Not sure ;-)
+ 'About_Title' => 'No translation available!', #No translation available!
+ 'Footnotes_Title' => 'No translation available!',
+ 'See' => 'Veja',
+ 'see' => 'veja',
+ 'section' => 'Se&ccedil;&atilde;o',
+};
+
+$T2H_WORDS =
+{
+ 'en' => $T2H_WORDS_EN,
+ 'de' => $T2H_WORDS_DE,
+ 'nl' => $T2H_WORDS_NL,
+ 'es' => $T2H_WORDS_ES,
+ 'no' => $T2H_WORDS_NO,
+ 'pt' => $T2H_WORDS_PT
+};
+
+@MONTH_NAMES_EN =
+(
+ 'January', 'February', 'March', 'April', 'May',
+ 'June', 'July', 'August', 'September', 'October',
+ 'November', 'December'
+);
+
+@MONTH_NAMES_DE =
+(
+ 'Januar', 'Februar', 'M&auml;rz', 'April', 'Mai',
+ 'Juni', 'Juli', 'August', 'September', 'Oktober',
+ 'November', 'Dezember'
+);
+
+@MONTH_NAMES_NL =
+(
+ 'Januari', 'Februari', 'Maart', 'April', 'Mei',
+ 'Juni', 'Juli', 'Augustus', 'September', 'Oktober',
+ 'November', 'December'
+);
+
+@MONTH_NAMES_ES =
+(
+ 'enero', 'febrero', 'marzo', 'abril', 'mayo',
+ 'junio', 'julio', 'agosto', 'septiembre', 'octubre',
+ 'noviembre', 'diciembre'
+);
+
+@MONTH_NAMES_NO =
+(
+
+ 'januar', 'februar', 'mars', 'april', 'mai',
+ 'juni', 'juli', 'august', 'september', 'oktober',
+ 'november', 'desember'
+);
+
+@MONTH_NAMES_PT =
+(
+ 'Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio',
+ 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro',
+ 'Novembro', 'Dezembro'
+);
+
+
+$MONTH_NAMES =
+{
+ 'en' => \@MONTH_NAMES_EN,
+ 'de' => \@MONTH_NAMES_DE,
+ 'es' => \@MONTH_NAMES_ES,
+ 'nl' => \@MONTH_NAMES_NL,
+ 'no' => \@MONTH_NAMES_NO,
+ 'pt' => \@MONTH_NAMES_PT
+};
+########################################################################
+# Control of Page layout:
+# You can make changes of the Page layout at two levels:
+# 1.) For small changes, it is often enough to change the value of
+# some global string/hash/array variables
+# 2.) For larger changes, reimplement one of the T2H_DEFAULT_<fnc>* routines,
+# give them another name, and assign them to the respective
+# $T2H_<fnc> variable.
+
+# As a general interface, the hashes T2H_HREF, T2H_NAME, T2H_NODE hold
+# href, html-name, node-name of
+# This -- current section (resp. html page)
+# Top -- top page ($T2H_TOP_FILE)
+# Contents -- Table of contents
+# Overview -- Short table of contents
+# Index -- Index page
+# About -- page which explain "navigation buttons"
+# First -- first node
+# Last -- last node
+#
+# Whether or not the following hash values are set, depends on the context
+# (all values are w.r.t. 'This' section)
+# Next -- next node of texinfo
+# Prev -- previous node of texinfo
+# Up -- up node of texinfo
+# Forward -- next node in reading order
+# Back -- previous node in reading order
+# FastForward -- if leave node, up and next, else next node
+# FastBackward-- if leave node, up and prev, else prev node
+#
+# Furthermore, the following global variabels are set:
+# $T2H_THISDOC{title} -- title as set by @setttile
+# $T2H_THISDOC{fulltitle} -- full title as set by @title...
+# $T2H_THISDOC{subtitle} -- subtitle as set by @subtitle
+# $T2H_THISDOC{author} -- author as set by @author
+#
+# and pointer to arrays of lines which need to be printed by t2h_print_lines
+# $T2H_OVERVIEW -- lines of short table of contents
+# $T2H_TOC -- lines of table of contents
+# $T2H_TOP -- lines of Top texinfo node
+# $T2H_THIS_SECTION -- lines of 'This' section
+
+#
+# There are the following subs which control the layout:
+#
+$T2H_print_section = \&T2H_DEFAULT_print_section;
+$T2H_print_Top_header = \&T2H_DEFAULT_print_Top_header;
+$T2H_print_Top_footer = \&T2H_DEFAULT_print_Top_footer;
+$T2H_print_Top = \&T2H_DEFAULT_print_Top;
+$T2H_print_Toc = \&T2H_DEFAULT_print_Toc;
+$T2H_print_Overview = \&T2H_DEFAULT_print_Overview;
+$T2H_print_Footnotes = \&T2H_DEFAULT_print_Footnotes;
+$T2H_print_About = \&T2H_DEFAULT_print_About;
+$T2H_print_misc_header = \&T2H_DEFAULT_print_misc_header;
+$T2H_print_misc_footer = \&T2H_DEFAULT_print_misc_footer;
+$T2H_print_misc = \&T2H_DEFAULT_print_misc;
+$T2H_print_chapter_header = \&T2H_DEFAULT_print_chapter_header;
+$T2H_print_chapter_footer = \&T2H_DEFAULT_print_chapter_footer;
+$T2H_print_page_head = \&T2H_DEFAULT_print_page_head;
+$T2H_print_page_foot = \&T2H_DEFAULT_print_page_foot;
+$T2H_print_head_navigation = \&T2H_DEFAULT_print_head_navigation;
+$T2H_print_foot_navigation = \&T2H_DEFAULT_print_foot_navigation;
+$T2H_button_icon_img = \&T2H_DEFAULT_button_icon_img;
+$T2H_print_navigation = \&T2H_DEFAULT_print_navigation;
+$T2H_about_body = \&T2H_DEFAULT_about_body;
+$T2H_print_frame = \&T2H_DEFAULT_print_frame;
+$T2H_print_toc_frame = \&T2H_DEFAULT_print_toc_frame;
+
+########################################################################
+# Layout for html for every sections
+#
+sub T2H_DEFAULT_print_section
+{
+ my $fh = shift;
+ local $T2H_BUTTONS = \@T2H_SECTION_BUTTONS;
+ &$T2H_print_head_navigation($fh) if $T2H_SECTION_NAVIGATION;
+ my $nw = t2h_print_lines($fh);
+ if ($T2H_SPLIT eq 'section' && $T2H_SECTION_NAVIGATION)
+ {
+ &$T2H_print_foot_navigation($fh, $nw);
+ }
+ else
+ {
+ print $fh '<HR SIZE="6">' . "\n";
+ }
+}
+
+###################################################################
+# Layout of top-page I recommend that you use @ifnothtml, @ifhtml,
+# @html within the Top texinfo node to specify content of top-level
+# page.
+#
+# If you enclose everything in @ifnothtml, then title, subtitle,
+# author and overview is printed
+# T2H_HREF of Next, Prev, Up, Forward, Back are not defined
+# if $T2H_SPLIT then Top page is in its own html file
+sub T2H_DEFAULT_print_Top_header
+{
+ &$T2H_print_page_head(@_) if $T2H_SPLIT;
+ t2h_print_label(@_); # this needs to be called, otherwise no label set
+ &$T2H_print_head_navigation(@_);
+}
+sub T2H_DEFAULT_print_Top_footer
+{
+ &$T2H_print_foot_navigation(@_);
+ &$T2H_print_page_foot(@_) if $T2H_SPLIT;
+}
+sub T2H_DEFAULT_print_Top
+{
+ my $fh = shift;
+
+ # for redefining navigation buttons use:
+ # local $T2H_BUTTONS = [...];
+ # as it is, 'Top', 'Contents', 'Index', 'About' are printed
+ local $T2H_BUTTONS = \@T2H_MISC_BUTTONS;
+ &$T2H_print_Top_header($fh);
+ if ($T2H_THIS_SECTION)
+ {
+ # if top-level node has content, then print it with extra header
+ print $fh "<H1>$T2H_NAME{Top}</H1>"
+ unless ($T2H_HAS_TOP_HEADING);
+ t2h_print_lines($fh, $T2H_THIS_SECTION)
+ }
+ else
+ {
+ # top-level node is fully enclosed in @ifnothtml
+ # print fulltitle, subtitle, author, Overview
+ print $fh
+ "<CENTER>\n<H1>" .
+ join("</H1>\n<H1>", split(/\n/, $T2H_THISDOC{fulltitle})) .
+ "</H1>\n";
+ print $fh "<H2>$T2H_THISDOC{subtitle}</H2>\n" if $T2H_THISDOC{subtitle};
+ print $fh "$T2H_THISDOC{author}\n" if $T2H_THISDOC{author};
+ print $fh <<EOT;
+</CENTER>
+<HR>
+<P></P>
+<H2> Overview: </H2>
+<BLOCKQUOTE>
+EOT
+ t2h_print_lines($fh, $T2H_OVERVIEW);
+ print $fh "</BLOCKQUOTE>\n";
+ }
+ &$T2H_print_Top_footer($fh);
+}
+
+###################################################################
+# Layout of Toc, Overview, and Footnotes pages
+# By default, we use "normal" layout
+# T2H_HREF of Next, Prev, Up, Forward, Back, etc are not defined
+# use: local $T2H_BUTTONS = [...] to redefine navigation buttons
+sub T2H_DEFAULT_print_Toc
+{
+ return &$T2H_print_misc(@_);
+}
+sub T2H_DEFAULT_print_Overview
+{
+ return &$T2H_print_misc(@_);
+}
+sub T2H_DEFAULT_print_Footnotes
+{
+ return &$T2H_print_misc(@_);
+}
+sub T2H_DEFAULT_print_About
+{
+ return &$T2H_print_misc(@_);
+}
+
+sub T2H_DEFAULT_print_misc_header
+{
+ &$T2H_print_page_head(@_) if $T2H_SPLIT;
+ # this needs to be called, otherwise, no labels are set
+ t2h_print_label(@_);
+ &$T2H_print_head_navigation(@_);
+}
+sub T2H_DEFAULT_print_misc_footer
+{
+ &$T2H_print_foot_navigation(@_);
+ &$T2H_print_page_foot(@_) if $T2H_SPLIT;
+}
+sub T2H_DEFAULT_print_misc
+{
+ my $fh = shift;
+ local $T2H_BUTTONS = \@T2H_MISC_BUTTONS;
+ &$T2H_print_misc_header($fh);
+ print $fh "<H1>$T2H_NAME{This}</H1>\n";
+ t2h_print_lines($fh);
+ &$T2H_print_misc_footer($fh);
+}
+
+###################################################################
+# chapter_header and chapter_footer are only called if
+# T2H_SPLIT eq 'chapter'
+# chapter_header: after print_page_header, before print_section
+# chapter_footer: after print_section of last section, before print_page_footer
+#
+# If you want to get rid of navigation stuff after each section,
+# redefine print_section such that it does not call print_navigation,
+# and put print_navigation into print_chapter_header
+@T2H_CHAPTER_BUTTONS =
+ (
+ 'FastBack', 'FastForward', ' ',
+ ' ', ' ', ' ', ' ',
+ 'Top', 'Contents', 'Index', 'About',
+ );
+
+sub T2H_DEFAULT_print_chapter_header
+{
+ # nothing to do there, by default
+ if (! $T2H_SECTION_NAVIGATION)
+ {
+ my $fh = shift;
+ local $T2H_BUTTONS = \@T2H_CHAPTER_BUTTONS;
+ &$T2H_print_navigation($fh);
+ print $fh "\n<HR SIZE=2>\n";
+ }
+}
+
+sub T2H_DEFAULT_print_chapter_footer
+{
+ local $T2H_BUTTONS = \@T2H_CHAPTER_BUTTONS;
+ &$T2H_print_navigation(@_);
+}
+###################################################################
+$T2H_TODAY = &pretty_date; # like "20 September 1993"
+
+sub pretty_date {
+ local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
+
+ ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
+ $year += ($year < 70) ? 2000 : 1900;
+ # obachman: Let's do it as the Americans do
+ return($MONTH_NAMES->{$T2H_LANG}[$mon] . ", " . $mday . " " . $year);
+}
+
+
+###################################################################
+# Layout of standard header and footer
+#
+
+# Set the default body text, inserted between <BODY ... >
+###$T2H_BODYTEXT = 'LANG="EN" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"';
+$T2H_BODYTEXT = 'LANG="' . $T2H_LANG . '" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"';
+# text inserted after <BODY ...>
+$T2H_AFTER_BODY_OPEN = '';
+#text inserted before </BODY>
+$T2H_PRE_BODY_CLOSE = '';
+# this is used in footer
+$T2H_ADDRESS = "by <I>$T2H_USER</I> " if $T2H_USER;
+$T2H_ADDRESS .= "on <I>$T2H_TODAY</I>";
+# this is added inside <HEAD></HEAD> after <TITLE> and some META NAME stuff
+# can be used for <style> <script>, <meta> tags
+$T2H_EXTRA_HEAD = '';
+
+sub T2H_DEFAULT_print_page_head
+{
+ my $fh = shift;
+ my $longtitle = "$T2H_THISDOC{title}: $T2H_NAME{This}";
+ print $fh <<EOT;
+<HTML>
+$T2H_DOCTYPE
+<!-- Created on $T2H_TODAY by $THISPROG -->
+<!--
+$T2H_AUTHORS
+-->
+<HEAD>
+<TITLE>$longtitle</TITLE>
+
+<META NAME="description" CONTENT="$longtitle">
+<META NAME="keywords" CONTENT="$longtitle">
+<META NAME="resource-type" CONTENT="document">
+<META NAME="distribution" CONTENT="global">
+<META NAME="Generator" CONTENT="$THISPROG">
+$T2H_EXTRA_HEAD
+</HEAD>
+
+<BODY $T2H_BODYTEXT>
+$T2H_AFTER_BODY_OPEN
+EOT
+}
+
+sub T2H_DEFAULT_print_page_foot
+{
+ my $fh = shift;
+ print $fh <<EOT;
+<BR>
+<FONT SIZE="-1">
+This document was generated
+$T2H_ADDRESS
+using <A HREF="$T2H_HOMEPAGE"><I>texi2html</I></A>
+$T2H_PRE_BODY_CLOSE
+</BODY>
+</HTML>
+EOT
+}
+
+###################################################################
+# Layout of navigation panel
+
+# if this is set, then a vertical navigation panel is used
+$T2H_VERTICAL_HEAD_NAVIGATION = 0;
+sub T2H_DEFAULT_print_head_navigation
+{
+ my $fh = shift;
+ if ($T2H_VERTICAL_HEAD_NAVIGATION)
+ {
+ print $fh <<EOT;
+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
+<TR VALIGN="TOP">
+<TD ALIGN="LEFT">
+EOT
+ }
+ &$T2H_print_navigation($fh, $T2H_VERTICAL_HEAD_NAVIGATION);
+ if ($T2H_VERTICAL_HEAD_NAVIGATION)
+ {
+ print $fh <<EOT;
+</TD>
+<TD ALIGN="LEFT">
+EOT
+ }
+ elsif ($T2H_SPLIT eq 'section')
+ {
+ print $fh "<HR SIZE=1>\n";
+ }
+}
+
+# Specifies the minimum page length required before a navigation panel
+# is placed at the bottom of a page (the default is that of latex2html)
+# T2H_THIS_WORDS_IN_PAGE holds number of words of current page
+$T2H_WORDS_IN_PAGE = 300;
+sub T2H_DEFAULT_print_foot_navigation
+{
+ my $fh = shift;
+ my $nwords = shift;
+ if ($T2H_VERTICAL_HEAD_NAVIGATION)
+ {
+ print $fh <<EOT;
+</TD>
+</TR>
+</TABLE>
+EOT
+ }
+ print $fh "<HR SIZE=1>\n";
+ &$T2H_print_navigation($fh) if ($nwords >= $T2H_WORDS_IN_PAGE)
+}
+
+######################################################################
+# navigation panel
+#
+# specify in this array which "buttons" should appear in which order
+# in the navigation panel for sections; use ' ' for empty buttons (space)
+@T2H_SECTION_BUTTONS =
+ (
+ 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward',
+ ' ', ' ', ' ', ' ',
+ 'Top', 'Contents', 'Index', 'About',
+ );
+
+# buttons for misc stuff
+@T2H_MISC_BUTTONS = ('Top', 'Contents', 'Index', 'About');
+
+# insert here name of icon images for buttons
+# Icons are used, if $T2H_ICONS and resp. value are set
+%T2H_ACTIVE_ICONS =
+ (
+ 'Top', '',
+ 'Contents', '',
+ 'Overview', '',
+ 'Index', '',
+ 'Back', '',
+ 'FastBack', '',
+ 'Prev', '',
+ 'Up', '',
+ 'Next', '',
+ 'Forward', '',
+ 'FastForward', '',
+ 'About' , '',
+ 'First', '',
+ 'Last', '',
+ ' ', ''
+ );
+
+# insert here name of icon images for these, if button is inactive
+%T2H_PASSIVE_ICONS =
+ (
+ 'Top', '',
+ 'Contents', '',
+ 'Overview', '',
+ 'Index', '',
+ 'Back', '',
+ 'FastBack', '',
+ 'Prev', '',
+ 'Up', '',
+ 'Next', '',
+ 'Forward', '',
+ 'FastForward', '',
+ 'About', '',
+ 'First', '',
+ 'Last', '',
+ );
+
+# how to create IMG tag
+sub T2H_DEFAULT_button_icon_img
+{
+ my $button = shift;
+ my $icon = shift;
+ my $name = shift;
+ return qq{<IMG SRC="$icon" BORDER="0" ALT="$button: $name" ALIGN="MIDDLE">};
+}
+
+# Names of text as alternative for icons
+%T2H_NAVIGATION_TEXT =
+ (
+ 'Top', 'Top',
+ 'Contents', 'Contents',
+ 'Overview', 'Overview',
+ 'Index', 'Index',
+ ' ', ' &nbsp; ',
+ 'Back', ' &lt; ',
+ 'FastBack', ' &lt;&lt; ',
+ 'Prev', 'Prev',
+ 'Up', ' Up ',
+ 'Next', 'Next',
+ 'Forward', ' &gt; ',
+ 'FastForward', ' &gt;&gt; ',
+ 'About', ' ? ',
+ 'First', ' |&lt; ',
+ 'Last', ' &gt;| '
+ );
+
+sub T2H_DEFAULT_print_navigation
+{
+ my $fh = shift;
+ my $vertical = shift;
+ my $spacing = 1;
+ print $fh "<TABLE CELLPADDING=$spacing CELLSPACING=$spacing BORDER=0>\n";
+
+ print $fh "<TR>" unless $vertical;
+ for $button (@$T2H_BUTTONS)
+ {
+ print $fh qq{<TR VALIGN="TOP" ALIGN="LEFT">\n} if $vertical;
+ print $fh qq{<TD VALIGN="MIDDLE" ALIGN="LEFT">};
+
+ if (ref($button) eq 'CODE')
+ {
+ &$button($fh, $vertical);
+ }
+ elsif ($button eq ' ')
+ { # handle space button
+ print $fh
+ $T2H_ICONS && $T2H_ACTIVE_ICONS{' '} ?
+ &$T2H_button_icon_img($button, $T2H_ACTIVE_ICONS{' '}) :
+ $T2H_NAVIGATION_TEXT{' '};
+ next;
+ }
+ elsif ($T2H_HREF{$button})
+ { # button is active
+ print $fh
+ $T2H_ICONS && $T2H_ACTIVE_ICONS{$button} ? # use icon ?
+ t2h_anchor('', $T2H_HREF{$button}, # yes
+ &$T2H_button_icon_img($button,
+ $T2H_ACTIVE_ICONS{$button},
+ $T2H_NAME{$button}))
+ : # use text
+ "[" .
+ t2h_anchor('', $T2H_HREF{$button}, $T2H_NAVIGATION_TEXT{$button}) .
+ "]";
+ }
+ else
+ { # button is passive
+ print $fh
+ $T2H_ICONS && $T2H_PASSIVE_ICONS{$button} ?
+ &$T2H_button_icon_img($button,
+ $T2H_PASSIVE_ICONS{$button},
+ $T2H_NAME{$button}) :
+
+ "[" . $T2H_NAVIGATION_TEXT{$button} . "]";
+ }
+ print $fh "</TD>\n";
+ print $fh "</TR>\n" if $vertical;
+ }
+ print $fh "</TR>" unless $vertical;
+ print $fh "</TABLE>\n";
+}
+
+######################################################################
+# Frames: this is from "Richard Y. Kim" <ryk@coho.net>
+# Should be improved to be more conforming to other _print* functions
+
+sub T2H_DEFAULT_print_frame
+{
+ my $fh = shift;
+ print $fh <<EOT;
+<HTML>
+<HEAD><TITLE>$T2H_THISDOC{title}</TITLE></HEAD>
+<FRAMESET cols="140,*">
+ <FRAME name=toc src="$docu_toc_frame_file">
+ <FRAME name=main src="$docu_doc">
+</FRAMESET>
+</HTML>
+EOT
+}
+
+sub T2H_DEFAULT_print_toc_frame
+{
+ my $fh = shift;
+ &$T2H_print_page_head($fh);
+ print $fh <<EOT;
+<H2>Content</H2>
+EOT
+ print $fh map {s/HREF=/target=\"main\" HREF=/; $_;} @stoc_lines;
+ print $fh "</BODY></HTML>\n";
+}
+
+######################################################################
+# About page
+#
+
+# T2H_PRE_ABOUT might be a function
+$T2H_PRE_ABOUT = <<EOT;
+This document was generated $T2H_ADDRESS
+using <A HREF="$T2H_HOMEPAGE"><I>texi2html</I></A>
+<P></P>
+EOT
+$T2H_AFTER_ABOUT = '';
+
+sub T2H_DEFAULT_about_body
+{
+ my $about;
+ if (ref($T2H_PRE_ABOUT) eq 'CODE')
+ {
+ $about = &$T2H_PRE_ABOUT();
+ }
+ else
+ {
+ $about = $T2H_PRE_ABOUT;
+ }
+ $about .= <<EOT;
+The buttons in the navigation panels have the following meaning:
+<P></P>
+<table border = "1">
+<TR>
+<TH> Button </TH>
+<TH> Name </TH>
+<TH> Go to </TH>
+<TH> From 1.2.3 go to</TH>
+</TR>
+EOT
+
+ for $button (@T2H_SECTION_BUTTONS)
+ {
+ next if $button eq ' ' || ref($button) eq 'CODE';
+ $about .= <<EOT;
+<TR>
+<TD ALIGN="CENTER">
+EOT
+ $about .=
+ ($T2H_ICONS && $T2H_ACTIVE_ICONS{$button} ?
+ &$T2H_button_icon_img($button, $T2H_ACTIVE_ICONS{$button}) :
+ " [" . $T2H_NAVIGATION_TEXT{$button} . "] ");
+ $about .= <<EOT;
+</TD>
+<TD ALIGN="CENTER">
+$button
+</TD>
+<TD>
+$T2H_BUTTONS_GOTO{$button}
+</TD>
+<TD>
+$T2H_BUTTONS_EXAMPLE{$button}
+</TD>
+</TR>
+EOT
+ }
+
+ $about .= <<EOT;
+</TABLE>
+<P></P>
+where the <STRONG> Example </STRONG> assumes that the current position
+is at <STRONG> Subsubsection One-Two-Three </STRONG> of a document of
+the following structure:
+<UL>
+<LI> 1. Section One </LI>
+<UL>
+<LI>1.1 Subsection One-One</LI>
+<UL>
+<LI> ... </LI>
+</UL>
+<LI>1.2 Subsection One-Two</LI>
+<UL>
+<LI>1.2.1 Subsubsection One-Two-One
+</LI><LI>1.2.2 Subsubsection One-Two-Two
+</LI><LI>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp; <STRONG>
+&lt;== Current Position </STRONG>
+</LI><LI>1.2.4 Subsubsection One-Two-Four
+</LI></UL>
+<LI>1.3 Subsection One-Three</LI>
+<UL>
+<LI> ... </LI>
+</UL>
+<LI>1.4 Subsection One-Four</LI>
+</UL>
+</UL>
+$T2H_AFTER_ABOUT
+EOT
+ return $about;
+}
+
+
+%T2H_BUTTONS_GOTO =
+ (
+ 'Top', 'cover (top) of document',
+ 'Contents', 'table of contents',
+ 'Overview', 'short table of contents',
+ 'Index', 'concept index',
+ 'Back', 'previous section in reading order',
+ 'FastBack', 'previous or up-and-previous section ',
+ 'Prev', 'previous section same level',
+ 'Up', 'up section',
+ 'Next', 'next section same level',
+ 'Forward', 'next section in reading order',
+ 'FastForward', 'next or up-and-next section',
+ 'About' , 'this page',
+ 'First', 'first section in reading order',
+ 'Last', 'last section in reading order',
+ );
+
+%T2H_BUTTONS_EXAMPLE =
+(
+ 'Top', ' &nbsp; ',
+ 'Contents', ' &nbsp; ',
+ 'Overview', ' &nbsp; ',
+ 'Index', ' &nbsp; ',
+ 'Back', '1.2.2',
+ 'FastBack', '1.1',
+ 'Prev', '1.2.2',
+ 'Up', '1.2',
+ 'Next', '1.2.4',
+ 'Forward', '1.2.4',
+ 'FastForward', '1.3',
+ 'About', ' &nbsp; ',
+ 'First', '1.',
+ 'Last', '1.2.4',
+);
+
+
+######################################################################
+# from here on, its l2h init stuff
+#
+
+## initialization for latex2html as for Singular manual generation
+## obachman 3/99
+
+#
+# Options controlling Titles, File-Names, Tracing and Sectioning
+#
+$TITLE = '';
+
+$SHORTEXTN = 0;
+
+$LONG_TITLES = 0;
+
+$DESTDIR = ''; # should be overwritten by cmd-line argument
+
+$NO_SUBDIR = 0;# should be overwritten by cmd-line argument
+
+$PREFIX = ''; # should be overwritten by cmd-line argument
+
+$AUTO_PREFIX = 0; # this is needed, so that prefix settings are used
+
+$AUTO_LINK = 0;
+
+$SPLIT = 0;
+
+$MAX_LINK_DEPTH = 0;
+
+$TMP = ''; # should be overwritten by cmd-line argument
+
+$DEBUG = 0;
+
+$VERBOSE = 1;
+
+#
+# Options controlling Extensions and Special Features
+#
+$HTML_VERSION = "3.2";
+
+$TEXDEFS = 1; # we absolutely need that
+
+$EXTERNAL_FILE = '';
+
+$SCALABLE_FONTS = 1;
+
+$NO_SIMPLE_MATH = 1;
+
+$LOCAL_ICONS = 1;
+
+$SHORT_INDEX = 0;
+
+$NO_FOOTNODE = 1;
+
+$ADDRESS = '';
+
+$INFO = '';
+
+#
+# Switches controlling Image Generation
+#
+$ASCII_MODE = 0;
+
+$NOLATEX = 0;
+
+$EXTERNAL_IMAGES = 0;
+
+$PS_IMAGES = 0;
+
+$NO_IMAGES = 0;
+
+$IMAGES_ONLY = 0;
+
+$REUSE = 2;
+
+$ANTI_ALIAS = 1;
+
+$ANTI_ALIAS_TEXT = 1;
+
+#
+#Switches controlling Navigation Panels
+#
+$NO_NAVIGATION = 1;
+$ADDRESS = '';
+$INFO = 0; # 0 = do not make a "About this document..." section
+
+#
+#Switches for Linking to other documents
+#
+# actuall -- we don't care
+
+$MAX_SPLIT_DEPTH = 0; # Stop making separate files at this depth
+
+$MAX_LINK_DEPTH = 0; # Stop showing child nodes at this depth
+
+$NOLATEX = 0; # 1 = do not pass unknown environments to Latex
+
+$EXTERNAL_IMAGES = 0; # 1 = leave the images outside the document
+
+$ASCII_MODE = 0; # 1 = do not use any icons or internal images
+
+# 1 = use links to external postscript images rather than inlined bitmap
+# images.
+$PS_IMAGES = 0;
+$SHOW_SECTION_NUMBERS = 0;
+
+### Other global variables ###############################################
+$CHILDLINE = "";
+
+# This is the line width measured in pixels and it is used to right justify
+# equations and equation arrays;
+$LINE_WIDTH = 500;
+
+# Used in conjunction with AUTO_NAVIGATION
+$WORDS_IN_PAGE = 300;
+
+# Affects ONLY the way accents are processed
+$default_language = 'english';
+
+# The value of this variable determines how many words to use in each
+# title that is added to the navigation panel (see below)
+#
+$WORDS_IN_NAVIGATION_PANEL_TITLES = 0;
+
+# This number will determine the size of the equations, special characters,
+# and anything which will be converted into an inlined image
+# *except* "image generating environments" such as "figure", "table"
+# or "minipage".
+# Effective values are those greater than 0.
+# Sensible values are between 0.1 - 4.
+$MATH_SCALE_FACTOR = 1.5;
+
+# This number will determine the size of
+# image generating environments such as "figure", "table" or "minipage".
+# Effective values are those greater than 0.
+# Sensible values are between 0.1 - 4.
+$FIGURE_SCALE_FACTOR = 1.6;
+
+
+# If both of the following two variables are set then the "Up" button
+# of the navigation panel in the first node/page of a converted document
+# will point to $EXTERNAL_UP_LINK. $EXTERNAL_UP_TITLE should be set
+# to some text which describes this external link.
+$EXTERNAL_UP_LINK = "";
+$EXTERNAL_UP_TITLE = "";
+
+# If this is set then the resulting HTML will look marginally better if viewed
+# with Netscape.
+$NETSCAPE_HTML = 1;
+
+# Valid paper sizes are "letter", "legal", "a4","a3","a2" and "a0"
+# Paper sizes has no effect other than in the time it takes to create inlined
+# images and in whether large images can be created at all ie
+# - larger paper sizes *MAY* help with large image problems
+# - smaller paper sizes are quicker to handle
+$PAPERSIZE = "a4";
+
+# Replace "english" with another language in order to tell LaTeX2HTML that you
+# want some generated section titles (eg "Table of Contents" or "References")
+# to appear in a different language. Currently only "english" and "french"
+# is supported but it is very easy to add your own. See the example in the
+# file "latex2html.config"
+$TITLES_LANGUAGE = "english";
+
+1; # This must be the last non-comment line
+
+# End File texi2html.init
+######################################################################
+
+
+require "$ENV{T2H_HOME}/texi2html.init"
+ if ($0 =~ /\.pl$/ &&
+ -e "$ENV{T2H_HOME}/texi2html.init" && -r "$ENV{T2H_HOME}/texi2html.init");
+
+#+++############################################################################
+# #
+# Initialization #
+# Pasted content of File $(srcdir)/MySimple.pm: Command-line processing #
+# #
+#---############################################################################
+
+# leave this within comments, and keep the require statement
+# This way, you can directly run texi2html.pl, if $ENV{T2H_HOME}/texi2html.init
+# exists.
+
+#
+package Getopt::MySimple;
+
+# Name:
+# Getopt::MySimple.
+#
+# Documentation:
+# POD-style (incomplete) documentation is in file MySimple.pod
+#
+# Tabs:
+# 4 spaces || die.
+#
+# Author:
+# Ron Savage rpsavage@ozemail.com.au.
+# 1.00 19-Aug-97 Initial version.
+# 1.10 13-Oct-97 Add arrays of switches (eg '=s@').
+# 1.20 3-Dec-97 Add 'Help' on a per-switch basis.
+# 1.30 11-Dec-97 Change 'Help' to 'verbose'. Make all hash keys lowercase.
+# 1.40 10-Nov-98 Change width of help report. Restructure tests.
+# 1-Jul-00 Modifications for Texi2html
+
+# --------------------------------------------------------------------------
+# Locally modified by obachman (Display type instead of env, order by cmp)
+# $Id: MySimple.pm,v 1.1 2000/07/03 08:44:13 obachman Exp $
+
+# use strict;
+# no strict 'refs';
+
+use vars qw(@EXPORT @EXPORT_OK @ISA);
+use vars qw($fieldWidth $opt $VERSION);
+
+use Exporter();
+use Getopt::Long;
+
+@ISA = qw(Exporter);
+@EXPORT = qw();
+@EXPORT_OK = qw($opt); # An alias for $self -> {'opt'}.
+
+# --------------------------------------------------------------------------
+
+$fieldWidth = 20;
+$VERSION = '1.41';
+
+# --------------------------------------------------------------------------
+
+sub byOrder
+{
+ my($self) = @_;
+
+ return uc($a) cmp (uc($b));
+}
+
+# --------------------------------------------------------------------------
+
+sub dumpOptions
+{
+ my($self) = @_;
+
+ print 'Option', ' ' x ($fieldWidth - length('Option') ), "Value\n";
+
+ for (sort byOrder keys(%{$self -> {'opt'} }) )
+ {
+ print "-$_", ' ' x ($fieldWidth - (1 + length) ), "${$self->{'opt'} }{$_}\n";
+ }
+
+ print "\n";
+
+} # End of dumpOptions.
+
+# --------------------------------------------------------------------------
+# Return:
+# 0 -> Error.
+# 1 -> Ok.
+
+sub getOptions
+{
+ push(@_, 0) if ($#_ == 2); # Default for $ignoreCase is 0.
+ push(@_, 1) if ($#_ == 3); # Default for $helpThenExit is 1.
+
+ my($self, $default, $helpText, $versionText,
+ $helpThenExit, $versionThenExit, $ignoreCase) = @_;
+
+ $helpThenExit = 1 unless (defined($helpThenExit));
+ $versionThenExit = 1 unless (defined($versionThenExit));
+ $ignoreCase = 0 unless (defined($ignoreCase));
+
+ $self -> {'default'} = $default;
+ $self -> {'helpText'} = $helpText;
+ $self -> {'versionText'} = $versionText;
+ $Getopt::Long::ignorecase = $ignoreCase;
+
+ unless (defined($self -> {'default'}{'help'}))
+ {
+ $self -> {'default'}{'help'} =
+ {
+ type => ':i',
+ default => '',
+ linkage => sub {$self->helpOptions($_[1]); exit (0) if $helpThenExit;},
+ verbose => "print help and exit"
+ };
+ }
+
+ unless (defined($self -> {'default'}{'version'}))
+ {
+ $self -> {'default'}{'version'} =
+ {
+ type => '',
+ default => '',
+ linkage => sub {print $self->{'versionText'}; exit (0) if versionTheExit;},
+ verbose => "print version and exit"
+ };
+ }
+
+ for (keys(%{$self -> {'default'} }) )
+ {
+ my $type = ${$self -> {'default'} }{$_}{'type'};
+ push(@{$self -> {'type'} }, "$_$type");
+ $self->{'opt'}->{$_} = ${$self -> {'default'} }{$_}{'linkage'}
+ if ${$self -> {'default'} }{$_}{'linkage'};
+ }
+
+ my($result) = &GetOptions($self -> {'opt'}, @{$self -> {'type'} });
+
+ return $result unless $result;
+
+ for (keys(%{$self -> {'default'} }) )
+ {
+ if (! defined(${$self -> {'opt'} }{$_})) #{
+ {
+ ${$self -> {'opt'} }{$_} = ${$self -> {'default'} }{$_}{'default'};
+ }
+ }
+
+ $result;
+} # End of getOptions.
+
+# --------------------------------------------------------------------------
+
+sub helpOptions
+{
+ my($self) = shift;
+ my($noHelp) = shift;
+ $noHelp = 0 unless $noHelp;
+ my($optwidth, $typewidth, $defaultwidth, $maxlinewidth, $valind, $valwidth)
+ = (10, 5, 9, 78, 4, 11);
+
+ print "$self->{'helpText'}" if ($self -> {'helpText'});
+
+ print ' Option', ' ' x ($optwidth - length('Option') -1 ),
+ 'Type', ' ' x ($typewidth - length('Type') + 1),
+ 'Default', ' ' x ($defaultwidth - length('Default') ),
+ "Description\n";
+
+ for (sort byOrder keys(%{$self -> {'default'} }) )
+ {
+ my($line, $help, $option, $val);
+ $option = $_;
+ next if ${$self->{'default'} }{$_}{'noHelp'} && ${$self->{'default'} }{$_}{'noHelp'} > $noHelp;
+ $line = " -$_ " . ' ' x ($optwidth - (2 + length) ) .
+ "${$self->{'default'} }{$_}{'type'} ".
+ ' ' x ($typewidth - (1+length(${$self -> {'default'} }{$_}{'type'}) ));
+
+ $val = ${$self->{'default'} }{$_}{'linkage'};
+ if ($val)
+ {
+ if (ref($val) eq 'SCALAR')
+ {
+ $val = $$val;
+ }
+ else
+ {
+ $val = '';
+ }
+ }
+ else
+ {
+ $val = ${$self->{'default'} }{$_}{'default'};
+ }
+ $line .= "$val ";
+ $line .= ' ' x ($optwidth + $typewidth + $defaultwidth + 1 - length($line));
+
+ if (defined(${$self -> {'default'} }{$_}{'verbose'}) &&
+ ${$self -> {'default'} }{$_}{'verbose'} ne '')
+ {
+ $help = "${$self->{'default'} }{$_}{'verbose'}";
+ }
+ else
+ {
+ $help = ' ';
+ }
+ if ((length("$line") + length($help)) < $maxlinewidth)
+ {
+ print $line , $help, "\n";
+ }
+ else
+ {
+ print $line, "\n", ' ' x $valind, $help, "\n";
+ }
+ for $val (sort byOrder keys(%{${$self->{'default'}}{$option}{'values'}}))
+ {
+ print ' ' x ($valind + 2);
+ print $val, ' ', ' ' x ($valwidth - length($val) - 2);
+ print ${$self->{'default'}}{$option}{'values'}{$val}, "\n";
+ }
+ }
+
+ print <<EOT;
+Note: 'Options' may be abbreviated. 'Type' specifications mean:
+ <none>| ! no argument: variable is set to 1 on -foo (or, to 0 on -nofoo)
+ =s | :s mandatory (or, optional) string argument
+ =i | :i mandatory (or, optional) integer argument
+EOT
+} # End of helpOptions.
+
+#-------------------------------------------------------------------
+
+sub new
+{
+ my($class) = @_;
+ my($self) = {};
+ $self -> {'default'} = {};
+ $self -> {'helpText'} = '';
+ $self -> {'opt'} = {};
+ $opt = $self -> {'opt'}; # An alias for $self -> {'opt'}.
+ $self -> {'type'} = ();
+
+ return bless $self, $class;
+
+} # End of new.
+
+# --------------------------------------------------------------------------
+
+1;
+
+# End MySimple.pm
+
+require "$ENV{T2H_HOME}/MySimple.pm"
+ if ($0 =~ /\.pl$/ &&
+ -e "$ENV{T2H_HOME}/texi2html.init" && -r "$ENV{T2H_HOME}/texi2html.init");
+
+package main;
+
+#+++############################################################################
+# #
+# Constants #
+# #
+#---############################################################################
+
+$DEBUG_TOC = 1;
+$DEBUG_INDEX = 2;
+$DEBUG_BIB = 4;
+$DEBUG_GLOSS = 8;
+$DEBUG_DEF = 16;
+$DEBUG_HTML = 32;
+$DEBUG_USER = 64;
+$DEBUG_L2H = 128;
+
+
+$BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference
+$FILERE = '[\/\w.+-]+'; # RE for a file name
+$VARRE = '[^\s\{\}]+'; # RE for a variable name
+$NODERE = '[^,:]+'; # RE for a node name
+$NODESRE = '[^:]+'; # RE for a list of node names
+
+$ERROR = "***"; # prefix for errors
+$WARN = "**"; # prefix for warnings
+
+ # program home page
+$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections
+
+$CHAPTEREND = "<!-- End chapter -->\n"; # to know where a chpater ends
+$SECTIONEND = "<!-- End section -->\n"; # to know where section ends
+$TOPEND = "<!-- End top -->\n"; # to know where top ends
+
+
+
+#
+# pre-defined indices
+#
+$index_properties =
+{
+ 'c' => { name => 'cp'},
+ 'f' => { name => 'fn', code => 1},
+ 'v' => { name => 'vr', code => 1},
+ 'k' => { name => 'ky', code => 1},
+ 'p' => { name => 'pg', code => 1},
+ 't' => { name => 'tp', code => 1}
+};
+
+
+%predefined_index = (
+ 'cp', 'c',
+ 'fn', 'f',
+ 'vr', 'v',
+ 'ky', 'k',
+ 'pg', 'p',
+ 'tp', 't',
+ );
+
+#
+# valid indices
+#
+%valid_index = (
+ 'c', 1,
+ 'f', 1,
+ 'v', 1,
+ 'k', 1,
+ 'p', 1,
+ 't', 1,
+ );
+
+#
+# texinfo section names to level
+#
+%sec2level = (
+ 'top', 0,
+ 'chapter', 1,
+ 'unnumbered', 1,
+ 'majorheading', 1,
+ 'chapheading', 1,
+ 'appendix', 1,
+ 'section', 2,
+ 'unnumberedsec', 2,
+ 'heading', 2,
+ 'appendixsec', 2,
+ 'appendixsection', 2,
+ 'subsection', 3,
+ 'unnumberedsubsec', 3,
+ 'subheading', 3,
+ 'appendixsubsec', 3,
+ 'subsubsection', 4,
+ 'unnumberedsubsubsec', 4,
+ 'subsubheading', 4,
+ 'appendixsubsubsec', 4,
+ );
+
+#
+# accent map, TeX command to ISO name
+#
+%accent_map = (
+ '"', 'uml',
+ '~', 'tilde',
+ '^', 'circ',
+ '`', 'grave',
+ '\'', 'acute',
+ );
+
+#
+# texinfo "simple things" (@foo) to HTML ones
+#
+%simple_map = (
+ # cf. makeinfo.c
+ "*", "<BR>", # HTML+
+ " ", " ",
+ "\t", " ",
+ "-", "&#173;", # soft hyphen
+ "\n", "\n",
+ "|", "",
+ 'tab', '<\/TD><TD>',
+ # spacing commands
+ ":", "",
+ "!", "!",
+ "?", "?",
+ ".", ".",
+ "-", "",
+ );
+
+#
+# texinfo "things" (@foo{}) to HTML ones
+#
+%things_map = (
+ 'TeX', 'TeX',
+ 'br', '<P>', # paragraph break
+ 'bullet', '*',
+ 'copyright', '(C)',
+ 'dots', '<small>...<\/small>',
+ 'enddots', '<small>....<\/small>',
+ 'equiv', '==',
+ 'error', 'error-->',
+ 'expansion', '==>',
+ 'minus', '-',
+ 'point', '-!-',
+ 'print', '-|',
+ 'result', '=>',
+ 'today', $T2H_TODAY,
+ 'aa', '&aring;',
+ 'AA', '&Aring;',
+ 'ae', '&aelig;',
+ 'oe', '&#156;',
+ 'AE', '&AElig;',
+ 'OE', '&#140;',
+ 'o', '&oslash;',
+ 'O', '&Oslash;',
+ 'ss', '&szlig;',
+ 'l', '\/l',
+ 'L', '\/L',
+ 'exclamdown', '&iexcl;',
+ 'questiondown', '&iquest;',
+ 'pounds', '&pound;'
+ );
+
+#
+# texinfo styles (@foo{bar}) to HTML ones
+#
+%style_map = (
+ 'acronym', '&do_acronym',
+ 'asis', '',
+ 'b', 'B',
+ 'cite', 'CITE',
+ 'code', 'CODE',
+ 'command', 'CODE',
+ 'ctrl', '&do_ctrl', # special case
+ 'dfn', 'EM', # DFN tag is illegal in the standard
+ 'dmn', '', # useless
+ 'email', '&do_email', # insert a clickable email address
+ 'emph', 'EM',
+ 'env', 'CODE',
+ 'file', '"TT', # will put quotes, cf. &apply_style
+ 'i', 'I',
+ 'kbd', 'KBD',
+ 'key', 'KBD',
+ 'math', '&do_math',
+ 'option', '"SAMP', # will put quotes, cf. &apply_style
+ 'r', '', # unsupported
+ 'samp', '"SAMP', # will put quotes, cf. &apply_style
+ 'sc', '&do_sc', # special case
+ 'strong', 'STRONG',
+ 't', 'TT',
+ 'titlefont', '', # useless
+ 'uref', '&do_uref', # insert a clickable URL
+ 'url', '&do_url', # insert a clickable URL
+ 'var', 'VAR',
+ 'w', '', # unsupported
+ 'H', '&do_accent',
+ 'dotaccent', '&do_accent',
+ 'ringaccent','&do_accent',
+ 'tieaccent', '&do_accent',
+ 'u','&do_accent',
+ 'ubaraccent','&do_accent',
+ 'udotaccent','&do_accent',
+ 'v', '&do_accent',
+ ',', '&do_accent',
+ 'dotless', '&do_accent'
+ );
+
+#
+# texinfo format (@foo/@end foo) to HTML ones
+#
+%format_map = (
+ 'quotation', 'BLOCKQUOTE',
+ # lists
+ 'itemize', 'UL',
+ 'enumerate', 'OL',
+ # poorly supported
+ 'flushleft', 'PRE',
+ 'flushright', 'PRE',
+ );
+
+#
+# an eval of these $complex_format_map->{what}->[0] yields beginning
+# an eval of these $complex_format_map->{what}->[1] yieleds end
+$complex_format_map =
+{
+ example =>
+ [
+ q{"<TABLE><tr>$T2H_EXAMPLE_INDENT_CELL<td class=example><pre>"},
+ q{'</pre></td></tr></table>'}
+ ],
+ smallexample =>
+ [
+ q{"<TABLE><tr>$T2H_SMALL_EXAMPLE_INDENT_CELL<td class=smallexample><FONT SIZE=$T2H_SMALL_FONT_SIZE><pre>"},
+ q{'</FONT></pre></td></tr></table>'}
+ ],
+ display =>
+ [
+ q{"<TABLE><tr>$T2H_EXAMPLE_INDENT_CELL<td class=display><pre " . 'style="font-family: serif">'},
+ q{'</pre></td></tr></table>'}
+ ],
+ smalldisplay =>
+ [
+ q{"<TABLE><tr>$T2H_SMALL_EXAMPLE_INDENT_CELL<td class=smalldisplay><FONT SIZE=$T2H_SMALL_FONT_SIZE><pre " . 'style="font-family: serif">'},
+ q{'</pre></FONT></td></tr></table>'}
+ ]
+};
+
+$complex_format_map->{lisp} = $complex_format_map->{example};
+$complex_format_map->{smalllisp} = $complex_format_map->{smallexample};
+$complex_format_map->{format} = $complex_format_map->{display};
+$complex_format_map->{smallformat} = $complex_format_map->{smalldisplay};
+
+#
+# texinfo definition shortcuts to real ones
+#
+%def_map = (
+ # basic commands
+ 'deffn', 0,
+ 'defvr', 0,
+ 'deftypefn', 0,
+ 'deftypevr', 0,
+ 'defcv', 0,
+ 'defop', 0,
+ 'deftp', 0,
+ # basic x commands
+ 'deffnx', 0,
+ 'defvrx', 0,
+ 'deftypefnx', 0,
+ 'deftypevrx', 0,
+ 'defcvx', 0,
+ 'defopx', 0,
+ 'deftpx', 0,
+ # shortcuts
+ 'defun', 'deffn Function',
+ 'defmac', 'deffn Macro',
+ 'defspec', 'deffn {Special Form}',
+ 'defvar', 'defvr Variable',
+ 'defopt', 'defvr {User Option}',
+ 'deftypefun', 'deftypefn Function',
+ 'deftypevar', 'deftypevr Variable',
+ 'defivar', 'defcv {Instance Variable}',
+ 'deftypeivar', 'defcv {Instance Variable}', # NEW: FIXME
+ 'defmethod', 'defop Method',
+ 'deftypemethod', 'defop Method', # NEW:FIXME
+ # x shortcuts
+ 'defunx', 'deffnx Function',
+ 'defmacx', 'deffnx Macro',
+ 'defspecx', 'deffnx {Special Form}',
+ 'defvarx', 'defvrx Variable',
+ 'defoptx', 'defvrx {User Option}',
+ 'deftypefunx', 'deftypefnx Function',
+ 'deftypevarx', 'deftypevrx Variable',
+ 'defivarx', 'defcvx {Instance Variable}',
+ 'defmethodx', 'defopx Method',
+ );
+
+#
+# things to skip
+#
+%to_skip = (
+ # comments
+ 'c', 1,
+ 'comment', 1,
+ 'ifnotinfo', 1,
+ 'ifnottex', 1,
+ 'ifhtml', 1,
+ 'end ifhtml', 1,
+ 'end ifnotinfo', 1,
+ 'end ifnottex', 1,
+ # useless
+ 'detailmenu', 1,
+ 'direntry', 1,
+ 'contents', 1,
+ 'shortcontents', 1,
+ 'summarycontents', 1,
+ 'footnotestyle', 1,
+ 'end ifclear', 1,
+ 'end ifset', 1,
+ 'titlepage', 1,
+ 'end titlepage', 1,
+ # unsupported commands (formatting)
+ 'afourpaper', 1,
+ 'cropmarks', 1,
+ 'finalout', 1,
+ 'headings', 1,
+ 'sp', 1,
+ 'need', 1,
+ 'page', 1,
+ 'setchapternewpage', 1,
+ 'everyheading', 1,
+ 'everyfooting', 1,
+ 'evenheading', 1,
+ 'evenfooting', 1,
+ 'oddheading', 1,
+ 'oddfooting', 1,
+ 'smallbook', 1,
+ 'vskip', 1,
+ 'filbreak', 1,
+ 'paragraphindent', 1,
+ # unsupported formats
+ 'cartouche', 1,
+ 'end cartouche', 1,
+ 'group', 1,
+ 'end group', 1,
+ );
+
+#+++############################################################################
+# #
+# Argument parsing, initialisation #
+# #
+#---############################################################################
+
+#
+# flush stdout and stderr after every write
+#
+select(STDERR);
+$| = 1;
+select(STDOUT);
+$| = 1;
+
+
+%value = (); # hold texinfo variables, see also -D
+$use_bibliography = 1;
+$use_acc = 1;
+
+#
+# called on -init-file
+sub LoadInitFile
+{
+ my $init_file = shift;
+ # second argument is value of options
+ $init_file = shift;
+ if (-f $init_file)
+ {
+ print "# reading initialization file from $init_file\n"
+ if ($T2H_VERBOSE);
+ require($init_file);
+ }
+ else
+ {
+ print "$ERROR Error: can't read init file $int_file\n";
+ $init_file = '';
+ }
+}
+
+#
+# called on -lang
+sub SetDocumentLanguage
+{
+ my $lang = shift;
+ if (! exists($T2H_WORDS->{$lang}))
+ {
+ warn "$ERROR: Language specs for '$lang' do not exists. Reverting to '" .
+ ($T2H_LANG ? T2H_LANG : "en") . "'\n";
+ }
+ else
+ {
+ print "# using '$lang' as document language\n" if ($T2H_VERBOSE);
+ $T2H_LANG = $lang;
+ }
+}
+
+##
+## obsolete cmd line options
+##
+$T2H_OBSOLETE_OPTIONS -> {'no-section_navigation'} =
+{
+ type => '!',
+ linkage => sub {$main::T2H_SECTION_NAVIGATION = 0;},
+ verbose => 'obsolete, use -nosec_nav',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {use_acc} =
+{
+ type => '!',
+ linkage => \$use_acc,
+ verbose => 'obsolete',
+ noHelp => 2
+};
+$T2H_OBSOLETE_OPTIONS -> {expandinfo} =
+{
+ type => '!',
+ linkage => sub {$main::T2H_EXPAND = 'info';},
+ verbose => 'obsolete, use "-expand info" instead',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {expandtex} =
+{
+ type => '!',
+ linkage => sub {$main::T2H_EXPAND = 'tex';},
+ verbose => 'obsolete, use "-expand tex" instead',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {monolithic} =
+{
+ type => '!',
+ linkage => sub {$main::T2H_SPLIT = '';},
+ verbose => 'obsolete, use "-split no" instead',
+ noHelp => 2
+};
+$T2H_OBSOLETE_OPTIONS -> {split_node} =
+{
+ type => '!',
+ linkage => sub{$main::T2H_SPLIT = 'section';},
+ verbose => 'obsolete, use "-split section" instead',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {split_chapter} =
+{
+ type => '!',
+ linkage => sub{$main::T2H_SPLIT = 'chapter';},
+ verbose => 'obsolete, use "-split chapter" instead',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {no_verbose} =
+{
+ type => '!',
+ linkage => sub {$main::T2H_VERBOSE = 0;},
+ verbose => 'obsolete, use -noverbose instead',
+ noHelp => 2,
+};
+$T2H_OBSOLETE_OPTIONS -> {output_file} =
+{
+ type => '=s',
+ linkage => sub {$main::T2H_OUT = @_[1]; $T2H_SPLIT = '';},
+ verbose => 'obsolete, use -out_file instead',
+ noHelp => 2
+};
+
+$T2H_OBSOLETE_OPTIONS -> {section_navigation} =
+{
+ type => '!',
+ linkage => \$T2H_SECTION_NAVIGATION,
+ verbose => 'obsolete, use -sec_nav instead',
+ noHelp => 2,
+};
+
+$T2H_OBSOLETE_OPTIONS -> {verbose} =
+{
+ type => '!',
+ linkage => \$T2H_VERBOSE,
+ verbose => 'obsolete, use -Verbose instead',
+ noHelp => 2
+};
+
+# read initialzation from $sysconfdir/texi2htmlrc or $HOME/.texi2htmlrc
+my $home = $ENV{HOME};
+defined($home) or $home = '';
+foreach $i ('/usr/local/etc/texi2htmlrc', "$home/.texi2htmlrc") {
+ if (-f $i) {
+ print "# reading initialization file from $i\n"
+ if ($T2H_VERBOSE);
+ require($i);
+ }
+}
+
+
+#+++############################################################################
+# #
+# parse command-line options
+# #
+#---############################################################################
+$T2H_USAGE_TEXT = <<EOT;
+Usage: texi2html [OPTIONS] TEXINFO-FILE
+Translates Texinfo source documentation to HTML.
+EOT
+$T2H_FAILURE_TEXT = <<EOT;
+Try 'texi2html -help' for usage instructions.
+EOT
+$options = new Getopt::MySimple;
+
+# some older version of GetOpt::Long don't have
+# Getopt::Long::Configure("pass_through")
+eval {Getopt::Long::Configure("pass_through");};
+$Configure_failed = $@ && <<EOT;
+**WARNING: Parsing of obsolete command-line options could have failed.
+ Consider to use only documented command-line options (run
+ 'texi2html -help 2' for a complete list) or upgrade to perl
+ version 5.005 or higher.
+EOT
+
+if (! $options->getOptions($T2H_OPTIONS, $T2H_USAGE_TEXT, "$THISVERSION\n"))
+{
+ print $Configure_failed if $Configure_failed;
+ die $T2H_FAILURE_TEXT;
+}
+
+if (@ARGV > 1)
+{
+ eval {Getopt::Long::Configure("no_pass_through");};
+ if (! $options->getOptions($T2H_OBSOLETE_OPTIONS, $T2H_USAGE_TEXT, "$THISVERSION\n"))
+ {
+ print $Configure_failed if $Configure_failed;
+ die $T2H_FAILURE_TEXT;
+ }
+}
+
+if ($T2H_CHECK) {
+ die "Need file to check\n$T2H_FAILURE_TEXT" unless @ARGV > 0;
+ &check;
+ exit;
+}
+
+#+++############################################################################
+# #
+# evaluation of cmd line options
+# #
+#---############################################################################
+
+if ($T2H_EXPAND eq 'info')
+{
+ $to_skip{'ifinfo'} = 1;
+ $to_skip{'end ifinfo'} = 1;
+}
+elsif ($T2H_EXPAND eq 'tex')
+{
+ $to_skip{'iftex'} = 1;
+ $to_skip{'end iftex'} = 1;
+
+}
+
+$T2H_INVISIBLE_MARK = '<IMG SRC="invisible.xbm">' if $T2H_INVISIBLE_MARK eq 'xbm';
+
+#
+# file name buisness
+#
+die "Need exactly one file to translate\n$T2H_FAILURE_TEXT" unless @ARGV == 1;
+$docu = shift(@ARGV);
+if ($docu =~ /.*\//) {
+ chop($docu_dir = $&);
+ $docu_name = $';
+} else {
+ $docu_dir = '.';
+ $docu_name = $docu;
+}
+unshift(@T2H_INCLUDE_DIRS, $docu_dir);
+$docu_name =~ s/\.te?x(i|info)?$//; # basename of the document
+$docu_name = $T2H_PREFIX if ($T2H_PREFIX);
+
+# subdir
+if ($T2H_SUBDIR && ! $T2H_OUT)
+{
+ $T2H_SUBDIR =~ s|/*$||;
+ unless (-d "$T2H_SUBDIR" && -w "$T2H_SUBDIR")
+ {
+ if ( mkdir($T2H_SUBDIR, oct(755)))
+ {
+ print "# created directory $T2H_SUBDIR\n" if ($T2H_VERBOSE);
+ }
+ else
+ {
+ warn "$ERROR can't create directory $T2H_SUBDIR. Put results into current directory\n";
+ $T2H_SUBDIR = '';
+ }
+ }
+}
+
+if ($T2H_SUBDIR && ! $T2H_OUT)
+{
+ $docu_rdir = "$T2H_SUBDIR/";
+ print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
+}
+else
+{
+ if ($T2H_OUT && $T2H_OUT =~ m|(.*)/|)
+ {
+ $docu_rdir = "$1/";
+ print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
+ }
+ else
+ {
+ print "# putting result files into current directory \n" if ($T2H_VERBOSE);
+ $docu_rdir = '';
+ }
+}
+
+# extension
+if ($T2H_SHORTEXTN)
+{
+ $docu_ext = "htm";
+}
+else
+{
+ $docu_ext = "html";
+}
+if ($T2H_TOP_FILE =~ /\..*$/)
+{
+ $T2H_TOP_FILE = $`.".$docu_ext";
+}
+
+# result files
+if (! $T2H_OUT && ($T2H_SPLIT =~ /section/i || $T2H_SPLIT =~ /node/i))
+{
+ $T2H_SPLIT = 'section';
+}
+elsif (! $T2H_OUT && $T2H_SPLIT =~ /chapter/i)
+{
+ $T2H_SPLIT = 'chapter'
+}
+else
+{
+ undef $T2H_SPLIT;
+}
+
+$docu_doc = "$docu_name.$docu_ext"; # document's contents
+$docu_doc_file = "$docu_rdir$docu_doc";
+if ($T2H_SPLIT)
+{
+ $docu_toc = $T2H_TOC_FILE || "${docu_name}_toc.$docu_ext"; # document's table of contents
+ $docu_stoc = "${docu_name}_ovr.$docu_ext"; # document's short toc
+ $docu_foot = "${docu_name}_fot.$docu_ext"; # document's footnotes
+ $docu_about = "${docu_name}_abt.$docu_ext"; # about this document
+ $docu_top = $T2H_TOP_FILE || $docu_doc;
+}
+else
+{
+ if ($T2H_OUT)
+ {
+ $docu_doc = $T2H_OUT;
+ $docu_doc =~ s|.*/||;
+ }
+ $docu_toc = $docu_foot = $docu_stoc = $docu_about = $docu_top = $docu_doc;
+}
+
+$docu_toc_file = "$docu_rdir$docu_toc";
+$docu_stoc_file = "$docu_rdir$docu_stoc";
+$docu_foot_file = "$docu_rdir$docu_foot";
+$docu_about_file = "$docu_rdir$docu_about";
+$docu_top_file = "$docu_rdir$docu_top";
+
+$docu_frame_file = "$docu_rdir${docu_name}_frame.$docu_ext";
+$docu_toc_frame_file = "$docu_rdir${docu_name}_toc_frame.$docu_ext";
+
+#
+# variables
+#
+$value{'html'} = 1; # predefine html (the output format)
+$value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator)
+# _foo: internal to track @foo
+foreach ('_author', '_title', '_subtitle',
+ '_settitle', '_setfilename', '_shorttitle') {
+ $value{$_} = ''; # prevent -w warnings
+}
+%node2sec = (); # node to section name
+%sec2node = (); # section to node name
+%sec2number = (); # section to number
+%number2sec = (); # number to section
+%idx2node = (); # index keys to node
+%node2href = (); # node to HREF
+%node2next = (); # node to next
+%node2prev = (); # node to prev
+%node2up = (); # node to up
+%bib2href = (); # bibliography reference to HREF
+%gloss2href = (); # glossary term to HREF
+@sections = (); # list of sections
+%tag2pro = (); # protected sections
+
+#
+# initial indexes
+#
+$bib_num = 0;
+$foot_num = 0;
+$gloss_num = 0;
+$idx_num = 0;
+$sec_num = 0;
+$doc_num = 0;
+$html_num = 0;
+
+#
+# can I use ISO8879 characters? (HTML+)
+#
+if ($T2H_USE_ISO) {
+ $things_map{'bullet'} = "&bull;";
+ $things_map{'copyright'} = "&copy;";
+ $things_map{'dots'} = "&hellip;";
+ $things_map{'equiv'} = "&equiv;";
+ $things_map{'expansion'} = "&rarr;";
+ $things_map{'point'} = "&lowast;";
+ $things_map{'result'} = "&rArr;";
+}
+
+#
+# read texi2html extensions (if any)
+#
+$extensions = 'texi2html.ext'; # extensions in working directory
+if (-f $extensions) {
+ print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
+ require($extensions);
+}
+($progdir = $0) =~ s/[^\/]+$//;
+if ($progdir && ($progdir ne './')) {
+ $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory
+ if (-f $extensions) {
+ print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
+ require($extensions);
+ }
+}
+
+
+print "# reading from $docu\n" if $T2H_VERBOSE;
+
+#########################################################################
+#
+# latex2html stuff
+#
+# latex2html conversions consist of three stages:
+# 1) ToLatex: Put "latex" code into a latex file
+# 2) ToHtml: Use latex2html to generate corresponding html code and images
+# 3) FromHtml: Extract generated code and images from latex2html run
+#
+
+##########################
+# default settings
+#
+
+# defaults for files and names
+
+sub l2h_Init
+{
+ local($root) = @_;
+
+ return 0 unless ($root);
+
+ $l2h_name = "${root}_l2h";
+
+ $l2h_latex_file = "$docu_rdir${l2h_name}.tex";
+ $l2h_cache_file = "${docu_rdir}l2h_cache.pm";
+ $T2H_L2H_L2H = "latex2html" unless ($T2H_L2H_L2H);
+
+ # destination dir -- generated images are put there, should be the same
+ # as dir of enclosing html document --
+ $l2h_html_file = "$docu_rdir${l2h_name}.html";
+ $l2h_prefix = "${l2h_name}_";
+ return 1;
+}
+
+
+##########################
+#
+# First stage: Generation of Latex file
+# Initialize with: l2h_InitToLatex
+# Add content with: l2h_ToLatex($text) --> HTML placeholder comment
+# Finish with: l2h_FinishToLatex
+#
+
+$l2h_latex_preample = <<EOT;
+% This document was automatically generated by the l2h extenstion of texi2html
+% DO NOT EDIT !!!
+\\documentclass{article}
+\\usepackage{html}
+\\begin{document}
+EOT
+
+$l2h_latex_closing = <<EOT;
+\\end{document}
+EOT
+
+# return used latex 1, if l2h could be initalized properly, 0 otherwise
+sub l2h_InitToLatex
+{
+ %l2h_to_latex = ();
+ unless ($T2H_L2H_SKIP)
+ {
+ unless (open(L2H_LATEX, ">$l2h_latex_file"))
+ {
+ warn "$ERROR Error l2h: Can't open latex file '$latex_file' for writing\n";
+ return 0;
+ }
+ print "# l2h: use ${l2h_latex_file} as latex file\n" if ($T2H_VERBOSE);
+ print L2H_LATEX $l2h_latex_preample;
+ }
+ # open database for caching
+ l2h_InitCache();
+ $l2h_latex_count = 0;
+ $l2h_to_latex_count = 0;
+ $l2h_cached_count = 0;
+ return 1;
+}
+
+# print text (1st arg) into latex file (if not already there), return
+# HTML commentary which can be later on replaced by the latex2html
+# generated text
+sub l2h_ToLatex
+{
+ my($text) = @_;
+ my($count);
+
+ $l2h_to_latex_count++;
+ $text =~ s/(\s*)$//;
+
+ # try whether we can cache it
+ my $cached_text = l2h_FromCache($text);
+ if ($cached_text)
+ {
+ $l2h_cached_count++;
+ return $cached_text;
+ }
+
+ # try whether we have text already on things to do
+ unless ($count = $l2h_to_latex{$text})
+ {
+ $count = $l2h_latex_count;
+ $l2h_latex_count++;
+ $l2h_to_latex{$text} = $count;
+ $l2h_to_latex[$count] = $text;
+ unless ($T2H_L2H_SKIP)
+ {
+ print L2H_LATEX "\\begin{rawhtml}\n";
+ print L2H_LATEX "<!-- l2h_begin ${l2h_name} ${count} -->\n";
+ print L2H_LATEX "\\end{rawhtml}\n";
+
+ print L2H_LATEX "$text\n";
+
+ print L2H_LATEX "\\begin{rawhtml}\n";
+ print L2H_LATEX "<!-- l2h_end ${l2h_name} ${count} -->\n";
+ print L2H_LATEX "\\end{rawhtml}\n";
+ }
+ }
+ return "<!-- l2h_replace ${l2h_name} ${count} -->";
+}
+
+# print closing into latex file and close it
+sub l2h_FinishToLatex
+{
+ local ($reused);
+
+ $reused = $l2h_to_latex_count - $l2h_latex_count - $l2h_cached_count;
+ unless ($T2H_L2H_SKIP)
+ {
+ print L2H_LATEX $l2h_latex_closing;
+ close(L2H_LATEX);
+ }
+ print "# l2h: finished to latex ($l2h_cached_count cached, $reused reused, $l2h_latex_count contents)\n" if ($T2H_VERBOSE);
+ unless ($l2h_latex_count)
+ {
+ l2h_Finish();
+ return 0;
+ }
+ return 1;
+}
+
+###################################
+# Second stage: Use latex2html to generate corresponding html code and images
+#
+# l2h_ToHtml([$l2h_latex_file, [$l2h_html_dir]]):
+# Call latex2html on $l2h_latex_file
+# Put images (prefixed with $l2h_name."_") and html file(s) in $l2h_html_dir
+# Return 1, on success
+# 0, otherwise
+#
+sub l2h_ToHtml
+{
+ local($call, $ext, $root, $dotbug);
+
+ if ($T2H_L2H_SKIP)
+ {
+ print "# l2h: skipping latex2html run\n" if ($T2H_VERBOSE);
+ return 1;
+ }
+
+ # Check for dot in directory where dvips will work
+ if ($T2H_L2H_TMP)
+ {
+ if ($T2H_L2H_TMP =~ /\./)
+ {
+ warn "$ERROR Warning l2h: l2h_tmp dir contains a dot. Use /tmp, instead\n";
+ $dotbug = 1;
+ }
+ }
+ else
+ {
+ if (&getcwd =~ /\./)
+ {
+ warn "$ERROR Warning l2h: current dir contains a dot. Use /tmp as l2h_tmp dir \n";
+ $dotbug = 1;
+ }
+ }
+ # fix it, if necessary and hope that it works
+ $T2H_L2H_TMP = "/tmp" if ($dotbug);
+
+ $call = $T2H_L2H_L2H;
+ # use init file, if specified
+ $call = $call . " -init_file " . $init_file if ($init_file && -f $init_file);
+ # set output dir
+ $call .= ($docu_rdir ? " -dir $docu_rdir" : " -no_subdir");
+ # use l2h_tmp, if specified
+ $call = $call . " -tmp $T2H_L2H_TMP" if ($T2H_L2H_TMP);
+ # options we want to be sure of
+ $call = $call ." -address 0 -info 0 -split 0 -no_navigation -no_auto_link";
+ $call = $call ." -prefix ${l2h_prefix} $l2h_latex_file";
+
+ print "# l2h: executing '$call'\n" if ($T2H_VERBOSE);
+ if (system($call))
+ {
+ warn "l2h ***Error: '${call}' did not succeed\n";
+ return 0;
+ }
+ else
+ {
+ print "# l2h: latex2html finished successfully\n" if ($T2H_VERBOSE);
+ return 1;
+ }
+}
+
+# this is directly pasted over from latex2html
+sub getcwd {
+ local($_) = `pwd`;
+
+ die "'pwd' failed (out of memory?)\n"
+ unless length;
+ chop;
+ $_;
+}
+
+
+##########################
+# Third stage: Extract generated contents from latex2html run
+# Initialize with: l2h_InitFromHtml
+# open $l2h_html_file for reading
+# reads in contents into array indexed by numbers
+# return 1, on success -- 0, otherwise
+# Extract Html code with: l2h_FromHtml($text)
+# replaces in $text all previosuly inserted comments by generated html code
+# returns (possibly changed) $text
+# Finish with: l2h_FinishFromHtml
+# closes $l2h_html_dir/$l2h_name.".$docu_ext"
+
+sub l2h_InitFromHtml
+{
+ local($h_line, $h_content, $count, %l2h_img);
+
+ if (! open(L2H_HTML, "<${l2h_html_file}"))
+ {
+ print "$ERROR Error l2h: Can't open ${l2h_html_file} for reading\n";
+ return 0;
+ }
+ print "# l2h: use ${l2h_html_file} as html file\n" if ($T2H_VERBOSE);
+
+ $l2h_html_count = 0;
+
+ while ($h_line = <L2H_HTML>)
+ {
+ if ($h_line =~ /^<!-- l2h_begin $l2h_name ([0-9]+) -->/)
+ {
+ $count = $1;
+ $h_content = "";
+ while ($h_line = <L2H_HTML>)
+ {
+ if ($h_line =~ /^<!-- l2h_end $l2h_name $count -->/)
+ {
+ chomp $h_content;
+ chomp $h_content;
+ $l2h_html_count++;
+ $h_content = l2h_ToCache($count, $h_content);
+ $l2h_from_html[$count] = $h_content;
+ $h_content = '';
+ last;
+ }
+ $h_content = $h_content.$h_line;
+ }
+ if ($hcontent)
+ {
+ print "$ERROR Warning l2h: l2h_end $l2h_name $count not found\n"
+ if ($T2H_VERBOSE);
+ close(L2H_HTML);
+ return 0;
+ }
+ }
+ }
+ print "# l2h: Got $l2h_html_count of $l2h_latex_count html contents\n"
+ if ($T2H_VERBOSE);
+
+ close(L2H_HTML);
+ return 1;
+}
+
+sub l2h_FromHtml
+{
+ local($text) = @_;
+ local($done, $to_do, $count);
+
+ $to_do = $text;
+
+ while ($to_do =~ /([^\000]*)<!-- l2h_replace $l2h_name ([0-9]+) -->([^\000]*)/)
+ {
+ $to_do = $1;
+ $count = $2;
+ $done = $3.$done;
+
+ $done = "<!-- l2h_end $l2h_name $count -->".$done
+ if ($T2H_DEBUG & $DEBUG_L2H);
+
+ $done = &l2h_ExtractFromHtml($count) . $done;
+
+ $done = "<!-- l2h_begin $l2h_name $count -->".$done
+ if ($T2H_DEBUG & $DEBUG_L2H);
+ }
+ return $to_do.$done;
+}
+
+
+sub l2h_ExtractFromHtml
+{
+ local($count) = @_;
+
+ return $l2h_from_html[$count] if ($l2h_from_html[$count]);
+
+ if ($count >= 0 && $count < $l2h_latex_count)
+ {
+ # now we are in trouble
+ local($l_l2h, $_);
+
+ $l2h_extract_error++;
+ print "$ERROR l2h: can't extract content $count from html\n"
+ if ($T2H_VERBOSE);
+ # try simple (ordinary) substition (without l2h)
+ $l_l2h = $T2H_L2H;
+ $T2H_L2H = 0;
+ $_ = $l2h_to_latex{$count};
+ $_ = &substitute_style($_);
+ &unprotect_texi;
+ $_ = "<!-- l2h: ". __LINE__ . " use texi2html -->" . $_
+ if ($T2H_DEBUG & $DEBUG_L2H);
+ $T2H_L2H = $l_l2h;
+ return $_;
+ }
+ else
+ {
+ # now we have been incorrectly called
+ $l2h_range_error++;
+ print "$ERROR l2h: Request of $count content which is out of valide range [0,$l2h_latex_count)\n";
+ return "<!-- l2h: ". __LINE__ . " out of range count $count -->"
+ if ($T2H_DEBUG & $DEBUG_L2H);
+ return "<!-- l2h: out of range count $count -->";
+ }
+}
+
+sub l2h_FinishFromHtml
+{
+ if ($T2H_VERBOSE)
+ {
+ if ($l2h_extract_error + $l2h_range_error)
+ {
+ print "# l2h: finished from html ($l2h_extract_error extract and $l2h_range_error errors)\n";
+ }
+ else
+ {
+ print "# l2h: finished from html (no errors)\n";
+ }
+ }
+}
+
+sub l2h_Finish
+{
+ l2h_StoreCache();
+ if ($T2H_L2H_CLEAN)
+ {
+ print "# l2h: removing temporary files generated by l2h extension\n"
+ if $T2H_VERBOSE;
+ while (<"$docu_rdir$l2h_name"*>)
+ {
+ unlink $_;
+ }
+ }
+ print "# l2h: Finished\n" if $T2H_VERBOSE;
+ return 1;
+}
+
+##############################
+# stuff for l2h caching
+#
+
+# I tried doing this with a dbm data base, but it did not store all
+# keys/values. Hence, I did as latex2html does it
+sub l2h_InitCache
+{
+ if (-r "$l2h_cache_file")
+ {
+ my $rdo = do "$l2h_cache_file";
+ warn("$ERROR l2h Error: could not load $docu_rdir$l2h_cache_file: $@\n")
+ unless ($rdo);
+ }
+}
+
+sub l2h_StoreCache
+{
+ return unless $l2h_latex_count;
+
+ my ($key, $value);
+ open(FH, ">$l2h_cache_file") || return warn"$ERROR l2h Error: could not open $docu_rdir$l2h_cache_file for writing: $!\n";
+
+
+ while (($key, $value) = each %l2h_cache)
+ {
+ # escape stuff
+ $key =~ s|/|\\/|g;
+ $key =~ s|\\\\/|\\/|g;
+ # weird, a \ at the end of the key results in an error
+ # maybe this also broke the dbm database stuff
+ $key =~ s|\\$|\\\\|;
+ $value =~ s/\|/\\\|/g;
+ $value =~ s/\\\\\|/\\\|/g;
+ $value =~ s|\\\\|\\\\\\\\|g;
+ print FH "\n\$l2h_cache_key = q/$key/;\n";
+ print FH "\$l2h_cache{\$l2h_cache_key} = q|$value|;\n";
+ }
+ print FH "1;";
+ close(FH);
+}
+
+# return cached html, if it exists for text, and if all pictures
+# are there, as well
+sub l2h_FromCache
+{
+ my $text = shift;
+ my $cached = $l2h_cache{$text};
+ if ($cached)
+ {
+ while ($cached =~ m/SRC="(.*?)"/g)
+ {
+ unless (-e "$docu_rdir$1")
+ {
+ return undef;
+ }
+ }
+ return $cached;
+ }
+ return undef;
+}
+
+# insert generated html into cache, move away images,
+# return transformed html
+$maximage = 1;
+sub l2h_ToCache
+{
+ my $count = shift;
+ my $content = shift;
+ my @images = ($content =~ /SRC="(.*?)"/g);
+ my ($src, $dest);
+
+ for $src (@images)
+ {
+ $dest = $l2h_img{$src};
+ unless ($dest)
+ {
+ my $ext;
+ if ($src =~ /.*\.(.*)$/ && $1 ne $docu_ext)
+ {
+ $ext = $1;
+ }
+ else
+ {
+ warn "$ERROR: L2h image $src has invalid extension\n";
+ next;
+ }
+ while (-e "$docu_rdir${docu_name}_$maximage.$ext") { $maximage++;}
+ $dest = "${docu_name}_$maximage.$ext";
+ system("cp -f $docu_rdir$src $docu_rdir$dest");
+ $l2h_img{$src} = $dest;
+ unlink "$docu_rdir$src" unless ($DEBUG & DEBUG_L2H);
+ }
+ $content =~ s/$src/$dest/g;
+ }
+ $l2h_cache{$l2h_to_latex[$count]} = $content;
+ return $content;
+}
+
+
+#+++############################################################################
+# #
+# Pass 1: read source, handle command, variable, simple substitution #
+# #
+#---############################################################################
+
+@lines = (); # whole document
+@toc_lines = (); # table of contents
+@stoc_lines = (); # table of contents
+$curlevel = 0; # current level in TOC
+$node = ''; # current node name
+$node_next = ''; # current node next name
+$node_prev = ''; # current node prev name
+$node_up = ''; # current node up name
+$in_table = 0; # am I inside a table
+$table_type = ''; # type of table ('', 'f', 'v', 'multi')
+@tables = (); # nested table support
+$in_bibliography = 0; # am I inside a bibliography
+$in_glossary = 0; # am I inside a glossary
+$in_top = 0; # am I inside the top node
+$has_top = 0; # did I see a top node?
+$has_top_command = 0; # did I see @top for automatic pointers?
+$in_pre = 0; # am I inside a preformatted section
+$in_list = 0; # am I inside a list
+$in_html = 0; # am I inside an HTML section
+$first_line = 1; # is it the first line
+$dont_html = 0; # don't protect HTML on this line
+$deferred_ref = ''; # deferred reference for indexes
+@html_stack = (); # HTML elements stack
+$html_element = ''; # current HTML element
+&html_reset;
+%macros = (); # macros
+
+# init l2h
+$T2H_L2H = &l2h_Init($docu_name) if ($T2H_L2H);
+$T2H_L2H = &l2h_InitToLatex if ($T2H_L2H);
+
+# build code for simple substitutions
+# the maps used (%simple_map and %things_map) MUST be aware of this
+# watch out for regexps, / and escaped characters!
+$subst_code = '';
+foreach (keys(%simple_map)) {
+ ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars
+ $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n";
+}
+foreach (keys(%things_map)) {
+ $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n";
+}
+if ($use_acc) {
+ # accentuated characters
+ foreach (keys(%accent_map)) {
+ if ($_ eq "`") {
+ $subst_code .= "s/$;3";
+ } elsif ($_ eq "'") {
+ $subst_code .= "s/$;4";
+ } else {
+ $subst_code .= "s/\\\@\\$_";
+ }
+ $subst_code .= "([a-z])/&\${1}$accent_map{$_};/gi;\n";
+ }
+}
+eval("sub simple_substitutions { $subst_code }");
+
+&init_input;
+INPUT_LINE: while ($_ = &next_line) {
+ #
+ # remove \input on the first lines only
+ #
+ if ($first_line) {
+ next if /^\\input/;
+ $first_line = 0;
+ }
+ # non-@ substitutions cf. texinfmt.el
+ #
+ # parse texinfo tags
+ #
+ $tag = '';
+ $end_tag = '';
+ if (/^\s*\@end\s+(\w+)\b/) {
+ $end_tag = $1;
+ } elsif (/^\s*\@(\w+)\b/) {
+ $tag = $1;
+ }
+ #
+ # handle @html / @end html
+ #
+ if ($in_html) {
+ if ($end_tag eq 'html') {
+ $in_html = 0;
+ } else {
+ $tag2pro{$in_html} .= $_;
+ }
+ next;
+ } elsif ($tag eq 'html') {
+ $in_html = $PROTECTTAG . ++$html_num;
+ push(@lines, $in_html);
+ next;
+ }
+
+ #
+ # try to remove inlined comments
+ # syntax from tex-mode.el comment-start-skip
+ #
+ s/((^|[^\@])(\@\@)*)\@c(omment | |\{|$).*/$1/;
+
+# Sometimes I use @c right at the end of a line ( to suppress the line feed )
+# s/((^|[^\@])(\@\@)*)\@c(omment)?$/$1/;
+# s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/;
+# s/(.*)\@c{.*?}(.*)/$1$2/;
+# s/(.*)\@comment{.*?}(.*)/$1$2/;
+# s/^(.*)\@c /$1/;
+# s/^(.*)\@comment /$1/;
+
+ #############################################################
+ # value substitution before macro expansion, so that
+ # it works in macro arguments
+ s/\@value{($VARRE)}/$value{$1}/eg;
+
+ #############################################################
+ # macro substitution
+ while (/\@(\w+)/g)
+ {
+ if (exists($macros->{$1}))
+ {
+ my $before = $`;
+ my $name = $1;
+ my $after = $';
+ my @args;
+ my $args;
+ if ($after =~ /^\s*{(.*?[^\\])}(.*)/)
+ {
+ $args = $1;
+ $after = $2;
+ }
+ elsif (@{$macros->{$name}->{Args}} == 1)
+ {
+ $args = $after;
+ $args =~ s/^\s*//;
+ $args =~ s/\s*$//;
+ $after = '';
+ }
+ $args =~ s|\\\\|\\|g;
+ $args =~ s|\\{|{|g;
+ $args =~ s|\\}|}|g;
+ if (@{$macros->{$name}->{Args}} > 1)
+ {
+ $args =~ s/(^|[^\\]),/$1$;/g ;
+ $args =~ s|\\,|,|g;
+ @args = split(/$;\s*/, $args) if (@{$macros->{$name}->{Args}} > 1);
+ }
+ else
+ {
+ $args =~ s|\\,|,|g;
+ @args = ($args);
+ }
+ my $macrobody = $macros->{$name}->{Body};
+ for ($i=0; $i<=$#args; $i++)
+ {
+ $macrobody =~ s|\\$macros->{$name}->{Args}->[$i]\\|$args[$i]|g;
+ }
+ $macrobody =~ s|\\\\|\\|g;
+ $_ = $before . $macrobody . $after;
+ unshift @input_spool, map {$_ = $_."\n"} split(/\n/, $_);
+ next INPUT_LINE;
+ }
+ } #
+
+
+ #
+ # try to skip the line
+ #
+ if ($end_tag) {
+ $in_titlepage = 0 if $end_tag eq 'titlepage';
+ next if $to_skip{"end $end_tag"};
+ } elsif ($tag) {
+ $in_titlepage = 1 if $tag eq 'titlepage';
+ next if $to_skip{$tag};
+ last if $tag eq 'bye';
+ }
+ if ($in_top) {
+ # parsing the top node
+ if ($tag eq 'node' ||
+ ($sec2level{$tag} && $tag !~ /unnumbered/ && $tag !~ /heading/))
+ {
+ # no more in top
+ $in_top = 0;
+ push(@lines, $TOPEND);
+ }
+ }
+ unless ($in_pre) {
+ s/``/\"/g;
+ s/''/\"/g;
+ s/([\w ])---([\w ])/$1--$2/g;
+ }
+ #
+ # analyze the tag
+ #
+ if ($tag) {
+ # skip lines
+ &skip_until($tag), next if $tag eq 'ignore';
+ &skip_until($tag), next if $tag eq 'ifnothtml';
+ if ($tag eq 'ifinfo')
+ {
+ &skip_until($tag), next unless $T2H_EXPAND eq 'info';
+ }
+ if ($tag eq 'iftex')
+ {
+ &skip_until($tag), next unless $T2H_EXPAND eq 'tex';
+ }
+ if ($tag eq 'tex')
+ {
+ # add to latex2html file
+ if ($T2H_EXPAND eq 'tex' && $T2H_L2H && ! $in_pre)
+ {
+ # add space to the end -- tex(i2dvi) does this, as well
+ push(@lines, &l2h_ToLatex(&string_until($tag) . " "));
+ }
+ else
+ {
+ &skip_until($tag);
+ }
+ next;
+ }
+ if ($tag eq 'titlepage')
+ {
+ next;
+ }
+ # handle special tables
+ if ($tag =~ /^(|f|v|multi)table$/) {
+ $table_type = $1;
+ $tag = 'table';
+ }
+ # special cases
+ if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) {
+ $in_top = 1;
+ $has_top = 1;
+ $has_top_command = 1 if $tag eq 'top';
+ @lines = (); # ignore all lines before top (title page garbage)
+ next;
+ } elsif ($tag eq 'node') {
+ if ($in_top)
+ {
+ $in_top = 0;
+ push(@lines, $TOPEND);
+ }
+ warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o;
+ # request of "Richard Y. Kim" <ryk@ap.com>
+ s/^\@node\s+//;
+ $_ = &protect_html($_); # if node contains '&' for instance
+ ($node, $node_next, $node_prev, $node_up) = split(/,/);
+ &normalise_node($node);
+ &normalise_node($node_next);
+ &normalise_node($node_prev);
+ &normalise_node($node_up);
+ $node =~ /\"/ ?
+ push @lines, &html_debug("<A NAME='$node'></A>\n", __LINE__) :
+ push @lines, &html_debug("<A NAME=\"$node\"></A>\n", __LINE__);
+ next;
+ } elsif ($tag eq 'include') {
+ if (/^\@include\s+($FILERE)\s*$/o) {
+ $file = LocateIncludeFile($1);
+ if ($file && -e $file) {
+ &open($file);
+ print "# including $file\n" if $T2H_VERBOSE;
+ } else {
+ warn "$ERROR Can't find $1, skipping";
+ }
+ } else {
+ warn "$ERROR Bad include line: $_";
+ }
+ next;
+ } elsif ($tag eq 'ifclear') {
+ if (/^\@ifclear\s+($VARRE)\s*$/o) {
+ next unless defined($value{$1});
+ &skip_until($tag);
+ } else {
+ warn "$ERROR Bad ifclear line: $_";
+ }
+ next;
+ } elsif ($tag eq 'ifset') {
+ if (/^\@ifset\s+($VARRE)\s*$/o) {
+ next if defined($value{$1});
+ &skip_until($tag);
+ } else {
+ warn "$ERROR Bad ifset line: $_";
+ }
+ next;
+ } elsif ($tag eq 'menu') {
+ unless ($T2H_SHOW_MENU) {
+ &skip_until($tag);
+ next;
+ }
+ &html_push_if($tag);
+ push(@lines, &html_debug('', __LINE__));
+ } elsif ($format_map{$tag}) {
+ $in_pre = 1 if $format_map{$tag} eq 'PRE';
+ &html_push_if($format_map{$tag});
+ push(@lines, &html_debug('', __LINE__));
+ $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ;
+# push(@lines, &debug("<BLOCKQUOTE>\n", __LINE__))
+# if $tag =~ /example/i;
+ # sunshine@sunshineco.com: <PRE>bla</PRE> looks better than
+ # <PRE>\nbla</PRE> (at least on NeXTstep browser
+ push(@lines, &debug("<$format_map{$tag}>" .
+ ($in_pre ? '' : "\n"), __LINE__));
+ next;
+ }
+ elsif (exists $complex_format_map->{$tag})
+ {
+ my $start = eval $complex_format_map->{$tag}->[0];
+ if ($@)
+ {
+ print "$ERROR: eval of complex_format_map->{$tag}->[0] $complex_format_map->{$tag}->[0]: $@";
+ $start = '<pre>'
+ }
+ $in_pre = 1 if $start =~ /<pre/;
+ push(@lines, html_debug($start. ($in_pre ? '' : "\n"), __LINE__));
+ next;
+ } elsif ($tag eq 'table') {
+ # anorland@hem2.passagen.se
+ # if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) {
+ if (/^\s*\@(|f|v|multi)table\s+\@(\w+)|(\{[^\}]*\})/) {
+ $in_table = $2;
+ unshift(@tables, join($;, $table_type, $in_table));
+ if ($table_type eq "multi") {
+ # don't use borders -- gets confused by empty cells
+ push(@lines, &debug("<TABLE>\n", __LINE__));
+ &html_push_if('TABLE');
+ } else {
+ push(@lines, &debug("<DL COMPACT>\n", __LINE__));
+ &html_push_if('DL');
+ }
+ push(@lines, &html_debug('', __LINE__));
+ } else {
+ warn "$ERROR Bad table line: $_";
+ }
+ next;
+ }
+ elsif ($tag eq 'synindex' || $tag eq 'syncodeindex')
+ {
+ if (/^\@$tag\s+(\w+)\s+(\w+)\s*$/)
+ {
+ my $from = $1;
+ my $to = $2;
+ my $prefix_from = IndexName2Prefix($from);
+ my $prefix_to = IndexName2Prefix($to);
+
+ warn("$ERROR unknown from index name $from ind syn*index line: $_"), next
+ unless $prefix_from;
+ warn("$ERROR unknown to index name $to ind syn*index line: $_"), next
+ unless $prefix_to;
+
+ if ($tag eq 'syncodeindex')
+ {
+ $index_properties->{$prefix_to}->{'from_code'}->{$prefix_from} = 1;
+ }
+ else
+ {
+ $index_properties->{$prefix_to}->{'from'}->{$prefix_from} = 1;
+ }
+ }
+ else
+ {
+ warn "$ERROR Bad syn*index line: $_";
+ }
+ next;
+ }
+ elsif ($tag eq 'defindex' || $tag eq 'defcodeindex')
+ {
+ if (/^\@$tag\s+(\w+)\s*$/)
+ {
+ my $name = $1;
+ $index_properties->{$name}->{name} = $name;
+ $index_properties->{$name}->{code} = 1 if $tag eq 'defcodeindex';
+ }
+ else
+ {
+ warn "$ERROR Bad defindex line: $_";
+ }
+ next;
+ }
+ elsif (/^\@printindex/)
+ {
+ push (@lines, "<!--::${section}::-->$_");
+ next;
+ }
+ elsif ($tag eq 'sp') {
+ push(@lines, &debug("<P>\n", __LINE__));
+ next;
+ } elsif ($tag eq 'center') {
+ push(@lines, &debug("<center>\n", __LINE__));
+ s/\@center//;
+ } elsif ($tag eq 'setref') {
+ &protect_html; # if setref contains '&' for instance
+ if (/^\@$tag\s*{($NODERE)}\s*$/) {
+ $setref = $1;
+ $setref =~ s/\s+/ /g; # normalize
+ $setref =~ s/ $//;
+ $node2sec{$setref} = $name;
+ $sec2node{$name} = $setref;
+ $node2href{$setref} = "$docu_doc#$docid";
+ } else {
+ warn "$ERROR Bad setref line: $_";
+ }
+ next;
+ } elsif ($tag eq 'lowersections') {
+ local ($sec, $level);
+ while (($sec, $level) = each %sec2level) {
+ $sec2level{$sec} = $level + 1;
+ }
+ next;
+ } elsif ($tag eq 'raisesections') {
+ local ($sec, $level);
+ while (($sec, $level) = each %sec2level) {
+ $sec2level{$sec} = $level - 1;
+ }
+ next;
+ }
+ elsif ($tag eq 'macro' || $tag eq 'rmacro')
+ {
+ if (/^\@$tag\s*(\w+)\s*(.*)/)
+ {
+ my $name = $1;
+ my @args;
+ @args = split(/\s*,\s*/ , $1)
+ if ($2 =~ /^\s*{(.*)}\s*/);
+
+ $macros->{$name}->{Args} = \@args;
+ $macros->{$name}->{Body} = '';
+ while (($_ = &next_line) && $_ !~ /\@end $tag/)
+ {
+ $macros->{$name}->{Body} .= $_;
+ }
+ die "ERROR: No closing '\@end $tag' found for macro definition of '$name'\n"
+ unless (/\@end $tag/);
+ chomp $macros->{$name}->{Body};
+ }
+ else
+ {
+ warn "$ERROR: Bad macro defintion $_"
+ }
+ next;
+ }
+ elsif ($tag eq 'unmacro')
+ {
+ delete $macros->{$1} if (/^\@unmacro\s*(\w+)/);
+ next;
+ }
+ elsif ($tag eq 'documentlanguage')
+ {
+ SetDocumentLanguage($1) if (!$T2H_LANG && /documentlanguage\s*(\w+)/);
+ }
+ elsif (defined($def_map{$tag})) {
+ if ($def_map{$tag}) {
+ s/^\@$tag\s+//;
+ $tag = $def_map{$tag};
+ $_ = "\@$tag $_";
+ $tag =~ s/\s.*//;
+ }
+ } elsif (defined($user_sub{$tag})) {
+ s/^\@$tag\s+//;
+ $sub = $user_sub{$tag};
+ print "# user $tag = $sub, arg: $_" if $T2H_DEBUG & $DEBUG_USER;
+ if (defined(&$sub)) {
+ chop($_);
+ &$sub($_);
+ } else {
+ warn "$ERROR Bad user sub for $tag: $sub\n";
+ }
+ next;
+ }
+ if (defined($def_map{$tag})) {
+ s/^\@$tag\s+//;
+ if ($tag =~ /x$/) {
+ # extra definition line
+ $tag = $`;
+ $is_extra = 1;
+ } else {
+ $is_extra = 0;
+ }
+ while (/\{([^\{\}]*)\}/) {
+ # this is a {} construct
+ ($before, $contents, $after) = ($`, $1, $');
+ # protect spaces
+ $contents =~ s/\s+/$;9/g;
+ # restore $_ protecting {}
+ $_ = "$before$;7$contents$;8$after";
+ }
+ @args = split(/\s+/, &protect_html($_));
+ foreach (@args) {
+ s/$;9/ /g; # unprotect spaces
+ s/$;7/\{/g; # ... {
+ s/$;8/\}/g; # ... }
+ }
+ $type = shift(@args);
+ $type =~ s/^\{(.*)\}$/$1/;
+ print "# def ($tag): {$type} ", join(', ', @args), "\n"
+ if $T2H_DEBUG & $DEBUG_DEF;
+ $type .= ':'; # it's nicer like this
+ my $name = shift(@args);
+ $name =~ s/^\{(.*)\}$/$1/;
+ if ($is_extra) {
+ $_ = &debug("<DT>", __LINE__);
+ } else {
+ $_ = &debug("<DL>\n<DT>", __LINE__);
+ }
+ if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') {
+ $_ .= "<U>$type</U> <B>$name</B>";
+ $_ .= " <I>@args</I>" if @args;
+ } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr'
+ || $tag eq 'defcv' || $tag eq 'defop') {
+ $ftype = $name;
+ $name = shift(@args);
+ $name =~ s/^\{(.*)\}$/$1/;
+ $_ .= "<U>$type</U> $ftype <B>$name</B>";
+ $_ .= " <I>@args</I>" if @args;
+ } else {
+ warn "$ERROR Unknown definition type: $tag\n";
+ $_ .= "<U>$type</U> <B>$name</B>";
+ $_ .= " <I>@args</I>" if @args;
+ }
+ $_ .= &debug("\n<DD>", __LINE__);
+ $name = &unprotect_html($name);
+ if ($tag eq 'deffn' || $tag eq 'deftypefn') {
+ EnterIndexEntry('f', $name, $docu_doc, $section, \@lines);
+# unshift(@input_spool, "\@findex $name\n");
+ } elsif ($tag eq 'defop') {
+ EnterIndexEntry('f', "$name on $ftype", $docu_doc, $section, \@lines);
+# unshift(@input_spool, "\@findex $name on $ftype\n");
+ } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') {
+ EnterIndexEntry('v', $name, $docu_doc, $section, \@lines);
+# unshift(@input_spool, "\@vindex $name\n");
+ } else {
+ EnterIndexEntry('t', $name, $docu_doc, $section, \@lines);
+# unshift(@input_spool, "\@tindex $name\n");
+ }
+ $dont_html = 1;
+ }
+ } elsif ($end_tag) {
+ if ($format_map{$end_tag}) {
+ $in_pre = 0 if $format_map{$end_tag} eq 'PRE';
+ $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ;
+ &html_pop_if('P');
+ &html_pop_if('LI');
+ &html_pop_if();
+ push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__));
+ push(@lines, &html_debug('', __LINE__));
+ }
+ elsif (exists $complex_format_map->{$end_tag})
+ {
+ my $end = eval $complex_format_map->{$end_tag}->[1];
+ if ($@)
+ {
+ print "$ERROR: eval of complex_format_map->{$end_tag}->[1] $complex_format_map->{$end_tag}->[0]: $@";
+ $end = '</pre>'
+ }
+ $in_pre = 0 if $end =~ m|</pre>|;
+ push(@lines, html_debug($end, __LINE__));
+ } elsif ($end_tag =~ /^(|f|v|multi)table$/) {
+ unless (@tables) {
+ warn "$ERROR \@end $end_tag without \@*table\n";
+ next;
+ }
+ &html_pop_if('P');
+ ($table_type, $in_table) = split($;, shift(@tables));
+ unless ($1 eq $table_type) {
+ warn "$ERROR \@end $end_tag without matching \@$end_tag\n";
+ next;
+ }
+ if ($table_type eq "multi") {
+ push(@lines, "</TR></TABLE>\n");
+ &html_pop_if('TR');
+ } else {
+ push(@lines, "</DL>\n");
+ &html_pop_if('DD');
+ }
+ &html_pop_if();
+ if (@tables) {
+ ($table_type, $in_table) = split($;, $tables[0]);
+ } else {
+ $in_table = 0;
+ }
+ } elsif (defined($def_map{$end_tag})) {
+ push(@lines, &debug("</DL>\n", __LINE__));
+ } elsif ($end_tag eq 'menu') {
+ &html_pop_if();
+ push(@lines, $_); # must keep it for pass 2
+ }
+ next;
+ }
+ #############################################################
+ # anchor insertion
+ while (/\@anchor\s*\{(.*?)\}/)
+ {
+ $_ = $`.$';
+ my $anchor = $1;
+ $anchor = &normalise_node($anchor);
+ push @lines, &html_debug("<A NAME=\"$anchor\"></A>\n");
+ $node2href{$anchor} = "$docu_doc#$anchor";
+ next INPUT_LINE if $_ =~ /^\s*$/;
+ }
+
+ #############################################################
+ # index entry generation, after value substitutions
+ if (/^\@(\w+?)index\s+/)
+ {
+ EnterIndexEntry($1, $', $docu_doc, $section, \@lines);
+ next;
+ }
+ #
+ # protect texi and HTML things
+ &protect_texi;
+ $_ = &protect_html($_) unless $dont_html;
+ $dont_html = 0;
+ # substitution (unsupported things)
+ s/^\@exdent\s+//g;
+ s/\@noindent\s+//g;
+ s/\@refill\s+//g;
+ # other substitutions
+ &simple_substitutions;
+ s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4
+ #
+ # analyze the tag again
+ #
+ if ($tag) {
+ if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) {
+ if (/^\@$tag\s+(.+)$/) {
+ $name = $1;
+ $name = &normalise_node($name);
+ $level = $sec2level{$tag};
+ # check for index
+ $first_index_chapter = $node
+ if ($level == 1 && !$first_index_chapter &&
+ $name =~ /index/i);
+ if ($in_top && /heading/){
+ $T2H_HAS_TOP_HEADING = 1;
+ $_ = &debug("<H$level>$name</H$level>\n", __LINE__);
+ &html_push_if('body');
+ print "# top heading, section $name, level $level\n"
+ if $T2H_DEBUG & $DEBUG_TOC;
+ }
+ else
+ {
+ unless (/^\@\w*heading/)
+ {
+ unless (/^\@unnumbered/)
+ {
+ my $number = &update_sec_num($tag, $level);
+ $name = $number. ' ' . $name if $T2H_NUMBER_SECTIONS;
+ $sec2number{$name} = $number;
+ $number2sec{$number} = $name;
+ }
+ if (defined($toplevel))
+ {
+ push @lines, ($level==$toplevel ? $CHAPTEREND : $SECTIONEND);
+ }
+ else
+ {
+ # first time we see a "section"
+ unless ($level == 1)
+ {
+ warn "$WARN The first section found is not of level 1: $_";
+ }
+ $toplevel = $level;
+ }
+ push(@sections, $name);
+ next_doc() if ($T2H_SPLIT eq 'section' ||
+ $T2H_SPLIT && $level == $toplevel);
+ }
+ $sec_num++;
+ $docid = "SEC$sec_num";
+ $tocid = (/^\@\w*heading/ ? undef : "TOC$sec_num");
+ # check biblio and glossary
+ $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i);
+ $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i);
+ # check node
+ if ($node)
+ {
+ warn "$ERROR Duplicate node found: $node\n"
+ if ($node2sec{$node});
+ }
+ else
+ {
+ $name .= ' ' while ($node2sec{$name});
+ $node = $name;
+ }
+ $name .= ' ' while ($sec2node{$name});
+ $section = $name;
+ $node2sec{$node} = $name;
+ $sec2node{$name} = $node;
+ $node2href{$node} = "$docu_doc#$docid";
+ $node2next{$node} = $node_next;
+ $node2prev{$node} = $node_prev;
+ $node2up{$node} = $node_up;
+ print "# node $node, section $name, level $level\n"
+ if $T2H_DEBUG & $DEBUG_TOC;
+
+ $node = '';
+ $node_next = '';
+ $node_prev = '';
+ $node_next = '';
+ if ($tocid)
+ {
+ # update TOC
+ while ($level > $curlevel) {
+ $curlevel++;
+ push(@toc_lines, "<UL>\n");
+ }
+ while ($level < $curlevel) {
+ $curlevel--;
+ push(@toc_lines, "</UL>\n");
+ }
+ $_ = &t2h_anchor($tocid, "$docu_doc#$docid", $name, 1);
+ $_ = &substitute_style($_);
+ push(@stoc_lines, "$_<BR>\n") if ($level == 1);
+ if ($T2H_NUMBER_SECTIONS)
+ {
+ push(@toc_lines, $_ . "<BR>\n")
+ }
+ else
+ {
+ push(@toc_lines, "<LI>" . $_ ."</LI>");
+ }
+ }
+ else
+ {
+ push(@lines, &html_debug("<A NAME=\"$docid\"></A>\n",
+ __LINE__));
+ }
+ # update DOC
+ push(@lines, &html_debug('', __LINE__));
+ &html_reset;
+ $_ = "<H$level> $name </H$level>\n<!--docid::${docid}::-->\n";
+ $_ = &debug($_, __LINE__);
+ push(@lines, &html_debug('', __LINE__));
+ }
+ # update DOC
+ foreach $line (split(/\n+/, $_)) {
+ push(@lines, "$line\n");
+ }
+ next;
+ } else {
+ warn "$ERROR Bad section line: $_";
+ }
+ } else {
+ # track variables
+ $value{$1} = Unprotect_texi($2), next if /^\@set\s+($VARRE)\s+(.*)$/o;
+ delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o;
+ # store things
+ $value{'_shorttitle'} = Unprotect_texi($1), next if /^\@shorttitle\s+(.*)$/;
+ $value{'_setfilename'} = Unprotect_texi($1), next if /^\@setfilename\s+(.*)$/;
+ $value{'_settitle'} = Unprotect_texi($1), next if /^\@settitle\s+(.*)$/;
+ $value{'_author'} .= Unprotect_texi($1)."\n", next if /^\@author\s+(.*)$/;
+ $value{'_subtitle'} .= Unprotect_texi($1)."\n", next if /^\@subtitle\s+(.*)$/;
+ $value{'_title'} .= Unprotect_texi($1)."\n", next if /^\@title\s+(.*)$/;
+
+ # list item
+ if (/^\s*\@itemx?\s+/) {
+ $what = $';
+ $what =~ s/\s+$//;
+ if ($in_bibliography && $use_bibliography) {
+ if ($what =~ /^$BIBRE$/o) {
+ $id = 'BIB' . ++$bib_num;
+ $bib2href{$what} = "$docu_doc#$id";
+ print "# found bibliography for '$what' id $id\n"
+ if $T2H_DEBUG & $DEBUG_BIB;
+ $what = &t2h_anchor($id, '', $what);
+ }
+ } elsif ($in_glossary && $T2H_USE_GLOSSARY) {
+ $id = 'GLOSS' . ++$gloss_num;
+ $entry = $what;
+ $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
+ $gloss2href{$entry} = "$docu_doc#$id";
+ print "# found glossary for '$entry' id $id\n"
+ if $T2H_DEBUG & $DEBUG_GLOSS;
+ $what = &t2h_anchor($id, '', $what);
+ }
+ elsif ($in_table && ($table_type eq 'f' || $table_type eq 'v'))
+ {
+ EnterIndexEntry($table_type, $what, $docu_doc, $section, \@lines);
+ }
+ &html_pop_if('P');
+ if ($html_element eq 'DL' || $html_element eq 'DD') {
+ if ($things_map{$in_table} && !$what) {
+ # special case to allow @table @bullet for instance
+ push(@lines, &debug("<DT>$things_map{$in_table}\n", __LINE__));
+ } else {
+ push(@lines, &debug("<DT>\@$in_table\{$what\}\n", __LINE__));
+ }
+ push(@lines, "<DD>");
+ &html_push('DD') unless $html_element eq 'DD';
+ if ($table_type) { # add also an index
+ unshift(@input_spool, "\@${table_type}index $what\n");
+ }
+ } elsif ($html_element eq 'TABLE') {
+ push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
+ &html_push('TR');
+ } elsif ($html_element eq 'TR') {
+ push(@lines, &debug("</TR>\n", __LINE__));
+ push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
+ } else {
+ push(@lines, &debug("<LI>$what\n", __LINE__));
+ &html_push('LI') unless $html_element eq 'LI';
+ }
+ push(@lines, &html_debug('', __LINE__));
+ if ($deferred_ref) {
+ push(@lines, &debug("$deferred_ref\n", __LINE__));
+ $deferred_ref = '';
+ }
+ next;
+ } elsif (/^\@tab\s+(.*)$/) {
+ push(@lines, "<TD>$1</TD>\n");
+ next;
+ }
+ }
+ }
+ # paragraph separator
+ if ($_ eq "\n" && ! $in_pre) {
+ next if $#lines >= 0 && $lines[$#lines] eq "\n";
+ if ($html_element eq 'P') {
+ push (@lines, &debug("</P><P>\n", __LINE__));
+ }
+# else
+# {
+# push(@lines, "<P></P>\n");
+# $_ = &debug("<P></P>\n", __LINE__);
+# }
+ elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE' || $html_element eq 'DD' || $html_element eq 'LI')
+ {
+ &html_push('P');
+ push(@lines, &debug("<P>\n", __LINE__));
+ }
+ }
+ # otherwise
+ push(@lines, $_) unless $in_titlepage;
+ push(@lines, &debug("</center>\n", __LINE__)) if ($tag eq 'center');
+}
+
+# finish TOC
+$level = 0;
+while ($level < $curlevel) {
+ $curlevel--;
+ push(@toc_lines, "</UL>\n");
+}
+
+print "# end of pass 1\n" if $T2H_VERBOSE;
+
+SetDocumentLanguage('en') unless ($T2H_LANG);
+#+++############################################################################
+# #
+# Stuff related to Index generation #
+# #
+#---############################################################################
+
+sub EnterIndexEntry
+{
+ my $prefix = shift;
+ my $key = shift;
+ my $docu_doc = shift;
+ my $section = shift;
+ my $lines = shift;
+ local $_;
+
+ warn "$ERROR Undefined index command: $_", next
+ unless (exists ($index_properties->{$prefix}));
+ $key =~ s/\s+$//;
+ $_ = $key;
+ &protect_texi;
+ $key = $_;
+ $_ = &protect_html($_);
+ my $html_key = substitute_style($_);
+ my $id;
+ $key = remove_style($key);
+ $key = remove_things($key);
+ $_ = $key;
+ &unprotect_texi;
+ $key = $_;
+ while (exists $index->{$prefix}->{$key}) {$key .= ' '};
+ if ($lines->[$#lines] =~ /^<!--docid::(.+)::-->$/)
+ {
+ $id = $1;
+ }
+ else
+ {
+ $id = 'IDX' . ++$idx_num;
+ push(@$lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre));
+ }
+ $index->{$prefix}->{$key}->{html_key} = $html_key;
+ $index->{$prefix}->{$key}->{section} = $section;
+ $index->{$prefix}->{$key}->{href} = "$docu_doc#$id";
+ print "# found ${prefix}index for '$key' with id $id\n"
+ if $T2H_DEBUG & $DEBUG_INDEX;
+}
+
+sub IndexName2Prefix
+{
+ my $name = shift;
+ my $prefix;
+
+ for $prefix (keys %$index_properties)
+ {
+ return $prefix if ($index_properties->{$prefix}->{name} eq $name);
+ }
+ return undef;
+}
+
+sub GetIndexEntries
+{
+ my $normal = shift;
+ my $code = shift;
+ my ($entries, $prefix, $key) = ({});
+
+ for $prefix (keys %$normal)
+ {
+ for $key (keys %{$index->{$prefix}})
+ {
+ $entries->{$key} = {%{$index->{$prefix}->{$key}}};
+ }
+ }
+
+ if (defined($code))
+ {
+ for $prefix (keys %$code)
+ {
+ unless (exists $normal->{$keys})
+ {
+ for $key (keys %{$index->{$prefix}})
+ {
+ $entries->{$key} = {%{$index->{$prefix}->{$key}}};
+ $entries->{$key}->{html_key} = "<CODE>$entries->{$key}->{html_key}</CODE>";
+ }
+ }
+ }
+ }
+ return $entries;
+}
+
+sub byAlpha
+{
+ if ($a =~ /^[A-Za-z]/)
+ {
+ if ($b =~ /^[A-Za-z]/)
+ {
+ return lc($a) cmp lc($b);
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ elsif ($b =~ /^[A-Za-z]/)
+ {
+ return -1;
+ }
+ else
+ {
+ return lc($a) cmp lc($b);
+ }
+}
+
+sub GetIndexPages
+{
+ my $entries = shift;
+ my (@Letters, $key);
+ my ($EntriesByLetter, $Pages, $page) = ({}, [], {});
+ my @keys = sort byAlpha keys %$entries;
+
+ for $key (@keys)
+ {
+ push @{$EntriesByLetter->{uc(substr($key,0, 1))}} , $entries->{$key};
+ }
+ @Letters = sort byAlpha keys %$EntriesByLetter;
+
+ $T2H_SPLIT_INDEX = 0 unless ($T2H_SPLIT);
+
+ unless ($T2H_SPLIT_INDEX)
+ {
+ $page->{First} = $Letters[0];
+ $page->{Last} = $Letters[$#Letters];
+ $page->{Letters} = \@Letters;
+ $page->{EntriesByLetter} = $EntriesByLetter;
+ push @$Pages, $page;
+ return $Pages;
+ }
+
+ if ($T2H_SPLIT_INDEX =~ /^\d+$/)
+ {
+ my $i = 0;
+ my ($prev_letter, $letter);
+ $page->{First} = $Letters[0];
+ for $letter (@Letters)
+ {
+ if ($i > $T2H_SPLIT_INDEX)
+ {
+ $page->{Last} = $prev_letter;
+ push @$Pages, {%$page};
+ $page->{Letters} = [];
+ $page->{EntriesByLetter} = {};
+ $page->{First} = $letter;
+ $i=0;
+ }
+ push @{$page->{Letters}}, $letter;
+ $page->{EntriesByLetter}->{$letter} = [@{$EntriesByLetter->{$letter}}];
+ $i += scalar(@{$EntriesByLetter->{$letter}});
+ $prev_letter = $letter;
+ }
+ $page->{Last} = $Letters[$#Letters];
+ push @$Pages, {%$page};
+ }
+ return $Pages;
+}
+
+sub GetIndexSummary
+{
+ my $first_page = shift;
+ my $Pages = shift;
+ my $name = shift;
+ my ($page, $letter, $summary, $i, $l1, $l2, $l);
+
+ $i = 0;
+ $summary = '<table><tr><th valign=top>Jump to: &nbsp; </th><td>';
+
+ for $page ($first_page, @$Pages)
+ {
+ for $letter (@{$page->{Letters}})
+ {
+ $l = t2h_anchor('', "$page->{href}#${name}_$letter", "<b>$letter</b>",
+ 0, 'style="text-decoration:none"') . "\n &nbsp; \n";
+
+ if ($letter =~ /^[A-Za-z]/)
+ {
+ $l2 .= $l;
+ }
+ else
+ {
+ $l1 .= $l;
+ }
+ }
+ }
+ $summary .= $l1 . "<BR>\n" if ($l1);
+ $summary .= $l2 . '</td></tr></table><br>';
+ return $summary;
+}
+
+sub PrintIndexPage
+{
+ my $lines = shift;
+ my $summary = shift;
+ my $page = shift;
+ my $name = shift;
+
+ push @$lines, $summary;
+
+ push @$lines , <<EOT;
+<P></P>
+<TABLE border=0>
+<TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR>
+<TR><TD COLSPAN=3> <HR></TD></TR>
+EOT
+
+ for $letter (@{$page->{Letters}})
+ {
+ push @$lines, "<TR><TH><A NAME=\"${name}_$letter\"></A>$letter</TH><TD></TD><TD></TD></TR>\n";
+ for $entry (@{$page->{EntriesByLetter}->{$letter}})
+ {
+ push @$lines,
+ "<TR><TD></TD><TD valign=top>" .
+ t2h_anchor('', $entry->{href}, $entry->{html_key}) .
+ "</TD><TD valign=top>" .
+ t2h_anchor('', sec_href($entry->{section}), clean_name($entry->{section})) .
+ "</TD></TR>\n";
+ }
+ push @$lines, "<TR><TD COLSPAN=3> <HR></TD></TR>\n";
+ }
+ push @$lines, "</TABLE><P></P>";
+ push @$lines, $summary;
+}
+
+sub PrintIndex
+{
+ my $lines = shift;
+ my $name = shift;
+ my $section = shift;
+ $section = 'Top' unless $section;
+ my $prefix = IndexName2Prefix($name);
+
+ warn ("$ERROR printindex: bad index name: $name"), return
+ unless $prefix;
+
+ if ($index_properties->{$prefix}->{code})
+ {
+ $index_properties->{$prefix}->{from_code}->{$prefix} = 1;
+ }
+ else
+ {
+ $index_properties->{$prefix}->{from}->{$prefix}= 1;
+ }
+
+ my $Entries = GetIndexEntries($index_properties->{$prefix}->{from},
+ $index_properties->{$prefix}->{from_code});
+ return unless %$Entries;
+
+ if ($T2H_IDX_SUMMARY)
+ {
+ my $key;
+ open(FHIDX, ">$docu_rdir$docu_name" . "_$name.idx")
+ || die "Can't open > $docu_rdir$docu_name" . "_$name.idx for writing: $!\n";
+ print "# writing $name index summary in $docu_rdir$docu_name" . "_$name.idx...\n" if $T2H_VERBOSE;
+
+ for $key (sort keys %$Entries)
+ {
+ print FHIDX "$key\t$Entries->{$key}->{href}\n";
+ }
+ }
+
+ my $Pages = GetIndexPages($Entries);
+ my $page;
+ my $first_page = shift @$Pages;
+ my $sec_name = $section;
+ # remove section number
+ $sec_name =~ s/.*? // if $sec_name =~ /^([A-Z]|\d+)\./;
+
+ ($first_page->{href} = sec_href($section)) =~ s/\#.*$//;
+ # Update tree structure of document
+ if (@$Pages)
+ {
+ my $sec;
+ my @after;
+
+ while (@sections && $sections[$#sections] ne $section)
+ {
+ unshift @after, pop @sections;
+ }
+
+ for $page (@$Pages)
+ {
+ my $node = ($page->{First} ne $page->{Last} ?
+ "$sec_name: $page->{First} -- $page->{Last}" :
+ "$sec_name: $page->{First}");
+ push @sections, $node;
+ $node2sec{$node} = $node;
+ $sec2node{$node} = $node;
+ $node2up{$node} = $section;
+ $page->{href} = next_doc();
+ $page->{name} = $node;
+ $node2href{$node} = $page->{href};
+ if ($prev_node)
+ {
+ $node2next{$prev_node} = $node;
+ $node2prev{$node} = $prev_node;
+ }
+ $prev_node = $node;
+ }
+ push @sections, @after;
+ }
+
+ my $summary = GetIndexSummary($first_page, $Pages, $name);
+ PrintIndexPage($lines, $summary, $first_page, $name);
+ for $page (@$Pages)
+ {
+ push @$lines, ($T2H_SPLIT eq 'chapter' ? $CHAPTEREND : $SECTIONEND);
+ push @$lines, "<H2 ALIGN=\"Left\">$page->{name}</H2>\n";
+ PrintIndexPage($lines, $summary, $page, $name);
+ }
+}
+
+
+#+++############################################################################
+# #
+# Pass 2/3: handle style, menu, index, cross-reference #
+# #
+#---############################################################################
+
+@lines2 = (); # whole document (2nd pass)
+@lines3 = (); # whole document (3rd pass)
+$in_menu = 0; # am I inside a menu
+
+while (@lines) {
+ $_ = shift(@lines);
+ #
+ # special case (protected sections)
+ #
+ if (/^$PROTECTTAG/o) {
+ push(@lines2, $_);
+ next;
+ }
+ #
+ # menu
+ #
+ if (/^\@menu\b/)
+ {
+ $in_menu = 1;
+ $in_menu_listing = 1;
+ push(@lines2, &debug("<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> \n", __LINE__));
+ next;
+ }
+ if (/^\@end\s+menu\b/)
+ {
+ if ($in_menu_listing)
+ {
+ push(@lines2, &debug("</TABLE></BLOCKQUOTE>\n", __LINE__));
+ }
+ else
+ {
+ push(@lines2, &debug("</BLOCKQUOTE>\n", __LINE__));
+ }
+ $in_menu = 0;
+ $in_menu_listing = 0;
+ next;
+ }
+ if ($in_menu)
+ {
+ my ($node, $name, $descr);
+ if (/^\*\s+($NODERE)::/o)
+ {
+ $node = $1;
+ $descr = $';
+ }
+ elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/)
+ {
+ $name = $1;
+ $node = $2;
+ $descr = $';
+ }
+ elsif (/^\*/)
+ {
+ warn "$ERROR Bad menu line: $_";
+ }
+ else
+ {
+ if ($in_menu_listing)
+ {
+ $in_menu_listing = 0;
+ push(@lines2, &debug("</TABLE>\n", __LINE__));
+ }
+ # should be like verbatim -- preseve spaces, etc
+ s/ /\&nbsp;/g;
+ $_ .= "<br>\n";
+ push(@lines2, $_);
+ }
+ if ($node)
+ {
+ if (! $in_menu_listing)
+ {
+ $in_menu_listing = 1;
+ push(@lines2, &debug("<TABLE BORDER=0 CELLSPACING=0>\n", __LINE__));
+ }
+ # look for continuation
+ while ($lines[0] =~ /^\s+\w+/)
+ {
+ $descr .= shift(@lines);
+ }
+ &menu_entry($node, $name, $descr);
+ }
+ next;
+ }
+ #
+ # printindex
+ #
+ PrintIndex(\@lines2, $2, $1), next
+ if (/^<!--::(.*)::-->\@printindex\s+(\w+)/);
+ #
+ # simple style substitutions
+ #
+ $_ = &substitute_style($_);
+ #
+ # xref
+ #
+ while (/\@(x|px|info|)ref{([^{}]+)(}?)/) {
+ # note: Texinfo may accept other characters
+ ($type, $nodes, $full) = ($1, $2, $3);
+ ($before, $after) = ($`, $');
+ if (! $full && $after) {
+ warn "$ERROR Bad xref (no ending } on line): $_";
+ $_ = "$before$;0${type}ref\{$nodes$after";
+ next; # while xref
+ }
+ if ($type eq 'x') {
+ $type = "$T2H_WORDS->{$T2H_LANG}->{'See'} ";
+ } elsif ($type eq 'px') {
+ $type = "$T2H_WORDS->{$T2H_LANG}->{'see'} ";
+ } elsif ($type eq 'info') {
+ $type = "$T2H_WORDS->{$T2H_LANG}->{'See'} Info";
+ } else {
+ $type = '';
+ }
+ unless ($full) {
+ $next = shift(@lines);
+ $next = &substitute_style($next);
+ chop($nodes); # remove final newline
+ if ($next =~ /\}/) { # split on 2 lines
+ $nodes .= " $`";
+ $after = $';
+ } else {
+ $nodes .= " $next";
+ $next = shift(@lines);
+ $next = &substitute_style($next);
+ chop($nodes);
+ if ($next =~ /\}/) { # split on 3 lines
+ $nodes .= " $`";
+ $after = $';
+ } else {
+ warn "$ERROR Bad xref (no ending }): $_";
+ $_ = "$before$;0xref\{$nodes$after";
+ unshift(@lines, $next);
+ next; # while xref
+ }
+ }
+ }
+ $nodes =~ s/\s+/ /g; # remove useless spaces
+ @args = split(/\s*,\s*/, $nodes);
+ $node = $args[0]; # the node is always the first arg
+ $node = &normalise_node($node);
+ $sec = $args[2] || $args[1] || $node2sec{$node};
+ $href = $node2href{$node};
+ if (@args == 5) { # reference to another manual
+ $sec = $args[2] || $node;
+ $man = $args[4] || $args[3];
+ $_ = "${before}${type}$T2H_WORDS->{$T2H_LANG}->{'section'} `$sec' in \@cite{$man}$after";
+ } elsif ($type =~ /Info/) { # inforef
+ warn "$ERROR Wrong number of arguments: $_" unless @args == 3;
+ ($nn, $_, $in) = @args;
+ $_ = "${before}${type} file `$in', node `$nn'$after";
+ } elsif ($sec && $href && ! $T2H_SHORT_REF) {
+ $_ = "${before}${type}";
+ $_ .= "$T2H_WORDS->{$T2H_LANG}->{'section'} " if ${type};
+ $_ .= &t2h_anchor('', $href, $sec) . $after;
+ }
+ elsif ($href)
+ {
+ $_ = "${before}${type} " .
+ &t2h_anchor('', $href, $args[2] || $args[1] || $node) .
+ $after;
+ }
+ else {
+ warn "$ERROR Undefined node ($node): $_";
+ $_ = "$before$;0xref{$nodes}$after";
+ }
+ }
+
+ # replace images
+ s[\@image\s*{(.+?)}]
+ {
+ my @args = split (/\s*,\s*/, $1);
+ my $base = $args[0];
+ my $image =
+ LocateIncludeFile("$base.png") ||
+ LocateIncludeFile("$base.jpg") ||
+ LocateIncludeFile("$base.gif");
+ warn "$ERROR no image file for $base: $_" unless ($image && -e $image);
+ "<IMG SRC=\"$image\" ALT=\"$base\">";
+ ($T2H_CENTER_IMAGE ?
+ "<CENTER><IMG SRC=\"$image\" ALT=\"$base\"></CENTER>" :
+ "<IMG SRC=\"$image\" ALT=\"$base\">");
+ }eg;
+
+ #
+ # try to guess bibliography references or glossary terms
+ #
+ unless (/^<H\d><A NAME=\"SEC\d/) {
+ if ($use_bibliography) {
+ $done = '';
+ while (/$BIBRE/o) {
+ ($pre, $what, $post) = ($`, $&, $');
+ $href = $bib2href{$what};
+ if (defined($href) && $post !~ /^[^<]*<\/A>/) {
+ $done .= $pre . &t2h_anchor('', $href, $what);
+ } else {
+ $done .= "$pre$what";
+ }
+ $_ = $post;
+ }
+ $_ = $done . $_;
+ }
+ if ($T2H_USE_GLOSSARY) {
+ $done = '';
+ while (/\b\w+\b/) {
+ ($pre, $what, $post) = ($`, $&, $');
+ $entry = $what;
+ $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
+ $href = $gloss2href{$entry};
+ if (defined($href) && $post !~ /^[^<]*<\/A>/) {
+ $done .= $pre . &t2h_anchor('', $href, $what);
+ } else {
+ $done .= "$pre$what";
+ }
+ $_ = $post;
+ }
+ $_ = $done . $_;
+ }
+ }
+ # otherwise
+ push(@lines2, $_);
+}
+print "# end of pass 2\n" if $T2H_VERBOSE;
+
+#
+# split style substitutions
+#
+while (@lines2) {
+ $_ = shift(@lines2);
+ #
+ # special case (protected sections)
+ #
+ if (/^$PROTECTTAG/o) {
+ push(@lines3, $_);
+ next;
+ }
+ #
+ # split style substitutions
+ #
+ $old = '';
+ while ($old ne $_) {
+ $old = $_;
+ if (/\@(\w+)\{/) {
+ ($before, $style, $after) = ($`, $1, $');
+ if (defined($style_map{$style})) {
+ $_ = $after;
+ $text = '';
+ $after = '';
+ $failed = 1;
+ while (@lines2) {
+ if (/\}/) {
+ $text .= $`;
+ $after = $';
+ $failed = 0;
+ last;
+ } else {
+ $text .= $_;
+ $_ = shift(@lines2);
+ }
+ }
+ if ($failed) {
+ die "* Bad syntax (\@$style) after: $before\n";
+ } else {
+ $text = &apply_style($style, $text);
+ $_ = "$before$text$after";
+ }
+ }
+ }
+ }
+ # otherwise
+ push(@lines3, $_);
+}
+print "# end of pass 3\n" if $T2H_VERBOSE;
+
+#+++############################################################################
+# #
+# Pass 4: foot notes, final cleanup #
+# #
+#---############################################################################
+
+@foot_lines = (); # footnotes
+@doc_lines = (); # final document
+$end_of_para = 0; # true if last line is <P>
+
+while (@lines3) {
+ $_ = shift(@lines3);
+ #
+ # special case (protected sections)
+ #
+ if (/^$PROTECTTAG/o) {
+ push(@doc_lines, $_);
+ $end_of_para = 0;
+ next;
+ }
+ #
+ # footnotes
+ #
+ while (/\@footnote([^\{\s]+)\{/) {
+ ($before, $d, $after) = ($`, $1, $');
+ $_ = $after;
+ $text = '';
+ $after = '';
+ $failed = 1;
+ while (@lines3) {
+ if (/\}/) {
+ $text .= $`;
+ $after = $';
+ $failed = 0;
+ last;
+ } else {
+ $text .= $_;
+ $_ = shift(@lines3);
+ }
+ }
+ if ($failed) {
+ die "* Bad syntax (\@footnote) after: $before\n";
+ } else {
+ $foot_num++;
+ $docid = "DOCF$foot_num";
+ $footid = "FOOT$foot_num";
+ $foot = "($foot_num)";
+ push(@foot_lines, "<H3>" . &t2h_anchor($footid, "$d#$docid", $foot) . "</H3>\n");
+ $text = "<P>$text" unless $text =~ /^\s*<P>/;
+ push(@foot_lines, "$text\n");
+ $_ = $before . &t2h_anchor($docid, "$docu_foot#$footid", $foot) . $after;
+ }
+ }
+ #
+ # remove unnecessary <P>
+ #
+ if (/^\s*<P>\s*$/) {
+ next if $end_of_para++;
+ } else {
+ $end_of_para = 0;
+ }
+ # otherwise
+ push(@doc_lines, $_);
+}
+
+print "# end of pass 4\n" if $T2H_VERBOSE;
+
+#+++############################################################################
+# #
+# Pass 5: print things #
+# #
+#---############################################################################
+
+$T2H_L2H = &l2h_FinishToLatex if ($T2H_L2H);
+$T2H_L2H = &l2h_ToHtml if ($T2H_L2H);
+$T2H_L2H = &l2h_InitFromHtml if ($T2H_L2H);
+
+# fix node2up, node2prev, node2next, if desired
+if ($has_top_command)
+{
+ for $section (keys %sec2number)
+ {
+ $node = $sec2node{$section};
+ $node2up{$node} = Sec2UpNode($section) unless $node2up{$node};
+ $node2prev{$node} = Sec2PrevNode($section) unless $node2prev{$node};
+ $node2next{$node} = Sec2NextNode($section) unless $node2next{$node};
+ }
+}
+
+# prepare %T2H_THISDOC
+$T2H_THISDOC{fulltitle} = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
+$T2H_THISDOC{title} = $value{'_settitle'} || $T2H_THISDOC{fulltitle};
+$T2H_THISDOC{author} = $value{'_author'};
+$T2H_THISDOC{subtitle} = $value{'_subtitle'};
+$T2H_THISDOC{shorttitle} = $value{'_shorttitle'};
+for $key (keys %T2H_THISDOC)
+{
+ $_ = &substitute_style($T2H_THISDOC{$key});
+ &unprotect_texi;
+ s/\s*$//;
+ $T2H_THISDOC{$key} = $_;
+}
+
+# if no sections, then simply print document as is
+unless (@sections)
+{
+ print "# Writing content into $docu_top_file \n" if $T2H_VERBOSE;
+ open(FILE, "> $docu_top_file")
+ || die "$ERROR: Can't open $docu_top_file for writing: $!\n";
+
+ &$T2H_print_page_head(\*FILE);
+ $T2H_THIS_SECTION = \@doc_lines;
+ t2h_print_lines(\*FILE);
+ &$T2H_print_foot_navigation(\*FILE);
+ &$T2H_print_page_foot(\*FILE);
+ close(FILE);
+ goto Finish;
+}
+
+# initialize $T2H_HREF, $T2H_NAME
+%T2H_HREF =
+ (
+ 'First' , sec_href($sections[0]),
+ 'Last', sec_href($sections[$#sections]),
+ 'About', $docu_about. '#SEC_About',
+ );
+
+# prepare TOC, OVERVIEW, TOP
+$T2H_TOC = \@toc_lines;
+$T2H_OVERVIEW = \@stoc_lines;
+if ($has_top)
+{
+ while (1)
+ {
+ $_ = shift @doc_lines;
+ last if /$TOPEND/;
+ push @$T2H_TOP, $_;
+ }
+ $T2H_HREF{'Top'} = $docu_top . '#SEC_Top';
+}
+else
+{
+ $T2H_HREF{'Top'} = $T2H_HREF{First};
+}
+
+$node2href{Top} = $T2H_HREF{Top};
+$T2H_HREF{Contents} = $docu_toc.'#SEC_Contents' if @toc_lines;
+$T2H_HREF{Overview} = $docu_stoc.'#SEC_OVERVIEW' if @stoc_lines;
+
+# settle on index
+if ($T2H_INDEX_CHAPTER)
+{
+ $T2H_HREF{Index} = $node2href{normalise_node($T2H_INDEX_CHAPTER)};
+ warn "$ERROR T2H_INDEX_CHAPTER '$T2H_INDEX_CHAPTER' not found\n"
+ unless $T2H_HREF{Index};
+}
+if (! $T2H_HREF{Index} && $first_index_chapter)
+{
+ $T2H_INDEX_CHAPTER = $first_index_chapter;
+ $T2H_HREF{Index} = $node2href{$T2H_INDEX_CHAPTER};
+}
+
+print "# Using '" . clean_name($T2H_INDEX_CHAPTER) . "' as index page\n"
+ if ($T2H_VERBOSE && $T2H_HREF{Index});
+
+%T2H_NAME =
+ (
+ 'First', clean_name($sec2node{$sections[0]}),
+ 'Last', clean_name($sec2node{$sections[$#sections]}),
+ 'About', $T2H_WORDS->{$T2H_LANG}->{'About_Title'},
+ 'Contents', $T2H_WORDS->{$T2H_LANG}->{'ToC_Title'},
+ 'Overview', $T2H_WORDS->{$T2H_LANG}->{'Overview_Title'},
+ 'Index' , clean_name($T2H_INDEX_CHAPTER),
+ 'Top', clean_name($T2H_TOP_HEADING || $T2H_THISDOC{'title'} || $T2H_THISDOC{'shorttitle'}),
+ );
+
+#############################################################################
+# print frame and frame toc file
+#
+if ( $T2H_FRAMES )
+{
+ open(FILE, "> $docu_frame_file")
+ || die "$ERROR: Can't open $docu_frame_file for writing: $!\n";
+ print "# Creating frame in $docu_frame_file ...\n" if $T2H_VERBOSE;
+ &$T2H_print_frame(\*FILE);
+ close(FILE);
+
+ open(FILE, "> $docu_toc_frame_file")
+ || die "$ERROR: Can't open $docu_toc_frame_file for writing: $!\n";
+ print "# Creating toc frame in $docu_frame_file ...\n" if $T2H_VERBOSE;
+ &$T2H_print_toc_frame(\*FILE);
+ close(FILE);
+}
+
+
+#############################################################################
+# print Top
+#
+open(FILE, "> $docu_top_file")
+ || die "$ERROR: Can't open $docu_top_file for writing: $!\n";
+&$T2H_print_page_head(\*FILE) unless ($T2H_SPLIT);
+
+if ($has_top)
+{
+ print "# Creating Top in $docu_top_file ...\n" if $T2H_VERBOSE;
+ $T2H_THIS_SECTION = $T2H_TOP;
+ $T2H_HREF{This} = $T2H_HREF{Top};
+ $T2H_NAME{This} = $T2H_NAME{Top};
+ &$T2H_print_Top(\*FILE);
+}
+
+close(FILE) if $T2H_SPLIT;
+
+#############################################################################
+# Print sections
+#
+$T2H_NODE{Forward} = $sec2node{$sections[0]};
+$T2H_NAME{Forward} = &clean_name($sec2node{$sections[0]});
+$T2H_HREF{Forward} = sec_href($sections[0]);
+$T2H_NODE{This} = 'Top';
+$T2H_NAME{This} = $T2H_NAME{Top};
+$T2H_HREF{This} = $T2H_HREF{Top};
+if ($T2H_SPLIT)
+{
+ print "# writing " . scalar(@sections) .
+ " sections in $docu_rdir$docu_name"."_[1..$doc_num]"
+ if $T2H_VERBOSE;
+ $previous = ($T2H_SPLIT eq 'chapter' ? $CHAPTEREND : $SECTIONEND);
+ undef $FH;
+ $doc_num = 0;
+}
+else
+{
+ print "# writing " . scalar(@sections) . " sections in $docu_top_file ..."
+ if $T2H_VERBOSE;
+ $FH = \*FILE;
+ $previous = '';
+}
+
+$counter = 0;
+# loop through sections
+while ($section = shift(@sections))
+{
+ if ($T2H_SPLIT && ($T2H_SPLIT eq 'section' || $previous eq $CHAPTEREND))
+ {
+ if ($FH)
+ {
+ #close previous page
+ &$T2H_print_chapter_footer($FH) if $T2H_SPLIT eq 'chapter';
+ &$T2H_print_page_foot($FH);
+ close($FH);
+ undef $FH;
+ }
+ }
+ $T2H_NAME{Back} = $T2H_NAME{This};
+ $T2H_HREF{Back} = $T2H_HREF{This};
+ $T2H_NODE{Back} = $T2H_NODE{This};
+ $T2H_NAME{This} = $T2H_NAME{Forward};
+ $T2H_HREF{This} = $T2H_HREF{Forward};
+ $T2H_NODE{This} = $T2H_NODE{Forward};
+ if ($sections[0])
+ {
+ $T2H_NODE{Forward} = $sec2node{$sections[0]};
+ $T2H_NAME{Forward} = &clean_name($T2H_NODE{Forward});
+ $T2H_HREF{Forward} = sec_href($sections[0]);
+ }
+ else
+ {
+ undef $T2H_HREF{Forward}, $T2H_NODE{Forward}, $T2H_NAME{Forward};
+ }
+
+ $node = $node2up{$T2H_NODE{This}};
+ $T2H_HREF{Up} = $node2href{$node};
+ if ($T2H_HREF{Up} eq $T2H_HREF{This} || ! $T2H_HREF{Up})
+ {
+ $T2H_NAME{Up} = $T2H_NAME{Top};
+ $T2H_HREF{Up} = $T2H_HREF{Top};
+ $T2H_NODE{Up} = 'Up';
+ }
+ else
+ {
+ $T2H_NAME{Up} = &clean_name($node);
+ $T2H_NODE{Up} = $node;
+ }
+
+ $node = $T2H_NODE{This};
+ $node = $node2prev{$node};
+ $T2H_NAME{Prev} = &clean_name($node);
+ $T2H_HREF{Prev} = $node2href{$node};
+ $T2H_NODE{Prev} = $node;
+
+ $node = $T2H_NODE{This};
+ if ($node2up{$node} && $node2up{$node} ne 'Top'&&
+ ($node2prev{$node} eq $T2H_NODE{Back} || ! $node2prev{$node}))
+ {
+ $node = $node2up{$node};
+ while ($node && $node ne $node2up{$node} && ! $node2prev{$node})
+ {
+ $node = $node2up{$node};
+ }
+ $node = $node2prev{$node}
+ unless $node2up{$node} eq 'Top' || ! $node2up{$node};
+ }
+ else
+ {
+ $node = $node2prev{$node};
+ }
+ $T2H_NAME{FastBack} = &clean_name($node);
+ $T2H_HREF{FastBack} = $node2href{$node};
+ $T2H_NODE{FastBack} = $node;
+
+ $node = $T2H_NODE{This};
+ $node = $node2next{$node};
+ $T2H_NAME{Next} = &clean_name($node);
+ $T2H_HREF{Next} = $node2href{$node};
+ $T2H_NODE{Next} = $node;
+
+ $node = $T2H_NODE{This};
+ if ($node2up{$node} && $node2up{$node} ne 'Top'&&
+ ($node2next{$node} eq $T2H_NODE{Forward} || ! $node2next{$node}))
+ {
+ $node = $node2up{$node};
+ while ($node && $node ne $node2up{$node} && ! $node2next{$node})
+ {
+ $node = $node2up{$node};
+ }
+ }
+ $node = $node2next{$node};
+ $T2H_NAME{FastForward} = &clean_name($node);
+ $T2H_HREF{FastForward} = $node2href{$node};
+ $T2H_NODE{FastForward} = $node;
+
+ if (! defined($FH))
+ {
+ my $file = $T2H_HREF{This};
+ $file =~ s/\#.*$//;
+ open(FILE, "> $docu_rdir$file") ||
+ die "$ERROR: Can't open $docu_rdir$file for writing: $!\n";
+ $FH = \*FILE;
+ &$T2H_print_page_head($FH);
+ t2h_print_label($FH);
+ &$T2H_print_chapter_header($FH) if $T2H_SPLIT eq 'chapter';
+ }
+ else
+ {
+ t2h_print_label($FH);
+ }
+
+ $T2H_THIS_SECTION = [];
+ while (@doc_lines) {
+ $_ = shift(@doc_lines);
+ last if ($_ eq $SECTIONEND || $_ eq $CHAPTEREND);
+ push(@$T2H_THIS_SECTION, $_);
+ }
+ $previous = $_;
+ &$T2H_print_section($FH);
+
+ if ($T2H_VERBOSE)
+ {
+ $counter++;
+ print "." if $counter =~ /00$/;
+ }
+}
+if ($T2H_SPLIT)
+{
+ &$T2H_print_chapter_footer($FH) if $T2H_SPLIT eq 'chapter';
+ &$T2H_print_page_foot($FH);
+ close($FH);
+}
+print "\n" if $T2H_VERBOSE;
+
+#############################################################################
+# Print ToC, Overview, Footnotes
+#
+undef $T2H_HREF{Prev};
+undef $T2H_HREF{Next};
+undef $T2H_HREF{Back};
+undef $T2H_HREF{Forward};
+undef $T2H_HREF{Up};
+
+if (@foot_lines)
+{
+ print "# writing Footnotes in $docu_foot_file...\n" if $T2H_VERBOSE;
+ open (FILE, "> $docu_foot_file") || die "$ERROR: Can't open $docu_foot_file for writing: $!\n"
+ if $T2H_SPLIT;
+ $T2H_HREF{This} = $docu_foot;
+ $T2H_NAME{This} = $T2H_WORDS->{$T2H_LANG}->{'Footnotes_Title'};
+ $T2H_THIS_SECTION = \@foot_lines;
+ &$T2H_print_Footnotes(\*FILE);
+ close(FILE) if $T2H_SPLIT;
+}
+
+if (@toc_lines)
+{
+ print "# writing Toc in $docu_toc_file...\n" if $T2H_VERBOSE;
+ open (FILE, "> $docu_toc_file") || die "$ERROR: Can't open $docu_toc_file for writing: $!\n"
+ if $T2H_SPLIT;
+ $T2H_HREF{This} = $T2H_HREF{Contents};
+ $T2H_NAME{This} = $T2H_NAME{Contents};
+ $T2H_THIS_SECTION = \@toc_lines;
+ &$T2H_print_Toc(\*FILE);
+ close(FILE) if $T2H_SPLIT;
+}
+
+if (@stoc_lines)
+{
+ print "# writing Overview in $docu_stoc_file...\n" if $T2H_VERBOSE;
+ open (FILE, "> $docu_stoc_file") || die "$ERROR: Can't open $docu_stoc_file for writing: $!\n"
+ if $T2H_SPLIT;
+
+ $T2H_HREF{This} = $T2H_HREF{Overview};
+ $T2H_NAME{This} = $T2H_NAME{Overview};
+ $T2H_THIS_SECTION = \@stoc_lines;
+ unshift @$T2H_THIS_SECTION, "<BLOCKQUOTE>\n";
+ push @$T2H_THIS_SECTION, "\n</BLOCKQUOTE>\n";
+ &$T2H_print_Overview(\*FILE);
+ close(FILE) if $T2H_SPLIT;
+}
+
+if ($about_body = &$T2H_about_body())
+{
+ print "# writing About in $docu_about_file...\n" if $T2H_VERBOSE;
+ open (FILE, "> $docu_about_file") || die "$ERROR: Can't open $docu_about_file for writing: $!\n"
+ if $T2H_SPLIT;
+
+ $T2H_HREF{This} = $T2H_HREF{About};
+ $T2H_NAME{This} = $T2H_NAME{About};
+ $T2H_THIS_SECTION = [$about_body];
+ &$T2H_print_About(\*FILE);
+ close(FILE) if $T2H_SPLIT;
+}
+
+unless ($T2H_SPLIT)
+{
+ &$T2H_print_page_foot(\*FILE);
+ close (FILE);
+}
+
+Finish:
+&l2h_FinishFromHtml if ($T2H_L2H);
+&l2h_Finish if($T2H_L2H);
+print "# that's all folks\n" if $T2H_VERBOSE;
+
+exit(0);
+
+#+++############################################################################
+# #
+# Low level functions #
+# #
+#---############################################################################
+
+sub LocateIncludeFile
+{
+ my $file = shift;
+ my $dir;
+
+ return $file if (-e $file && -r $file);
+ foreach $dir (@T2H_INCLUDE_DIRS)
+ {
+ return "$dir/$file" if (-e "$dir/$file" && -r "$dir/$file");
+ }
+ return undef;
+}
+
+sub clean_name
+{
+ local ($_);
+ $_ = &remove_style($_[0]);
+ &unprotect_texi;
+ return $_;
+}
+
+sub update_sec_num {
+ local($name, $level) = @_;
+ my $ret;
+
+ $level--; # here we start at 0
+ if ($name =~ /^appendix/ || defined(@appendix_sec_num)) {
+ # appendix style
+ if (defined(@appendix_sec_num)) {
+ &incr_sec_num($level, @appendix_sec_num);
+ } else {
+ @appendix_sec_num = ('A', 0, 0, 0);
+ }
+ $ret = join('.', @appendix_sec_num[0..$level]);
+ } else {
+ # normal style
+ if (defined(@normal_sec_num))
+ {
+ &incr_sec_num($level, @normal_sec_num);
+ }
+ else
+ {
+ @normal_sec_num = (1, 0, 0, 0);
+ }
+ $ret = join('.', @normal_sec_num[0..$level]);
+ }
+
+ $ret .= "." if $level == 0;
+ return $ret;
+}
+
+sub incr_sec_num {
+ local($level, $l);
+ $level = shift(@_);
+ $_[$level]++;
+ foreach $l ($level+1 .. 3) {
+ $_[$l] = 0;
+ }
+}
+
+sub Sec2UpNode
+{
+ my $sec = shift;
+ my $num = $sec2number{$sec};
+
+ return '' unless $num;
+ return 'Top' unless $num =~ /\.\d+/;
+ $num =~ s/\.[^\.]*$//;
+ $num = $num . '.' unless $num =~ /\./;
+ return $sec2node{$number2sec{$num}};
+}
+
+sub Sec2PrevNode
+{
+ my $sec = shift;
+ my $num = $sec2number{$sec};
+ my ($i, $post);
+
+ if ($num =~ /(\w+)(\.$|$)/)
+ {
+ $num = $`;
+ $i = $1;
+ $post = $2;
+ if ($i eq 'A')
+ {
+ $i = $normal_sec_num[0];
+ }
+ elsif ($i ne '1')
+ {
+ # unfortunately, -- operator is not magical
+ $i = chr(ord($i) + 1);
+ }
+ else
+ {
+ return '';
+ }
+ return $sec2node{$number2sec{$num . $i . $post}}
+ }
+ return '';
+}
+
+sub Sec2NextNode
+{
+ my $sec = shift;
+ my $num = $sec2number{$sec};
+ my $i;
+
+ if ($num =~ /(\w+)(\.$|$)/)
+ {
+ $num = $`;
+ $i = $1;
+ $post = $2;
+ if ($post eq '.' && $i eq $normal_sec_num[0])
+ {
+ $i = 'A';
+ }
+ else
+ {
+ $i++;
+ }
+ return $sec2node{$number2sec{$num . $i . $post}}
+ }
+ return '';
+}
+
+sub check {
+ local($_, %seen, %context, $before, $match, $after);
+
+ while (<>) {
+ if (/\@(\*|\.|\:|\@|\{|\})/) {
+ $seen{$&}++;
+ $context{$&} .= "> $_" if $T2H_VERBOSE;
+ $_ = "$`XX$'";
+ redo;
+ }
+ if (/\@(\w+)/) {
+ ($before, $match, $after) = ($`, $&, $');
+ if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address
+ $seen{'e-mail address'}++;
+ $context{'e-mail address'} .= "> $_" if $T2H_VERBOSE;
+ } else {
+ $seen{$match}++;
+ $context{$match} .= "> $_" if $T2H_VERBOSE;
+ }
+ $match =~ s/^\@/X/;
+ $_ = "$before$match$after";
+ redo;
+ }
+ }
+
+ foreach (sort(keys(%seen))) {
+ if ($T2H_VERBOSE) {
+ print "$_\n";
+ print $context{$_};
+ } else {
+ print "$_ ($seen{$_})\n";
+ }
+ }
+}
+
+sub open {
+ local($name) = @_;
+
+ ++$fh_name;
+ if (open($fh_name, $name)) {
+ unshift(@fhs, $fh_name);
+ } else {
+ warn "$ERROR Can't read file $name: $!\n";
+ }
+}
+
+sub init_input {
+ @fhs = (); # hold the file handles to read
+ @input_spool = (); # spooled lines to read
+ $fh_name = 'FH000';
+ &open($docu);
+}
+
+sub next_line {
+ local($fh, $line);
+
+ if (@input_spool) {
+ $line = shift(@input_spool);
+ return($line);
+ }
+ while (@fhs) {
+ $fh = $fhs[0];
+ $line = <$fh>;
+ return($line) if $line;
+ close($fh);
+ shift(@fhs);
+ }
+ return(undef);
+}
+
+# used in pass 1, use &next_line
+sub skip_until {
+ local($tag) = @_;
+ local($_);
+
+ while ($_ = &next_line) {
+ return if /^\@end\s+$tag\s*$/;
+ }
+ die "* Failed to find '$tag' after: " . $lines[$#lines];
+}
+
+# used in pass 1 for l2h use &next_line
+sub string_until {
+ local($tag) = @_;
+ local($_, $string);
+
+ while ($_ = &next_line) {
+ return $string if /^\@end\s+$tag\s*$/;
+# $_ =~ s/hbox/mbox/g;
+ $string = $string.$_;
+ }
+ die "* Failed to find '$tag' after: " . $lines[$#lines];
+}
+
+#
+# HTML stacking to have a better HTML output
+#
+
+sub html_reset {
+ @html_stack = ('html');
+ $html_element = 'body';
+}
+
+sub html_push {
+ local($what) = @_;
+ push(@html_stack, $html_element);
+ $html_element = $what;
+}
+
+sub html_push_if {
+ local($what) = @_;
+ push(@html_stack, $html_element)
+ if ($html_element && $html_element ne 'P');
+ $html_element = $what;
+}
+
+sub html_pop {
+ $html_element = pop(@html_stack);
+}
+
+sub html_pop_if {
+ local($elt);
+
+ if (@_) {
+ foreach $elt (@_) {
+ if ($elt eq $html_element) {
+ $html_element = pop(@html_stack) if @html_stack;
+ last;
+ }
+ }
+ } else {
+ $html_element = pop(@html_stack) if @html_stack;
+ }
+}
+
+sub html_debug {
+ local($what, $line) = @_;
+ if ($T2H_DEBUG & $DEBUG_HTML)
+ {
+ $what = "\n" unless $what;
+ return("<!-- $line @html_stack, $html_element -->$what")
+ }
+ return($what);
+}
+
+# to debug the output...
+sub debug {
+ local($what, $line) = @_;
+ return("<!-- $line -->$what")
+ if $T2H_DEBUG & $DEBUG_HTML;
+ return($what);
+}
+
+sub SimpleTexi2Html
+{
+ local $_ = $_[0];
+ &protect_texi;
+ &protect_html;
+ $_ = substitute_style($_);
+ $_[0] = $_;
+}
+
+sub normalise_node {
+ local $_ = $_[0];
+ s/\s+/ /g;
+ s/ $//;
+ s/^ //;
+ &protect_texi;
+ &protect_html;
+ $_ = substitute_style($_);
+ $_[0] = $_;
+}
+
+sub menu_entry
+{
+ my ($node, $name, $descr) = @_;
+ my ($href, $entry);
+
+ &normalise_node($node);
+ $href = $node2href{$node};
+ if ($href)
+ {
+ $descr =~ s/^\s+//;
+ $descr =~ s/\s*$//;
+ $descr = SimpleTexi2Html($descr);
+ if ($T2H_NUMBER_SECTIONS && !$T2H_NODE_NAME_IN_MENU && $node2sec{$node})
+ {
+ $entry = $node2sec{$node};
+ $name = '';
+ }
+ else
+ {
+ &normalise_node($name);
+ $entry = ($name && ($name ne $node || ! $T2H_AVOID_MENU_REDUNDANCY)
+ ? "$name : $node" : $node);
+ }
+
+ if ($T2H_AVOID_MENU_REDUNDANCY && $descr)
+ {
+ my $clean_entry = $entry;
+ $clean_entry =~ s/^.*? // if ($clean_entry =~ /^([A-Z]|\d+)\.[\d\.]* /);
+ $clean_entry =~ s/[^\w]//g;
+ my $clean_descr = $descr;
+ $clean_descr =~ s/[^\w]//g;
+ $descr = '' if ($clean_entry eq $clean_descr)
+ }
+ push(@lines2,&debug('<TR><TD ALIGN="left" VALIGN="TOP">' .
+ &t2h_anchor('', $href, $entry) .
+ '</TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">' .
+ $descr .
+ "</TD></TR>\n", __LINE__));
+ }
+ elsif ($node =~ /^\(.*\)\w+/)
+ {
+ push(@lines2,&debug('<TR><TD ALIGN="left" VALIGN="TOP">' .
+ $entry .
+ '</TD><TD ALIGN="left" VALIGN="TOP">' . $descr .
+ "</TD></TR>\n", __LINE__))
+ }
+ else
+ {
+ warn "$ERROR Undefined node of menu_entry ($node): $_";
+ }
+}
+
+sub do_ctrl { "^$_[0]" }
+
+sub do_email {
+ local($addr, $text) = split(/,\s*/, $_[0]);
+
+ $text = $addr unless $text;
+ &t2h_anchor('', "mailto:$addr", $text);
+}
+
+sub do_sc
+{
+ # l2h does this much better
+ return &l2h_ToLatex("{\\sc ".&unprotect_html($_[0])."}") if ($T2H_L2H);
+ return "\U$_[0]\E";
+}
+
+sub do_math
+{
+ return &l2h_ToLatex("\$".&unprotect_html($_[0])."\$") if ($T2H_L2H);
+ return "<EM>".$text."</EM>";
+}
+
+sub do_uref {
+ local($url, $text, $only_text) = split(/,\s*/, $_[0]);
+
+ $text = $only_text if $only_text;
+ $text = $url unless $text;
+ &t2h_anchor('', $url, $text);
+}
+
+sub do_url { &t2h_anchor('', $_[0], $_[0]) }
+
+sub do_acronym
+{
+ return '<FONT SIZE="-1">' . $_[0] . '</FONT>';
+}
+
+sub do_accent
+{
+ return "&$_[0]acute;" if $_[1] eq 'H';
+ return "$_[0]." if $_[1] eq 'dotaccent';
+ return "$_[0]*" if $_[1] eq 'ringaccent';
+ return "$_[0]".'[' if $_[1] eq 'tieaccent';
+ return "$_[0]".'(' if $_[1] eq 'u';
+ return "$_[0]_" if $_[1] eq 'ubaraccent';
+ return ".$_[0]" if $_[1] eq 'udotaccent';
+ return "$_[0]&lt;" if $_[1] eq 'v';
+ return "&$_[0]cedil;" if $_[1] eq ',';
+ return "$_[0]" if $_[1] eq 'dotless';
+ return undef;
+}
+
+sub apply_style {
+ local($texi_style, $text) = @_;
+ local($style);
+
+ $style = $style_map{$texi_style};
+ if (defined($style)) { # known style
+ if ($style =~ /^\"/) { # add quotes
+ $style = $';
+ $text = "\`$text\'";
+ }
+ if ($style =~ /^\&/) { # custom
+ $style = $';
+ $text = &$style($text, $texi_style);
+ } elsif ($style) { # good style
+ $text = "<$style>$text</$style>";
+ } else { # no style
+ }
+ } else { # unknown style
+ $text = undef;
+ }
+ return($text);
+}
+
+# remove Texinfo styles
+sub remove_style {
+ local($_) = @_;
+ 1 while(s/\@\w+{([^\{\}]+)}/$1/g);
+ return($_);
+}
+
+sub remove_things
+{
+ local ($_) = @_;
+ s|\@(\w+)\{\}|$1|g;
+ return $_;
+}
+
+sub substitute_style {
+ local($_) = @_;
+ local($changed, $done, $style, $text);
+
+ &simple_substitutions;
+ $changed = 1;
+ while ($changed) {
+ $changed = 0;
+ $done = '';
+ while (/\@(\w+){([^\{\}]+)}/ || /\@(,){([^\{\}]+)}/) {
+ $text = &apply_style($1, $2);
+ if ($text) {
+ $_ = "$`$text$'";
+ $changed = 1;
+ } else {
+ $done .= "$`\@$1";
+ $_ = "{$2}$'";
+ }
+ }
+ $_ = $done . $_;
+ }
+ return($_);
+}
+
+sub t2h_anchor {
+ local($name, $href, $text, $newline, $extra_attribs) = @_;
+ local($result);
+
+ $result = "<A";
+ $result .= " NAME=\"$name\"" if $name;
+ if ($href)
+ {
+ $href =~ s|^$T2H_HREF_DIR_INSTEAD_FILE|./|
+ if ($T2H_HREF_DIR_INSTEAD_FILE);
+ $result .= ($href =~ /\"/ ? " HREF='$href'" : " HREF=\"$href\"");
+ }
+ $result .= " $extra_attribs" if $extra_attribs;
+ $result .= ">$text</A>";
+ $result .= "\n" if $newline;
+ return($result);
+}
+
+sub pretty_date {
+ local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
+
+ @MoY = ('January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December');
+ ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
+ $year += ($year < 70) ? 2000 : 1900;
+ # obachman: Let's do it as the Americans do
+ return("$MoY[$mon], $mday $year");
+}
+
+sub doc_href {
+ local($num) = @_;
+
+ return("${docu_name}_$num.$docu_ext");
+}
+
+sub sec_href
+{
+ return $node2href{$sec2node{$_[0]}};
+}
+
+sub next_doc {
+ $docu_doc = &doc_href(++$doc_num);
+}
+
+sub t2h_print_lines {
+ my ($fh, $lines) = @_;
+ local($_);
+ $lines = $T2H_THIS_SECTION unless $lines;
+ my $cnt = 0;
+ for (@$lines)
+ {
+ $_ = l2h_FromHtml($_) if ($T2H_L2H);
+ if (/^$PROTECTTAG/o) {
+ $_ = $tag2pro{$_};
+ } else {
+ &unprotect_texi;
+ }
+ print $fh $_;
+ $cnt += split(/\W*\s+\W*/);
+ }
+ return $cnt;
+}
+
+sub protect_texi {
+ # protect @ { } ` '
+ s/\@\@/$;0/go;
+ s/\@\{/$;1/go;
+ s/\@\}/$;2/go;
+ s/\@\`/$;3/go;
+ s/\@\'/$;4/go;
+}
+
+sub protect_html {
+ local($what) = @_;
+ # protect & < >
+ $what =~ s/\&/\&\#38;/g;
+ $what =~ s/\</\&\#60;/g;
+ $what =~ s/\>/\&\#62;/g;
+ # restore anything in quotes
+ # this fixes my problem where I had:
+ # < IMG SRC="leftarrow.gif" ALT="<--" > but what if I wanted &#60; in my ALT text ??
+ # maybe byte stuffing or some other technique should be used.
+ $what =~ s/\"([^\&]+)\&\#60;(.*)\"/"$1<$2"/g;
+ $what =~ s/\"([^\&]+)\&\#62;(.*)\"/"$1>$2"/g;
+ $what =~ s/\"([^\&]+)\&\#38;(.*)\"/"$1&$2"/g;
+ # but recognize some HTML things
+ $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # </A>
+ $what =~ s/\&\#60;A ([^\&]+)\&\#62;/<A $1>/g; # <A [^&]+>
+ $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;/<IMG $1>/g; # <IMG [^&]+>
+ return($what);
+}
+
+sub unprotect_texi {
+ s/$;0/\@/go;
+ s/$;1/\{/go;
+ s/$;2/\}/go;
+ s/$;3/\`/go;
+ s/$;4/\'/go;
+}
+
+sub Unprotect_texi
+{
+ local $_ = shift;
+ &unprotect_texi;
+ return($_);
+}
+
+sub unprotect_html {
+ local($what) = @_;
+ $what =~ s/\&\#38;/\&/g;
+ $what =~ s/\&\#60;/\</g;
+ $what =~ s/\&\#62;/\>/g;
+ return($what);
+}
+
+sub t2h_print_label
+{
+ my $fh = shift;
+ my $href = shift || $T2H_HREF{This};
+ $href =~ s/.*#(.*)$/$1/;
+ print $fh qq{<A NAME="$href"></A>\n};
+}
+
+##############################################################################
+
+ # These next few lines are legal in both Perl and nroff.
+
+.00 ; # finish .ig
+
+'di \" finish diversion--previous line must be blank
+.nr nl 0-1 \" fake up transition to first page again
+.nr % 0 \" start at page 1
+'; __END__ ############# From here on it's a standard manual page ############
+.so /usr/local/man/man1/texi2html.1
diff --git a/support/xcase.c b/support/xcase.c
new file mode 100644
index 0000000..527840d
--- /dev/null
+++ b/support/xcase.c
@@ -0,0 +1,98 @@
+/* xcase - change uppercase characters to lowercase or vice versa. */
+
+/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "bashansi.h"
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+extern int optind;
+
+#define LOWER 1
+#define UPPER 2
+
+int
+main(ac, av)
+int ac;
+char **av;
+{
+ int c, x;
+ int op;
+ FILE *inf;
+
+ op = 0;
+ while ((c = getopt(ac, av, "lnu")) != EOF) {
+ switch (c) {
+ case 'n':
+ setbuf (stdout, (char *)NULL);
+ break;
+ case 'u':
+ op = UPPER;
+ break;
+ case 'l':
+ op = LOWER;
+ break;
+ default:
+ fprintf(stderr, "casemod: usage: casemod [-lnu] [file]\n");
+ exit(2);
+ }
+ }
+ av += optind;
+ ac -= optind;
+
+ if (av[0] && (av[0][0] != '-' || av[0][1])) {
+ inf = fopen(av[0], "r");
+ if (inf == 0) {
+ fprintf(stderr, "casemod: %s: cannot open: %s\n", av[0], strerror(errno));
+ exit(1);
+ }
+ } else
+ inf = stdin;
+
+ while ((c = getc(inf)) != EOF) {
+ switch (op) {
+ case UPPER:
+ x = islower(c) ? toupper(c) : c;
+ break;
+ case LOWER:
+ x = isupper(c) ? tolower(c) : c;
+ break;
+ default:
+ x = c;
+ break;
+ }
+ putchar(x);
+ }
+
+ exit(0);
+}
diff --git a/support/xenix-link.sh b/support/xenix-link.sh
new file mode 100755
index 0000000..4d82e00
--- /dev/null
+++ b/support/xenix-link.sh
@@ -0,0 +1,84 @@
+:
+# link bash for Xenix under SCO Unix
+#
+# For xenix 2.2:
+# CC="cc -xenix -lx" ./configure
+# edit config.h:
+# comment out the define for HAVE_DIRENT_H
+# enable the define for HAVE_SYS_NDIR_H to 1
+# make
+# CC="cc -xenix -lx" ./link.sh
+#
+# For xenix 2.3:
+# CC="cc -x2.3" ./configure
+# make
+# CC="cc -x2.3" ./link.sh
+
+# Copyright (C) 1989-2002 Free Software Foundation, Inc.
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+set -x
+
+rm -f bash
+
+if [ -z "$CC" ]
+then
+ if [ -f /unix ] && [ ! -f /xenix ]
+ then
+ CC="cc -xenix"
+ else
+ CC=gcc
+ fi
+fi
+
+try_dir=no
+try_23=no
+try_x=yes
+
+case "$CC" in
+*-ldir*) try_dir=yes ;;
+esac
+
+case "$CC" in
+*-lx*) try_23=no ; try_x=yes ;;
+esac
+
+case "$CC" in
+*-x2.3*|*-l2.3*) try_23=yes ; try_dir=yes ;;
+esac
+
+libs=
+try="socket"
+if [ $try_dir = yes ] ; then try="$try dir" ; fi
+if [ $try_23 = yes ] ; then try="$try 2.3" ; fi
+if [ $try_x = yes ] ; then try="$try x" ; fi
+for name in $try
+do
+ if [ -r "/lib/386/Slib${name}.a" ] ; then libs="$libs -l$name" ; fi
+done
+
+$CC -o bash shell.o eval.o y.tab.o \
+general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o \
+copy_cmd.o error.o expr.o flags.o nojobs.o subst.o hashcmd.o hashlib.o \
+mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o \
+version.o alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
+getcwd.o siglist.o vprint.o oslib.o list.o stringlib.o locale.o \
+xmalloc.o builtins/libbuiltins.a \
+lib/readline/libreadline.a lib/readline/libhistory.a \
+-ltermcap lib/glob/libglob.a lib/tilde/libtilde.a lib/malloc/libmalloc.a \
+$libs
+
+ls -l bash
diff --git a/support/zecho.c b/support/zecho.c
new file mode 100644
index 0000000..f3a4fe0
--- /dev/null
+++ b/support/zecho.c
@@ -0,0 +1,43 @@
+/* zecho - bare-bones echo */
+
+/* Copyright (C) 1996-2002 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash 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 3 of the License, or
+ (at your option) any later version.
+
+ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include "bashansi.h"
+#include <stdio.h>
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+ argv++;
+
+ while (*argv) {
+ (void)printf("%s", *argv);
+ if (*++argv)
+ putchar(' ');
+ }
+
+ putchar('\n');
+ exit(0);
+}