diff options
Diffstat (limited to 'Build/source/texk/seetexk')
72 files changed, 22856 insertions, 0 deletions
diff --git a/Build/source/texk/seetexk/ChangeLog b/Build/source/texk/seetexk/ChangeLog new file mode 100644 index 00000000000..7474ed5dd38 --- /dev/null +++ b/Build/source/texk/seetexk/ChangeLog @@ -0,0 +1,91 @@ +2004-12-30 Peter Breitenlohner <peb@mppmu.mpg.de> + + * dvibook.c(main): Removed prototype, explicit int return type, + changed exit at end into return. + + * dviconcat.c(main): Changed return type void into int, changed + exit at end into return. + + * dviselect.c(main): Explicit int return type, changed exit at end + into return. + + * dvitodvi.c(main): Removed prototype, changed return type void + into int, changed exit at end into return. + +1998-03-26 Eli Zaretskii <eliz@is.elta.co.il> + + * tempfile.c: Use text/binary parameterization from Kpathsea. + (RemoveTempFile): New function, to remove temporary file on exit. + (MakeRWTempFile): Use "." as directory for temporary file on MSDOS + as well. Call RemoveTempFile instead of relying on it being + unlinked when it is closed, on DOSISH systems. + + * seek.c: Use text/binary parameterization from Kpathsea. + (CopyFile): Make sure the temporary file is put into the same mode + (text or binary) as the original input handle. + + * dvitodvi.c: Use text/binary parameterization from Kpathsea. + (main): Switch standard streams to binary mode when necessary. + + * dviselect.c: Use text/binary parameterization from Kpathsea. + + * dviconcat.c: Use text/binary parameterization from Kpathsea. + (main): Switch standard streams to binary mode when necessary. + + * dvibook.c: Use text/binary parameterization from Kpathsea. + + * Makefile.in (prog_cflags): Add HAVE_CONFIG_H and -I with paths + to Kpathsea directory. + +Tue Feb 24 11:56:33 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * error.c: cleanup for win32 from Fabrice Popineau + +Mon Feb 2 11:15:48 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * more fixes to error.* from Peter Breitenlohner + + * Makefile.in: install man pages for dvibook and dvitodvi + +Wed Jan 28 09:46:59 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * application programs and error.*: prototyping improved by + Fabrice Popineau + +Tue Jan 27 14:32:25 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * rewrite of error function by Thomas Esser. needed check of + strerror in configure.in + + * configure etc: new configure.in, c-auto.in, Makefile.in from + Olaf Weber + +Tue Jan 20 10:14:41 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * fiddled about with NeedVarargs etc to use + HAVE_PROTOTYPES. Depended all the malloc etc declarations on + #ifndef KPATHSEA + + * added check of function prototypes to c-auto.in; added + additional Amiga check to dvibook and dvitodvi + +Mon Jan 19 20:45:47 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * cut down contents of libtex.a to bare minimum + +Sat Jan 17 15:08:03 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * assorted patches from Olaf Weber, + Peter Breitenlohner, Fabrice Popineau + etc. va_start drove me mad. I never want to see this again. + +Wed Jan 7 14:46:38 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * Added Angus Duggan's dvibook and dvitodvi programs. + +Thu Jan 1 11:00:52 1998 Sebastian Rahtz <s.rahtz@elsevier.co.uk> + + * Started ChangeLog for seetexk. This is a very rough addition to + the texk family to allow us to have just dviconcat and + dviselect. No attempt to compile xtex! Made a configure file. + diff --git a/Build/source/texk/seetexk/Makefile.in b/Build/source/texk/seetexk/Makefile.in new file mode 100644 index 00000000000..b1b57d0b99e --- /dev/null +++ b/Build/source/texk/seetexk/Makefile.in @@ -0,0 +1,81 @@ +# Makefile for seetexk -- S Rahtz s.rahtz@elsevier.co.uk. Public domain. +version = 1.0 + +kpse_include ../make/paths.mk +kpse_include ../make/common.mk +kpse_include ../make/programs.mk +kpse_include ../make/texi.mk +prog_cflags = -DUNIX -DKPATHSEA -DNeedFunctionPrototypes -DHAVE_CONFIG_H \ + -I$(kpathsea_dir) -I$(kpathsea_srcdir) + +RANLIB=@RANLIB@ +AR=ar + +ALLLIBOBJS= bcopy.o bzero.o conv.o dvi_draw.o dviclass.o dvistate.o dvistuff.o \ + error.o findpost.o fio.o font_subr.o getopt.o gfclass.o gffont.o \ + gripes0.o gripes1.o magfactor.o pkfont.o pxlfont.o rotate.o rstfont.o \ + scaletfm.o scanpost.o search.o seek.o skip.o split.o \ + strsave.o strtol.o tempfile.o tfm.o tfmfont.o + +LIBOBJS= error.o fio.o search.o gripes0.o gripes1.o dviclass.o tempfile.o seek.o + +library = tex + +objects = dviconcat.o dviselect.o dvibook.o dvitodvi.o + +program = dviconcat dviselect dvibook dvitodvi +programs =$(program) + +default all: $(programs) + +libtex.a: $(LIBOBJS) + $(AR) rc $@ $(LIBOBJS) + $(RANLIB) $@ + +dviconcat: $(kpathsea) dviconcat.o libtex.a + $(kpathsea_link) dviconcat.o libtex.a $(LOADLIBES) + +dviselect: $(kpathsea) dviselect.o libtex.a + $(kpathsea_link) dviselect.o libtex.a $(LOADLIBES) + +dvibook: $(kpathsea) dvibook.o libtex.a + $(kpathsea_link) dvibook.o libtex.a $(LOADLIBES) + +dvitodvi: $(kpathsea) dvitodvi.o libtex.a + $(kpathsea_link) dvitodvi.o libtex.a $(LOADLIBES) + +kpse_include ../make/tkpathsea.mk + +install: install-exec install-data + +uninstall: uninstall-exec uninstall-data + +install-exec: all + $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) + for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done +uninstall-exec: + for p in $(programs); do rm -f $(bindir)/$$p; done + +install-data: + $(SHELL) $(top_srcdir)/../mkinstalldirs $(man1dir) + $(INSTALL_DATA) $(srcdir)/dviselect.man $(man1dir)/dviselect.1 + $(INSTALL_DATA) $(srcdir)/dviconcat.man $(man1dir)/dviconcat.1 + $(INSTALL_DATA) $(srcdir)/dvibook.man $(man1dir)/dvibook.1 + $(INSTALL_DATA) $(srcdir)/dvitodvi.man $(man1dir)/dvitodvi.1 + +uninstall-data: + rm -f $(man1dir)/dviselect.1 + rm -f $(man1dir)/dviconcat.1 + rm -f $(man1dir)/dvibook.1 + rm -f $(man1dir)/dvitodvi.1 + +distname = seetexk + +kpse_include ../make/dist.mk +kpse_include ../make/config.mk + +info dvi check: + +kpse_include ../make/clean.mk +kpse_include ../make/rdepend.mk +kpse_include depend.mk diff --git a/Build/source/texk/seetexk/README b/Build/source/texk/seetexk/README new file mode 100644 index 00000000000..a9d6c80e9d3 --- /dev/null +++ b/Build/source/texk/seetexk/README @@ -0,0 +1,7 @@ +Note that this is is a *partial* repackaging of elements of the SeeTeX +package by Chris Torek <torek@bsdi.com>; the full package is in +CTAN:drivers. Here we just want dviconcat and dviselect, plus Angus +Duggan's dvibook and dvitodvi. + +Sebastian Rahtz <s.rahtz@elsevier.co.uk> +January 1998 diff --git a/Build/source/texk/seetexk/acconfig.h b/Build/source/texk/seetexk/acconfig.h new file mode 100644 index 00000000000..461e5c875f5 --- /dev/null +++ b/Build/source/texk/seetexk/acconfig.h @@ -0,0 +1,26 @@ +/* Define if your compiler understands prototypes. */ +#undef HAVE_PROTOTYPES + +/* Define if your putenv doesn't waste space when the same environment + variable is assigned more than once, with different (malloced) + values. This is true only on NetBSD/FreeBSD, as far as I know. See + xputenv.c. */ +#undef SMART_PUTENV + +/* Define if getcwd if implemented using fork or vfork. Let me know + if you have to add this by hand because configure failed to detect + it. */ +#undef GETCWD_FORKS + +/* Define if you are using GNU libc or otherwise have global variables + `program_invocation_name' and `program_invocation_short_name'. */ +#undef HAVE_PROGRAM_INVOCATION_NAME + +/* all: Define to enable running scripts when missing input files. */ +#define MAKE_TEX_MF_BY_DEFAULT 0 +#define MAKE_TEX_PK_BY_DEFAULT 0 +#define MAKE_TEX_TEX_BY_DEFAULT 0 +#define MAKE_TEX_TFM_BY_DEFAULT 0 +#define MAKE_TEX_FMT_BY_DEFAULT 0 +#define MAKE_OMEGA_OFM_BY_DEFAULT 0 +#define MAKE_OMEGA_OCP_BY_DEFAULT 0 diff --git a/Build/source/texk/seetexk/bcopy.c b/Build/source/texk/seetexk/bcopy.c new file mode 100644 index 00000000000..e9bb17ea79e --- /dev/null +++ b/Build/source/texk/seetexk/bcopy.c @@ -0,0 +1,26 @@ +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/bcopy.c,v 3.1 89/08/22 21:42:07 chris Exp $"; +#endif + +/* + * Sample bcopy() routine. + * This should be rewritten to be as fast as possible for your + * machine. + */ +void bcopy(from, to, count) + register char *from, *to; + register int count; +{ + + if (from == to) + return; + if (from > to) { + while (--count >= 0) + *to++ = *from++; + } else { + from += count; + to += count; + while (--count >= 0) + *--to = *--from; + } +} diff --git a/Build/source/texk/seetexk/bzero.c b/Build/source/texk/seetexk/bzero.c new file mode 100644 index 00000000000..cf1dd416452 --- /dev/null +++ b/Build/source/texk/seetexk/bzero.c @@ -0,0 +1,17 @@ +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/bzero.c,v 3.1 89/08/22 21:42:12 chris Exp $"; +#endif + +/* + * Sample bzero() routine. + * This should be rewritten to be as fast as possible for your + * machine. + */ +bzero(addr, count) + register char *addr; + register int count; +{ + + while (--count >= 0) + *addr++ = 0; +} diff --git a/Build/source/texk/seetexk/c-auto.in b/Build/source/texk/seetexk/c-auto.in new file mode 100644 index 00000000000..4e34810adfd --- /dev/null +++ b/Build/source/texk/seetexk/c-auto.in @@ -0,0 +1,136 @@ +/* c-auto.in. Generated automatically from configure.in by autoheader. */ + +/* Define if the closedir function returns void instead of int. */ +#undef CLOSEDIR_VOID + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if your compiler understands prototypes. */ +#undef HAVE_PROTOTYPES + +/* Define if your putenv doesn't waste space when the same environment + variable is assigned more than once, with different (malloced) + values. This is true only on NetBSD/FreeBSD, as far as I know. See + xputenv.c. */ +#undef SMART_PUTENV + +/* Define if getcwd if implemented using fork or vfork. Let me know + if you have to add this by hand because configure failed to detect + it. */ +#undef GETCWD_FORKS + +/* Define if you are using GNU libc or otherwise have global variables + `program_invocation_name' and `program_invocation_short_name'. */ +#undef HAVE_PROGRAM_INVOCATION_NAME + +/* all: Define to enable running scripts when missing input files. */ +#define MAKE_TEX_MF_BY_DEFAULT 0 +#define MAKE_TEX_PK_BY_DEFAULT 0 +#define MAKE_TEX_TEX_BY_DEFAULT 0 +#define MAKE_TEX_TFM_BY_DEFAULT 0 +#define MAKE_TEX_FMT_BY_DEFAULT 0 +#define MAKE_OMEGA_OFM_BY_DEFAULT 0 +#define MAKE_OMEGA_OCP_BY_DEFAULT 0 + +/* The number of bytes in a int. */ +#undef SIZEOF_INT + +/* Define if you have the bcmp function. */ +#undef HAVE_BCMP + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the bzero function. */ +#undef HAVE_BZERO + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the getwd function. */ +#undef HAVE_GETWD + +/* Define if you have the index function. */ +#undef HAVE_INDEX + +/* Define if you have the memcmp function. */ +#undef HAVE_MEMCMP + +/* Define if you have the memcpy function. */ +#undef HAVE_MEMCPY + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV + +/* Define if you have the rindex function. */ +#undef HAVE_RINDEX + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the strchr function. */ +#undef HAVE_STRCHR + +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR + +/* Define if you have the strrchr function. */ +#undef HAVE_STRRCHR + +/* Define if you have the strstr function. */ +#undef HAVE_STRSTR + +/* Define if you have the strtol function. */ +#undef HAVE_STRTOL + +/* Define if you have the <assert.h> header file. */ +#undef HAVE_ASSERT_H + +/* Define if you have the <dirent.h> header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define if you have the <errno.h> header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the <float.h> header file. */ +#undef HAVE_FLOAT_H + +/* Define if you have the <limits.h> header file. */ +#undef HAVE_LIMITS_H + +/* Define if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define if you have the <ndir.h> header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the <pwd.h> header file. */ +#undef HAVE_PWD_H + +/* Define if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define if you have the <sys/dir.h> header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the <sys/ndir.h> header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the <sys/param.h> header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM diff --git a/Build/source/texk/seetexk/configure b/Build/source/texk/seetexk/configure new file mode 100755 index 00000000000..0f6781ef900 --- /dev/null +++ b/Build/source/texk/seetexk/configure @@ -0,0 +1,7453 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-shared[=PKGS] build shared libraries [default=yes]" +ac_help="$ac_help + --enable-static[=PKGS] build static libraries [default=yes]" +ac_help="$ac_help + --enable-fast-install[=PKGS] optimize for fast installation [default=yes]" +ac_help="$ac_help + --with-gnu-ld assume the C compiler uses GNU ld [default=no]" + +# Find the correct PATH separator. Usually this is `:', but +# DJGPP uses `;' like DOS. +if test "X${PATH_SEPARATOR+set}" != Xset; then + UNAME=${UNAME-`uname 2>/dev/null`} + case X$UNAME in + *-DOS) lt_cv_sys_path_separator=';' ;; + *) lt_cv_sys_path_separator=':' ;; + esac + PATH_SEPARATOR=$lt_cv_sys_path_separator +fi + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<EOF + +EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + +ac_help="$ac_help + --disable-libtool-lock avoid locking (might break parallel builds)" +ac_help="$ac_help + --with-pic try to use only PIC/non-PIC objects [default=use both]" +ac_help="$ac_help + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer" +ac_help="$ac_help + --without-mktexmf-default do not run mktexmf if MF source missing" +ac_help="$ac_help + --without-mktexpk-default do not run mktexpk if PK font missing" +ac_help="$ac_help + --without-mktextfm-default do not run mktextfm if TFM file missing" +ac_help="$ac_help + --without-mkocp-default do not run mkocp if OCP file missing" +ac_help="$ac_help + --without-mkofm-default do not run mkofm if OFM file missing" +ac_help="$ac_help + --with-mktexfmt-default run mktexfmt if format file missing" +ac_help="$ac_help + --with-mktextex-default run mktextex if TeX source missing" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +ac_config_files= +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_envvar| sed 's/[_a-zA-Z0-9]//g'`"; then + { echo "configure: error: invalid variable name: $ac_envvar" 1>&2; exit 1; } + fi + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=dviselect.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + + + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:733: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:764: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:816: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:849: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 860 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:891: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:896: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:905: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:924: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + case $ac_dir in + /*|[A-z]:/*) ac_aux_dir=$ac_dir;; + *) ac_aux_dir=`pwd`/$ac_dir;; + esac + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + case $ac_dir in + /*|[A-z]:/*) ac_aux_dir=$ac_dir;; + *) ac_aux_dir=`pwd`/$ac_dir;; + esac + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:992: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + # Hack for MSDOS and descendants. + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test $ac_x $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +echo "configure:1047: checking whether ln -s works" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftestdata +# MS-DOS is a special case, because it sort of pretends that ln -s +# works for executables. +if test -z "$COMSPEC" && ln -s X conftestdata 2>/dev/null +then + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi +fi +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:1070: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- +## Copyright 1996, 1997, 1998, 1999, 2000, 2001 +## Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 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 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +## 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. + +# serial 46 AC_PROG_LIBTOOL + + + + + +# AC_LIBTOOL_HEADER_ASSERT +# ------------------------ +# AC_LIBTOOL_HEADER_ASSERT + +# _LT_AC_CHECK_DLFCN +# -------------------- +# _LT_AC_CHECK_DLFCN + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- + # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + +# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR +# --------------------------------- +# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +# _LT_AC_PROG_ECHO_BACKSLASH + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +# _LT_AC_TRY_DLOPEN_SELF + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +# AC_LIBTOOL_DLOPEN_SELF + +# _LT_AC_LTCONFIG_HACK + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support + + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's + + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. + + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared + + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. + + +# AC_DISABLE_STATIC - set the default static flag to --disable-static + + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. + + +# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install + + +# AC_LIBTOOL_PICMODE - implement the --with-pic flag +# Usage: AC_LIBTOOL_PICMODE[(MODE)] +# Where MODE is either `yes' or `no'. If omitted, it defaults to +# `both'. + + + +# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library + + + +# AC_PATH_MAGIC - find a file program which can recognise a shared library + + + +# AC_PROG_LD - find the path to the GNU or non-GNU linker + + +# AC_PROG_LD_GNU - + + +# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker +# -- PORTME Some linkers may need a different reload flag. + + +# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics + + + +# AC_PROG_NM - find the path to a BSD-compatible name lister + + +# AC_CHECK_LIBM - check for math library + + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and LTDLINCL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and LTDLINCL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and LTDLINCL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. + + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and LTDLINCL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and LTDLINCL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. + + +# old names + + + + + + + + +# This is just to silence aclocal about the macro not being used + + +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. + + + +# Find the correct PATH separator. Usually this is `:', but +# DJGPP uses `;' like DOS. +if test "X${PATH_SEPARATOR+set}" != Xset; then + UNAME=${UNAME-`uname 2>/dev/null`} + case X$UNAME in + *-DOS) lt_cv_sys_path_separator=';' ;; + *) lt_cv_sys_path_separator=':' ;; + esac + PATH_SEPARATOR=$lt_cv_sys_path_separator +fi + +echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 +echo "configure:1292: checking for Cygwin environment" >&5 +if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1297 "configure" +#include "confdefs.h" + +int main() { + +#ifndef __CYGWIN__ +#define __CYGWIN__ __CYGWIN32__ +#endif +return __CYGWIN__; +; return 0; } +EOF +if { (eval echo configure:1308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_cygwin=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_cygwin=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_cygwin" 1>&6 +CYGWIN= +test "$ac_cv_cygwin" = yes && CYGWIN=yes +echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 +echo "configure:1325: checking for mingw32 environment" >&5 +if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1330 "configure" +#include "confdefs.h" + +int main() { +return __MINGW32__; +; return 0; } +EOF +if { (eval echo configure:1337: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_mingw32=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_mingw32=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_mingw32" 1>&6 +MINGW32= +test "$ac_cv_mingw32" = yes && MINGW32=yes +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1354: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 1369 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 1386 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1392: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 1403 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1409: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case $enableval in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=yes +fi + +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} +case $enableval in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_static=yes +fi + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} +case $enableval in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_fast_install=yes +fi + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:1509: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:1530: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 +echo "configure:1559: checking for ld used by GCC" >&5 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 +echo "configure:1589: checking for GNU ld" >&5 +else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 +echo "configure:1592: checking for non-GNU ld" >&5 +fi +if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$lt_cv_path_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } +echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 +echo "configure:1627: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then + lt_cv_prog_gnu_ld=yes +else + lt_cv_prog_gnu_ld=no +fi +fi + +echo "$ac_t""$lt_cv_prog_gnu_ld" 1>&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + +echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 +echo "configure:1644: checking for $LD option to reload object files" >&5 +if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + lt_cv_ld_reload_flag='-r' +fi + +echo "$ac_t""$lt_cv_ld_reload_flag" 1>&6 +reload_flag=$lt_cv_ld_reload_flag +test -n "$reload_flag" && reload_flag=" $reload_flag" + +echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 +echo "configure:1656: checking for BSD-compatible nm" >&5 +if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/${ac_tool_prefix}nm + if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then + lt_cv_path_NM="$tmp_nm -B" + break + elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + lt_cv_path_NM="$tmp_nm -p" + break + else + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi +fi + +NM="$lt_cv_path_NM" +echo "$ac_t""$NM" 1>&6 + +echo $ac_n "checking for a sed that does not truncate output""... $ac_c" 1>&6 +echo "configure:1694: checking for a sed that does not truncate output" >&5 +if eval "test \"`echo '$''{'lt_cv_path_SED'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_executable_p="test -f" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext" + fi + done + done +done + + # Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/sed$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} + _max=0 + _count=0 + # Add /usr/xpg4/bin/sed as it is typically found on Solaris + # along with /bin/sed that truncates output. + for _sed in $_sed_list /usr/xpg4/bin/sed; do + test ! -f ${_sed} && break + cat /dev/null > "$tmp/sed.in" + _count=0 + echo ${ECHO_N-$ac_n} "0123456789${ECHO_C-$ac_c}" >"$tmp/sed.in" + # Check for GNU sed and select it if it is found. + if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then + lt_cv_path_SED=${_sed} + break + fi + while true; do + cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp" + mv "$tmp/sed.tmp" "$tmp/sed.in" + cp "$tmp/sed.in" "$tmp/sed.nl" + echo >>"$tmp/sed.nl" + ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break + cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break + # 40000 chars as input seems more than enough + test $_count -gt 10 && break + _count=`expr $_count + 1` + if test $_count -gt $_max; then + _max=$_count + lt_cv_path_SED=$_sed + fi + done + done + rm -rf "$tmp" + +fi + +if test "X$SED" != "X"; then + lt_cv_path_SED=$SED +else + SED=$lt_cv_path_SED +fi +echo "$ac_t""$SED" 1>&6 + +echo $ac_n "checking how to recognise dependent libraries""... $ac_c" 1>&6 +echo "configure:1778: checking how to recognise dependent libraries" >&5 +if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi4*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin* | mingw* | pw32*) + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' + lt_cv_file_magic_cmd='/usr/bin/file -L' + case "$host_os" in + rhapsody* | darwin1.[012]) + lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` + ;; + *) # Darwin 1.3 on + lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' + ;; + esac + ;; + +freebsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20*|hpux11*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + irix5* | nonstopux*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" + ;; + esac + lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux-gnu*) + case $host_cpu in + alpha* | hppa* | i*86 | mips | mipsel | powerpc* | sparc* | ia64*) + lt_cv_deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; + esac + lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' + lt_cv_file_magic_test_file=/shlib/libc.so + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + lt_cv_file_magic_test_file=/lib/libc.so + ;; + +sysv5uw[78]* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; +esac + +fi + +echo "$ac_t""$lt_cv_deplibs_check_method" 1>&6 +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method + +echo $ac_n "checking for object suffix""... $ac_c" 1>&6 +echo "configure:1964: checking for object suffix" >&5 +if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftest* +echo 'int i = 1;' > conftest.$ac_ext +if { (eval echo configure:1970: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + for ac_file in conftest.*; do + case $ac_file in + *.c) ;; + *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done +else + { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; } +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_objext" 1>&6 +OBJEXT=$ac_cv_objext +ac_objext=$ac_cv_objext + + + +echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 +echo "configure:1990: checking for executable suffix" >&5 +if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$CYGWIN" = yes || test "$MINGW32" = yes; then + ac_cv_exeext=.exe +else + rm -f conftest* + echo 'int main () { return 0; }' > conftest.$ac_ext + ac_cv_exeext= + if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + for file in conftest.*; do + case $file in + *.c | *.o | *.obj) ;; + *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + else + { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; } + fi + rm -f conftest* + test x"${ac_cv_exeext}" = x && ac_cv_exeext=no +fi +fi + +EXEEXT="" +test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} +echo "$ac_t""${ac_cv_exeext}" 1>&6 +ac_exeext=$EXEEXT + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + + + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6 +echo "configure:2031: checking command to parse $NM output" >&5 +if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris* | sysv5*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $host_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTW]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. +lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + rm -f conftest* + cat > conftest.$ac_ext <<EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +EOF + + if { (eval echo configure:2114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo configure:2117: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat <<EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' + + cat <<EOF >> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{ +EOF + sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo configure:2168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" +if test -z "$lt_cv_sys_global_symbol_pipe"; then + global_symbol_to_cdecl= + global_symbol_to_c_name_address= +else + global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" + global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" +fi +if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; +then + echo "$ac_t""failed" 1>&6 +else + echo "$ac_t""ok" 1>&6 +fi + +for ac_hdr in dlfcn.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2217: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2222 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2227: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + + + + + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 +echo "configure:2263: checking for ${ac_tool_prefix}file" >&5 +if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case $MAGIC_CMD in + /*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; + ?:/*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. + ;; + *) + ac_save_MAGIC_CMD="$MAGIC_CMD" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="/usr/bin:$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <<EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$ac_save_ifs" + MAGIC_CMD="$ac_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$ac_t""$MAGIC_CMD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + echo $ac_n "checking for file""... $ac_c" 1>&6 +echo "configure:2325: checking for file" >&5 +if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case $MAGIC_CMD in + /*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; + ?:/*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. + ;; + *) + ac_save_MAGIC_CMD="$MAGIC_CMD" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="/usr/bin:$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <<EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$ac_save_ifs" + MAGIC_CMD="$ac_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$ac_t""$MAGIC_CMD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2396: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_RANLIB"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2429: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + RANLIB=":" +fi +fi + +# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2465: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +STRIP="$ac_cv_prog_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_STRIP"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2498: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test $ac_x $ac_dir/$ac_word; then + ac_cv_prog_STRIP="strip" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_STRIP" && ac_cv_prog_STRIP=":" +fi +fi +STRIP="$ac_cv_prog_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + STRIP=":" +fi +fi + + +enable_dlopen=no +enable_win32_dll=no + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 2548 "configure"' > conftest.$ac_ext + if { (eval echo configure:2549: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 +echo "configure:2570: checking whether the C compiler needs -belf" >&5 +if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + + cat > conftest.$ac_ext <<EOF +#line 2583 "configure" +#include "confdefs.h" + +int main() { + +; return 0; } +EOF +if { (eval echo configure:2590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_cc_needs_belf=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_needs_belf=no +fi +rm -f conftest* + ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +fi + +echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + + +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" +need_locks="$enable_libtool_lock" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +if test x"$host" != x"$build"; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case $host_os in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +## FIXME: this should be a separate macro +## +echo $ac_n "checking for objdir""... $ac_c" 1>&6 +echo "configure:2712: checking for objdir" >&5 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t""$objdir" 1>&6 +## +## END FIXME + + +## FIXME: this should be a separate macro +## +# Check whether --with-pic or --without-pic was given. +if test "${with_pic+set}" = set; then + withval="$with_pic" + pic_mode="$withval" +else + pic_mode=default +fi + +test -z "$pic_mode" && pic_mode=default + +# We assume here that the value for lt_cv_prog_cc_pic will not be cached +# in isolation, and that seeing it set (from the cache) indicates that +# the associated values are set (in the cache) correctly too. +echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6 +echo "configure:2743: checking for $compiler option to produce PIC" >&5 +if eval "test \"`echo '$''{'lt_cv_prog_cc_pic'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + lt_cv_prog_cc_pic= + lt_cv_prog_cc_shlib= + lt_cv_prog_cc_wl= + lt_cv_prog_cc_static= + lt_cv_prog_cc_no_builtin= + lt_cv_prog_cc_can_build_shared=$can_build_shared + + if test "$GCC" = yes; then + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-static' + + case $host_os in + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # not sure about C++ programs. + lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_cv_prog_cc_pic='-fno-common' + ;; + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_cv_prog_cc_pic=-Kconform_pic + fi + ;; + *) + lt_cv_prog_cc_pic='-fPIC' + ;; + esac + else + # PORTME Check for PIC flags for the system compiler. + case $host_os in + aix3* | aix4* | aix5*) + lt_cv_prog_cc_wl='-Wl,' + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_cv_prog_cc_static='-Bstatic' + else + lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better lt_cv_prog_cc_static that works with the bundled CC? + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" + lt_cv_prog_cc_pic='+Z' + ;; + + irix5* | irix6* | nonstopux*) + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + + newsos6) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + ;; + + sco3.2v5*) + lt_cv_prog_cc_pic='-Kpic' + lt_cv_prog_cc_static='-dn' + lt_cv_prog_cc_shlib='-belf' + ;; + + solaris*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Wl,' + ;; + + sunos4*) + lt_cv_prog_cc_pic='-PIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Wl,' + ;; + + uts4*) + lt_cv_prog_cc_pic='-pic' + lt_cv_prog_cc_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_cv_prog_cc_pic='-Kconform_pic' + lt_cv_prog_cc_static='-Bstatic' + fi + ;; + + *) + lt_cv_prog_cc_can_build_shared=no + ;; + esac + fi + +fi + +if test -z "$lt_cv_prog_cc_pic"; then + echo "$ac_t""none" 1>&6 +else + echo "$ac_t""$lt_cv_prog_cc_pic" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6 +echo "configure:2891: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 + if eval "test \"`echo '$''{'lt_cv_prog_cc_pic_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" + cat > conftest.$ac_ext <<EOF +#line 2898 "configure" +#include "confdefs.h" + +int main() { + +; return 0; } +EOF +if { (eval echo configure:2905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + case $host_os in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then + # they create non-PIC objects. So, if there were any warnings, we + # assume that PIC is not supported. + if test -s conftest.err; then + lt_cv_prog_cc_pic_works=no + else + lt_cv_prog_cc_pic_works=yes + fi + ;; + *) + lt_cv_prog_cc_pic_works=yes + ;; + esac + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_prog_cc_pic_works=no + +fi +rm -f conftest* + CFLAGS="$save_CFLAGS" + +fi + + + if test "X$lt_cv_prog_cc_pic_works" = Xno; then + lt_cv_prog_cc_pic= + lt_cv_prog_cc_can_build_shared=no + else + lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" + fi + + echo "$ac_t""$lt_cv_prog_cc_pic_works" 1>&6 +fi +## +## END FIXME + +# Check for any special shared library compilation flags. +if test -n "$lt_cv_prog_cc_shlib"; then + echo "configure: warning: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then : + else + echo "configure: warning: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" 1>&2 + lt_cv_prog_cc_can_build_shared=no + fi +fi + +## FIXME: this should be a separate macro +## +echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6 +echo "configure:2961: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 +if eval "test \"`echo '$''{'lt_cv_prog_cc_static_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + lt_cv_prog_cc_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" + cat > conftest.$ac_ext <<EOF +#line 2969 "configure" +#include "confdefs.h" + +int main() { + +; return 0; } +EOF +if { (eval echo configure:2976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_prog_cc_static_works=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + LDFLAGS="$save_LDFLAGS" + +fi + + +# Belt *and* braces to stop my trousers falling down: +test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= +echo "$ac_t""$lt_cv_prog_cc_static_works" 1>&6 + +pic_flag="$lt_cv_prog_cc_pic" +special_shlib_compile_flags="$lt_cv_prog_cc_shlib" +wl="$lt_cv_prog_cc_wl" +link_static_flag="$lt_cv_prog_cc_static" +no_builtin_flag="$lt_cv_prog_cc_no_builtin" +can_build_shared="$lt_cv_prog_cc_can_build_shared" +## +## END FIXME + + +## FIXME: this should be a separate macro +## +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6 +echo "configure:3007: checking if $compiler supports -c -o file.$ac_objext" >&5 +if eval "test \"`echo '$''{'lt_cv_compiler_c_o'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +echo "int some_variable = 0;" > conftest.$ac_ext +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" +compiler_c_o=no +if { (eval echo configure:3026: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + lt_cv_compiler_c_o=no + else + lt_cv_compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + lt_cv_compiler_c_o=no +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +fi + +compiler_c_o=$lt_cv_compiler_c_o +echo "$ac_t""$compiler_c_o" 1>&6 + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6 +echo "configure:3055: checking if $compiler supports -c -o file.lo" >&5 + if eval "test \"`echo '$''{'lt_cv_compiler_o_lo'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + lt_cv_compiler_o_lo=no + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + save_objext="$ac_objext" + ac_objext=lo + cat > conftest.$ac_ext <<EOF +#line 3066 "configure" +#include "confdefs.h" + +int main() { +int some_variable = 0; +; return 0; } +EOF +if { (eval echo configure:3073: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + lt_cv_compiler_o_lo=no + else + lt_cv_compiler_o_lo=yes + fi + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + ac_objext="$save_objext" + CFLAGS="$save_CFLAGS" + +fi + + compiler_o_lo=$lt_cv_compiler_o_lo + echo "$ac_t""$compiler_o_lo" 1>&6 +else + compiler_o_lo=no +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6 +echo "configure:3108: checking if we can lock with hard links" >&5 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t""$hard_links" 1>&6 + if test "$hard_links" = no; then + echo "configure: warning: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" 1>&2 + need_locks=warn + fi +else + need_locks=no +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +if test "$GCC" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6 +echo "configure:3131: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + echo "int some_variable = 0;" > conftest.$ac_ext + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" + compiler_rtti_exceptions=no + cat > conftest.$ac_ext <<EOF +#line 3137 "configure" +#include "confdefs.h" + +int main() { +int some_variable = 0; +; return 0; } +EOF +if { (eval echo configure:3144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + compiler_rtti_exceptions=no + else + compiler_rtti_exceptions=yes + fi + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + CFLAGS="$save_CFLAGS" + echo "$ac_t""$compiler_rtti_exceptions" 1>&6 + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6 +echo "configure:3175: checking whether the linker ($LD) supports shared libraries" >&5 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +old_archive_from_expsyms_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_into_libs=no +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +link_all_deplibs=unknown +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. +extract_expsyms_cmds= + +case $host_os in +cygwin* | mingw* | pw32*) + # 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 + ;; +openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX, the GNU linker is very broken + # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. + ld_shlibs=no + cat <<EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ + sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ + test -f $output_objdir/impgen.exe || (cd $output_objdir && \ + if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ + else $CC -o impgen impgen.c ; fi)~ + $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' + + old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' + + # cygwin and mingw dlls have different entry points and sets of symbols + # to exclude. + # FIXME: what about values for MSVC? + dll_entry=__cygwin_dll_entry@12 + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ + case $host_os in + mingw*) + # mingw values + dll_entry=_DllMainCRTStartup@12 + dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ + ;; + esac + + # mingw and cygwin differ, and it's simplest to just exclude the union + # of the two symbol sets. + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one (in ltdll.c) + if test "x$lt_cv_need_dllmain" = "xyes"; then + ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " + ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ + test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' + else + ltdll_obj= + ltdll_cmds= + fi + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left be newer dlltools. + export_symbols_cmds="$ltdll_cmds"' + $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' + + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is. + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='if test "x`sed 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname-def; + else + echo EXPORTS > $output_objdir/$soname-def; + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \$# in + 2) echo " \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; + 4) echo " \$2 \$3 \$4 ; " >> $output_objdir/$soname-def; _lt_hint=`expr \$_lt_hint - 1`;; + *) echo " \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done; + fi~ + '"$ltdll_cmds"' + $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ + $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ + $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw* | pw32*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + 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 + exp_sym_flag='-Bexport' + no_entry_flag="" + 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].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + hardcode_direct=yes + archive_cmds='' + 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 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + shared_flag='${wl}-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall can do strange things, so it is better to + # generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='${wl}-berok' + # This is a bit strange, but is similar to how AIX traditionally builds + # it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw* | pw32*) + # 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=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + esac + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. Also zsh mangles + # `"' quotes if we put them in here... so don't! + archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)' + # We need to add '_' to the symbols in $export_symbols first + #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' + hardcode_direct=yes + hardcode_shlibpath_var=no + whole_archive_flag_spec='-all_load $convenience' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case $host_os in + hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + #Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + export_dynamic_flag_spec='${wl}-Bexport' + ;; + + solaris*) + # gcc --version < 3.0 without binutils cannot create self contained + # shared libraries reliably, requiring libgcc.a to resolve some of + # the object symbols generated in some cases. Libraries that use + # assert need libgcc.a to resolve __eprintf, for example. Linking + # a copy of libgcc.a into every shared library to guarantee resolving + # such symbols causes other problems: According to Tim Van Holder + # <tim.van.holder@pandora.be>, C++ libraries end up with a separate + # (to the application) exception stack for one thing. + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + case `$CC --version 2>/dev/null` in + [12].*) + cat <<EOF 1>&2 + +*** Warning: Releases of GCC earlier than version 3.0 cannot reliably +*** create self contained shared libraries on Solaris systems, without +*** introducing a dependency on libgcc.a. Therefore, libtool is disabling +*** -no-undefined support, which will at least allow you to build shared +*** libraries. However, you may find that when you link such libraries +*** into an application without using GCC, you have to manually add +*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to +*** upgrade to a newer version of GCC. Another option is to rebuild your +*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. + +EOF + no_undefined_flag= + ;; + esac + fi + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5uw7* | unixware7*) + no_undefined_flag='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t""$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6 +echo "configure:3878: checking how to hardcode library paths into programs" >&5 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t""$hardcode_action" 1>&6 +## +## END FIXME + +## FIXME: this should be a separate macro +## +striplib= +old_striplib= +echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6 +echo "configure:3910: checking whether stripping libraries is possible" >&5 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +## +## END FIXME + +reload_cmds='$LD$reload_flag -o $output$reload_objs' +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +## FIXME: this should be a separate macro +## +# PORTME Fill in your ld.so characteristics +echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6 +echo "configure:3928: checking dynamic linker characteristics" >&5 +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can + # not hardcode correct soname into executable. Probably we can + # add versioning support to collect2, so additional links can + # be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}.so$major' + fi + shlibpath_var=LIBPATH + fi + hardcode_into_libs=yes + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + need_version=no + need_lib_prefix=no + case $GCC,$host_os in + yes,cygwin*) + library_names_spec='$libname.dll.a' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' + postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog .libs/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + ;; + yes,mingw*) + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g" -e "s,=/,/,g"` + ;; + yes,pw32*) + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll' + ;; + *) + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. + library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' + soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU/FreeBSD ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + *) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) version_type=irix ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case "$host_os" in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + need_lib_prefix=no + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + hardcode_into_libs=yes + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t""$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Report the final consequences. +echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6 +echo "configure:4356: checking if libtool supports shared libraries" >&5 +echo "$ac_t""$can_build_shared" 1>&6 +## +## END FIXME + +## FIXME: this should be a separate macro +## +echo $ac_n "checking whether to build shared libraries""... $ac_c" 1>&6 +echo "configure:4364: checking whether to build shared libraries" >&5 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +echo "$ac_t""$enable_shared" 1>&6 +## +## END FIXME + +## FIXME: this should be a separate macro +## +echo $ac_n "checking whether to build static libraries""... $ac_c" 1>&6 +echo "configure:4391: checking whether to build static libraries" >&5 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$ac_t""$enable_static" 1>&6 +## +## END FIXME + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + cygwin* | mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + *) + echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "configure:4434: checking for shl_load" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4439 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shl_load=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shl_load=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "configure:4480: checking for shl_load in -ldld" >&5 +ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4488 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load(); + +int main() { +shl_load() +; return 0; } +EOF +if { (eval echo configure:4499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "configure:4518: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4523 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "configure:4564: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4572 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { +dlopen() +; return 0; } +EOF +if { (eval echo configure:4583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6 +echo "configure:4602: checking for dlopen in -lsvld" >&5 +ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsvld $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4610 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { +dlopen() +; return 0; } +EOF +if { (eval echo configure:4621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "configure:4640: checking for dld_link in -ldld" >&5 +ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4648 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dld_link(); + +int main() { +dld_link() +; return 0; } +EOF +if { (eval echo configure:4659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "configure:4715: checking whether a program can dlopen itself" >&5 +if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<EOF +#line 4725 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif + +#include <stdio.h> + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo configure:4786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "configure:4809: checking whether a statically linked program can dlopen itself" >&5 +if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<EOF +#line 4819 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif + +#include <stdio.h> + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo configure:4880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +## FIXME: this should be a separate macro +## +if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6 +echo "configure:4931: checking whether -lc should be explicitly linked in" >&5 + if eval "test \"`echo '$''{'lt_cv_archive_cmds_need_lc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + $rm conftest* + echo 'static int dummy;' > conftest.$ac_ext + + if { (eval echo configure:4938: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_cv_prog_cc_wl + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo configure:4951: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi +fi + + echo "$ac_t""$lt_cv_archive_cmds_need_lc" 1>&6 + ;; + esac +fi +need_lc=${lt_cv_archive_cmds_need_lc-yes} +## +## END FIXME + +## FIXME: this should be a separate macro +## +# The second clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + : +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + test -f Makefile && make "$ltmain" +fi + +if test -f "$ltmain"; then + trap "$rm \"${ofile}T\"; exit 1" 1 2 15 + $rm -f "${ofile}T" + + echo creating $ofile + + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS SED \ + AR AR_FLAGS CC LD LN_S NM SHELL \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ + postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ + old_striplib striplib file_magic_cmd export_symbols_cmds \ + deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + global_symbol_to_c_name_address \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case $var in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + cat <<__EOF__ > "${ofile}T" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996-2000 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 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 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# 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. + +# A sed that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="${SED} -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$need_lc + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# The default C compiler. +CC=$lt_CC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_pic_flag +pic_mode=$pic_mode + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$lt_compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_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 + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + case $host_os in + aix3*) + cat <<\EOF >> "${ofile}T" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + case $host_os in + cygwin* | mingw* | pw32* | os2*) + cat <<'EOF' >> "${ofile}T" + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include <windows.h> +# #undef WIN32_LEAN_AND_MEAN +# #include <stdio.h> +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include <cygwin/cygwin_dll.h> +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include <stdio.h> /* for printf() */ +# #include <unistd.h> /* for open(), lseek(), read() */ +# #include <fcntl.h> /* for O_RDONLY, O_BINARY */ +# #include <string.h> /* for strdup() */ +# +# /* O_BINARY isn't required (or even defined sometimes) under Unix */ +# #ifndef O_BINARY +# #define O_BINARY 0 +# #endif +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (dll < 1) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i<nexp; i++) +# { +# unsigned long name_rva = pe_as32 (erva+name_rvas+i*4); +# printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i); +# } +# +# return 0; +# } +# /* impgen.c ends here */ + +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "${ofile}T" || (rm -f "${ofile}T"; exit 1) + + mv -f "${ofile}T" "$ofile" || \ + (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") + chmod +x "$ofile" +fi +## +## END FIXME + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:5547: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5552 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:5560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + ac_header_dirent=$ac_hdr; break +else + echo "$ac_t""no" 1>&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:5585: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <<EOF +#line 5593 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:5604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:5626: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <<EOF +#line 5634 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:5645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:5668: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5673 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:5681: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 5698 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 5716 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 5737 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:5748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking whether closedir returns void""... $ac_c" 1>&6 +echo "configure:5772: checking whether closedir returns void" >&5 +if eval "test \"`echo '$''{'ac_cv_func_closedir_void'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_closedir_void=yes +else + cat > conftest.$ac_ext <<EOF +#line 5780 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_header_dirent> +int closedir(); main() { exit(closedir(opendir(".")) != 0); } +EOF +if { (eval echo configure:5786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_closedir_void=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_closedir_void=yes +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_closedir_void" 1>&6 +if test $ac_cv_func_closedir_void = yes; then + cat >> confdefs.h <<\EOF +#define CLOSEDIR_VOID 1 +EOF + +fi + +for ac_hdr in assert.h float.h limits.h memory.h pwd.h stdlib.h \ + string.h strings.h sys/param.h unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:5813: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5818 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:5823: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + +for ac_func in putenv +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:5853: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5858 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LTLIBOBJS="$LTLIBOBJS putenv.lo" +fi +done + +for ac_func in strcasecmp +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:5909: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5914 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LTLIBOBJS="$LTLIBOBJS strcasecmp.lo" +fi +done + +for ac_func in strtol +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:5965: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5970 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LTLIBOBJS="$LTLIBOBJS strtol.lo" +fi +done + +for ac_func in strstr +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:6021: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6026 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:6049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LTLIBOBJS="$LTLIBOBJS strstr.lo" +fi +done + + + +for ac_func in bcmp bcopy bzero getcwd getwd index memcmp memcpy rindex strchr strrchr +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:6079: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6084 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:6107: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:6133: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6138 "configure" +#include "confdefs.h" + +int main() { + +/* Ultrix mips cc rejects this. */ +typedef int charset[2]; const charset x; +/* SunOS 4.1.1 cc rejects this. */ +char const *const *ccp; +char **p; +/* NEC SVR4.0.2 mips cc rejects this. */ +struct point {int x, y;}; +static struct point const zero = {0,0}; +/* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in an arm + of an if-expression whose if-part is not a constant expression */ +const char *g = "string"; +ccp = &g + (g ? g-g : 0); +/* HPUX 7.0 cc rejects these. */ +++ccp; +p = (char**) ccp; +ccp = (char const *const *) p; +{ /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +} +{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; +} +{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; +} +{ /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:6187: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + + +# Check whether struct stat provides high-res time. +echo $ac_n "checking for st_mtim in struct stat""... $ac_c" 1>&6 +echo "configure:6210: checking for st_mtim in struct stat" >&5 +if eval "test \"`echo '$''{'ac_cv_struct_st_mtim'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6215 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <sys/stat.h> +int main() { +struct stat s; s.st_mtim; +; return 0; } +EOF +if { (eval echo configure:6223: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_struct_st_mtim=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_struct_st_mtim=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_struct_st_mtim" 1>&6 +if test $ac_cv_struct_st_mtim = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ST_MTIM 1 +EOF + +fi + + +# Check whether prototypes work. +echo $ac_n "checking whether the compiler accepts prototypes""... $ac_c" 1>&6 +echo "configure:6246: checking whether the compiler accepts prototypes" >&5 +if eval "test \"`echo '$''{'kb_cv_c_prototypes'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6251 "configure" +#include "confdefs.h" +#include <stdarg.h> +int main() { +extern void foo(int i,...); +; return 0; } +EOF +if { (eval echo configure:6258: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + kb_cv_c_prototypes=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + kb_cv_c_prototypes=no +fi +rm -f conftest* +fi +echo "$ac_t""$kb_cv_c_prototypes" 1>&6 +if test "$kb_cv_c_prototypes" = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_PROTOTYPES 1 +EOF + +fi + +# This is a GNU libc invention. +echo $ac_n "checking whether program_invocation_name is predefined""... $ac_c" 1>&6 +echo "configure:6279: checking whether program_invocation_name is predefined" >&5 +if eval "test \"`echo '$''{'kb_cv_var_program_inv_name'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6284 "configure" +#include "confdefs.h" + +int main() { +extern char *program_invocation_name; program_invocation_name = "love"; +; return 0; } +EOF +if { (eval echo configure:6291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + kb_cv_var_program_inv_name=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + kb_cv_var_program_inv_name=no +fi +rm -f conftest* +fi +echo "$ac_t""$kb_cv_var_program_inv_name" 1>&6 +if test "$kb_cv_var_program_inv_name" = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_PROGRAM_INVOCATION_NAME 1 +EOF + +fi + +# Some BSD putenv's, e.g., FreeBSD, do malloc/free's on the environment. +# This test program is due to Mike Hibler <mike@cs.utah.edu>. +# We don't actually need to run this if we don't have putenv, but it +# doesn't hurt. +echo $ac_n "checking whether putenv uses malloc""... $ac_c" 1>&6 +echo "configure:6315: checking whether putenv uses malloc" >&5 +if eval "test \"`echo '$''{'kb_cv_func_putenv_malloc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + kb_cv_func_putenv_malloc=no +else + cat > conftest.$ac_ext <<EOF +#line 6323 "configure" +#include "confdefs.h" + +#define VAR "YOW_VAR" +#define STRING1 "GabbaGabbaHey" +#define STRING2 "Yow!!" /* should be shorter than STRING1 */ +extern char *getenv (); /* in case char* and int don't mix gracefully */ +extern char *malloc (); /* ditto */ +main () +{ + char *str1, *rstr1, *str2, *rstr2; + str1 = getenv (VAR); + if (str1) + exit (1); + str1 = malloc (strlen (VAR) + 1 + strlen (STRING1) + 1); + if (str1 == 0) + exit (2); + strcpy (str1, VAR); + strcat (str1, "="); + strcat (str1, STRING1); + if (putenv (str1) < 0) + exit (3); + rstr1 = getenv (VAR); + if (rstr1 == 0) + exit (4); + rstr1 -= strlen (VAR) + 1; + if (strncmp (rstr1, VAR, strlen (VAR))) + exit (5); + str2 = malloc (strlen (VAR) + 1 + strlen (STRING2) + 1); + if (str2 == 0 || str1 == str2) + exit (6); + strcpy (str2, VAR); + strcat (str2, "="); + strcat (str2, STRING2); + if (putenv (str2) < 0) + exit (7); + rstr2 = getenv (VAR); + if (rstr2 == 0) + exit (8); + rstr2 -= strlen (VAR) + 1; +#if 0 + printf ("rstr1=0x%x, rstr2=0x%x\n", rstr1, rstr2); + /* + * If string from first call was reused for the second call, + * you had better not do a free on the first string! + */ + if (rstr1 == rstr2) + printf ("#define SMART_PUTENV\n"); + else + printf ("#undef SMART_PUTENV\n"); +#endif + exit (rstr1 == rstr2 ? 0 : 1); +} +EOF +if { (eval echo configure:6377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + kb_cv_func_putenv_malloc=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + kb_cv_func_putenv_malloc=no +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$kb_cv_func_putenv_malloc" 1>&6 +if test $kb_cv_func_putenv_malloc = yes; then + cat >> confdefs.h <<\EOF +#define SMART_PUTENV 1 +EOF + +fi + +if test $ac_cv_func_getcwd = yes; then +# We only need to run this if we have getcwd. +echo $ac_n "checking whether getcwd uses fork or vfork""... $ac_c" 1>&6 +echo "configure:6401: checking whether getcwd uses fork or vfork" >&5 +if eval "test \"`echo '$''{'kb_cv_func_getcwd_forks'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + kb_cv_func_getcwd_forks=no +else + cat > conftest.$ac_ext <<EOF +#line 6409 "configure" +#include "confdefs.h" + +int fork() { exit(1); } +int vfork() { exit(1); } +extern char *getcwd(); +char path[100]; +int main() { +getcwd(path,100); +return 0; +} +EOF +if { (eval echo configure:6421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + kb_cv_func_getcwd_forks=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + kb_cv_func_getcwd_forks=yes +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$kb_cv_func_getcwd_forks" 1>&6 +if test $kb_cv_func_getcwd_forks = yes; then + cat >> confdefs.h <<\EOF +#define GETCWD_FORKS 1 +EOF + +fi +fi + +# Common --with and --enable options. + +echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 +echo "configure:6446: checking whether to enable maintainer-specific portions of Makefiles" >&5 + # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval="$enable_maintainer_mode" + USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6 + if test "x$USE_MAINTAINER_MODE" = xyes; then + MAINT= + else + MAINT='#M#' + fi + + + +echo $ac_n "checking for loader (symbol LD)""... $ac_c" 1>&6 +echo "configure:6465: checking for loader (symbol LD)" >&5 +if eval "test \"`echo '$''{'cf_cv_subst_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + +test -z "$LD" && LD=ld +cf_cv_subst_LD=$LD +fi + +LD=${cf_cv_subst_LD} +echo "$ac_t""$LD" 1>&6 + + +echo $ac_n "checking for archiver (symbol AR)""... $ac_c" 1>&6 +echo "configure:6479: checking for archiver (symbol AR)" >&5 +if eval "test \"`echo '$''{'cf_cv_subst_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + +test -z "$AR" && AR=ar +cf_cv_subst_AR=$AR +fi + +AR=${cf_cv_subst_AR} +echo "$ac_t""$AR" 1>&6 + + +echo $ac_n "checking for archiver options (symbol ARFLAGS)""... $ac_c" 1>&6 +echo "configure:6493: checking for archiver options (symbol ARFLAGS)" >&5 +if eval "test \"`echo '$''{'cf_cv_subst_ARFLAGS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + +test -z "$ARFLAGS" && ARFLAGS=rc +cf_cv_subst_ARFLAGS=$ARFLAGS +fi + +ARFLAGS=${cf_cv_subst_ARFLAGS} +echo "$ac_t""$ARFLAGS" 1>&6 + + + +# Check whether --with-mktexmf-default or --without-mktexmf-default was given. +if test "${with_mktexmf_default+set}" = set; then + withval="$with_mktexmf_default" + : +else + with_mktexmf_default=yes +fi + +# Check whether --with-mktexpk-default or --without-mktexpk-default was given. +if test "${with_mktexpk_default+set}" = set; then + withval="$with_mktexpk_default" + : +else + with_mktexpk_default=yes +fi + +# Check whether --with-mktextfm-default or --without-mktextfm-default was given. +if test "${with_mktextfm_default+set}" = set; then + withval="$with_mktextfm_default" + : +else + with_mktextfm_default=yes +fi + +# Check whether --with-mkocp-default or --without-mkocp-default was given. +if test "${with_mkocp_default+set}" = set; then + withval="$with_mkocp_default" + : +else + with_mkocp_default=yes +fi + +# Check whether --with-mkofm-default or --without-mkofm-default was given. +if test "${with_mkofm_default+set}" = set; then + withval="$with_mkofm_default" + : +else + with_mkofm_default=yes +fi + +# Check whether --with-mktexfmt-default or --without-mktexfmt-default was given. +if test "${with_mktexfmt_default+set}" = set; then + withval="$with_mktexfmt_default" + : +fi + +# Check whether --with-mktextex-default or --without-mktextex-default was given. +if test "${with_mktextex_default+set}" = set; then + withval="$with_mktextex_default" + with_mktextex_default=yes +else + with_mktextex_default=no +fi + + +echo $ac_n "checking where the main texmf tree is located""... $ac_c" 1>&6 +echo "configure:6563: checking where the main texmf tree is located" >&5 +texmfmain= +if test -n "$TEXMFMAIN"; then + texmfmain="$TEXMFMAIN" + echo "$ac_t""$texmfmain (from TEXMFMAIN)" 1>&6 + +elif test "x$datadir" != 'x${prefix}/share'; then + # datadir is explicitly defined, assume datadir/texmf. + eval p=\"$datadir\" + # Unconditionally set the directory, but... + texmfmain=`echo "$p/texmf" | sed 's,//*,/,g'` + # ... do complain if it wasn't found. + if test -d "$texmfmain"; then + echo "$ac_t"""$texmfmain"" 1>&6 + else + echo "$ac_t""not found" 1>&6 + echo "configure: warning: No texmf tree found at datadir/texmf ($texmfmain)" 1>&2 + echo "configure: warning: proceeding anyway. + ***************************************************************** + * Warning: The main texmf tree was not found. * + * If you do not have the files, you should be able to find them * + * at the same place you got these sources, or from one of the * + * CTAN hosts. Good luck. * + ***************************************************************** +" 1>&2 + fi + +else + # Second case, datadir is default... + if test "x$prefix" = "xNONE"; then + p="$ac_default_prefix" + else + eval p=\"$prefix\" + fi + for e in share/texmf lib/texmf texmf; do + if test -d "$p/$e"; then + texmfmain='${prefix}'/"$e" + break + fi + done + if test -z "$texmfmain" && test "x$prefix" = "xNONE"; then + # Still no texmfmain found, no prefix set, perhaps kpsewhich is + # installed and can help us out. + texmfmain=`kpsewhich --expand-path='$TEXMFMAIN'` 2>/dev/null + fi + texmfmain=`echo "$texmfmain" | sed 's,//*,/,g'` + if test -n "$texmfmain"; then + echo "$ac_t"""$texmfmain"" 1>&6 + else + eval texmfmain="$datadir/texmf" + echo "$ac_t""not found" 1>&6 + echo "configure: warning: The main texmf tree was not found at $texmfmain. + ***************************************************************** + * Warning: The main texmf tree was not found. * + * Use the --datadir option to specify its parent directory. * + * If you do not have the files, you should be able to them from * + * the same place you got these sources from, or from one of the * + * CTAN hosts. * + ***************************************************************** + Winging it by pretending $texmfmain is correct." 1>&2 + fi +fi + + + +# Implementation of those options. +if test "x$with_mktexmf_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_TEX_MF_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mktexpk_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_TEX_PK_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mktextex_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_TEX_TEX_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mktexfmt_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_TEX_FMT_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mktextfm_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_TEX_TFM_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mkocp_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_OMEGA_OCP_BY_DEFAULT 1 +EOF + +fi +if test "x$with_mkofm_default" = xyes; then + cat >> confdefs.h <<\EOF +#define MAKE_OMEGA_OFM_BY_DEFAULT 1 +EOF + +fi + +# Is libm present. FIXME: do we need it at all? +echo $ac_n "checking for main in -lm""... $ac_c" 1>&6 +echo "configure:6674: checking for main in -lm" >&5 +ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lm $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6682 "configure" +#include "confdefs.h" + +int main() { +main() +; return 0; } +EOF +if { (eval echo configure:6689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <<EOF +#define $ac_tr_lib 1 +EOF + + LIBS="-lm $LIBS" + +else + echo "$ac_t""no" 1>&6 +fi + + +# If you're cross-compiling, these macros set up the variables in +# ../make/cross.mk: BUILDCC, BUILDCFLAGS, BUILDCCLD etc. +if test "$cross_compiling" = yes; then + if test -z "${BUILDCC}"; then + BUILDCC='cc' + fi + echo "$ac_t""setting \$BUILDCC to ${BUILDCC}" 1>&6 +else + if test -n "${BUILDCC}"; then + echo "configure: warning: \$BUILDCC set but not cross-compiling." 1>&2 + fi + BUILDCC='$(CC)' +fi + + +if test "$cross_compiling" = yes; then + if test -z "${BUILDCFLAGS}"; then + BUILDCFLAGS='$(BUILDXCFLAGS)' + fi + echo "$ac_t""setting \$BUILDCFLAGS to ${BUILDCFLAGS}" 1>&6 +else + if test -n "${BUILDCFLAGS}"; then + echo "configure: warning: \$BUILDCFLAGS set but not cross-compiling." 1>&2 + fi + BUILDCFLAGS='$(CFLAGS)' +fi + + +if test "$cross_compiling" = yes; then + if test -z "${BUILDCPPFLAGS}"; then + BUILDCPPFLAGS='$(BUILDXCPPFLAGS)' + fi + echo "$ac_t""setting \$BUILDCPPFLAGS to ${BUILDCPPFLAGS}" 1>&6 +else + if test -n "${BUILDCPPFLAGS}"; then + echo "configure: warning: \$BUILDCPPFLAGS set but not cross-compiling." 1>&2 + fi + BUILDCPPFLAGS='$(CPPFLAGS)' +fi + + +if test "$cross_compiling" = yes; then + if test -z "${BUILDLDFLAGS}"; then + BUILDLDFLAGS='$(BUILDXLDFLAGS)' + fi + echo "$ac_t""setting \$BUILDLDFLAGS to ${BUILDLDFLAGS}" 1>&6 +else + if test -n "${BUILDLDFLAGS}"; then + echo "configure: warning: \$BUILDLDFLAGS set but not cross-compiling." 1>&2 + fi + BUILDLDFLAGS='$(LDFLAGS)' +fi + + +if test "$cross_compiling" = yes; then + if test -z "${BUILDCCLD}"; then + BUILDCCLD='$(BUILDCC)' + fi + echo "$ac_t""setting \$BUILDCCLD to ${BUILDCCLD}" 1>&6 +else + if test -n "${BUILDCCLD}"; then + echo "configure: warning: \$BUILDCCLD set but not cross-compiling." 1>&2 + fi + BUILDCCLD='$(CCLD)' +fi + + + + +echo $ac_n "checking size of int""... $ac_c" 1>&6 +echo "configure:6787: checking size of int" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <<EOF +#line 6795 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(int)); + exit(0); +} +EOF +if { (eval echo configure:6806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_int=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_int" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_INT $ac_cv_sizeof_int +EOF + + +for ac_func in strerror +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:6828: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6833 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:6856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_hdr in errno.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:6884: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6889 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:6894: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + +ac_config_files="$ac_config_files Makefile" + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + + +trap 'rm -fr `echo "$ac_config_files c-auto.h:c-auto.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@LN_S@%$LN_S%g +s%@SET_MAKE@%$SET_MAKE%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@OBJEXT@%$OBJEXT%g +s%@EXEEXT@%$EXEEXT%g +s%@ECHO@%$ECHO%g +s%@RANLIB@%$RANLIB%g +s%@STRIP@%$STRIP%g +s%@CPP@%$CPP%g +s%@LIBTOOL@%$LIBTOOL%g +s%@LTLIBOBJS@%$LTLIBOBJS%g +s%@MAINT@%$MAINT%g +s%@LD@%$LD%g +s%@AR@%$AR%g +s%@ARFLAGS@%$ARFLAGS%g +s%@texmfmain@%$texmfmain%g +s%@BUILDCC@%$BUILDCC%g +s%@BUILDCFLAGS@%$BUILDCFLAGS%g +s%@BUILDCPPFLAGS@%$BUILDCPPFLAGS%g +s%@BUILDLDFLAGS@%$BUILDLDFLAGS%g +s%@BUILDCCLD@%$BUILDCCLD%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"$ac_config_files"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*|[A-z]:/*) # Absolute path. + srcdir="$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + "") ;; + [/$]*|[A-z]:/*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + rm -f conftest.in + ac_file_inputs=`echo $ac_file_in|sed -e "s%:% $ac_given_srcdir/%g" -e "s%^%$ac_given_srcdir/%"` + cat $ac_file_inputs > conftest.in + # + # Replace lines of the form ac_include foo with the contents of foo: + # first, from the ac_include lines construct a list of file names. + # From that list, we construct a second list of those files that exist. + # Then we construct lists of sed commands for including those files, + # and a sed command that removes the ac_include lines. We don't attempt + # to read non-existent files because some (buggy) versions of sed choke + # on this. Have to use sed because old (Ultrix, SunOS) awk does not support + # getline or system. (Anyway, configure scripts aren't supposed to use awk.) + # Can't use only one -e and commands {dr foo} because foo has to be last. + # Be careful, because the filename may contain /. Be careful with + # whitespace; we need to use echo. + # + file_substs=`sed -n '/^ac_include/s%ac_include[ ]*\(.*\)%\1%p' conftest.in` + # Create the sed command line ... + if test -n "$file_substs"; then + echo "configure: warning: ac_include is obsolete; instead use kpse_include" 1>&2 + file_subst_cmd="sed -e 's/^ac_include/kpse_include/'" + else + file_subst_cmd='sed' + fi + kpse_substs=`sed -n '/^kpse_include/s%kpse_include[ ]*\(.*\)%\1%p' conftest.in` + for ac_inc in $file_substs $kpse_substs; do + if test -f "$ac_given_srcdir/$ac_inc"; then + ac_mung=`echo $ac_inc | sed 's,/,%,g'` + file_subst_cmd="$file_subst_cmd -e '/^kpse_include $ac_mung$/r $ac_given_srcdir/$ac_inc'" + fi + done + file_subst_cmd="$file_subst_cmd -e '/^kpse_include/d'" + # ... and fix the whitespace and escaped slashes. + file_subst_cmd=`echo "$file_subst_cmd" | sed -e 's,%,\\\/,g' \ +-e 's/kpse_include /kpse_include[ ]*/g'` + # I can't find any way to do variable substitution in the sed commands + # (so the user could have, e.g., $top_srcdir in their ac_include line). + (eval $file_subst_cmd conftest.in) \ + | sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* conftest.in + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ].*$%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <<EOF + CONFIG_HEADERS=" c-auto.h:c-auto.in" +EOF +cat >> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%:% $ac_given_srcdir/%g" -e "s%^%$ac_given_srcdir/%"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <<EOF + + + +EOF +cat >> $CONFIG_STATUS <<\EOF +date >stamp-auto + + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + +if test "$no_recursion" != yes; then + + # Remove --cache-file and --srcdir arguments so they do not pile up. + ac_sub_configure_args= + ac_prev= + for ac_arg in $ac_configure_args; do + if test -n "$ac_prev"; then + ac_prev= + continue + fi + case "$ac_arg" in + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + ;; + *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; + esac + done + + for ac_config_dir in : $subdirs; do + + # Do not complain, so a configure script can configure whichever + # parts of a large source tree are present. + if test ! -d $srcdir/$ac_config_dir; then + continue + fi + + echo configuring in $ac_config_dir + + case "$srcdir" in + .) ;; + *) + if test -d ./$ac_config_dir || mkdir ./$ac_config_dir; then :; + else + { echo "configure: error: can not create `pwd`/$ac_config_dir" 1>&2; exit 1; } + fi + ;; + esac + + ac_popdir=`pwd` + cd $ac_config_dir + + # A "../" for each directory in /$ac_config_dir. + ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` + + case "$srcdir" in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + /*|[A-z]:/*) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_config_dir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_config_dir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f ./configure; then + ac_sub_configure=./configure + elif test -f $ac_sub_srcdir/configure; then + ac_sub_configure=$ac_sub_srcdir/configure + elif test -f $ac_sub_srcdir/configure.in; then + ac_sub_configure=$ac_configure + else + echo "configure: warning: no configuration information is in $ac_config_dir" 1>&2 + ac_sub_configure= + fi + + # The recursion is here. + if test -n "$ac_sub_configure"; then + + # Make the cache file name correct relative to the subdirectory. + case "$cache_file" in + /*|[A-z]:/*) ac_sub_cache_file=$cache_file ;; + *) # Relative path. + ac_sub_cache_file="$ac_dots$cache_file" ;; + esac + case "$ac_given_INSTALL" in + "") ;; + [/$]*|[A-z]:/*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" + # The eval makes quoting arguments work. + if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir + then : + else + { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; } + fi + fi + + cd $ac_popdir + done +fi + +date >stamp-auto diff --git a/Build/source/texk/seetexk/configure.in b/Build/source/texk/seetexk/configure.in new file mode 100644 index 00000000000..eedade9b23a --- /dev/null +++ b/Build/source/texk/seetexk/configure.in @@ -0,0 +1,14 @@ +dnl Public domain. +dnl Process this file with autoconf to produce a configure script. +AC_INIT(dviselect.c) + +sinclude(../kpathsea/common.ac) + +AC_CHECK_SIZEOF(int) +AC_CHECK_FUNCS(strerror) +AC_CHECK_HEADERS(errno.h) + +KPSE_CONFIG_FILES([Makefile]) +AC_OUTPUT +dnl Update stamp-auto, since we just remade `c-auto.h'. +date >stamp-auto diff --git a/Build/source/texk/seetexk/conv.c b/Build/source/texk/seetexk/conv.c new file mode 100644 index 00000000000..f2b096e8ddd --- /dev/null +++ b/Build/source/texk/seetexk/conv.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/conv.c,v 3.1 89/08/22 21:48:01 chris Exp $"; +#endif + +/* + * Conversions. + */ + +#include "types.h" +#include "conv.h" + +double DMagFactor(); + +Conv Conversion; /* the global conversion */ + +/* + * Set a conversion (possibly the global conversion). + */ +void +CSetConversion(c, dpi, usermag, num, denom, dvimag) + register struct conversion *c; + int dpi, usermag; + i32 num, denom, dvimag; +{ + double ddpi = dpi; + + c->c_mag = DMagFactor((int) dvimag) * DMagFactor(usermag); + c->c_dpi = ddpi; + + /* + * The conversion facture is figured as follows: there are exactly + * num/denom DVI units per decimicron, and 254000 decimicrons per + * inch, and dpi pixels per inch. Then we have to adjust this by + * the stated magnification. + */ + c->c_fromsp = (num / 254000.0) * (ddpi / denom) * c->c_mag; + + /* + * c->c_tosp is 1/c->c_fromsp, but we will invert the expression + * above in the hopes of some extra accuracy. + * + * IS THIS ANY GOOD? I NEED A NUMERICAL ANALYST! + */ + c->c_tosp = (254000.0 / num) * (denom / ddpi) * (1.0 / c->c_mag); +} diff --git a/Build/source/texk/seetexk/conv.h b/Build/source/texk/seetexk/conv.h new file mode 100644 index 00000000000..3350ff5a909 --- /dev/null +++ b/Build/source/texk/seetexk/conv.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Conversions. Conversion factors convert between values in scaled + * points and values in device-dependent units. The results of all + * conversions are rounded to the nearest integral value, of type (i32). + */ + +/* + * This is now done using `double' values, but may be changed to + * fixed-point or some other `fast' method, as long as the results + * are consistent and reasonably accurate. The structure `conversion' + * holds the conversion-method-dependent quantities; the macros + * fromSP and toSP apply the conversion to a value. (Note that + * fromSP and toSP need not be macros, but should be fast.) + * + * SetConversion sets the (single, global) conversion factor. + * If a driver needs special conversions, there is another routine, + * CSetConversion that sets a specific conversion, and cfromSP and + * ctoSP to apply these. + * + * IS USING DOTS PER INCH SUFFICIENT? (Pixels per point might be better.) + * + * Note that it is necessary to set the global conversion factor before + * using any fonts. + */ +typedef struct conversion { + double c_fromsp; /* multiplier to convert from scaled points */ + double c_tosp; /* multiplier to convert to scaled points: + could divide by c_fromsp, but this should + be faster and more accurate */ + double c_mag; /* the magnification this conversion + represents; mainly for GetFont() */ + double c_dpi; /* dpi (should be pixels per point?) */ +} Conv; + +extern Conv Conversion; /* the global conversion factor */ + +/* + * In order to do this, we need to round properly. The compilers I + * have tend to generate very poor code for this. The following is + * intended to help them out. Smarter compilers can do better, but + * if they are smart enough, they will realise that the variables + * here are not used anywhere else, and discard them. (For a compiler + * to do this given separate compliation, `static' is a must.) + */ +#ifdef lint /* or a smart compiler */ + +#define ROUND(f) ((i32) ((f) < 0.0 ? (f) - 0.5 : (f) + 0.5)) +#define CEIL(f) ((double) (i32) (f) < (f) ? (i32) (f) + 1 : (i32) (f)) + +#else /* lint */ + +static double _half = 0.5; +static double _d; +#define ROUND(f) ((i32) (_d = (f), _d < 0.0 ? _d - _half : _d + _half)) + +#ifdef NEGATIVE_FLOAT_ROUNDS_TO_NEGATIVE_INFINITY +#define CEIL(f) (-(i32) -(f)) +#else /* we will assume that floating to integer truncates */ +static i32 _i; +#define CEIL(f) (_i = _d = (f), _i < _d ? _i + 1 : _i) +#endif /* round towards negative infinity */ + +#endif /* lint */ + +#define SetConversion(dpi, usermag, num, denom, dvimag) \ + CSetConversion(&Conversion, dpi, usermag, num, denom, dvimag) + +#define cfromSP(c, v) ROUND((c)->c_fromsp * (v)) +#define ctoSP(c, v) ROUND((c)->c_tosp * (v)) + +#define fromSP(v) cfromSP(&Conversion, v) +#define toSP(v) ctoSP(&Conversion, v) + +/* + * Conversions for rules are a bit different: we must round up, rather + * than off. ConvRule applies the global conversion value for a rule + * value (height or width); CConvRule applies a specific conversion. + */ +#define CConvRule(c, v) CEIL((c)->c_fromsp * (v)) +#define ConvRule(v) CConvRule(&Conversion, v) + +void CSetConversion(); diff --git a/Build/source/texk/seetexk/convstruct.h b/Build/source/texk/seetexk/convstruct.h new file mode 100644 index 00000000000..b0f97088d8b --- /dev/null +++ b/Build/source/texk/seetexk/convstruct.h @@ -0,0 +1,38 @@ +/* + * Copyright 1989 Chris Torek + * + * 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 Chris Torek or M.I.T. + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Chris + * Torek and M.I.T. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * CHRIS TOREK AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL CHRIS TOREK OR M.I.T. BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Original Author: + * Chris Torek + * Dept. of Computer Science + * Univ. of Maryland + * chris@cs.umd.edu + */ + +typedef struct conversion { + double c_fromsp; /* multiplier to convert from scaled points */ + double c_tosp; /* multiplier to convert to scaled points: + could divide by c_fromsp, but this should + be faster and more accurate */ + double c_mag; /* the magnification this conversion + represents; mainly for GetFont() */ + double c_dpi; /* dpi (should be pixels per point?) */ +} Conv; diff --git a/Build/source/texk/seetexk/depend.mak b/Build/source/texk/seetexk/depend.mak new file mode 100644 index 00000000000..42a08a73fa3 --- /dev/null +++ b/Build/source/texk/seetexk/depend.mak @@ -0,0 +1,648 @@ +$(objdir)/strtol.obj: \ + + +$(objdir)/font.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + conv.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h + +$(objdir)/dviclass.obj: \ + dviclass.h + +$(objdir)/sdecode.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + sdecode.h + +$(objdir)/getopt.obj: \ + + +$(objdir)/skip.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + fio.h + +$(objdir)/scaletfm.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h + +$(objdir)/dvibook.obj: \ + $(kpathseadir)/c-fopen.h \ + $(kpathseadir)/getopt.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dviclass.h \ + dvicodes.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h \ + gripes.h \ + search.h \ + seek.h + +$(objdir)/error.obj: \ + c-auto.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h + +$(objdir)/gripes0.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + gripes.h + +$(objdir)/rstfont.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h \ + fio.h + +$(objdir)/rotate.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h + +$(objdir)/split.obj: \ + + +$(objdir)/font_subr.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h + +$(objdir)/dvistate.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + conv.h \ + dvicodes.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h \ + font.h \ + gripes.h \ + postamble.h \ + search.h \ + seek.h \ + dvistate.h + +$(objdir)/conv.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + conv.h + +$(objdir)/search.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + search.h + +$(objdir)/pxlfont.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h \ + fio.h + +$(objdir)/gripes1.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h \ + gripes.h + +$(objdir)/tfmfont.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + conv.h \ + font.h \ + tfm.h + +$(objdir)/scanpost.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dvicodes.h \ + fio.h \ + gripes.h \ + postamble.h + +$(objdir)/gfclass.obj: \ + gfclass.h + +$(objdir)/findpost.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dvicodes.h \ + fio.h \ + num.h + +$(objdir)/dvitodvi.obj: \ + $(kpathseadir)/c-fopen.h \ + $(kpathseadir)/getopt.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dviclass.h \ + dvicodes.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h \ + gripes.h \ + search.h \ + seek.h + +$(objdir)/dviselect.obj: \ + $(kpathseadir)/c-fopen.h \ + $(kpathseadir)/getopt.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dviclass.h \ + dvicodes.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h \ + gripes.h \ + search.h + +$(objdir)/tfm.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + fio.h \ + tfm.h + +$(objdir)/gffont.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h \ + gfcodes.h \ + gfclass.h \ + num.h + +$(objdir)/fio.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h + +$(objdir)/dvistuff.obj: \ + dvistuff.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + font.h \ + conv.h \ + dviclass.h \ + dvicodes.h \ + postamble.h \ + search.h \ + fio.h + +$(objdir)/dvi_draw.obj: \ + + +$(objdir)/dviconcat.obj: \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-fopen.h \ + $(kpathseadir)/getopt.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + dviclass.h \ + dvicodes.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + fio.h \ + gripes.h \ + search.h + +$(objdir)/tempfile.obj: \ + $(kpathseadir)/c-fopen.h + +$(objdir)/seek.obj: \ + $(kpathseadir)/c-fopen.h \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + seek.h + +$(objdir)/strsave.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h + +$(objdir)/pkfont.obj: \ + types.h \ + $(gnuw32dir)/win32lib.h \ + $(kpathseadir)/config.h \ + $(kpathseadir)/c-auto.h \ + $(kpathseadir)/c-std.h \ + $(kpathseadir)/c-unistd.h \ + $(kpathseadir)/systypes.h \ + $(kpathseadir)/c-memstr.h \ + $(kpathseadir)/c-errno.h \ + $(kpathseadir)/c-minmax.h \ + $(kpathseadir)/c-limits.h \ + $(kpathseadir)/c-proto.h \ + $(kpathseadir)/debug.h \ + $(kpathseadir)/types.h \ + $(kpathseadir)/lib.h \ + $(kpathseadir)/progname.h \ + error.h \ + $(kpathseadir)/c-vararg.h \ + font.h \ + num.h + diff --git a/Build/source/texk/seetexk/depend.mk b/Build/source/texk/seetexk/depend.mk new file mode 100644 index 00000000000..0eee2584fe7 --- /dev/null +++ b/Build/source/texk/seetexk/depend.mk @@ -0,0 +1,297 @@ +bcopy.o: bcopy.c +bzero.o: bzero.c +conv.o: conv.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h conv.h +dvi_draw.o: dvi_draw.c +dvibook.o: dvibook.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dviclass.h dvicodes.h error.h fio.h gripes.h \ + search.h seek.h +dviclass.o: dviclass.c dviclass.h +dviconcat.o: dviconcat.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dviclass.h dvicodes.h error.h fio.h gripes.h \ + search.h +dviselect.o: dviselect.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dviclass.h dvicodes.h error.h fio.h gripes.h \ + search.h +dvistate.o: dvistate.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h conv.h dvicodes.h error.h fio.h font.h \ + gripes.h postamble.h search.h seek.h dvistate.h +dvistuff.o: dvistuff.c \ + dvistuff.h types.h $(kpathsea_srcdir)/config.h \ + c-auto.h $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h font.h conv.h dviclass.h dvicodes.h \ + postamble.h search.h fio.h +dvitodvi.o: dvitodvi.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dviclass.h dvicodes.h error.h fio.h gripes.h \ + search.h seek.h +error.o: error.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h +findpost.o: findpost.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dvicodes.h fio.h num.h +fio.o: fio.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h fio.h +font.o: font.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h conv.h error.h font.h +font_subr.o: font_subr.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h +getopt.o: getopt.c +gfclass.o: gfclass.c gfclass.h +gffont.o: gffont.c \ + types.h \ + $(kpathsea_srcdir)/config.h c-auto.h $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h gfcodes.h gfclass.h num.h +gripes0.o: gripes0.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h gripes.h +gripes1.o: gripes1.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h gripes.h +magfactor.o: magfactor.c +pkfont.o: pkfont.c \ + types.h \ + $(kpathsea_srcdir)/config.h c-auto.h $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h num.h +pxlfont.o: pxlfont.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h fio.h +rotate.o: rotate.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h +rstfont.o: rstfont.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h fio.h +scaletfm.o: scaletfm.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h font.h +scanpost.o: scanpost.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h dvicodes.h fio.h gripes.h postamble.h +search.o: search.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h search.h +seek.o: seek.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h seek.h +skip.o: skip.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h fio.h +split.o: split.c +strsave.o: strsave.c types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h \ + $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h error.h +strtol.o: strtol.c +tempfile.o: tempfile.c +tfm.o: tfm.c \ + types.h $(kpathsea_srcdir)/config.h c-auto.h \ + $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h fio.h tfm.h +tfmfont.o: tfmfont.c \ + types.h \ + $(kpathsea_srcdir)/config.h c-auto.h $(kpathsea_srcdir)/c-std.h \ + $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \ + $(kpathsea_srcdir)/c-memstr.h \ + $(kpathsea_srcdir)/c-errno.h \ + $(kpathsea_srcdir)/c-minmax.h \ + $(kpathsea_srcdir)/c-limits.h \ + $(kpathsea_srcdir)/c-proto.h \ + $(kpathsea_srcdir)/debug.h $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h \ + $(kpathsea_srcdir)/progname.h conv.h font.h tfm.h diff --git a/Build/source/texk/seetexk/dvi_draw.c b/Build/source/texk/seetexk/dvi_draw.c new file mode 100644 index 00000000000..9f4f793b937 --- /dev/null +++ b/Build/source/texk/seetexk/dvi_draw.c @@ -0,0 +1,390 @@ +/* + * Support drawing routines for TeXsun and TeX + * + * Copyright, (C) 1987, 1988 Tim Morgan, UC Irvine + * Copyright 1989 Dirk Grunwald (extensions & fixes) + * + * 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 Tim Morgan, Dirk + * Grunwald or M.I.T. not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. Tim Morgan, Dirk Grunwald and 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. + * + * TIM MORGAN, + * DIRK GRUNWALD AND M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT + * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE + * OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: + * Tim Morgan + * Dept. of Computer Science + * Univ. of Calf. at Irvine + * + * Dirk Grunwald + * Dept. of Computer Science + * + * + * At the time these routines are called, the values of hh and vv should + * have been updated to the upper left corner of the graph (the position + * the \special appears at in the dvi file). Then the coordinates in the + * graphics commands are in terms of a virtual page with axes oriented the + * same as the Imagen and the SUN normally have: + * + * 0,0 + * +-----------> +x + * | + * | + * | + * \ / + * +y + * + * Angles are measured in the conventional way, from +x towards +y. + * Unfortunately, that reverses the meaning of "counterclockwise" + * from what it's normally thought of. + * + * A lot of floating point arithmetic has been converted to integer + * arithmetic for speed. In some places, this is kind-of kludgy, but + * it's worth it. + */ + +static char *rcsid="$Header: /usr/local/src/Uiuctex/libtex/RCS/dvi_draw.c,v 1.3 88/02/19 17:00:34 grunwald Exp Locker: grunwald $" ; + +#include <math.h> +#include <stdio.h> +#include <ctype.h> + +#define MAXPOINTS 300 /* Max points in a path */ +#define TWOPI (3.14159265359*2.0) +#define MAX_PEN_SIZE 7 /* Max pixels of pen width */ + + +static int xx[MAXPOINTS], yy[MAXPOINTS]; /* Path in milli-inches */ +static int path_len = 0; /* # points in current path */ +int pen_size = 1; /* Pixel width of lines drawn */ +#define FALSE 0 +#define TRUE 1 +int whiten = FALSE, shade = FALSE, blacken = FALSE; + +extern void dot_at(), line_btw(), do_attribute_path(); + +#define shrink_factor shrinkFactor[currentShrink] + +/* Unfortunately, these values also appear in dvisun.c */ +#define xRESOLUTION (dviDPI/shrink_factor) +#define yRESOLUTION (dviDPI/shrink_factor) + +extern int dviDPI, currentShrink, shrinkFactor[]; + + +/* + * Issue warning/error messages + */ +void Fatal(msg) +char *msg; +{ + fprintf(stderr, "%s\n", msg); + exit(1); +} + +static void Warning(fmt, msg) +char *fmt, *msg; +{ + fprintf(stderr, fmt, msg); + fputc ('\n', stderr); +} + + +/* + * Set the size of the virtual pen used to draw in milli-inches + */ +/* ARGSUSED */ +void set_pen_size(cp) +char *cp; +{ + int ps; + + if (sscanf(cp, " %d ", &ps) != 1) { + Warning("illegal .ps command format: %s", cp); + return; + } + pen_size = (ps*(xRESOLUTION+yRESOLUTION) + 1000) / 2000; + if (pen_size < 1) pen_size = 1; + else if (pen_size > MAX_PEN_SIZE) pen_size = MAX_PEN_SIZE; +} + + +/* + * Print the line defined by previous path commands + */ +void flush_path() +{ + register int i; + int last_min_x, last_max_x, last_min_y, last_max_y; + + last_min_x = 30000; last_min_y = 30000; + last_max_x = -30000; last_max_y = -30000; + for (i=1; i<path_len; i++) { + if (xx[i] > last_max_x) last_max_x = xx[i]; + if (xx[i] < last_min_x) last_min_x = xx[i]; + if (yy[i] > last_max_y) last_max_y = yy[i]; + if (yy[i] < last_min_y) last_min_y = yy[i]; + line_btw(xx[i], yy[i], xx[i+1], yy[i+1]); + } + if (xx[path_len] > last_max_x) last_max_x = xx[path_len]; + if (xx[path_len] < last_min_x) last_min_x = xx[path_len]; + if (yy[path_len] > last_max_y) last_max_y = yy[path_len]; + if (yy[path_len] < last_min_y) last_min_y = yy[path_len]; + path_len = 0; + do_attribute_path(last_min_x, last_max_x, last_min_y, last_max_y); +} + + +/* + * Print a dashed line along the previously defined path, with + * the dashes/inch defined. + */ +void flush_dashed(cp, dotted) +char *cp; +int dotted; +{ + int i, numdots, x0, y0, x1, y1; + int cx0, cy0, cx1, cy1; + float inchesperdash; + double d, spacesize, a, b, dx, dy, milliperdash; + + if (sscanf(cp, " %f ", &inchesperdash) != 1) { + Warning("illegal format for dotted/dashed line: %s", cp); + return; + } + if (path_len <= 1 || inchesperdash <= 0.0) { + Warning("illegal conditions for dotted/dashed line%s", ""); + return; + } + milliperdash = inchesperdash * 1000.0; + x0 = xx[1]; y0 = yy[1]; + x1 = xx[2]; y1 = yy[2]; + dx = x1 - x0; + dy = y1 - y0; + if (dotted) { + numdots = sqrt(dx*dx + dy*dy) / milliperdash + 0.5; + if ( numdots == 0 ) { /* always draw at least one dot */ + numdots = 1; + } + for (i=0; i <= numdots; i++) { + a = (float) i / (float) numdots; + cx0 = x0 + a*dx + 0.5; + cy0 = y0 + a*dy + 0.5; + dot_at(cx0, cy0); + } + } + else { + d = sqrt(dx*dx + dy*dy); + if (d <= 2.0*milliperdash) + line_btw(x0, y0, x1, y1); + else { + numdots = d / (2.0*milliperdash) + 1.0; + spacesize = (d - numdots * milliperdash) / (numdots - 1); + for (i=0; i<numdots-1; i++) { + a = i * (milliperdash + spacesize) / d; + b = a + milliperdash / d; + cx0 = x0 + a*dx + 0.5; + cy0 = y0 + a*dy + 0.5; + cx1 = x0 + b*dx + 0.5; + cy1 = y0 + b*dy + 0.5; + line_btw(cx0, cy0, cx1, cy1); + b += spacesize / d; + } + cx0 = x0 + b*dx + 0.5; + cy0 = y0 + b*dy + 0.5; + line_btw(cx0, cy0, x1, y1); + } + } + path_len = 0; +} + + +/* + * Add a point to the current path + */ +void add_path(cp) +char *cp; +{ + int pathx, pathy; + + if (++path_len >= MAXPOINTS) Fatal("Too many points"); + if (sscanf(cp, " %d %d ", &pathx, &pathy) != 2) + Fatal("Malformed path command"); + xx[path_len] = pathx; + yy[path_len] = pathy; +} + + +/* + * Draw to a floating point position + */ +static void im_fdraw(x, y) +double x,y; +{ + if (++path_len >= MAXPOINTS) Fatal("Too many arc points"); + xx[path_len] = x + 0.5; + yy[path_len] = y + 0.5; +} + + +/* + * Draw an arc + */ +void arc(cp) +char *cp; +{ + int xc, yc, xrad, yrad, n; + float start_angle, end_angle, angle, theta, r; + double xradius, yradius, xcenter, ycenter; + + if (sscanf(cp, " %d %d %d %d %f %f ", &xc, &yc, &xrad, &yrad, &start_angle, + &end_angle) != 6) { + Warning("illegal arc specification: %s", cp); + return; + } + /* We have a specialized fast way to draw closed circles/ellipses */ + if (start_angle <= 0.0 && end_angle >= 6.282) { + draw_ellipse(xc, yc, xrad, yrad); + return; + } + xcenter = xc; + ycenter = yc; + xradius = xrad; + yradius = yrad; + r = (xradius + yradius) / 2.0; + theta = sqrt(1.0 / r); + n = 0.3 * TWOPI / theta + 0.5; + if (n < 12) n = 12; + else if (n > 80) n = 80; + n /= 2; + theta = TWOPI / n; + flush_path(); + im_fdraw( xcenter + xradius*cos(start_angle), + ycenter + yradius*sin(start_angle) ); + angle = start_angle + theta; + while (angle < end_angle) { + im_fdraw(xcenter + xradius*cos(angle), + ycenter + yradius*sin(angle) ); + angle += theta; + } + im_fdraw(xcenter + xradius*cos(end_angle), + ycenter + yradius*sin(end_angle) ); + flush_path(); +} + + +/* + * APPROXIMATE integer distance between two points + */ +#define dist(x0, y0, x1, y1) (abs(x0-x1)+abs(y0-y1)) + + +/* + * Draw a spline along the previously defined path + */ +void flush_spline() +{ + int xp, yp, N, lastx=(-1), lasty; + int t1, t2, t3, steps, j; + register int i, w; + +#ifdef lint + lasty = -1; +#endif + N = path_len + 1; + xx[0] = xx[1]; yy[0] = yy[1]; + xx[N] = xx[N-1]; yy[N] = yy[N-1]; + for (i=0; i<N-1; i++) { /* interval */ + steps = (dist(xx[i], yy[i], xx[i+1], yy[i+1]) + + dist(xx[i+1], yy[i+1], xx[i+2], yy[i+2])) / 80; + for (j=0; j<steps; j++) { /* points within */ + w = (j*1000 + 500) / steps; + t1 = w * w / 20; + w -= 500; + t2 = (750000 - w * w) / 10; + w -= 500; + t3 = w * w / 20; + xp = (t1*xx[i+2] + t2*xx[i+1] + t3*xx[i] + 50000) / 100000; + yp = (t1*yy[i+2] + t2*yy[i+1] + t3*yy[i] + 50000) / 100000; + if (lastx > -1) line_btw(lastx, lasty, xp, yp); + lastx = xp; + lasty = yp; + } + } + path_len = 0; +} + + +/* + * Shade the last box, circle, or ellipse + */ +void shade_last() +{ + blacken = whiten = FALSE; + shade = TRUE; +} + + +/* + * Make the last box, circle, or ellipse, white inside (shade with white) + */ +void whiten_last() +{ + whiten = TRUE; + blacken = shade = FALSE; +} + + +/* + * Make last box, etc, black inside + */ +void blacken_last() +{ + blacken = TRUE; + whiten = shade = FALSE; +} + + +/* + * Draw an ellipse with the indicated center and radices. + */ +draw_ellipse(xc, yc, xr, yr) +int xc, yc, xr, yr; +{ + double angle, theta; + int n, px0, py0, px1, py1; + + angle = (xr + yr) / 2.0; + theta = sqrt(1.0 / angle); + n = TWOPI / theta + 0.5; + if (n < 12) n = 12; + else if (n > 80) n = 80; + n /= 2; + theta = TWOPI / n; + + angle = 0.0; + px0 = xc + xr; /* cos(0) = 1 */ + py0 = yc; /* Sin(0) = 0 */ + while ((angle += theta) <= TWOPI) { + px1 = xc + xr*cos(angle) + 0.5; + py1 = yc + yr*sin(angle) + 0.5; + line_btw(px0, py0, px1, py1); + px0 = px1; + py0 = py1; + } + line_btw(px0, py0, xc + xr, yc); +} diff --git a/Build/source/texk/seetexk/dvibook.c b/Build/source/texk/seetexk/dvibook.c new file mode 100644 index 00000000000..388aace141a --- /dev/null +++ b/Build/source/texk/seetexk/dvibook.c @@ -0,0 +1,938 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/dvi/RCS/dviselect.c,v 3.1 89/08/22 17:16:13 chris Exp $"; +#endif + +/* + * DVI page rearrangement program + * + * Reads DVI version 2 files and rearranges pages into signatures, + * writing a new DVI file. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-fopen.h> +#include <kpathsea/getopt.h> +#else +#define FOPEN_RBIN_MODE "r" +#define FOPEN_RBIN_MODE "w" +#define SET_BINARY(x) +extern char *optarg; +extern int optind; +#endif + +#include "types.h" +#include "dviclass.h" +#include "dvicodes.h" +#include "error.h" +#include "fio.h" +#include "gripes.h" +#include "search.h" +#include <stdio.h> +#include <ctype.h> +#include "seek.h" + +#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',') + +#define MAXDVIPAGES 1000 /* max (absolute) pages in DVI file */ + +char *ProgName; + +/* Globals */ +char serrbuf[BUFSIZ]; /* buffer for stderr */ + +/* + * We will try to keep output lines shorter than MAXCOL characters. + */ +#define MAXCOL 75 + +/* + * We use the following structure to keep track of fonts we have seen. + * The final DVI file lists only the fonts it uses. + */ +struct fontinfo { + i32 fi_newindex; /* font number in output file */ + int fi_reallyused; /* true => used on a page we copied */ + i32 fi_checksum; /* the checksum */ + i32 fi_mag; /* the magnification */ + i32 fi_designsize; /* the design size */ + short fi_n1; /* the name header length */ + short fi_n2; /* the name body length */ + char *fi_name; /* the name itself */ +}; + +int Signature; /* #pages per signature (multiple of 4) */ + +int SFlag; /* true => -s, silent operation */ + +struct search *FontFinder; /* maps from input indicies to fontinfo */ +i32 NextOutputFontIndex; /* generates output indicies */ +i32 CurrentFontIndex; /* current (old) index in input */ +i32 OutputFontIndex; /* current (new) index in ouput */ + +char *DVIFileName; /* name of input DVI file */ +FILE *inf; /* the input file itself */ +FILE *outf; /* the output DVI file */ + +long StartOfPage[MAXDVIPAGES]; /* The file positions of the + input pages */ + +long StartOfLastPage; /* The file position just before we + started the last page */ +long CurrentPosition; /* The current position of the file */ + +int UseThisPage; /* true => current page is selected */ + +i32 InputPageNumber; /* current absolute page in old DVI file */ +int NumberOfOutputPages; /* number of pages in new DVI file */ + +i32 Numerator; /* numerator from DVI file */ +i32 Denominator; /* denominator from DVI file */ +i32 DVIMag; /* magnification from DVI file */ + +i32 Count[10]; /* the 10 \count variables */ + +/* save some string space: we use this a lot */ +char writeerr[] = "error writing DVI file"; + +#ifndef KPATHSEA +char *malloc(), *realloc(); +#endif +/* + * You may get lint warnings about sprintf's return value. + * Older versions of 4BSD have `char *sprintf()'. ANSI and + * SysV use `int sprintf()'; so ignore the warnings. + */ + +/* + * Lint gets somewhat confused over putc. + */ +#ifdef lint +#undef putc +#ifdef ultrix /* grr */ +#define putc(c, f) fputc((char)(c), f) +#else +#define putc(c, f) fputc((int)(c), f) +#endif +#endif + +#ifdef HAVE_PROTOTYPES +void message(int space,char *str,int len); +void BeginPage(void); +void DviEndPage(void); +void PostAmbleFontEnumerator(char *addr,long key); +void HandlePostAmble(void); +void WriteFont(struct fontinfo *fi); +void HandlePreAmble(void); +void HandleFontDef(long strchr); +void HandleSpecial(int c,int l,long p); +void ReallyUseFont(void); +void PutFontSelector(long strchr); +void ScanDVIFile(void); +void HandleDVIFile(void); +int HandlePage(void); +void PutEmptyPage(void); +#else +void message(); +void BeginPage(); +void DviEndPage(); +void PostAmbleFontEnumerator(); +void HandlePostAmble(); +void WriteFont(); +void HandlePreAmble(); +void HandleFontDef(); +void HandleSpecial(); +void ReallyUseFont(); +void PutFontSelector(); +void ScanDVIFile(); +void HandleDVIFile(); +int HandlePage(); +void PutEmptyPage(); +#endif + +/* + * Print a message to stderr, with an optional leading space, and handling + * long line wraps. + */ +void +message(space, str, len) + int space; + register char *str; + register int len; +{ + static int beenhere; + static int col; + + if (!beenhere) + space = 0, beenhere++; + if (len == 0) + len = strlen(str); + col += len; + if (space) { + if (col >= MAXCOL) + (void) putc('\n', stderr), col = len; + else + (void) putc(' ', stderr), col++; + } + while (--len >= 0) + (void) putc(*str++, stderr); + (void) fflush(stderr); +} + +/* + * Start a page (process a DVI_BOP). + */ +void +BeginPage() +{ + register i32 *i; + + OutputFontIndex = -1; /* new page requires respecifying font */ + for (i = Count; i < &Count[10]; i++) + fGetLong(inf, *i); + (void) GetLong(inf); /* previous page pointer */ + + if (!UseThisPage) + return; + + putbyte(outf, DVI_BOP); + for (i = Count; i < &Count[10]; i++) + PutLong(outf, *i); + PutLong(outf, StartOfLastPage); + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 45; /* we just wrote this much */ + + if (!SFlag) { /* write nice page usage messages */ + register int z = 0; + register int mlen = 0; + char msg[80]; + + (void) sprintf(msg, "[%ld", (long)Count[0]); + mlen = strlen(msg); + for (i = &Count[1]; i < &Count[10]; i++) { + if (*i == 0) { + z++; + continue; + } + while (--z >= 0) + msg[mlen++] = '.', msg[mlen++] = '0'; + z = 0; + (void) sprintf(msg + mlen, ".%ld", (long)*i); + mlen += strlen(msg + mlen); + } + message(1, msg, mlen); + } +} + +/* + * End a page (process a DVI_EOP). + */ +void +EndPage() +{ + + if (!UseThisPage) + return; + if (!SFlag) + message(0, "]", 1); + putbyte(outf, DVI_EOP); + if (ferror(outf)) + error(1, -1, writeerr); + CurrentPosition++; + NumberOfOutputPages++; +} + +/* + * For each of the fonts used in the new DVI file, write out a definition. + */ +/* ARGSUSED */ +void +PostAmbleFontEnumerator(addr, key) + char *addr; + i32 key; +{ + + if (((struct fontinfo *)addr)->fi_reallyused) + WriteFont((struct fontinfo *)addr); +} + +void +HandlePostAmble() +{ + register i32 c; + + (void) GetLong(inf); /* previous page pointer */ + if (GetLong(inf) != Numerator) + GripeMismatchedValue("numerator"); + if (GetLong(inf) != Denominator) + GripeMismatchedValue("denominator"); + if (GetLong(inf) != DVIMag) + GripeMismatchedValue("\\magnification"); + + putbyte(outf, DVI_POST); + PutLong(outf, StartOfLastPage); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + c = GetLong(inf); + PutLong(outf, c); /* tallest page height */ + c = GetLong(inf); + PutLong(outf, c); /* widest page width */ + c = GetWord(inf); + PutWord(outf, c); /* DVI stack size */ + PutWord(outf, NumberOfOutputPages); + StartOfLastPage = CurrentPosition; /* point at post */ + CurrentPosition += 29; /* count all those `put's */ +#ifdef notdef + (void) GetWord(inf); /* skip original number of pages */ +#endif + + /* + * just ignore all the incoming font definitions; we are done with + * input file + */ + + /* + * run through the FontFinder table and dump definitions for the + * fonts we have used. + */ + SEnumerate(FontFinder, PostAmbleFontEnumerator); + + putbyte(outf, DVI_POSTPOST); + PutLong(outf, StartOfLastPage); /* actually start of postamble */ + putbyte(outf, DVI_VERSION); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + CurrentPosition += 10; + while (CurrentPosition & 3) { + putbyte(outf, DVI_FILLER); + CurrentPosition++; + } + if (ferror(outf)) + error(1, -1, writeerr); +} + +/* + * Write a font definition to the output file + */ +void +WriteFont(fi) + register struct fontinfo *fi; +{ + register int l; + register char *s; + + if (fi->fi_newindex < 256) { + putbyte(outf, DVI_FNTDEF1); + putbyte(outf, fi->fi_newindex); + CurrentPosition += 2; + } else if (fi->fi_newindex < 65536) { + putbyte(outf, DVI_FNTDEF2); + PutWord(outf, fi->fi_newindex); + CurrentPosition += 3; + } else if (fi->fi_newindex < 16777216) { + putbyte(outf, DVI_FNTDEF3); + Put3Byte(outf, fi->fi_newindex); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNTDEF4); + PutLong(outf, fi->fi_newindex); + CurrentPosition += 5; + } + PutLong(outf, fi->fi_checksum); + PutLong(outf, fi->fi_mag); + PutLong(outf, fi->fi_designsize); + putbyte(outf, fi->fi_n1); + putbyte(outf, fi->fi_n2); + l = fi->fi_n1 + fi->fi_n2; + CurrentPosition += 14 + l; + s = fi->fi_name; + while (--l >= 0) + putbyte(outf, *s++); +} + +/* + * Handle the preamble. Someday we should update the comment field. + */ +void +HandlePreAmble() +{ + register int n, c; + + c = getc(inf); + if (c == EOF) + GripeUnexpectedDVIEOF(); + if (c != DVI_PRE) + GripeMissingOp("PRE"); + if (getc(inf) != DVI_VERSION) + error(1, 0, "%s is not a DVI version %d file", + DVIFileName, DVI_VERSION); + Numerator = GetLong(inf); + Denominator = GetLong(inf); + DVIMag = GetLong(inf); + putbyte(outf, DVI_PRE); + putbyte(outf, DVI_VERSION); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + + n = UnSign8(GetByte(inf)); + CurrentPosition = 15 + n; /* well, almost */ + putbyte(outf, n); + while (--n >= 0) { + c = GetByte(inf); + putbyte(outf, c); + } +} + +int +main(argc, argv) + int argc; + register char **argv; +{ + register int c; + register char *s; + char *outname = NULL; + + Signature = 0; + + ProgName = *argv; + setbuf(stderr, serrbuf); + + while ((c = getopt(argc, argv, "i:o:s:q")) != EOF) { + switch (c) { + + case 'q': /* silent */ + SFlag++; + break; + + case 'i': + if (DVIFileName != NULL) + goto usage; + DVIFileName = optarg; + break; + + case 'o': + if (outname != NULL) + goto usage; + outname = optarg; + break; + + case 's': + if (Signature != 0) + goto usage; + Signature = atoi(optarg); + if (Signature <= 0) + error(1, -1, "-s parameter must be > 0"); + if (Signature % 4 != 0) + error(1, -1, + "-s parameter must be a multiple of 4"); + break; + + case '?': +usage: + (void) fprintf(stderr, "\ +Usage: %s [-s signature] [-q] [-i infile] [-o outfile] [infile [outfile]]\n", + ProgName); + (void) fflush(stderr); + exit(1); + } + } + + while (optind < argc) { + s = argv[optind++]; + c = *s; + if (DVIFileName == NULL) + DVIFileName = s; + else if (outname == NULL) + outname = s; + else + goto usage; + } + if (DVIFileName == NULL) { + DVIFileName = "`stdin'"; + inf = stdin; + if (!isatty(fileno(inf))) + SET_BINARY(fileno(inf)); + } else if ((inf = fopen(DVIFileName, FOPEN_RBIN_MODE)) == 0) + error(1, -1, "cannot read %s", DVIFileName); + if (outname == NULL) { + outf = stdout; + if (!isatty(fileno(outf))) + SET_BINARY(fileno(outf)); + } + else if ((outf = fopen(outname, FOPEN_WBIN_MODE)) == 0) + error(1, -1, "cannot write %s", outname); + + if ((FontFinder = SCreate(sizeof(struct fontinfo))) == 0) + error(1, 0, "cannot create font finder (out of memory?)"); + + /* copy inf to TEMP file if not seekable */ + if ((inf = SeekFile(inf)) == NULL) { + error(1, 0, "can't seek file"); + } + InputPageNumber = 0; + StartOfLastPage = -1; + HandlePreAmble(); + ScanDVIFile(); + HandleDVIFile(); + HandlePostAmble(); + if (!SFlag) + (void) fprintf(stderr, "\nWrote %d page%s, %ld bytes\n", + NumberOfOutputPages, NumberOfOutputPages == 1 ? "" : "s", + (long)CurrentPosition); + return 0; +} + +/* + * Handle a font definition. + */ +void +HandleFontDef(index) + i32 index; +{ + register struct fontinfo *fi; + register int i; + register char *s; + int def = S_CREATE | S_EXCL; + + if (!UseThisPage) { + if ((fi = (struct fontinfo *)SSearch(FontFinder, index, &def)) == 0) + if (def & S_COLL) + error(1, 0, "font %ld already defined", (long)index); + else + error(1, 0, "cannot stash font %ld (out of memory?)", + (long)index); + fi->fi_reallyused = 0; + fi->fi_checksum = GetLong(inf); + fi->fi_mag = GetLong(inf); + fi->fi_designsize = GetLong(inf); + fi->fi_n1 = UnSign8(GetByte(inf)); + fi->fi_n2 = UnSign8(GetByte(inf)); + i = fi->fi_n1 + fi->fi_n2; + if ((s = malloc((unsigned)i)) == 0) + GripeOutOfMemory(i, "font name"); + fi->fi_name = s; + while (--i >= 0) + *s++ = GetByte(inf); + } else { + (void) GetLong(inf); + (void) GetLong(inf); + (void) GetLong(inf); + i = UnSign8(GetByte(inf)); + i += UnSign8(GetByte(inf)); + while (--i >= 0) + (void) GetByte(inf); + } +} + +/* + * Handle a \special. + */ +void +HandleSpecial(c, l, p) + int c; + register int l; + register i32 p; +{ + register int i; + + if (UseThisPage) { + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + break; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + break; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + break; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + break; + + default: + panic("HandleSpecial l=%d", l); + /* NOTREACHED */ + } + CurrentPosition += p; + while (--p >= 0) { + i = getc(inf); + putbyte(outf, i); + } + if (feof(inf)) + GripeUnexpectedDVIEOF(); + if (ferror(outf)) + error(1, -1, writeerr); + } else + while (--p >= 0) + (void) getc(inf); +} + +void +ReallyUseFont() +{ + register struct fontinfo *fi; + int look = S_LOOKUP; + + fi = (struct fontinfo *)SSearch(FontFinder, CurrentFontIndex, &look); + if (fi == NULL) + error(1, 0, "DVI file requested font %ld without defining it", + (long)CurrentFontIndex); + if (fi->fi_reallyused == 0) { + fi->fi_reallyused++; + fi->fi_newindex = NextOutputFontIndex++; + WriteFont(fi); + } + if (fi->fi_newindex != OutputFontIndex) { + PutFontSelector(fi->fi_newindex); + OutputFontIndex = fi->fi_newindex; + } +} + +/* + * Write a font selection command to the output file + */ +void +PutFontSelector(index) + i32 index; +{ + + if (index < 64) { + putbyte(outf, index + DVI_FNTNUM0); + CurrentPosition++; + } else if (index < 256) { + putbyte(outf, DVI_FNT1); + putbyte(outf, index); + CurrentPosition += 2; + } else if (index < 65536) { + putbyte(outf, DVI_FNT2); + PutWord(outf, index); + CurrentPosition += 3; + } else if (index < 16777216) { + putbyte(outf, DVI_FNT3); + Put3Byte(outf, index); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNT4); + PutLong(outf, index); + CurrentPosition += 5; + } +} + +/* + * The following table describes the length (in bytes) of each of the DVI + * commands that we can simply copy, starting with DVI_SET1 (128). + */ +char oplen[128] = { + 0, 0, 0, 0, /* DVI_SET1 .. DVI_SET4 */ + 9, /* DVI_SETRULE */ + 0, 0, 0, 0, /* DVI_PUT1 .. DVI_PUT4 */ + 9, /* DVI_PUTRULE */ + 1, /* DVI_NOP */ + 0, /* DVI_BOP */ + 0, /* DVI_EOP */ + 1, /* DVI_PUSH */ + 1, /* DVI_POP */ + 2, 3, 4, 5, /* DVI_RIGHT1 .. DVI_RIGHT4 */ + 1, /* DVI_W0 */ + 2, 3, 4, 5, /* DVI_W1 .. DVI_W4 */ + 1, /* DVI_X0 */ + 2, 3, 4, 5, /* DVI_X1 .. DVI_X4 */ + 2, 3, 4, 5, /* DVI_DOWN1 .. DVI_DOWN4 */ + 1, /* DVI_Y0 */ + 2, 3, 4, 5, /* DVI_Y1 .. DVI_Y4 */ + 1, /* DVI_Z0 */ + 2, 3, 4, 5, /* DVI_Z1 .. DVI_Z4 */ + 0, /* DVI_FNTNUM0 (171) */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 172 .. 179 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 180 .. 187 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 188 .. 195 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 196 .. 203 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 204 .. 211 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 212 .. 219 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 220 .. 227 */ + 0, 0, 0, 0, 0, 0, 0, /* 228 .. 234 */ + 0, 0, 0, 0, /* DVI_FNT1 .. DVI_FNT4 */ + 0, 0, 0, 0, /* DVI_XXX1 .. DVI_XXX4 */ + 0, 0, 0, 0, /* DVI_FNTDEF1 .. DVI_FNTDEF4 */ + 0, /* DVI_PRE */ + 0, /* DVI_POST */ + 0, /* DVI_POSTPOST */ + 0, 0, 0, 0, 0, 0, /* 250 .. 255 */ +}; + +/* + * Here we scan the input DVI file and record pointers to the pages. + */ +void +ScanDVIFile() +{ + UseThisPage = 0; + + StartOfPage[InputPageNumber] = ftell(inf); + while (HandlePage()) { /* scan DVI file */ + StartOfPage[++InputPageNumber] = ftell(inf); + } +} + +/* + * Here we read the input DVI file and write relevant pages to the + * output DVI file. We also keep track of font changes, handle font + * definitions, and perform some other housekeeping. + */ +void +HandleDVIFile() +{ + int CurrentPage, ActualPage, MaxPage; + + UseThisPage = 1; + + MaxPage = InputPageNumber + (4-InputPageNumber%4)%4; + + if (!Signature) + Signature = MaxPage; + for (CurrentPage = 0; CurrentPage < MaxPage; CurrentPage++) { + ActualPage = CurrentPage - CurrentPage%Signature; + switch (CurrentPage%4) { + case 0: + case 3: + ActualPage += Signature-1-(CurrentPage%Signature)/2; + break; + case 1: + case 2: + ActualPage += (CurrentPage%Signature)/2; + break; + } + if (ActualPage < InputPageNumber) { + if (fseek(inf, StartOfPage[ActualPage], 0) == -1) + error(1, -1, + "can't seek page %d", ActualPage+1); + HandlePage(); + } else + PutEmptyPage(); + } + if (fseek(inf, StartOfPage[InputPageNumber]+1, 0) == -1) + error(1, -1, "can't seek last page"); +} + +int +HandlePage() +{ + register int c, l; + register i32 p; + register int CurrentFontOK = 0; + int doingpage = 0; + + /* Only way out is via "return" statement */ + for (;;) { + c = getc(inf); /* getc() returns unsigned values */ + if (DVI_IsChar(c)) { + /* + * Copy chars, note font usage, but ignore if + * page is not interesting. + */ + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + CurrentPosition++; + continue; + } + if (DVI_IsFont(c)) { /* note font change */ + CurrentFontIndex = c - DVI_FNTNUM0; + CurrentFontOK = 0; + continue; + } + if (c == EOF) + GripeUnexpectedDVIEOF(); + if ((l = (oplen - 128)[c]) != 0) { /* simple copy */ + if (!UseThisPage) { + while (--l > 0) + (void) getc(inf); + continue; + } + CurrentPosition += l; + putbyte(outf, c); + while (--l > 0) { + c = getc(inf); + putbyte(outf, c); + } + if (ferror(outf)) + error(1, -1, writeerr); + continue; + } + if ((l = DVI_OpLen(c)) != 0) { + /* + * Handle other generics. + * N.B.: there should only be unsigned parameters + * here (save SGN4), for commands with negative + * parameters have been taken care of above. + */ + switch (l) { + + case DPL_UNS1: + p = getc(inf); + break; + + case DPL_UNS2: + fGetWord(inf, p); + break; + + case DPL_UNS3: + fGet3Byte(inf, p); + break; + + case DPL_SGN4: + fGetLong(inf, p); + break; + + default: + panic("HandleDVIFile l=%d", l); + } + + /* + * Now that we have the parameter, perform the + * command. + */ + switch (DVI_DT(c)) { + + case DT_SET: + case DT_PUT: + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + continue; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + continue; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + continue; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + continue; + } + + case DT_FNT: + CurrentFontIndex = p; + CurrentFontOK = 0; + continue; + + case DT_XXX: + HandleSpecial(c, l, p); + continue; + + case DT_FNTDEF: + HandleFontDef(p); + continue; + + default: + panic("HandleDVIFile DVI_DT(%d)=%d", + c, DVI_DT(c)); + } + continue; + } + + switch (c) { /* handle the few remaining cases */ + + case DVI_BOP: + if (doingpage) + GripeUnexpectedOp("BOP (during page)"); + BeginPage(); + doingpage = 1; + break; + + case DVI_EOP: + if (!doingpage) + GripeUnexpectedOp("EOP (outside page)"); + EndPage(); + doingpage = 0; + return(1); + + case DVI_PRE: + GripeUnexpectedOp("PRE"); + /* NOTREACHED */ + + case DVI_POST: + if (doingpage) + GripeUnexpectedOp("POST (inside page)"); + return(0); + + case DVI_POSTPOST: + GripeUnexpectedOp("POSTPOST"); + /* NOTREACHED */ + + default: + GripeUndefinedOp(c); + /* NOTREACHED */ + } + } +} + +/* write an empty page to fill out space */ +void +PutEmptyPage() +{ + int i; + + putbyte(outf, DVI_BOP); + PutLong(outf, -1L); + for (i = 1; i < 10; i++) /* set all sub counts to 0 */ + PutLong(outf, 0L); + PutLong(outf, StartOfLastPage); + putbyte(outf, DVI_EOP); + if (!SFlag) { /* write nice page usage messages */ + char *msg = "[*]"; + message(1, msg, strlen(msg)); + } + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 46; /* we just wrote this much */ + NumberOfOutputPages++; +} diff --git a/Build/source/texk/seetexk/dvibook.man b/Build/source/texk/seetexk/dvibook.man new file mode 100644 index 00000000000..dd0bce06108 --- /dev/null +++ b/Build/source/texk/seetexk/dvibook.man @@ -0,0 +1,53 @@ +.TH DVIBOOK 1 +.SH NAME +dvibook \- rearrange pages in DVI file into signatures +.SH SYNOPSIS +.B dvibook +[ +.B \-q +] [ +.B \-s\fI<num> +] [ +.B \-i +.I infile +] [ +.B \-o +.I outfile +] +[ +.I infile +[ +.I outfile +] ] +.SH DESCRIPTION +.I Dvibook +rearranges pages from a DVI file produced by TeX into ``signatures'' for +printing books or booklets, creating a new DVI file +usable by any of the TeX conversion programs. +.PP +The +.I \-s +option selects the size of signature which will be used. The signature size is +the number of sides which will be folded and bound together; the number given +should be a multiple of four. The default is to use one signature for the +whole file. Extra blank sides will be added if the file does not contain a +multiple of four pages. +.PP +Dvibook normally prints the page numbers of the pages rearranged; the +.I \-q +option suppresses this. +.SH AUTHOR +Angus Duggan, from dviselect(1), by +Chris Torek, University of Maryland +.SH "SEE ALSO" +dviconcat(1), dviselect(1), latex(1), tex(1) +.br +.I "MC-TeX User's Guide" +.br +.I "The TeXbook" +.SH BUGS +.I Dvibook +does not adjust the parameters in the postamble; however, since these +values are normally used only to size certain structures in the output +conversion programs, and the parameters never need to be adjusted upward, +this has not proven to be a problem. diff --git a/Build/source/texk/seetexk/dviclass.c b/Build/source/texk/seetexk/dviclass.c new file mode 100644 index 00000000000..2897a00b7cf --- /dev/null +++ b/Build/source/texk/seetexk/dviclass.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/dviclass.c,v 3.1 89/08/22 21:48:35 chris Exp $"; +#endif + +/* + * dviclass - DVI code classification tables. + */ + +#include "dviclass.h" + +/* shorthand---in lowercase for contrast (read on!) */ +#define four(x) x, x, x, x +#define six(x) four(x), x, x +#define sixteen(x) four(x), four(x), four(x), four(x) +#define sixty_four(x) sixteen(x), sixteen(x), sixteen(x), sixteen(x) +#define one_twenty_eight(x) sixty_four(x), sixty_four(x) + +/* + * This table contains the byte length of the single operand, or DPL_NONE + * if no operand, or if it cannot be decoded this way. + * + * The sequences UNS1, UNS2, UNS3, SGN4 (`SEQ_U') and SGN1, SGN2, SGN3, + * SGN4 (`SEQ_S') are rather common, and so we define macros for these. + */ +#define SEQ_U DPL_UNS1, DPL_UNS2, DPL_UNS3, DPL_SGN4 +#define SEQ_S DPL_SGN1, DPL_SGN2, DPL_SGN3, DPL_SGN4 + +char dvi_oplen[256] = { + one_twenty_eight(DPL_NONE), + /* characters 0 through 127 */ + SEQ_U, /* DVI_SET1 through DVI_SET4 */ + DPL_NONE, /* DVI_SETRULE */ + SEQ_U, /* DVI_PUT1 through DVI_PUT4 */ + DPL_NONE, /* DVI_PUTRULE */ + DPL_NONE, /* DVI_NOP */ + DPL_NONE, /* DVI_BOP */ + DPL_NONE, /* DVI_EOP */ + DPL_NONE, /* DVI_PUSH */ + DPL_NONE, /* DVI_POP */ + SEQ_S, /* DVI_RIGHT1 through DVI_RIGHT4 */ + DPL_NONE, /* DVI_W0 */ + SEQ_S, /* DVI_W1 through DVI_W4 */ + DPL_NONE, /* DVI_X0 */ + SEQ_S, /* DVI_X1 through DVI_X4 */ + SEQ_S, /* DVI_DOWN1 through DVI_DOWN4 */ + DPL_NONE, /* DVI_Y0 */ + SEQ_S, /* DVI_Y1 through DVI_Y4 */ + DPL_NONE, /* DVI_Z0 */ + SEQ_S, /* DVI_Z1 through DVI_Z4 */ + sixty_four(DPL_NONE), /* DVI_FNTNUM0 through DVI_FNTNUM63 */ + SEQ_U, /* DVI_FNT1 through DVI_FNT4 */ + SEQ_U, /* DVI_XXX1 through DVI_XXX4 */ + SEQ_U, /* DVI_FNTDEF1 through DVI_FNTDEF4 */ + DPL_NONE, /* DVI_PRE */ + DPL_NONE, /* DVI_POST */ + DPL_NONE, /* DVI_POSTPOST */ + six(DPL_NONE) /* 250 through 255 */ +}; + +char dvi_dt[256] = { + one_twenty_eight(DT_CHAR), + /* characters 0 through 127 */ + four(DT_SET), /* DVI_SET1 through DVI_SET4 */ + DT_SETRULE, /* DVI_SETRULE */ + four(DT_PUT), /* DVI_PUT1 through DVI_PUT4 */ + DT_PUTRULE, /* DVI_PUTRULE */ + DT_NOP, /* DVI_NOP */ + DT_BOP, /* DVI_BOP */ + DT_EOP, /* DVI_EOP */ + DT_PUSH, /* DVI_PUSH */ + DT_POP, /* DVI_POP */ + four(DT_RIGHT), /* DVI_RIGHT1 through DVI_RIGHT4 */ + DT_W0, /* DVI_W0 */ + four(DT_W), /* DVI_W1 through DVI_W4 */ + DT_X0, /* DVI_X0 */ + four(DT_X), /* DVI_X1 through DVI_X4 */ + four(DT_DOWN), /* DVI_DOWN1 through DVI_DOWN4 */ + DT_Y0, /* DVI_Y0 */ + four(DT_Y), /* DVI_Y1 through DVI_Y4 */ + DT_Z0, /* DVI_Z0 */ + four(DT_Z), /* DVI_Z1 through DVI_Z4 */ + sixty_four(DT_FNTNUM), /* DVI_FNTNUM0 through DVI_FNTNUM63 */ + four(DT_FNT), /* DVI_FNT1 through DVI_FNT4 */ + four(DT_XXX), /* DVI_XXX1 through DVI_XXX4 */ + four(DT_FNTDEF), /* DVI_FNTDEF1 through DVI_FNTDEF4 */ + DT_PRE, /* DVI_PRE */ + DT_POST, /* DVI_POST */ + DT_POSTPOST, /* DVI_POSTPOST */ + six(DT_UNDEF) /* 250 through 255 */ +}; diff --git a/Build/source/texk/seetexk/dviclass.h b/Build/source/texk/seetexk/dviclass.h new file mode 100644 index 00000000000..32b8ce0be6c --- /dev/null +++ b/Build/source/texk/seetexk/dviclass.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Macros to convert DVI opcodes to (hopefully) simpler values. + */ + +/* + * Large range types---code may be any value (including EOF). + */ +#define DVI_IsChar(code) ((ui32)(code) < 128) +#define DVI_IsFont(code) ((code) >= 171 && (code) < 235) + +/* + * Symbolic names for generic types (for things with parameters). + * These are obtained via the macro DVI_DT(int c), where 0 <= c <= 255. + */ +#define DT_CHAR 0 +#define DT_SET 1 +#define DT_SETRULE 2 +#define DT_PUT 3 +#define DT_PUTRULE 4 +#define DT_NOP 5 +#define DT_BOP 6 +#define DT_EOP 7 +#define DT_PUSH 8 +#define DT_POP 9 +#define DT_RIGHT 10 +#define DT_W0 11 +#define DT_W 12 +#define DT_X0 13 +#define DT_X 14 +#define DT_DOWN 15 +#define DT_Y0 16 +#define DT_Y 17 +#define DT_Z0 18 +#define DT_Z 19 +#define DT_FNTNUM 20 +#define DT_FNT 21 +#define DT_XXX 22 +#define DT_FNTDEF 23 +#define DT_PRE 24 +#define DT_POST 25 +#define DT_POSTPOST 26 +#define DT_UNDEF 27 + +/* + * Symbolic names for parameter lengths, obtained via the macro + * DVL_OpLen(int c). + * + * N.B.: older drivers may assume that 0 => none, 1-4 => 1-4 bytes + * and 5-7 => unsigned version of 1-4---so DO NOT change these values! + */ +#define DPL_NONE 0 +#define DPL_SGN1 1 +#define DPL_SGN2 2 +#define DPL_SGN3 3 +#define DPL_SGN4 4 +#define DPL_UNS1 5 +#define DPL_UNS2 6 +#define DPL_UNS3 7 +/* there are no unsigned four byte parameters */ + +#define DVI_OpLen(code) (dvi_oplen[code]) +#define DVI_DT(code) (dvi_dt[code]) +extern char dvi_oplen[]; +extern char dvi_dt[]; diff --git a/Build/source/texk/seetexk/dvicodes.h b/Build/source/texk/seetexk/dvicodes.h new file mode 100644 index 00000000000..4f93c35c892 --- /dev/null +++ b/Build/source/texk/seetexk/dvicodes.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* DVI opcodes */ + +#define DVI_VERSION 2 /* version number that should appear in + pre- and post-ambles */ + +#define DVI_SET1 128 /* set character, 1 byte param */ +#define DVI_SET2 129 /* set character, 2 byte param */ +#define DVI_SET3 130 /* set character, 3 byte param */ +#define DVI_SET4 131 /* set character, 4 byte param */ +#define DVI_SETRULE 132 /* set a rule */ +#define DVI_PUT1 133 /* put char, don't move right */ +#define DVI_PUT2 134 /* put char, 2 byte */ +#define DVI_PUT3 135 /* etc */ +#define DVI_PUT4 136 +#define DVI_PUTRULE 137 /* put rule, don't move right */ +#define DVI_NOP 138 /* no-op */ +#define DVI_BOP 139 /* begin page */ +#define DVI_EOP 140 /* end page */ +#define DVI_PUSH 141 /* push h,v,w,x,y,z */ +#define DVI_POP 142 /* pop h,v,w,x,y,z */ +#define DVI_RIGHT1 143 /* move right, 1 byte signed param */ +#define DVI_RIGHT2 144 /* move right, 2 byte signed param */ +#define DVI_RIGHT3 145 /* etc */ +#define DVI_RIGHT4 146 +#define DVI_W0 147 /* h += w */ +#define DVI_W1 148 /* w = 1 byte signed param, h += w */ +#define DVI_W2 149 /* w = 2 byte etc, h += w */ +#define DVI_W3 150 +#define DVI_W4 151 +#define DVI_X0 152 /* like DVI_W0 but for x */ +#define DVI_X1 153 /* etc */ +#define DVI_X2 154 +#define DVI_X3 155 +#define DVI_X4 156 +#define DVI_DOWN1 157 /* v += 1 byte signed param */ +#define DVI_DOWN2 158 /* v += 2 byte signed param */ +#define DVI_DOWN3 159 /* etc */ +#define DVI_DOWN4 160 +#define DVI_Y0 161 /* y = 1 byte signed param, v += y */ +#define DVI_Y1 162 /* etc */ +#define DVI_Y2 163 +#define DVI_Y3 164 +#define DVI_Y4 165 +#define DVI_Z0 166 /* z = 1 byte signed param, v += z */ +#define DVI_Z1 167 /* etc */ +#define DVI_Z2 168 +#define DVI_Z3 169 +#define DVI_Z4 170 +#define DVI_FNTNUM0 171 + +#define DVI_FNT1 235 /* select font, 1 byte param */ +#define DVI_FNT2 236 /* etc */ +#define DVI_FNT3 237 +#define DVI_FNT4 238 +#define DVI_XXX1 239 /* for \special: if length < 256 */ +#define DVI_XXX2 240 /* etc */ +#define DVI_XXX3 241 +#define DVI_XXX4 242 +#define DVI_FNTDEF1 243 /* Define font, 1 byte param (0 to 63) */ +#define DVI_FNTDEF2 244 /* etc */ +#define DVI_FNTDEF3 245 +#define DVI_FNTDEF4 246 +#define DVI_PRE 247 /* preamble */ +#define DVI_POST 248 /* postamble */ +#define DVI_POSTPOST 249 /* end of postamble */ +#define DVI_FILLER 223 /* filler bytes at end of dvi file */ diff --git a/Build/source/texk/seetexk/dviconcat.c b/Build/source/texk/seetexk/dviconcat.c new file mode 100644 index 00000000000..c8410ac9dc5 --- /dev/null +++ b/Build/source/texk/seetexk/dviconcat.c @@ -0,0 +1,795 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/dvi/RCS/dviconcat.c,v 3.1 89/08/22 17:23:15 chris Exp $"; +#endif + +/* + * DVI page concatenation program. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-auto.h> +#include <kpathsea/c-fopen.h> +#include <kpathsea/getopt.h> +#else +#define FOPEN_RBIN_MODE "rb" +#define FOPEN_RBIN_MODE "wb" +#define SET_BINARY(x) +extern char *optarg; +extern int optind; +#endif + +#include "types.h" +#include "dviclass.h" +#include "dvicodes.h" +#include "error.h" +#include "fio.h" +#include "gripes.h" +#include "search.h" +#include <stdio.h> +#include <ctype.h> + +char *ProgName; + +/* + * We use the following structure to keep track of fonts we have seen. + * The final DVI file lists all the fonts used in each of the input + * files. + */ +struct fontinfo { + struct fontinfo *fi_next;/* next in list */ + i32 fi_index; /* font number in output file */ + i32 fi_checksum; /* the checksum */ + i32 fi_mag; /* the magnification */ + i32 fi_designsize; /* the design size */ + short fi_n1; /* the name header length */ + short fi_n2; /* the name body length */ + char *fi_name; /* the name itself */ +} *fonts; + +struct search *FontFinder; /* input indicies to ptr-to-fontinfo */ +i32 NextOutputFontIndex; /* generates output indicies */ +i32 OutputFontIndex; /* current (new) index in ouput */ + +char *DVIFileName; /* the current input file name */ +FILE *inf; /* the current input DVI file */ +FILE *outf; /* the output DVI file */ + +int errs; /* counts non-fatal errors */ + +long StartOfLastPage; /* The file position just before we started + the last page (this is later written to + the output file as the previous page + pointer). */ +long CurrentPosition; /* The current position of the file */ + +int NumberOfOutputPages; /* number of pages in new DVI file */ + +i32 Numerator; /* numerator from current DVI file */ +i32 Denominator; /* denominator from current DVI file */ +i32 DVIMag; /* magnification from current DVI file */ + +i32 OutputNumerator; /* numerator from first DVI file */ +i32 OutputDenominator; /* denominator from first DVI file */ +i32 OutputMag; /* magnification from first DVI file or arg */ + +i32 TallestPageHeight; /* max of all tallest-page-height values */ +i32 WidestPageWidth; /* max of all widest-page-widths */ +i16 DVIStackSize; /* max of all stack sizes */ + +/* save some string space: we use this a lot */ +char writeerr[] = "error writing DVI file"; + +#ifdef NeedFunctionPrototypes +void HandleDVIFile(); +void HandleFontDef(i32); +void HandleSpecial(int, int, i32); +void UseFont(); +#ifdef _AMIGA +#define bcmp(s1, s2, len) memcmp(s1, s2, len) +#define bzero(s, len) memset(s, '\0', len) +#define index(s, c) strchr(s, c) +#endif /* _AMIGA */ + +#ifndef KPATHSEA +char *malloc(), *realloc(); +#endif +#endif +/* extern int getopt(int, char **, char*); */ + +/* + * You may get lint warnings about sprintf's return value. + * Older versions of 4BSD have `char *sprintf()'. ANSI and + * SysV use `int sprintf()'; so ignore the warnings. + */ + +/* + * Lint gets somewhat confused over putc. + */ +#ifdef lint +#define putc(c, f) fputc((int) c, f) +#endif + +/* + * Start a page (process a DVI_BOP). + */ +void +BeginPage() +{ + register i32 t; + register int i; + + OutputFontIndex = -1; /* new page requires respecifying font */ + putbyte(outf, DVI_BOP); + /* copy the count registers */ + for (i = 10; --i >= 0;) { + fGetLong(inf, t); + PutLong(outf, t); + } + (void) GetLong(inf); /* previous page pointer */ + PutLong(outf, StartOfLastPage); + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 45; /* we just wrote this much */ +} + +/* + * End a page (process a DVI_EOP). + */ +void +EndPage() +{ + + putbyte(outf, DVI_EOP); + if (ferror(outf)) + error(1, -1, writeerr); + CurrentPosition++; + NumberOfOutputPages++; +} + +/* + * Write a font definition to the output file. + */ +void +WriteFont(fi) + register struct fontinfo *fi; +{ + register int l; + register char *s; + + if (fi->fi_index < 256) { + putbyte(outf, DVI_FNTDEF1); + putbyte(outf, fi->fi_index); + CurrentPosition += 2; + } else if (fi->fi_index < 65536) { + putbyte(outf, DVI_FNTDEF2); + PutWord(outf, fi->fi_index); + CurrentPosition += 3; + } else if (fi->fi_index < 16777216) { + putbyte(outf, DVI_FNTDEF3); + Put3Byte(outf, fi->fi_index); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNTDEF4); + PutLong(outf, fi->fi_index); + CurrentPosition += 5; + } + PutLong(outf, fi->fi_checksum); + PutLong(outf, fi->fi_mag); + PutLong(outf, fi->fi_designsize); + putbyte(outf, fi->fi_n1); + putbyte(outf, fi->fi_n2); + l = fi->fi_n1 + fi->fi_n2; + CurrentPosition += 14 + l; + s = fi->fi_name; + while (--l >= 0) + putbyte(outf, *s++); +} + +/* + * Write the postamble for the concatenation of all the input files. + */ +void +WritePostAmble() +{ + register struct fontinfo *fi; + register i32 postpos = CurrentPosition; /* remember for later */ + + /* POST p n d m h w s pages */ + putbyte(outf, DVI_POST); + PutLong(outf, StartOfLastPage); + PutLong(outf, OutputNumerator); + PutLong(outf, OutputDenominator); + PutLong(outf, OutputMag); + PutLong(outf, TallestPageHeight); + PutLong(outf, WidestPageWidth); + PutWord(outf, DVIStackSize); + PutWord(outf, NumberOfOutputPages); + CurrentPosition += 29; /* count all those `put's */ + + for (fi = fonts; fi != NULL; fi = fi->fi_next) + WriteFont(fi); + + putbyte(outf, DVI_POSTPOST); + PutLong(outf, postpos); + putbyte(outf, DVI_VERSION); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + CurrentPosition += 10; + while (CurrentPosition & 3) { + putbyte(outf, DVI_FILLER); + CurrentPosition++; + } + if (ferror(outf)) + error(1, -1, writeerr); +} + +/* + * Read the information we need from the postamble for the current DVI file. + */ +void +HandlePostAmble() +{ + register i32 t; + register i16 w; + + (void) GetLong(inf); /* previous page pointer */ + if (GetLong(inf) != Numerator) { + error(0, 0, + "%s: postamble's numerator does not match preamble's", + DVIFileName); + errs++; + } + if (GetLong(inf) != Denominator) { + error(0, 0, + "%s: postamble's denominator does not match preamble's", + DVIFileName); + errs++; + } + if (GetLong(inf) != DVIMag) { + error(0, 0, + "%s: postamble's magnification does not match preamble's", + DVIFileName); + errs++; + } + + /* + * Find maximum of tallest page height, widest page width, and + * stack size. + */ + t = GetLong(inf); + if (t > TallestPageHeight) + TallestPageHeight = t; + t = GetLong(inf); + if (t > WidestPageWidth) + WidestPageWidth = t; + w = GetWord(inf); + if (w > DVIStackSize) + DVIStackSize = w; + + /* + * The remainder of the file---number of pages, list of fonts, + * postpost, pointer, version, and filler---we simply ignore. + */ +} + +/* + * Handle a preamble. + * `firstone' is true if this is the first input file. + * Return true iff something is wrong with the file. + */ +int +HandlePreAmble(firstone) + int firstone; +{ + register int n, c; + static char warn1[] = "%s: Warning: preamble %s of %ld"; + static char warn2[] = "does not match first file's value of %ld"; + + if (getc(inf) != DVI_PRE) { + error(0, 0, "%s does not begin with a preamble", DVIFileName); + error(0, 0, "(are you sure it is a DVI file?)"); + errs++; + return (1); + } + if (getc(inf) != DVI_VERSION) { + error(0, 0, "%s is not a DVI version %d file", DVIFileName, + DVI_VERSION); + errs++; + return (1); + } + + /* committed to DVI file: now most errors are fatal */ + if (firstone) { + OutputNumerator = Numerator = GetLong(inf); + OutputDenominator = Denominator = GetLong(inf); + } else { + Numerator = GetLong(inf); + if (Numerator != OutputNumerator) { + error(0, 0, warn1, DVIFileName, "numerator", + (long)Numerator); + error(0, 0, warn2, (long)OutputNumerator); + errs++; + } + Denominator = GetLong(inf); + if (Denominator != OutputDenominator) { + error(0, 0, warn1, DVIFileName, "denominator", + (long)Denominator); + error(0, 0, warn2, (long)OutputDenominator); + errs++; + } + } + DVIMag = GetLong(inf); + if (OutputMag == 0) + OutputMag = DVIMag; + else if (DVIMag != OutputMag) { + error(0, 0, + "%s: Warning: magnification of %ld changed to %ld", + DVIFileName, (long)DVIMag, (long)OutputMag); + errs++; + } + n = UnSign8(GetByte(inf)); /* comment length */ + if (firstone) { + putbyte(outf, DVI_PRE); + putbyte(outf, DVI_VERSION); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, OutputMag); + + CurrentPosition = 15 + n; /* well, almost */ + putbyte(outf, n); + while (--n >= 0) { + c = GetByte(inf); + putbyte(outf, c); + } + } else { + while (--n >= 0) + (void) GetByte(inf); + } + return (0); +} + +/* + * Read one DVI file, concatenating it with the previous one (if any) + * or starting up the output file (otherwise). + */ +void +doit(name, fp) + char *name; + FILE *fp; +{ + static int started; + + DVIFileName = name; + inf = fp; + if (HandlePreAmble(started ? 0 : 1)) + return; + SClear(FontFinder); + HandleDVIFile(); + HandlePostAmble(); + started = 1; +} + +int +main(argc, argv) + int argc; + register char **argv; +{ + register int c; + register char *s; + FILE *f; + + ProgName = *argv; + + /* + * Handle arguments. + */ + while ((c = getopt(argc, argv, "m:o:")) != EOF) { + switch (c) { + + case 'm': + if (OutputMag) + goto usage; + OutputMag = atoi(optarg); + break; + + case 'o': + if (outf != NULL) + goto usage; + if ((outf = fopen(optarg, FOPEN_WBIN_MODE)) == NULL) + error(1, -1, "cannot write %s", optarg); + break; + + case '?': +usage: + (void) fprintf(stderr, + "Usage: %s [-m mag] [-o outfile] [files]\n", + ProgName); + (void) fflush(stderr); + exit(1); + } + } + + /* setup */ + if (outf == NULL) { + outf = stdout; + if (!isatty(fileno(outf))) + SET_BINARY(fileno(outf)); + } + if ((FontFinder = SCreate(sizeof(struct fontinfo *))) == 0) + error(1, 0, "cannot create font finder (out of memory?)"); + StartOfLastPage = -1; + + /* + * Concatenate the named input file(s). + * We write a preamble based on the first input file. + */ + if (optind >= argc) { + if (!isatty(fileno(stdin))) + SET_BINARY(fileno(stdin)); + doit("`stdin'", stdin); + } + else { + for (c = optind; c < argc; c++) { + s = argv[c]; + if (*s == '-' && s[1] == 0) { + if (!isatty(fileno(stdin))) + SET_BINARY(fileno(stdin)); + doit("`stdin'", stdin); + } + else if ((f = fopen(s, FOPEN_RBIN_MODE)) == NULL) { + error(0, -1, "cannot read %s", s); + errs++; + } else { + doit(s, f); + (void) fclose(f); + } + } + } + if (CurrentPosition) + WritePostAmble(); + + (void) fprintf(stderr, "Wrote %d page%s, %ld bytes\n", + NumberOfOutputPages, NumberOfOutputPages == 1 ? "" : "s", + (long)CurrentPosition); + return errs ? 2 : 0; +} + +/* + * Handle a font definition. + */ +void HandleFontDef(index) + i32 index; +{ + register struct fontinfo *fi; + register int i; + register char *s; + register i32 checksum, mag, designsize; + register int n1, n2; + struct fontinfo **p; + char *name; + int d = S_CREATE | S_EXCL; + + if ((p = (struct fontinfo **)SSearch(FontFinder, index, &d)) == NULL) + if (d & S_COLL) + error(1, 0, "font %ld already defined", (long)index); + else + error(1, 0, "cannot stash font %ld (out of memory?)", + (long)index); + + /* collect the font information */ + checksum = GetLong(inf); + mag = GetLong(inf); + designsize = GetLong(inf); + n1 = UnSign8(GetByte(inf)); + n2 = UnSign8(GetByte(inf)); + i = n1 + n2; + if ((s = malloc((unsigned)i)) == NULL) + GripeOutOfMemory(i, "font name"); + for (name = s; --i >= 0;) + *s++ = GetByte(inf); + s = name; + + /* + * We have not seen the font before in this input file, + * but we may have seen it in a previous file, so we + * must search. + */ + i = n1 + n2; + for (fi = fonts; fi != NULL; fi = fi->fi_next) { + if (fi->fi_designsize == designsize && + fi->fi_mag == mag && + fi->fi_n1 == n1 && fi->fi_n2 == n2 && + bcmp(fi->fi_name, s, i) == 0) { + if (fi->fi_checksum == 0) + fi->fi_checksum = checksum; + else if (checksum && fi->fi_checksum != checksum) { + error(0, 0, "\ +%s: Warning: font checksum mismatch for %.*s detected", + DVIFileName, i, s); + errs++; + } + *p = fi; + return; + } + } + /* it is really new; add it to the list */ + if ((fi = (struct fontinfo *)malloc(sizeof *fi)) == NULL) + GripeOutOfMemory(sizeof *fi, "font information"); + fi->fi_next = fonts; + fi->fi_index = NextOutputFontIndex++; + fi->fi_checksum = checksum; + fi->fi_mag = mag; + fi->fi_designsize = designsize; + fi->fi_n1 = n1; + fi->fi_n2 = n2; + fi->fi_name = s; + fonts = fi; + WriteFont(fi); + *p = fi; +} + +/* + * Handle a \special. + */ +void HandleSpecial(c, l, p) + int c; + register int l; + register i32 p; +{ + register int i; + + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + break; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + break; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + break; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + break; + + default: + panic("HandleSpecial l=%d", l); + /* NOTREACHED */ + } + CurrentPosition += p; + while (--p >= 0) { + i = getc(inf); + putbyte(outf, i); + } + if (feof(inf)) + GripeUnexpectedDVIEOF(); + if (ferror(outf)) + error(1, -1, writeerr); +} + +void UseFont(index) + register i32 index; +{ + struct fontinfo *fi, **p; + int look = S_LOOKUP; + + p = (struct fontinfo **)SSearch(FontFinder, index, &look); + if (p == NULL) + error(1, 0, "%s requested font %ld without defining it", + (long)index); + if ((fi = *p) == NULL) + panic("null entry in FontFinder for %ld", (long)index); + index = fi->fi_index; + if (index < 64) { + putbyte(outf, index + DVI_FNTNUM0); + CurrentPosition++; + } else if (index < 256) { + putbyte(outf, DVI_FNT1); + putbyte(outf, index); + CurrentPosition += 2; + } else if (index < 65536) { + putbyte(outf, DVI_FNT2); + PutWord(outf, index); + CurrentPosition += 3; + } else if (index < 16777216) { + putbyte(outf, DVI_FNT3); + Put3Byte(outf, index); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNT4); + PutLong(outf, index); + CurrentPosition += 5; + } +} + +/* + * The following table describes the length (in bytes) of each of the DVI + * commands that we can simply copy, starting with DVI_SET1 (128). + */ +char oplen[128] = { + 2, 3, 4, 5, /* DVI_SET1 .. DVI_SET4 */ + 9, /* DVI_SETRULE */ + 2, 3, 4, 5, /* DVI_PUT1 .. DVI_PUT4 */ + 9, /* DVI_PUTRULE */ + 1, /* DVI_NOP */ + 0, /* DVI_BOP */ + 0, /* DVI_EOP */ + 1, /* DVI_PUSH */ + 1, /* DVI_POP */ + 2, 3, 4, 5, /* DVI_RIGHT1 .. DVI_RIGHT4 */ + 1, /* DVI_W0 */ + 2, 3, 4, 5, /* DVI_W1 .. DVI_W4 */ + 1, /* DVI_X0 */ + 2, 3, 4, 5, /* DVI_X1 .. DVI_X4 */ + 2, 3, 4, 5, /* DVI_DOWN1 .. DVI_DOWN4 */ + 1, /* DVI_Y0 */ + 2, 3, 4, 5, /* DVI_Y1 .. DVI_Y4 */ + 1, /* DVI_Z0 */ + 2, 3, 4, 5, /* DVI_Z1 .. DVI_Z4 */ + 0, /* DVI_FNTNUM0 (171) */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 172 .. 179 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 180 .. 187 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 188 .. 195 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 196 .. 203 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 204 .. 211 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 212 .. 219 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 220 .. 227 */ + 0, 0, 0, 0, 0, 0, 0, /* 228 .. 234 */ + 0, 0, 0, 0, /* DVI_FNT1 .. DVI_FNT4 */ + 0, 0, 0, 0, /* DVI_XXX1 .. DVI_XXX4 */ + 0, 0, 0, 0, /* DVI_FNTDEF1 .. DVI_FNTDEF4 */ + 0, /* DVI_PRE */ + 0, /* DVI_POST */ + 0, /* DVI_POSTPOST */ + 0, 0, 0, 0, 0, 0, /* 250 .. 255 */ +}; + +/* + * Here we read the input DVI file and copy the pages to the output + * DVI file, renumbering fonts. We also keep track of font changes, + * handle font definitions, and perform some other housekeeping. + */ +void HandleDVIFile() +{ + register int c, l; + register i32 p; + int doingpage = 0; + + /* Only way out is via "return" statement */ + for (;;) { + c = getc(inf); /* getc() returns unsigned values */ + if (DVI_IsChar(c)) { + putbyte(outf, c); + CurrentPosition++; + continue; + } + if (DVI_IsFont(c)) { /* note font change */ + UseFont((i32)(c - DVI_FNTNUM0)); + continue; + } + if (c == EOF) + GripeUnexpectedDVIEOF(); + if ((l = (oplen - 128)[c]) != 0) { /* simple copy */ + CurrentPosition += l; + putbyte(outf, c); + while (--l > 0) { + c = getc(inf); + putbyte(outf, c); + } + if (ferror(outf)) + error(1, -1, writeerr); + continue; + } + if ((l = DVI_OpLen(c)) != 0) { + /* + * Handle other generics. + * N.B.: there should only be unsigned parameters + * here (save SGN4), for commands with negative + * parameters have been taken care of above. + */ + switch (l) { + + case DPL_UNS1: + p = getc(inf); + break; + + case DPL_UNS2: + fGetWord(inf, p); + break; + + case DPL_UNS3: + fGet3Byte(inf, p); + break; + + case DPL_SGN4: + fGetLong(inf, p); + break; + + default: + panic("HandleDVIFile l=%d", l); + } + + /* + * Now that we have the parameter, perform the + * command. + */ + switch (DVI_DT(c)) { + + case DT_FNT: + UseFont(p); + continue; + + case DT_XXX: + HandleSpecial(c, l, p); + continue; + + case DT_FNTDEF: + HandleFontDef(p); + continue; + + default: + panic("HandleDVIFile DVI_DT(%d)=%d", + c, DVI_DT(c)); + } + continue; + } + + switch (c) { /* handle the few remaining cases */ + + case DVI_BOP: + if (doingpage) + GripeUnexpectedOp("BOP (during page)"); + BeginPage(); + doingpage = 1; + break; + + case DVI_EOP: + if (!doingpage) + GripeUnexpectedOp("EOP (outside page)"); + EndPage(); + doingpage = 0; + break; + + case DVI_PRE: + GripeUnexpectedOp("PRE"); + /* NOTREACHED */ + + case DVI_POST: + if (doingpage) + GripeUnexpectedOp("POST (inside page)"); + return; + + case DVI_POSTPOST: + GripeUnexpectedOp("POSTPOST"); + /* NOTREACHED */ + + default: + GripeUndefinedOp(c); + /* NOTREACHED */ + } + } +} diff --git a/Build/source/texk/seetexk/dviconcat.man b/Build/source/texk/seetexk/dviconcat.man new file mode 100644 index 00000000000..9267446095a --- /dev/null +++ b/Build/source/texk/seetexk/dviconcat.man @@ -0,0 +1,46 @@ +.TH DVICONCAT 1 +.SH NAME +dviconcat \- concatenate DVI files +.SH SYNOPSIS +.B dviconcat +[ +.B \-m +.I magnification +] [ +.B \-o +.I outfile +] +.I "list of files" +.SH DESCRIPTION +.I Dviconcat +concatenates the named +.IR file s +(or standard input, if no file names are given) +onto the standard output +or the given +.IR outfile , +creating a new DVI file +usable by any of the TeX conversion programs, +or even by +.I dviconcat +itself. +.PP +The magnification of the output file +is the same as that of the first input file +unless the +.B \-m +option is given. +When +.I dviconcat +changes the magnification of any input file, +it prints a warning to this effect. +.SH AUTHOR +Chris Torek, University of Maryland +.SH "SEE ALSO" +dviselect(1), latex(1), tex(1) +.br +.I "MC-TeX User's Guide" +.SH BUGS +The program should be called +.IR dvicat , +but that name was taken (for the driver for the C/A/T typesetter). diff --git a/Build/source/texk/seetexk/dviselect.c b/Build/source/texk/seetexk/dviselect.c new file mode 100644 index 00000000000..1d9296cca6c --- /dev/null +++ b/Build/source/texk/seetexk/dviselect.c @@ -0,0 +1,1088 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/dvi/RCS/dviselect.c,v 3.1 89/08/22 17:16:13 chris Exp $"; +#endif + +/* + * DVI page selection program + * + * Reads DVI version 2 files and selects pages, writing a new DVI + * file. The new DVI file is technically correct, though we do not + * adjust the tallest and widest page values, nor the DVI stack size. + * This is all right since the values will never become too small, + * but it might be nice to fix them up. Perhaps someday . . . . + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-fopen.h> +#include <kpathsea/getopt.h> +#else +#define FOPEN_RBIN_MODE "rb" +#define FOPEN_RBIN_MODE "wb" +#define SET_BINARY(x) +extern char *optarg; +extern int optind; +#endif + +#include "types.h" +#include "dviclass.h" +#include "dvicodes.h" +#include "error.h" +#include "fio.h" +#include "gripes.h" +#include "search.h" +#include <stdio.h> +#include <ctype.h> + +#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',') + +char *ProgName; +/* Globals */ +char serrbuf[BUFSIZ]; /* buffer for stderr */ + +/* + * We will try to keep output lines shorter than MAXCOL characters. + */ +#define MAXCOL 75 + +/* + * We use the following structure to keep track of fonts we have seen. + * The final DVI file lists only the fonts it uses. + */ +struct fontinfo { + i32 fi_newindex; /* font number in output file */ + int fi_reallyused; /* true => used on a page we copied */ + i32 fi_checksum; /* the checksum */ + i32 fi_mag; /* the magnification */ + i32 fi_designsize; /* the design size */ + short fi_n1; /* the name header length */ + short fi_n2; /* the name body length */ + char *fi_name; /* the name itself */ +}; + +/* + * We need to remember which pages the user would like. We build a linked + * list that allows us to decide (for any given page) whether it should + * be included in the output file. Each page has ten \count variables + * associated with it. We put a bound on the values allowed for each, and + * keep a linked list of alternatives should any be outside the allowed + * range. For example, `dviselect *.3,10-15' would generate a two-element + * page list, with the first allowing any value for \count0 (and \counts 2 to + * 9) but \count1 restricted to the range 3-3, and the second restricting + * \count0 to the range 10-15 but leaving \counts 1 to 9 unrestrained. + * + * We remember whether a bound is specified, so that we need not fix + * some `large' number as a maximum value. + * + * We also allow `absolute' page references, where the first page is + * page 1, the second 2, and so forth. These are specified with an + * equal sign: `dviselect =4:10' picks up the fourth through tenth + * sequential pages, irrespective of \count values. + * + * There is also an even/odd switch (which can be applied to absolute + * or relative pages): dviselect =even, even.3, etc. + */ +enum pstype { + pt_lu, /* have both lower and upper bounds */ + pt_l, /* lower bound only */ + pt_u, /* upper bound only */ + pt_unbounded, /* any value at all */ + pt_even, /* even values only */ + pt_odd /* odd values only */ +}; +struct pagesel { + enum pstype ps_type; /* type of selector */ + i32 ps_low; /* lower bound */ + i32 ps_high; /* upper bound */ +}; +struct pagelist { + struct pagelist *pl_alt; /* next in a series of alternates */ + int pl_len; /* number of ranges to check */ + int pl_abs; /* true iff absolute page ref */ + struct pagesel pl_pages[10]; /* one for each \count variable */ +}; + +int SFlag; /* true => -s, silent operation */ + +struct search *FontFinder; /* maps from input indicies to fontinfo */ +i32 NextOutputFontIndex; /* generates output indicies */ +i32 CurrentFontIndex; /* current (old) index in input */ +i32 OutputFontIndex; /* current (new) index in ouput */ + +struct pagelist *PageList; /* the list of allowed pages */ + +char *DVIFileName; /* name of input DVI file */ +FILE *inf; /* the input file itself */ +FILE *outf; /* the output DVI file */ + +long StartOfLastPage; /* The file position just before we started + the last page (this is later written to + the output file as the previous page + pointer). */ +long CurrentPosition; /* The current position of the file */ + +int UseThisPage; /* true => current page is selected */ + +i32 InputPageNumber; /* current absolute page in old DVI file */ +int NumberOfOutputPages; /* number of pages in new DVI file */ + +i32 Numerator; /* numerator from DVI file */ +i32 Denominator; /* denominator from DVI file */ +i32 DVIMag; /* magnification from DVI file */ + +i32 Count[10]; /* the 10 \count variables */ + +/* save some string space: we use this a lot */ +char writeerr[] = "error writing DVI file"; + +#ifdef NeedFunctionPrototypes +#include <string.h> +void WriteFont(struct fontinfo *); +int evenodd(char *); +int ParsePages(char *); +void HandleDVIFile(); +void PutFontSelector(i32); + +#ifdef _AMIGA +#define bcmp(s1, s2, len) memcmp(s1, s2, len) +#define bzero(s, len) memset(s, '\0', len) +#define index(s, c) strchr(s, c) +#endif /* _AMIGA */ + +#ifndef KPATHSEA +char *malloc(), *realloc(); +#endif /* not WIN32 */ +#endif +/* + * You may get lint warnings about sprintf's return value. + * Older versions of 4BSD have `char *sprintf()'. ANSI and + * SysV use `int sprintf()'; so ignore the warnings. + */ + +/* + * Lint gets somewhat confused over putc. + */ +#ifdef lint +#undef putc +#ifdef ultrix /* grr */ +#define putc(c, f) fputc((char)(c), f) +#else +#define putc(c, f) fputc((int)(c), f) +#endif +#endif + +/* + * Return true iff the 10 \counts are one of the desired output pages. + */ +DesiredPageP() +{ + register struct pagelist *pl; + + for (pl = PageList; pl != NULL; pl = pl->pl_alt) { + register struct pagesel *ps = pl->pl_pages; + register int i; + register i32 *pagep; + + pagep = pl->pl_abs ? &InputPageNumber : &Count[0]; + for (i = 0; i < pl->pl_len; i++, ps++, pagep++) { + switch (ps->ps_type) { + + case pt_lu: /* check upper, fall through */ + if (*pagep > ps->ps_high) + goto no_good; + /* FALLTHROUGH */ + + case pt_l: /* only if not too low */ + if (*pagep < ps->ps_low) + goto no_good; + break; + + case pt_u: /* only if not too high */ + if (*pagep > ps->ps_high) + goto no_good; + break; + + case pt_unbounded: + break; + + case pt_even: /* only if even */ + if (*pagep & 1) + goto no_good; + break; + + case pt_odd: /* only if odd */ + if ((*pagep & 1) == 0) + goto no_good; + break; + } + } + return (1); /* success */ + no_good: + continue; + } + return (0); +} + +/* + * Print a message to stderr, with an optional leading space, and handling + * long line wraps. + */ +void message(space, str, len) + int space; + register char *str; + register int len; +{ + static int beenhere; + static int col; + + if (!beenhere) + space = 0, beenhere++; + if (len == 0) + len = strlen(str); + col += len; + if (space) { + if (col >= MAXCOL) + (void) putc('\n', stderr), col = len; + else + (void) putc(' ', stderr), col++; + } + while (--len >= 0) + (void) putc(*str++, stderr); + (void) fflush(stderr); +} + +/* + * Start a page (process a DVI_BOP). + */ +void BeginPage() +{ + register i32 *i; + + OutputFontIndex = -1; /* new page requires respecifying font */ + InputPageNumber++; /* count it */ + for (i = Count; i < &Count[10]; i++) + fGetLong(inf, *i); + (void) GetLong(inf); /* previous page pointer */ + + if ((UseThisPage = DesiredPageP()) == 0) + return; + + putbyte(outf, DVI_BOP); + for (i = Count; i < &Count[10]; i++) + PutLong(outf, *i); + PutLong(outf, StartOfLastPage); + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 45; /* we just wrote this much */ + + if (!SFlag) { /* write nice page usage messages */ + register int z = 0; + register int mlen = 0; + char msg[80]; + + (void) sprintf(msg, "[%ld", (long)Count[0]); + mlen = strlen(msg); + for (i = &Count[1]; i < &Count[10]; i++) { + if (*i == 0) { + z++; + continue; + } + while (--z >= 0) + msg[mlen++] = '.', msg[mlen++] = '0'; + z = 0; + (void) sprintf(msg + mlen, ".%ld", (long)*i); + mlen += strlen(msg + mlen); + } + message(1, msg, mlen); + } +} + +/* + * End a page (process a DVI_EOP). + */ +void EndPage() +{ + + if (!UseThisPage) + return; + if (!SFlag) + message(0, "]", 1); + putbyte(outf, DVI_EOP); + if (ferror(outf)) + error(1, -1, writeerr); + CurrentPosition++; + NumberOfOutputPages++; +} + +/* + * For each of the fonts used in the new DVI file, write out a definition. + */ +/* ARGSUSED */ +void +PostAmbleFontEnumerator(addr, key) + char *addr; + i32 key; +{ + + if (((struct fontinfo *)addr)->fi_reallyused) + WriteFont((struct fontinfo *)addr); +} + +void HandlePostAmble() +{ + register i32 c; + + (void) GetLong(inf); /* previous page pointer */ + if (GetLong(inf) != Numerator) + GripeMismatchedValue("numerator"); + if (GetLong(inf) != Denominator) + GripeMismatchedValue("denominator"); + if (GetLong(inf) != DVIMag) + GripeMismatchedValue("\\magnification"); + + putbyte(outf, DVI_POST); + PutLong(outf, StartOfLastPage); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + c = GetLong(inf); + PutLong(outf, c); /* tallest page height */ + c = GetLong(inf); + PutLong(outf, c); /* widest page width */ + c = GetWord(inf); + PutWord(outf, c); /* DVI stack size */ + PutWord(outf, NumberOfOutputPages); + StartOfLastPage = CurrentPosition; /* point at post */ + CurrentPosition += 29; /* count all those `put's */ +#ifdef notdef + (void) GetWord(inf); /* skip original number of pages */ +#endif + + /* + * just ignore all the incoming font definitions; we are done with + * input file + */ + + /* + * run through the FontFinder table and dump definitions for the + * fonts we have used. + */ + SEnumerate(FontFinder, PostAmbleFontEnumerator); + + putbyte(outf, DVI_POSTPOST); + PutLong(outf, StartOfLastPage); /* actually start of postamble */ + putbyte(outf, DVI_VERSION); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + CurrentPosition += 10; + while (CurrentPosition & 3) { + putbyte(outf, DVI_FILLER); + CurrentPosition++; + } + if (ferror(outf)) + error(1, -1, writeerr); +} + +/* + * Write a font definition to the output file + */ +void WriteFont(fi) + register struct fontinfo *fi; +{ + register int l; + register char *s; + + if (fi->fi_newindex < 256) { + putbyte(outf, DVI_FNTDEF1); + putbyte(outf, fi->fi_newindex); + CurrentPosition += 2; + } else if (fi->fi_newindex < 65536) { + putbyte(outf, DVI_FNTDEF2); + PutWord(outf, fi->fi_newindex); + CurrentPosition += 3; + } else if (fi->fi_newindex < 16777216) { + putbyte(outf, DVI_FNTDEF3); + Put3Byte(outf, fi->fi_newindex); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNTDEF4); + PutLong(outf, fi->fi_newindex); + CurrentPosition += 5; + } + PutLong(outf, fi->fi_checksum); + PutLong(outf, fi->fi_mag); + PutLong(outf, fi->fi_designsize); + putbyte(outf, fi->fi_n1); + putbyte(outf, fi->fi_n2); + l = fi->fi_n1 + fi->fi_n2; + CurrentPosition += 14 + l; + s = fi->fi_name; + while (--l >= 0) + putbyte(outf, *s++); +} + +/* + * Handle the preamble. Someday we should update the comment field. + */ +void HandlePreAmble() +{ + register int n, c; + + c = getc(inf); + if (c == EOF) + GripeUnexpectedDVIEOF(); + if (c != DVI_PRE) + GripeMissingOp("PRE"); + if (getc(inf) != DVI_VERSION) + error(1, 0, "%s is not a DVI version %d file", + DVIFileName, DVI_VERSION); + Numerator = GetLong(inf); + Denominator = GetLong(inf); + DVIMag = GetLong(inf); + putbyte(outf, DVI_PRE); + putbyte(outf, DVI_VERSION); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + + n = UnSign8(GetByte(inf)); + CurrentPosition = 15 + n; /* well, almost */ + putbyte(outf, n); + while (--n >= 0) { + c = GetByte(inf); + putbyte(outf, c); + } +} + +int +main(argc, argv) + int argc; + register char **argv; +{ + register int c; + register char *s; + char *outname = NULL; + + ProgName = *argv; + setbuf(stderr, serrbuf); + + while ((c = getopt(argc, argv, "i:o:s")) != EOF) { + switch (c) { + + case 's': /* silent */ + SFlag++; + break; + + case 'i': + if (DVIFileName != NULL) + goto usage; + DVIFileName = optarg; + break; + + case 'o': + if (outname != NULL) + goto usage; + outname = optarg; + break; + + case '?': +usage: + (void) fprintf(stderr, "\ +Usage: %s [-s] [-i infile] [-o outfile] pages [...] [infile [outfile]]\n", + ProgName); + (void) fflush(stderr); + exit(1); + } + } + + while (optind < argc) { + s = argv[optind++]; + c = *s; + if (!isalpha(c) && c != '/' || + (c == 'e' || c == 'o') && evenodd(s)) { + if (ParsePages(s)) + goto usage; + } else if (DVIFileName == NULL) + DVIFileName = s; + else if (outname == NULL) + outname = s; + else + goto usage; + } + if (PageList == NULL) + goto usage; + if (DVIFileName == NULL) { + DVIFileName = "`stdin'"; + inf = stdin; + if (!isatty(fileno(inf))) + SET_BINARY(fileno(inf)); + } else if ((inf = fopen(DVIFileName, FOPEN_RBIN_MODE)) == 0) + error(1, -1, "cannot read %s", DVIFileName); + if (outname == NULL) { + outf = stdout; + if (!isatty(fileno(outf))) + SET_BINARY(fileno(outf)); + } else if ((outf = fopen(outname, FOPEN_WBIN_MODE)) == 0) + error(1, -1, "cannot write %s", outname); + + if ((FontFinder = SCreate(sizeof(struct fontinfo))) == 0) + error(1, 0, "cannot create font finder (out of memory?)"); + + StartOfLastPage = -1; + HandlePreAmble(); + HandleDVIFile(); + HandlePostAmble(); + if (!SFlag) + (void) fprintf(stderr, "\nWrote %d page%s, %ld bytes\n", + NumberOfOutputPages, NumberOfOutputPages == 1 ? "" : "s", + (long)CurrentPosition); + return 0; +} + +struct pagelist * +InstallPL(ps, n, absolute) + register struct pagesel *ps; + register int n; + int absolute; +{ + register struct pagelist *pl; + + pl = (struct pagelist *)malloc(sizeof *pl); + if (pl == NULL) + GripeOutOfMemory(sizeof *pl, "page list"); + pl->pl_alt = PageList; + PageList = pl; + pl->pl_len = n; + while (--n >= 0) + pl->pl_pages[n] = ps[n]; + pl->pl_abs = absolute; + return pl; +} + +/* + * Return true iff the string `s' is the word `even' or `odd', + * followed by `.' or `white' characters. + */ +int +evenodd(s) + char *s; +{ + register int c; + + if (strncmp(s, "even", 4) == 0) + c = s[4]; + else if (strncmp(s, "odd", 3) == 0) + c = s[3]; + else + return (0); + if (c == 0 || c == '.' || white(c)) + return (1); + return (0); +} + +/* + * Parse a string representing a list of pages. Return 0 iff ok. As a + * side effect, the page selection(s) is (are) prepended to PageList. + */ +int ParsePages(s) + register char *s; +{ + register struct pagesel *ps; + register int c; /* current character */ + register i32 n; /* current numeric value */ + register int innumber; /* true => gathering a number */ + int i; /* next index in page select list */ + int range; /* true => saw a range indicator */ + int negative; /* true => number being built is negative */ + int absolute; /* true => absolute, not \count */ + int lb, ub, even, odd; /* flags for lower,upper,even,odd */ + struct pagesel pagesel[10]; + + range = 0; + innumber = 0; + absolute = 0; + i = 0; + ps = pagesel; + lb = ub = even = odd = 0; + /* + * Talk about ad hoc! (Not to mention convoluted.) + */ + for (;;) { + c = *s++; + if (i == 0 && !innumber && !range) { + /* nothing special going on */ + if (c == 0) + return 0; + if (white(c)) + continue; + } + if ((c == 'e' || c == 'o') && evenodd(s - 1)) { + if (innumber || range) + return (-1); + if (c == 'e') { + s += 3; + even = 1; + } else { + s += 2; + odd = 1; + } + c = *s++; + goto finishnum; + } + if (c == '_') { + /* kludge: should be '-' for negatives */ + if (innumber || absolute) + return (-1); + innumber = 1; + negative = 1; + n = 0; + continue; + } + if (c == '=') { + /* absolute page */ + if (innumber || range || i > 0) + return (-1); + absolute = 1; + negative = 0; + n = 0; + continue; + } + if (isdigit(c)) { + /* accumulate numeric value */ + if (!innumber) { + innumber = 1; + negative = 0; + n = c - '0'; + continue; + } + n *= 10; + n += negative ? '0' - c : c - '0'; + continue; + } + if (c == '-' || c == ':') { + /* here is a range */ + if (range) + return (-1); + if (innumber) { /* have a lower bound */ + ps->ps_low = n; + lb = 1; + } + range = 1; + innumber = 0; + continue; + } + if (c == '*') { + /* no lower bound, no upper bound */ + c = *s++; + if (innumber || range || (c && c != '.' && !white(c))) + return (-1); + goto finishnum; + } + if (c == 0 || c == '.' || white(c)) { + /* end of this range */ + if (innumber) { /* have an upper bound */ + ps->ps_high = n; + ub = 1; + if (!range) { + /* no range => lower bound == upper */ + ps->ps_low = ps->ps_high; + lb = 1; + } + } +finishnum: + if (even) + ps->ps_type = pt_even; + else if (odd) + ps->ps_type = pt_odd; + else if (lb) + ps->ps_type = ub ? pt_lu : pt_l; + else + ps->ps_type = ub ? pt_u : pt_unbounded; + if (c == '.') { + if (absolute) + return (-1); + if (++i >= 10) /* too many specifiers */ + return (-1); + ps++; + } else { + InstallPL(pagesel, i + 1, absolute); + ps = pagesel; + i = 0; + absolute = 0; + } + if (c == 0) + return (0); + range = 0; + innumber = 0; + lb = ub = even = odd = 0; + continue; + } + /* illegal character */ + return (-1); + } +} + +/* + * Handle a font definition. + */ +void HandleFontDef(index) + i32 index; +{ + register struct fontinfo *fi; + register int i; + register char *s; + int def = S_CREATE | S_EXCL; + + if ((fi = (struct fontinfo *)SSearch(FontFinder, index, &def)) == 0) + if (def & S_COLL) + error(1, 0, "font %ld already defined", (long)index); + else + error(1, 0, "cannot stash font %ld (out of memory?)", + (long)index); + fi->fi_reallyused = 0; + fi->fi_checksum = GetLong(inf); + fi->fi_mag = GetLong(inf); + fi->fi_designsize = GetLong(inf); + fi->fi_n1 = UnSign8(GetByte(inf)); + fi->fi_n2 = UnSign8(GetByte(inf)); + i = fi->fi_n1 + fi->fi_n2; + if ((s = malloc((unsigned)i)) == 0) + GripeOutOfMemory(i, "font name"); + fi->fi_name = s; + while (--i >= 0) + *s++ = GetByte(inf); +} + +/* + * Handle a \special. + */ +void HandleSpecial(c, l, p) + int c; + register int l; + register i32 p; +{ + register int i; + + if (UseThisPage) { + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + break; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + break; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + break; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + break; + + default: + panic("HandleSpecial l=%d", l); + /* NOTREACHED */ + } + CurrentPosition += p; + while (--p >= 0) { + i = getc(inf); + putbyte(outf, i); + } + if (feof(inf)) + GripeUnexpectedDVIEOF(); + if (ferror(outf)) + error(1, -1, writeerr); + } else + while (--p >= 0) + (void) getc(inf); +} + +void ReallyUseFont() +{ + register struct fontinfo *fi; + int look = S_LOOKUP; + + fi = (struct fontinfo *)SSearch(FontFinder, CurrentFontIndex, &look); + if (fi == NULL) + error(1, 0, "DVI file requested font %ld without defining it", + (long)CurrentFontIndex); + if (fi->fi_reallyused == 0) { + fi->fi_reallyused++; + fi->fi_newindex = NextOutputFontIndex++; + WriteFont(fi); + } + if (fi->fi_newindex != OutputFontIndex) { + PutFontSelector(fi->fi_newindex); + OutputFontIndex = fi->fi_newindex; + } +} + +/* + * Write a font selection command to the output file + */ +void PutFontSelector(index) + i32 index; +{ + + if (index < 64) { + putbyte(outf, index + DVI_FNTNUM0); + CurrentPosition++; + } else if (index < 256) { + putbyte(outf, DVI_FNT1); + putbyte(outf, index); + CurrentPosition += 2; + } else if (index < 65536) { + putbyte(outf, DVI_FNT2); + PutWord(outf, index); + CurrentPosition += 3; + } else if (index < 16777216) { + putbyte(outf, DVI_FNT3); + Put3Byte(outf, index); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNT4); + PutLong(outf, index); + CurrentPosition += 5; + } +} + +/* + * The following table describes the length (in bytes) of each of the DVI + * commands that we can simply copy, starting with DVI_SET1 (128). + */ +char oplen[128] = { + 0, 0, 0, 0, /* DVI_SET1 .. DVI_SET4 */ + 9, /* DVI_SETRULE */ + 0, 0, 0, 0, /* DVI_PUT1 .. DVI_PUT4 */ + 9, /* DVI_PUTRULE */ + 1, /* DVI_NOP */ + 0, /* DVI_BOP */ + 0, /* DVI_EOP */ + 1, /* DVI_PUSH */ + 1, /* DVI_POP */ + 2, 3, 4, 5, /* DVI_RIGHT1 .. DVI_RIGHT4 */ + 1, /* DVI_W0 */ + 2, 3, 4, 5, /* DVI_W1 .. DVI_W4 */ + 1, /* DVI_X0 */ + 2, 3, 4, 5, /* DVI_X1 .. DVI_X4 */ + 2, 3, 4, 5, /* DVI_DOWN1 .. DVI_DOWN4 */ + 1, /* DVI_Y0 */ + 2, 3, 4, 5, /* DVI_Y1 .. DVI_Y4 */ + 1, /* DVI_Z0 */ + 2, 3, 4, 5, /* DVI_Z1 .. DVI_Z4 */ + 0, /* DVI_FNTNUM0 (171) */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 172 .. 179 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 180 .. 187 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 188 .. 195 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 196 .. 203 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 204 .. 211 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 212 .. 219 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 220 .. 227 */ + 0, 0, 0, 0, 0, 0, 0, /* 228 .. 234 */ + 0, 0, 0, 0, /* DVI_FNT1 .. DVI_FNT4 */ + 0, 0, 0, 0, /* DVI_XXX1 .. DVI_XXX4 */ + 0, 0, 0, 0, /* DVI_FNTDEF1 .. DVI_FNTDEF4 */ + 0, /* DVI_PRE */ + 0, /* DVI_POST */ + 0, /* DVI_POSTPOST */ + 0, 0, 0, 0, 0, 0, /* 250 .. 255 */ +}; + +/* + * Here we read the input DVI file and write relevant pages to the + * output DVI file. We also keep track of font changes, handle font + * definitions, and perform some other housekeeping. + */ +void HandleDVIFile() +{ + register int c, l; + register i32 p; + register int CurrentFontOK = 0; + int doingpage = 0; + + /* Only way out is via "return" statement */ + for (;;) { + c = getc(inf); /* getc() returns unsigned values */ + if (DVI_IsChar(c)) { + /* + * Copy chars, note font usage, but ignore if + * page is not interesting. + */ + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + CurrentPosition++; + continue; + } + if (DVI_IsFont(c)) { /* note font change */ + CurrentFontIndex = c - DVI_FNTNUM0; + CurrentFontOK = 0; + continue; + } + if (c == EOF) + GripeUnexpectedDVIEOF(); + if ((l = (oplen - 128)[c]) != 0) { /* simple copy */ + if (!UseThisPage) { + while (--l > 0) + (void) getc(inf); + continue; + } + CurrentPosition += l; + putbyte(outf, c); + while (--l > 0) { + c = getc(inf); + putbyte(outf, c); + } + if (ferror(outf)) + error(1, -1, writeerr); + continue; + } + if ((l = DVI_OpLen(c)) != 0) { + /* + * Handle other generics. + * N.B.: there should only be unsigned parameters + * here (save SGN4), for commands with negative + * parameters have been taken care of above. + */ + switch (l) { + + case DPL_UNS1: + p = getc(inf); + break; + + case DPL_UNS2: + fGetWord(inf, p); + break; + + case DPL_UNS3: + fGet3Byte(inf, p); + break; + + case DPL_SGN4: + fGetLong(inf, p); + break; + + default: + panic("HandleDVIFile l=%d", l); + } + + /* + * Now that we have the parameter, perform the + * command. + */ + switch (DVI_DT(c)) { + + case DT_SET: + case DT_PUT: + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + continue; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + continue; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + continue; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + continue; + } + + case DT_FNT: + CurrentFontIndex = p; + CurrentFontOK = 0; + continue; + + case DT_XXX: + HandleSpecial(c, l, p); + continue; + + case DT_FNTDEF: + HandleFontDef(p); + continue; + + default: + panic("HandleDVIFile DVI_DT(%d)=%d", + c, DVI_DT(c)); + } + continue; + } + + switch (c) { /* handle the few remaining cases */ + + case DVI_BOP: + if (doingpage) + GripeUnexpectedOp("BOP (during page)"); + BeginPage(); + doingpage = 1; + CurrentFontOK = 0; + break; + + case DVI_EOP: + if (!doingpage) + GripeUnexpectedOp("EOP (outside page)"); + EndPage(); + doingpage = 0; + break; + + case DVI_PRE: + GripeUnexpectedOp("PRE"); + /* NOTREACHED */ + + case DVI_POST: + if (doingpage) + GripeUnexpectedOp("POST (inside page)"); + return; + + case DVI_POSTPOST: + GripeUnexpectedOp("POSTPOST"); + /* NOTREACHED */ + + default: + GripeUndefinedOp(c); + /* NOTREACHED */ + } + } +} diff --git a/Build/source/texk/seetexk/dviselect.man b/Build/source/texk/seetexk/dviselect.man new file mode 100644 index 00000000000..814f102308a --- /dev/null +++ b/Build/source/texk/seetexk/dviselect.man @@ -0,0 +1,129 @@ +.TH DVISELECT 1 +.SH NAME +dviselect \- extract pages from DVI files +.SH SYNOPSIS +.B dviselect +[ +.B \-s +] [ +.B \-i +.I infile +] [ +.B \-o +.I outfile +] +.I "list of pages" +[ +.I infile +[ +.I outfile +] ] +.SH DESCRIPTION +.I Dviselect +selects pages from a DVI file produced by TeX, +creating a new DVI file +usable by any of the TeX conversion programs, +or even by +.I dviselect +itself. +.PP +A +.I range +is a string of the form +.IR even , +.IR odd , +or +.I first:last +where both +.I first +and +.I last +are optional numeric strings, with negative numbers indicated by +a leading underscore character ``_''. If both +.I first +and +.I last +are omitted, the colon may also be omitted, or may be replaced +with an asterisk ``*''. A +.I page range +is a list of ranges separated by periods. A +.I "list of pages" +is described by a set of page ranges separated by commas and/or white space. +.PP +.I Dviselect +actually looks at the ten +.I count +variables that TeX writes; the first of these (\ecount0) is the +page number, with \ecount1 through \ecount9 having varied uses +depending on which macro packages are in use. (Typically \ecount1 +might be a chapter or section number.) A page is included in +.IR dviselect 's +output if all its \ecount values match any one of the ranges +listed on the command line. For example, the command +``dviselect *.1,35:'' +might select everything in chapter 1, as well as pages 35 and up. +``dviselect 10:30'' would select pages 10 through 30 (inclusive). +``:43'' means everything up to and including page 43 (including +negative-numbered pages). +To get all even-numbered pages, use ``even''; +to get all odd-numbered pages, use ``odd''. +If a Table of Contents has negative page numbers, ``:_1'' will select it. +Note that ``*'' must be quoted from the shell; +the empty string is more convenient to use, if harder to read. +.PP +Instead of \ecount values, +.I dviselect +can also select by ``absolute page number'', where the first page +is page 1, the second page 2, and so forth. Absolute page numbers +are indicated by a leading equal sign ``=''. Ranges of absolute +pages are also allowed: ``dviselect =3:7'' will extract the third +through seventh pages. Dot separators are not legal in absolute +ranges, and there are no negative absolute page numbers. +Even/odd specifiers, however, are legal; +``dviselect =even'' selects every other page, +starting with the second. +.PP +More precisely, an asterisk or an empty string implies no limit; +an equal sign means absolute page number rather than \ecounts; +a leading colon means everything up to and including the given page; a +trailing colon means everything from the given page on; +the word ``even'' means only even values shall be accepted; +the word ``odd'' means only odd values shall be accepted; and +a period indicates that the next \ecount should be examined. +If fewer than 10 ranges are specified, the remaining \ecounts +are left unrestricted (that is, ``1:5'' and ``1:5.*'' are equivalent). +A single number \fIn\fP is treated as if it were the range \fIn:n\fP. +An arbitrary number of page selectors may be given, separated by commas +or whitespace; a page is selected if any of the selectors matches +its \ecounts or absolute page number. +.PP +Dviselect normally prints the page numbers of the pages selected; the +.I \-s +option suppresses this. +.SH AUTHOR +Chris Torek, University of Maryland +.SH "SEE ALSO" +dviconcat(1), latex(1), tex(1) +.br +.I "MC-TeX User's Guide" +.br +.I "The TeXbook" +.SH BUGS +A leading ``-'' ought to be allowed for negative numbers, but it +is currently used as a synonym for ``:'', for backwards compatibility. +.PP +Section or subsection selection will sometimes fail, for the DVI +file lists only the \ecount values that were active when the page +ended. Clever macro packages can alleviate this by making use of +other ``free'' \ecount registers. Chapters normally begin on new +pages, and do not suffer from this particular problem. +.PP +The heuristic that decides which arguments are page selectors +and which are file names is often wrong. +Using shell redirection or the \-i and \-o options is safest. +.PP +.I Dviselect +does not adjust the parameters in the postamble; however, since these +values are normally used only to size certain structures in the output +conversion programs, and the parameters never need to be adjusted upward, +this has not proven to be a problem. diff --git a/Build/source/texk/seetexk/dvistate.c b/Build/source/texk/seetexk/dvistate.c new file mode 100644 index 00000000000..04d98d9c6b3 --- /dev/null +++ b/Build/source/texk/seetexk/dvistate.c @@ -0,0 +1,245 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/dvistate.c,v 1.1 89/08/22 21:49:03 chris Exp $"; +#endif + +/* + * dvistate - basic DVI machine interpreter + */ + +#include <stdio.h> +#include "types.h" +#include "conv.h" +#include "dvicodes.h" +#include "error.h" +#include "fio.h" +#include "font.h" +#include "gripes.h" +#include "postamble.h" +#include "search.h" +#include "seek.h" +#include "dvistate.h" + +struct dvi_state ds; + +/* yech, statics! */ +static struct font *(*s_deffnt)(); +static int s_dpi; +static int s_errs; + +static void pre(), post(), fntdef(); + +#if !defined( WIN32 ) && !defined( _AMIGA ) +char *malloc(); +#endif + +/* + * Read through the postamble and the preamble and set up the + * global DVI state. Each font is passed to (*fontfn)(). + * Upon return, the input file (fp) is positioned at the beginning + * of the first page. + * + * dpi is the resolution of the printer in pixels (dots) per inch, + * and xoffset and yoffset are the values from the -X and -Y flags + * (default zero). We add 1000 to each offset (since the offsets + * are in 1/1000ths of an inch), and then multiply by dpi and divide + * by 1000, to get the actual offset. + * + * If a device introduces a constant offset, e.g., of .25 inch + * horizontally and .31 inch vertically, the caller can compensate + * by passing (xflag - 2500) and (yflag - 3100). + */ +void +DVISetState(fp, fontfn, dpi, xoffset, yoffset) + FILE *fp; + struct font *(*fontfn)(); + int dpi, xoffset, yoffset; +{ + + /* make sure fseek() will work */ + if ((ds.ds_fp = SeekFile(fp)) == NULL) + error(1, -1, "unable to copy input to temp file (disk full?)"); + + /* h and v must be deferred until we have a conversion */ + ds.ds_fresh.hh = ((1000 + (i32)xoffset) * dpi) / 1000; + ds.ds_fresh.vv = ((1000 + (i32)yoffset) * dpi) / 1000; + + ds.ds_fonts = SCreate(sizeof(struct font *)); + if (ds.ds_fonts == NULL) + error(1, 0, "cannot create font table (out of memory?)"); + s_errs = 0; + s_dpi = dpi; + s_deffnt = fontfn; + ScanPostAmble(ds.ds_fp, post, fntdef); + if (s_errs) + GripeMissingFontsPreventOutput(s_errs); + pre(); +} + +/* + * Read the preamble and apply sanity checks. + * The presence of a preamble is virtually certain, + * since we have already found and read a postamble. + */ +static void +pre() +{ + register int n; + register FILE *fp = ds.ds_fp; + + rewind(fp); + if (GetByte(fp) != Sign8(DVI_PRE)) + GripeMissingOp("PRE"); + if (GetByte(fp) != Sign8(DVI_VERSION)) + GripeMismatchedValue("version number"); + if (GetLong(fp) != ds.ds_num) + GripeMismatchedValue("numerator"); + if (GetLong(fp) != ds.ds_denom) + GripeMismatchedValue("denominator"); + if (GetLong(fp) != ds.ds_dvimag) + GripeMismatchedValue("\\magnification"); + n = UnSign8(GetByte(fp)); + while (--n >= 0) + (void) GetByte(fp); +} + +/* + * Store the relevant information from the DVI postamble. + */ +static void +post(p) + register struct PostAmbleInfo *p; +{ + register int n; + + ds.ds_prevpage = p->pai_PrevPagePointer; + ds.ds_num = p->pai_Numerator; + ds.ds_denom = p->pai_Denominator; + ds.ds_dvimag = p->pai_DVIMag; + ds.ds_maxheight = p->pai_TallestPageHeight; + ds.ds_maxwidth = p->pai_WidestPageWidth; + ds.ds_npages = p->pai_NumberOfPages; + + /* set the global conversion factor */ + SetConversion(s_dpi, + ds.ds_usermag, ds.ds_num, ds.ds_denom, ds.ds_dvimag); + + ds.ds_fresh.h = toSP(ds.ds_fresh.hh); + ds.ds_fresh.v = toSP(ds.ds_fresh.vv); +#ifdef unneeded /* counting on init-to-zero ... */ + ds.ds_fresh.w = 0; + ds.ds_fresh.x = 0; + ds.ds_fresh.y = 0; + ds.ds_fresh.z = 0; +#endif + /* make the stack */ + n = p->pai_DVIStackSize * sizeof(DviStack); + if ((ds.ds_stack = (struct dvi_stack *)malloc((unsigned)n)) == NULL) + GripeOutOfMemory(n, "DVI stack"); + ds.ds_sp = ds.ds_stack; +} + +/* + * Handle a font definition from the postamble. + */ +static void +fntdef(p) + register struct PostAmbleFont *p; +{ + register struct font *f, **fp; + int def = S_CREATE | S_EXCL; + + fp = (struct font **)SSearch(ds.ds_fonts, p->paf_DVIFontIndex, &def); + if (fp == NULL) { + if (def & S_COLL) + GripeFontAlreadyDefined(p->paf_DVIFontIndex); + else + error(1, 0, "cannot stash font %ld (out of memory?)", + (long)p->paf_DVIFontIndex); + /* NOTREACHED */ + } + + /* apply driver function to get font */ + f = (*s_deffnt)(p->paf_name, p->paf_DVIMag, p->paf_DVIDesignSize); + if (f == NULL) { + s_errs++; + return; + } + *fp = f; + + /* match checksums, unless one is (or both are) zero */ + if (p->paf_DVIChecksum && f->f_checksum && + p->paf_DVIChecksum != f->f_checksum) + GripeDifferentChecksums(f->f_path, p->paf_DVIChecksum, + f->f_checksum); +} + +/* + * Given a font index, return the corresponding pointer. + */ +struct font * +DVIFindFont(n) + i32 n; +{ + int x = S_LOOKUP; + char *p; + + if ((p = SSearch(ds.ds_fonts, n, &x)) == NULL) { + GripeNoSuchFont(n); + /* NOTREACHED */ + } + return (*(struct font **)p); +} + +/* + * Handle a rule: read width and height, then call the given function. + * If `advance', move dvi position afterwards. + */ +void +DVIRule(fn, advance) + void (*fn)(); + int advance; +{ + register i32 h, w, ww; + register FILE *fp = ds.ds_fp; + + fGetLong(fp, h); + fGetLong(fp, ww); + h = ConvRule(h); + w = ConvRule(ww); + (*fn)(h, w); + if (advance) { + dvi_hh += w; + dvi_h += ww; + w = fromSP(dvi_h); + FIXDRIFT(dvi_hh, w); + } +} + +/* + * Handle a BOP: read the ten \count values and the previous page pointer, + * reset DVI position, and call the given function. + */ +void +DVIBeginPage(fn) + void (*fn)(); +{ + register int i; + i32 count[10]; + + for (i = 0; i < 10; i++) + count[i] = GetLong(ds.ds_fp); + ds.ds_prevpage = GetLong(ds.ds_fp); + + /* reset DVI page position and stack pointer, then call driver */ + ds.ds_cur = ds.ds_fresh; + ds.ds_sp = ds.ds_stack; + + (*fn)(count); +} diff --git a/Build/source/texk/seetexk/dvistate.h b/Build/source/texk/seetexk/dvistate.h new file mode 100644 index 00000000000..c0b3b7b00c4 --- /dev/null +++ b/Build/source/texk/seetexk/dvistate.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* DVI file information (as used by dvi-to-device programs) */ + +/* + * Units of distance are stored in scaled points, but we can convert to + * units of 10^-7 meters by multiplying by the numbers in the preamble. + * The values hh and vv are kept in device coordinates. + */ + +/* the structure of the stack used to hold the values (h,v,hh,vv,w,x,y,z) */ +typedef struct dvi_stack { + i32 h; /* the saved h */ + i32 v; /* the saved v */ + i32 hh; /* the saved hh */ + i32 vv; /* the saved vv */ + i32 w; /* etc */ + i32 x; + i32 y; + i32 z; +} DviStack; + +/* + * DVI state machine interpreter encapsulation (global state). + */ +struct dvi_state { + /* + * Variables that must be set by user before calling SetDVIState(). + */ + int ds_usermag; /* user-supplied (additional) magnification */ + int ds_maxdrift; /* maximum drift, typically 3 */ + + /* the rest are set by DVISetState() */ + + /* + * Values based on the (postamble of the) DVI file, + * or used by the interpreter. + */ + i32 ds_num; /* numerator from DVI file */ + i32 ds_denom; /* denominator from DVI file */ + i32 ds_dvimag; /* magnification from DVI file */ + i32 ds_maxheight; /* height of tallest page */ + i32 ds_maxwidth; /* width of widest page */ + i32 ds_prevpage; /* previous page of DVI file */ + int ds_npages; /* number of DVI pages */ + DviStack *ds_stack; /* base of stack of DVI values */ + DviStack *ds_sp; /* current place in stack */ + DviStack ds_cur; /* current values */ + DviStack ds_fresh; /* fresh values for new pages: not all + zero unless there are no margins. + This works because all DVI motion + is relative. */ + /* + * Although this is not strictly within the realm of DVI + * state, we need a place to store the fonts we allocate + * while reading through the postamble. Each entry in + * the ds_fonts search table is a pointer to a font, + * so that *(struct font **)SSearch(...) is the pointer. + */ + struct search *ds_fonts;/* font table */ + + /* + * A few routines want a private copy of the DVI file pointer. + */ + FILE *ds_fp; /* input DVI file */ +}; + +extern struct dvi_state ds; + +/* shorthand */ +#define dvi_h ds.ds_cur.h +#define dvi_v ds.ds_cur.v +#define dvi_hh ds.ds_cur.hh +#define dvi_vv ds.ds_cur.vv +#define dvi_w ds.ds_cur.w +#define dvi_x ds.ds_cur.x +#define dvi_y ds.ds_cur.y +#define dvi_z ds.ds_cur.z + +/* + * Set up the state for the interpreter loop. + */ +void DVISetState(); + +/* + * Service routines (called from main loop). + */ +struct font *DVIFindFont(); +void DVIRule(), DVIBeginPage(); + +/* + * Drift fixing. Note that the first argument must be an lvalue. + * It is the desired position in pixels, and is maintained within + * ds.ds_maxdrift pixels of the second argument, which is the + * `absolute' DVI position rounded to the nearest pixel. + */ +#define FIXDRIFT(xx, x) \ + if ((x) >= (xx)) \ + if ((x) - (xx) <= ds.ds_maxdrift) \ + /* position is in bounds */; \ + else \ + (xx) = (x) - ds.ds_maxdrift; \ + else \ + if ((xx) - (x) <= ds.ds_maxdrift) \ + /* position is in bounds */; \ + else \ + (xx) = (x) + ds.ds_maxdrift diff --git a/Build/source/texk/seetexk/dvistuff.c b/Build/source/texk/seetexk/dvistuff.c new file mode 100644 index 00000000000..1831de3df7d --- /dev/null +++ b/Build/source/texk/seetexk/dvistuff.c @@ -0,0 +1,1190 @@ +/* + * Copyright 1989 Dirk Grunwald + * + * 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 Dirk Grunwald or M.I.T. + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Dirk + * Grunwald and 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. + * + * DIRK GRUNWALD AND M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT + * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE + * OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: + * Dr. Dirk Grunwald + * Dept. of Computer Science + * Campus Box 430 + * Univ. of Colorado, Boulder + * Boulder, CO 80309 + * + * grunwald@colorado.edu + * + */ + +#include <stdio.h> +#include <ctype.h> + +#include "dvistuff.h" /* includes types & fonts */ + +static char *rcsid="$Header: /home/reed/grunwald/Iptex/drivers/RCS/dvistuff.c,v 1.17 88/07/07 23:25:32 grunwald Exp Locker: grunwald $" ; + +#include "dviclass.h" +#include "dvicodes.h" +#include "postamble.h" +#include "search.h" +#include "fio.h" + +int dviHH = -1; /* current horizontal position, in DEVs */ +int dviVV = -1; /* current vertical position, in DEVs */ +long *dviCount[DVI_COUNT]; /* values of count */ +DviStack dvi_current; +int dviHHMargin = -1; /* horizontal margin (in DEVs) */ +int dviVVMargin = -1; /* vertical margin (in DEVs) */ +int dviTallestPage = -1; +int dviWidestPage = -1 ; +int dviCurrentPage = -1; +int dviTotalPages = -1; +int dviDPI = -1; +int dviMaxDrift = -1; +int dviUserMag = -1; /* user-specified magnification */ +int dviBlackness = -1; +int dviFontRotation = -1; +char *DVIFileName; +static char *dviTmpFileName = 0; +static char dviTmpFileNameBuffer[256]; +FILE *dviFile; /* users file */ +char *dviPrintEngine = "canon"; + +char *ProgName; + +/* + * Similar to dvi_stack, but includes `dviHH and `dviVV, which are usually + * but not always the same as fromSP(h) and fromSP(v): + */ +struct localstack { + int stack_hh; + int stack_vv; + struct dvi_stack stack_dvi; +}; + +static struct localstack *dvi_stack = 0;/* base of stack */ +static struct localstack *dvi_stackp; /* current place in stack */ + +/* + * DVI preamble and postamble information. + */ + +static long Magnification; +static long Numerator; /* numerator from DVI file */ +static long Denominator; /* denominator from DVI file */ + +/* + * Font related things. + * We keep track of the current font, use the fontfiner + * and record errors in the dvi postable in FontErros. + * the NoFont is a used when we cant find a font, + * to avoid errors. + */ + +struct fontinfo *dviCurrentFont = 0; + +/* + * imagen1-special uses the NextFamilyNumber. *sigh* + */ + +int NextFamilyNumber = 0; +static int MaxFontFamily = MAX_FONTFAMILY; + +static struct search *FontFinder = 0; +int FontErrors = 0; +static struct fontinfo NoFont; +/* + * We keep a list of pointers to the beginning of pages. + * Each page is headed by a DVI_BOP + 44 bytes of information. + */ + +static long *pageOffset = 0; + +#undef FIXDRIFT +/* + * Correct devpos (the actual device position) to be within MaxDrift pixels + * of dvipos (the virtual DVI position). + */ +#define FIXDRIFT(devpos, dvipos) \ + if (ABS((devpos) - (dvipos)) <= dviMaxDrift) \ + /* void */; \ + else \ + if ((devpos) < (dvipos)) \ + (devpos) = (dvipos) - dviMaxDrift; \ + else \ + (devpos) = (dvipos) + dviMaxDrift + +#define ABS(X) ( (X) < 0 ? -(X) : (X) ) + + +/* + * Store the relevant information from the DVI postamble, and set up + * various internal things. + */ +static void +PostAmbleHeader(p) + register struct PostAmbleInfo *p; +{ + int i; + int page; + int pageSize; + int stackSize; + long prevPagePointer; + long wuzAt; + + Numerator = p->pai_Numerator; + Denominator = p->pai_Denominator; + Magnification = p->pai_DVIMag; + +/* + * Set the conversion factor. This must be done before using + * any fonts or the fromSP routine. + */ + + SetConversion(dviDPI, dviUserMag, Numerator, Denominator, Magnification); + + dviTotalPages = p -> pai_NumberOfPages; + dviWidestPage = fromSP(p -> pai_WidestPageWidth); + dviTallestPage = fromSP(p -> pai_TallestPageHeight); + +/* + * Set up the DVI stack + */ + stackSize = p -> pai_DVIStackSize * sizeof(*dvi_stack); + if (dvi_stack != 0) { + free(dvi_stack); + } + dvi_stack = (struct localstack *) malloc((unsigned) stackSize); + +/* + * Set of the table of pointers to pages and room for the + * count variables. + */ + + pageSize = dviTotalPages * sizeof(long); + if (pageOffset != 0) { + free(pageOffset); + } + pageOffset = (long *) malloc(pageSize); + + if (pageOffset == NULL) { + fprintf(stderr,"xdvi: Can not allocate page directory (%d pages)", + dviTotalPages); + exit(1); + } + + for (i = 0; i < DVI_COUNT; i++) { + if (dviCount[i] != 0) { + free(dviCount[i]); + } + dviCount[i] = (long*) malloc(pageSize); + if (dviCount[i] == NULL) { + fprintf(stderr,"xdvi: Can not allocate count directory (%d pages)", + dviTotalPages); + exit(1); + } + } + + +/* + * Follow back pointers through pages in the DVI file, + * storing the offsets in the pageOffset table. + */ + + prevPagePointer = p->pai_PrevPagePointer; + wuzAt = (long) ftell(dviFile); + + for (page = dviTotalPages - 1; page >= 0 ; page--) { + +/* + * Skip to previous page, but skip over BOP marker. + */ + pageOffset[page] = prevPagePointer; + if( fseek(dviFile, prevPagePointer+1, 0) < 0) { + perror("fseek"); + fprintf(stderr,"[postamble] improper seek looking up pages\n"); + fprintf(stderr,"prevPagePointer = %lx\n", + prevPagePointer); + exit(1); + } + +/* + * Read the other counters at the beginning of the page + */ + + for (i = 0; i < DVI_COUNT; i++) { + long value; + fGetLong(dviFile, value); + dviCount[i][page] = value; + } + fGetLong(dviFile, prevPagePointer); + } + fseek(dviFile, wuzAt, 0); +} + +static void +PostAmbleFontDef(p) +register struct PostAmbleFont *p; +{ + register struct fontinfo *fi; + register struct font *f; + + char *fname; + int def = S_CREATE | S_EXCL; + + fi = (struct fontinfo *) SSearch(FontFinder, p->paf_DVIFontIndex, + &def); + if (fi == NULL) { +/* + * If the font already exists, lets just check that its really the + * same thing & return + */ + + if ((def & S_FOUND) | (def & S_COLL)) { + + def = S_LOOKUP; + if ((fi = (struct fontinfo *) SSearch(FontFinder, + p -> paf_DVIFontIndex, + &def)) == 0){ + GripeNoSuchFont(p -> paf_DVIFontIndex); + exit(1); + } + + if (fi -> f == NULL) { + GripeCannotGetFont(p->paf_name, p->paf_DVIMag, + p->paf_DVIDesignSize, + dviPrintEngine, fname); + } + f = fi -> f; + if (p->paf_DVIChecksum && f->f_checksum && + p->paf_DVIChecksum != f->f_checksum) { + GripeDifferentChecksums(fname, p->paf_DVIChecksum, + f->f_checksum); + exit(1); + } + return; /* font already defined */ + } + else { + fprintf(stderr, "Can not stash font %ld (out of memory?)\n", + p -> paf_DVIFontIndex); + exit(1); + } + } + + if (NextFamilyNumber == MaxFontFamily) { + fprintf(stderr,"Out of font family!\n"); + exit(1); + } + + fi->family = NextFamilyNumber; + NextFamilyNumber++; + + f = GetFont(p->paf_name, p->paf_DVIMag, p->paf_DVIDesignSize, + dviPrintEngine, &fname); + +/* + * Give the application a chance to bang on this if they want to. + */ + + f = applicationNewFont(f, fi -> family); + + if ((fi->f = f) == NULL) { + GripeCannotGetFont(p->paf_name, p->paf_DVIMag, + p->paf_DVIDesignSize, dviPrintEngine, fname); + FontErrors++; + return; + } + + /* match checksums, if not zero */ + if (p->paf_DVIChecksum && f->f_checksum && + p->paf_DVIChecksum != f->f_checksum) + GripeDifferentChecksums(fname, p->paf_DVIChecksum, + f->f_checksum); + + fi->pspace = p->paf_DVIMag / 6; /* a three-unit "thin space" */ + fi->nspace = -4 * fi->pspace; + fi->vspace = 5 * fi->pspace; +} + +static void +ReadPostAmble() +{ + + if (FontFinder == 0) { + if ((FontFinder = SCreate(sizeof(struct fontinfo))) == 0) { + fprintf(stderr, "can not create FontFinder (out of memory?)"); + exit(1); + } + } + + ScanPostAmble(dviFile, PostAmbleHeader, PostAmbleFontDef); + + if (FontErrors) + GripeMissingFontsPreventOutput(FontErrors); +} + +/* + * Read the preamble and do a few sanity checks + */ + +static void +ReadPreAmble() +{ + register int n; + + rewind(dviFile); + if (GetByte(dviFile) != Sign8(DVI_PRE)) + GripeMissingOp("PRE"); + + if (GetByte(dviFile) != Sign8(DVI_VERSION)) + GripeMismatchedValue("version numbers"); + + if (GetLong(dviFile) != Numerator) + GripeMismatchedValue("numerator"); + + if (GetLong(dviFile) != Denominator) + GripeMismatchedValue("denominator"); + + if (GetLong(dviFile) != Magnification) + GripeMismatchedValue("\\magfactor"); + + n = UnSign8(GetByte(dviFile)); + while (--n >= 0) + (void) GetByte(dviFile); +} + +int +dviInit() +{ + extern char *ProgName; + FILE *tmpFile; +#ifndef WIN32 + char *mktemp(); +#endif + + dviFini(); /* clean up the old files */ + + if (DVIFileName == 0) { + dviFile = stdin; + DVIFileName = "<stdin>"; + }else if ((dviFile = fopen(DVIFileName, "r")) == NULL) { + int n = strlen(DVIFileName); + char *dvi_name; + + if (strcmp(DVIFileName + n - sizeof(".dvi") + 1, ".dvi") == 0) { + perror(DVIFileName); + return(1); + } + + dvi_name = (char *) malloc((unsigned) n + sizeof(".dvi")); + sprintf(dvi_name, "%s.dvi", DVIFileName); + + if ((dviFile = fopen(dvi_name, "r")) == NULL) { + perror(dvi_name); + return(1); + } + DVIFileName = dvi_name; + } + +/* + * node, copy the file to a temporary location. This lets the person + * peruse the file while theyre re-texing it + */ + strcpy(dviTmpFileNameBuffer,"/tmp/dvistuff.XXXXXX"); + dviTmpFileName = mktemp(dviTmpFileNameBuffer); + + if (!(tmpFile = fopen(dviTmpFileName,"w+"))) { + perror("fopen"); + fprintf(stderr,"Unable to create temporary file"); + dviTmpFileName = 0; + } else { + char buffer[BUFSIZ]; + int b; + + rewind(dviFile); + do { + b = fread(buffer, 1, BUFSIZ, dviFile); + fwrite(buffer, 1, b, tmpFile); + } while (! feof(dviFile)); + + fclose(dviFile); + dviFile = tmpFile; + rewind(dviFile); + } +/* + * Unlink the temporary file. This keeps tmp files from cluddering + * up /tmp and it does it in a very application-independent way. + * You can't reopen the tmp file, but we don't really allow that + * anyway (the tmp file is hidden from the user). + */ + if (dviTmpFileName != 0 && + strncmp(dviTmpFileName,"/tmp/",5) == 0) { + unlink(dviTmpFileName); + } + + if (dviUserMag == -1) { + dviUserMag = 1000; + } + + if (dviMaxDrift == -1) { + dviMaxDrift = DEFAULT_MAX_DRIFT; + } + + if (dviDPI == -1) { + dviDPI = DEFAULT_DPI; + } + + if (dviBlackness == -1) { + dviBlackness = DEFAULT_BLACKNESS; + } + + if (dviFontRotation == -1) { + dviFontRotation = ROT_NORM; + } + + ReadPostAmble(); + ReadPreAmble(); + + /* Margins -- needs work! */ + + if (dviHHMargin == -1) { + dviHHMargin = DEFAULT_HHMARGIN; + } + + if (dviVVMargin == -1) { + dviVVMargin = DEFAULT_VVMARGIN; + } + + dviCurrentFont = &NoFont; /* fake font, all zeros */ + + return(0); +} + +void +dviFini() +{ + if (dviFile != 0) { + fclose(dviFile); + } + + if (dviTmpFileName != 0 && + strncmp(dviTmpFileName,"/tmp/",5) == 0) { + unlink(dviTmpFileName); + } +} + + +static void +SelectFont(n) +i32 n; +{ + int x = S_LOOKUP; + + if ((dviCurrentFont = (struct fontinfo *)SSearch(FontFinder, n, &x)) == 0) + GripeNoSuchFont(n); +} + +/* Read the postamble. */ + +static void +doDviChar(c, advance) +int c; +int advance; +{ + register struct glyph *g; + register struct font *f; + int p; + + f = dviCurrentFont->f; + + if (c < f -> f_lowch || c > f -> f_highch) { + fprintf(stderr,"Character out of range: %d\n", + c); + return; + } + + g = GLYPH(f, c); + if (!GVALID(g)) { + fprintf(stderr, "there is no character %d in %s", + c, f->f_path); + exit(1); + } else { + + if (HASRASTER(g)) { /* workaround for Imagen bug */ + applicationPutChar(dviHH,dviVV,c); + } + + if (advance) { + dviHH += g->g_pixwidth; + dvi_h += g->g_tfmwidth; + p = fromSP(dvi_h); + FIXDRIFT(dviHH, p); + } + } +} + +/* + * The next two routines are used to reset all the glyphs. + * the dviResetFont routine is called for each font in the font table. + * It de-allocates the rasters & glyphs for the shrunken fonts, leaving + * the original glyph data untouched. + */ + + +static void +dviResetFont(fi, key) +struct fontinfo *fi; +int key; +{ + if (fi != 0) { + applicationResetFont(fi, fi -> family); + } +} + +void +dviResetAll() +{ + SEnumerate(FontFinder, dviResetFont); +} + +/* + * Process the DVI commands for page #page. If the page number is + * out of range, it is cropped to the end. + * + * Updates dviCurrentPage + */ +void +dviPreparePage(page) +int page; +{ + register int c; + register i32 p; + int advance; + + if (page < 0) { + page = 0; + } + + if (page >= dviTotalPages) { + page = dviTotalPages - 1; + } + + dviCurrentPage = page; + + fseek(dviFile, (long) pageOffset[page], 0); + + dviHH = dviHHMargin; + dviVV = dviVVMargin; + + dvi_h = toSP(dviHH); + dvi_v = toSP(dviVV); + + dvi_w = 0; + dvi_x = 0; + dvi_y = 0; + dvi_z = 0; + + dvi_stackp = dvi_stack; + + for(;;) { +/* + * Get the DVI byte, and switch on its parameter length and type. + * Note that getchar() returns unsigned values. + */ + + if (feof(dviFile)) { + fprintf(stderr,"Unexpected end-of-file\n"); + exit(1); + } + + c = getc(dviFile); + + if (DVI_IsChar(c)) { + advance = 1; + doDviChar(c, advance); + } else { + + switch (DVI_OpLen(c)) { + + case DPL_NONE: + break; + + case DPL_SGN1: + p = getc(dviFile); + p = Sign8(p); + break; + + case DPL_SGN2: + fGetWord(dviFile, p); + p = Sign16(p); + break; + + case DPL_SGN3: + fGet3Byte(dviFile, p); + p = Sign24(p); + break; + + case DPL_SGN4: + fGetLong(dviFile, p); + break; + + case DPL_UNS1: + p = UnSign8(getc(dviFile)); + break; + + case DPL_UNS2: + fGetWord(dviFile, p); + p = UnSign16(p); + break; + + case DPL_UNS3: + fGet3Byte(dviFile, p); + p = UnSign24(p); + break; + + default: + panic("DVI_OpLen(%d) = %d", c, DVI_OpLen(c)); + /* NOTREACHED */ + } + + switch (DVI_DT(c)) { + + case DT_SET: + c = p; + doDviChar(c, 1); + break; + + case DT_PUT: + c = p; + doDviChar(c, 0); + break; + + case DT_SETRULE: + case DT_PUTRULE: + + { + i32 h, w, rw; + + fGetLong(dviFile, h); + fGetLong(dviFile, rw); + + h = ConvRule(h); + w = ConvRule(rw); + + applicationSetRule(dviHH, dviVV, h,w); + + if (DVI_DT(c) == DT_SETRULE) { + dviHH += w; + dvi_h += rw; + w = fromSP(dvi_h); + FIXDRIFT(dviHH, w); + } + } + break; + + case DT_NOP: + break; + + case DT_BOP: +/* + * Each beginning of page has 11 4-byte words telling us things + * about the page. We ignore them. + */ + { + fseek(dviFile, (long) (11 * 4), 1); + } + + break; + + case DT_EOP: + return; + + case DT_PUSH: + dvi_stackp->stack_hh = dviHH; + dvi_stackp->stack_vv = dviVV; + dvi_stackp->stack_dvi = dvi_current; + dvi_stackp++; + break; + + case DT_POP: + dvi_stackp--; + dviHH = dvi_stackp->stack_hh; + dviVV = dvi_stackp->stack_vv; + dvi_current = dvi_stackp->stack_dvi; + break; + + case DT_W0: /* there should be a way to make these pretty */ + p = dvi_w; + goto move_right; + + case DT_W: + dvi_w = p; + goto move_right; + + case DT_X0: + p = dvi_x; + goto move_right; + + case DT_X: + dvi_x = p; + goto move_right; + + case DT_RIGHT: + move_right: + dvi_h += p; +/* + * DVItype tells us that we must round motions in this way: + * `When the horizontal motion is small, like a kern, hh + * changes by rounding the kern; but when the motion is + * large, hh changes by rounding the true position so that + * accumulated rounding errors disappear. + */ + if (p >= dviCurrentFont->pspace || p <= dviCurrentFont->nspace) + dviHH = fromSP(dvi_h); + else { + dviHH += fromSP(p); + p = fromSP(dvi_h); + FIXDRIFT(dviHH, p); + } + break; + + case DT_Y0: + p = dvi_y; + goto move_down; + + case DT_Y: + dvi_y = p; + goto move_down; + + case DT_Z0: + p = dvi_z; + goto move_down; + + case DT_Z: + dvi_z = p; + goto move_down; + + case DT_DOWN: + move_down: + dvi_v += p; +/* + * `Vertical motion is done similarly, but with the threshold + * between ``small and ``large increased by a factor of + * 5. The idea is to make fractions like $1\over2$ round + * consistently, but to absorb accumulated rounding errors in + * the baseline-skip moves. + */ + if (ABS(p) >= dviCurrentFont->vspace) + dviVV = fromSP(dvi_v); + else { + dviVV += fromSP(p); + p = fromSP(dvi_v); + FIXDRIFT(dviVV, p); + } + break; + + case DT_FNTNUM: + SelectFont((i32) (c - DVI_FNTNUM0)); + break; + + case DT_FNT: + SelectFont(p); + break; + + case DT_XXX: + { + char specialBuffer [2048]; + register char *cp; + int sweetp = 0; + + if (p > 2047) { + sweetp = p - 2047; + p = 2047; + } + + for (cp = specialBuffer ; p > 0; p--) { + *cp = getc(dviFile); + cp++; + } + *(cp) = 0; + + while(sweetp > 0) { + getc(dviFile); + } + + applicationDoSpecial(specialBuffer); + } + break; + + case DT_FNTDEF: + SkipFontDef(dviFile); + break; + + case DT_PRE: + GripeUnexpectedOp("PRE"); + /* NOTREACHED */ + + case DT_POST: + GripeUnexpectedOp("POST"); + /* NOTREACHED */ + + case DT_POSTPOST: + GripeUnexpectedOp("POSTPOST"); + /* NOTREACHED */ + + case DT_UNDEF: + GripeUndefinedOp(c); + /* NOTREACHED */ + + default: + panic("DVI_DT(%d) = %d", c, DVI_DT(c)); + /* NOTREACHED */ + } + } + } +} + +/* Transpose bytes in each pair of bytes (0123 -> 1032) */ +/* Reverse bits in a byte (01234567 -> 76543210) */ +/* needed for sun386i */ +/* Gerhard Fleischanderl & Wolfgang Nejdl */ + +#ifdef sun386 +static unsigned char pow2[]={1,2,4,8,16,32,64,128}; + +unsigned char reverseByte(oldByte) + unsigned char oldByte; +{ + unsigned short i; + unsigned char newByte=0; + + /* build newByte with bits mirrored */ + + for(i=0;i<8;i++) + if (oldByte & pow2[i]) + newByte |= pow2[7-i]; + + return newByte; +} + +#ifdef UNDEF +#define transposeBytesMirrorBits(pairPtr) \ +/* B16 *pairPtr; */ \ +/* B16 comprises 2 bytes */ \ +{ \ + unsigned char c0,c1, *bP = (unsigned char *) pairPtr; \ + \ + /* transpose neighbouring bytes and \ + reverse bits in each byte */ \ + \ + c0 = *bP; \ + c1 = *(bP+1); \ + *bP = ReverseByteTable[c1]; \ + *(bP+1) = ReverseByteTable[c0]; \ +} + +#else +#define transposeBytesMirrorBits(ptr) {*ptr = ReverseByteTable[ (*ptr)&0xff ];} +#endif /* undef */ + +#endif + + +/* + * The following routine is used to shrink a glyph by some + * shrink factor (in the width & height dimension). + * + * These shrunken glyphs are more appropriate for previewers. + * + * To do this, we simple scan the original raster, counting the + * number of pixels within a given area. If the number of on pixels is + * at least twice the total number of pixels, we turn the pixel in + * the shrunken glyph ON, else OFF. + * + * We use a lookup table to hasten the process of counting pixels. + * + * The method used should be independent of byte-order (I think). + * + * You need to define two types. One should be 32-bits long, and + * the other 16 bits long. + */ + +typedef unsigned char B8; +typedef unsigned short B16; +typedef unsigned long B32; + +#define LOOKUP_BYTES 256 +#define LOOKUP_BITS 8 +#define LOOKUP_MASK 0xff + +static char dviLookUpTable[LOOKUP_BYTES]; +static char tableNotInitialized = 1; + +#ifdef sun386 +static unsigned char ReverseByteTable[LOOKUP_BYTES]; +#endif + +struct glyph * +dviShrinkGlyph(gly, shrinkH, shrinkW) +DviGlyph *gly; +int shrinkH; +int shrinkW; +{ + int shrunkHeight; + int shrunkWidth; + int glyphWide; + int glyphHigh; + int glyphAdvance; + int shrunkAdvance; + + int bytesWide; + int shrunkBytesWide; + + struct glyph *ngly; + + B16 *shrunkRaster; + int rasterSize; + + int x,y; + B8 *cp; + B8 *ptr; + + B32 shrinkMask; + + int sampleSize; + + if (gly == 0 || !HASRASTER(gly)) { + return(0); + } + + if (gly -> g_raster == 0) { + gly-> g_raster = RASTER(gly, dviCurrentFont -> f, dviFontRotation); + } + +/* + * Initialize the lookup table of the number of bits in a given byte + */ + + if (tableNotInitialized) { + register int i; + register int j; + register int k; + register int acc; + for (i = 0; i < LOOKUP_BYTES; i++) { + j = i; + acc = 0; + for (k = 0; j != 0 && k < LOOKUP_BITS ; k++) { + acc += (j & 1); + j >>= 1; + } + dviLookUpTable[i] = acc; + } + +#ifdef sun386 + for (i = 0; i < LOOKUP_BYTES; i++) { + ReverseByteTable[i] = reverseByte(i); + } +#endif + + tableNotInitialized = 0; + } + +/* + * When shrinking the fonts, we convert them from byte alligned + * to 16 bit-aligned fonts. I think that this is needed by X, + * and also SunWindows. This is done rather than changing the + * library routines because some device drivers, i.e. imagen1, + * depend on the byte-alligned fonts. + */ + glyphHigh = gly -> g_height; + glyphWide = gly -> g_width; + + gly -> g_pixwidth = fromSP(gly -> g_tfmwidth); + glyphAdvance = gly -> g_pixwidth; + + shrunkHeight = (glyphHigh + shrinkH - 1) / shrinkH; + shrunkWidth = (glyphWide + shrinkW - 1) / shrinkW; + shrunkAdvance = (glyphAdvance + shrinkW - 1) / shrinkW; + + bytesWide = (gly -> g_width + 7) >> 3; + + shrunkBytesWide = ((shrunkWidth + 15) >> 4) * 2; + + rasterSize = (shrunkHeight + 1) * shrunkBytesWide; + shrunkRaster = (B16 *) malloc(rasterSize); + bzero(shrunkRaster, rasterSize); + ptr = (B8 *) shrunkRaster; + + if (shrunkRaster == NULL) { + fprintf(stderr, "Out of memory!\n"); + exit(1); + } + + for (y = 0; y < glyphHigh; y+= shrinkH) { + cp = (B8 *) ptr; + shrinkMask = 0x80; + for (x = 0; x < glyphWide; x += shrinkW) { + int i; + int samples; + B8 *baseP; + int upper; + register int thisShrinkW; + + baseP = (B8 *) gly -> g_raster + (y * bytesWide); + +/* + * Set the upper limit on the height iteration so we dont count + * off the end of the raster + */ + + upper = y + shrinkH; + if (upper > glyphHigh) { + upper = glyphHigh; + } + + if (x + shrinkW > glyphWide) { + thisShrinkW = glyphWide - x; + } else { + thisShrinkW = shrinkW; + } + + samples = 0; + sampleSize = thisShrinkW * (upper - y); + + for (i = y; i < upper; i++) { + register int acc; + register B8 *p; + register B8 *ep; +/* + * Determine how many bytes our shrink window crosses (we might + * overlap on byte-edges) + */ + + p = baseP + (x >> 3); + ep = baseP + ( (x + thisShrinkW - 1) >> 3); + baseP += bytesWide; + +/* + * stuff everything in the accumulator + */ + + acc = 0; + while (p <= ep) { + acc = ((acc << 8) & ~0xff) | *p; + p++; + } + +/* + * clean off the right hand-side of extra bits, then clean off + * the left hand side of extra bits, and then count them. + */ + + acc = acc >> ( 7 - ((x + thisShrinkW - 1) & 0x7)); + acc &= ~(-1 << thisShrinkW); + while (acc != 0) { + samples += dviLookUpTable[ acc & LOOKUP_MASK ]; + acc >>= LOOKUP_BITS; + } + } +/* + * If at least 1/blackness of the bits are on, treat this entire sample as + * being on. + */ + + if ((samples * dviBlackness) >= sampleSize) { + *ptr |= shrinkMask; + } else { + *ptr &= ~ shrinkMask; + } + shrinkMask >>= 1; + if (shrinkMask == 0) { + shrinkMask = 0x80; +#ifdef sun386 + transposeBytesMirrorBits(ptr) +#endif + ptr ++; + } + } +#ifdef sun386 + transposeBytesMirrorBits(ptr) +#endif + ptr = (B8 *) (cp + shrunkBytesWide); + } + +/* + * Build a new glyph from the shrunken raster + */ + +#ifdef UNDEF + if ( shrunkBytesWide != 2 ) + { + printf("Old glyph:\n"); + seeGlyph(gly -> g_raster, glyphHigh, bytesWide); + printf("%d ", shrunkBytesWide); + printf("New glyph:\n"); + seeGlyph(shrunkRaster, shrunkHeight, shrunkBytesWide); + } +#endif UNDEF + + ngly = (struct glyph *) malloc(sizeof(struct glyph)); + bzero(ngly, sizeof(struct glyph)); + + ngly -> g_raster = (char * ) shrunkRaster; + ngly -> g_width = shrunkWidth; + ngly -> g_pixwidth = shrunkAdvance; + ngly -> g_height = shrunkHeight; + + ngly -> g_xorigin = gly -> g_xorigin / shrinkH; + ngly -> g_yorigin = gly -> g_yorigin / shrinkW; + + ngly -> g_flags |= GF_SHRUNK; /* yes, its been shrunk */ + + return(ngly); +} + +#ifdef UNDEF + +seeGlyph(c, h, w) +char *c; +int h; +int w; +{ + int i,j; + + for (i = 0; i < h; i++ ) { + for (j = 0; j < w; j++) { + int k; + register int ch; + register int m; + char str[9]; + + ch = *(c++); + m = 0x80; + for (k = 0; k < 8; k++) { + str[k] = '"' + ( (ch & m) ? 1 : 0 ); + m >>= 1; + } + str[8] = 0; + printf("%s", str); + } + printf("\n"); + } +} + + +#endif UNDEF diff --git a/Build/source/texk/seetexk/dvistuff.h b/Build/source/texk/seetexk/dvistuff.h new file mode 100644 index 00000000000..040e02bdac1 --- /dev/null +++ b/Build/source/texk/seetexk/dvistuff.h @@ -0,0 +1,145 @@ +/* + * Copyright 1989 Dirk Grunwald + * + * 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 Dirk Grunwald or M.I.T. + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Dirk + * Grunwald and 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. + * + * DIRK GRUNWALD AND M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT + * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE + * OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: + * Dr. Dirk Grunwald + * Dept. of Computer Science + * Campus Box 430 + * Univ. of Colorado, Boulder + * Boulder, CO 80309 + * + * grunwald@colorado.edu + * + */ + +static char *dvistuff_header_rcsid="$Header: /home/reed/grunwald/Iptex/drivers/RCS/dvistuff.h,v 1.11 89/02/15 16:31:56 grunwald Exp $" ; + +/* + * Include the following from the CTex distribution + */ + +#include <stdio.h> + +#include "types.h" +#include "font.h" +#include "conv.h" + +/* + * We use the following flags to keep track of shrunk fonts + */ + +#define GF_SHRUNK GF_USR0 + +#define GLYPH_SHRUNK(g) ((g) -> g_flags & GF_SHRUNK) + +#define SHRUNK_GLYPH_BYTES_WIDE(g) ((((g) -> g_width + 15) >> 4) * 2) + +typedef struct font DviFont; +typedef struct glyph DviGlyph; + +#define MAX_GLYPH 128 +#define MAX_FONTFAMILY 128 + +#define DEFAULT_DPI 300 +#define DEFAULT_HHMARGIN DEFAULT_DPI +#define DEFAULT_VVMARGIN DEFAULT_DPI +#define DEFAULT_MAX_DRIFT 3 + +#define DEFAULT_BLACKNESS 3 + + +struct fontinfo { + struct font *f; /* the font */ + i32 pspace; /* boundary between `small & `large spaces + (for positive horizontal motion) */ + i32 nspace; /* -4 * pspace, for negative motion */ + i32 vspace; /* 5 * pspace, for vertical motion */ + int family; /* Imagen family number (we pick one) */ +}; + +typedef struct fontinfo DviFontInfo; + +/* DVI file info */ + +/* + * Units of distance are stored in scaled points, but we can convert to + * units of 10^-7 meters by multiplying by the numbers in the preamble. + */ + +/* the structure of the stack used to hold the values (h,v,w,x,y,z) */ + +typedef struct dvi_stack { + i32 h; /* the saved h */ + i32 v; /* the saved v */ + i32 w; /* etc */ + i32 x; + i32 y; + i32 z; +} DviStack; + +extern DviStack dvi_current; /* the current values of h, v, etc */ +extern int dvi_f; /* the current font */ + +#define dvi_h dvi_current.h +#define dvi_v dvi_current.v +#define dvi_w dvi_current.w +#define dvi_x dvi_current.x +#define dvi_y dvi_current.y +#define dvi_z dvi_current.z + + + +extern int dviHH; /* current horizontal position, in DEVs */ +extern int dviVV; /* current vertical position, in DEVs */ +#define DVI_COUNT 10 /* count0 .. count9 */ +extern long *dviCount[DVI_COUNT]; /* values of count */ + +extern Conv Conversion; + +extern int dviHHMargin; +extern int dviVVMargin; +extern int dviDPI; +extern int dviTallestPage; +extern int dviWidestPage; +extern int dviTotalPages; +extern int dviCurrentPage; +extern int dviMaxDrift; +extern char *dviPrintEngine; +extern int dviBlackness; +extern int dviFontRotation; +extern int dviUserMag; + +extern DviFontInfo *dviCurrentFont; +extern char *DVIFileName; +extern FILE *dviFile; /* user's file */ +extern char *ProgName; + +extern int dviInit(); +extern void dviFini(); +extern void dviPreparePage( /* int */ ); +extern struct glyph *dviShrinkGlyph(); + +void applicationPutChar( /* hh, vv, charCode */ ); +DviFont *applicationNewFont( /* font structure */); +void applicationResetFont(/* font info, key */); +void applicationSetRule( /* hh, vv, height, width : long*/ ); +void applicationDoSpecial(); diff --git a/Build/source/texk/seetexk/dvitodvi.c b/Build/source/texk/seetexk/dvitodvi.c new file mode 100644 index 00000000000..333db89697e --- /dev/null +++ b/Build/source/texk/seetexk/dvitodvi.c @@ -0,0 +1,1221 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/dvi/RCS/dviselect.c,v 3.1 89/08/22 17:16:13 chris Exp $"; +#endif + +/* + * DVI page rearrangement program + * + * Reads DVI version 2 files and rearranges pages, + * writing a new DVI file. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-fopen.h> +#include <kpathsea/getopt.h> +#else +#define FOPEN_RBIN_MODE "r" +#define FOPEN_RBIN_MODE "w" +#define SET_BINARY(x) +extern char *optarg; +extern int optind; +#endif + +#include "types.h" +#include "dviclass.h" +#include "dvicodes.h" +#include "error.h" +#include "fio.h" +#include "gripes.h" +#include "search.h" +#include <stdio.h> +#include <ctype.h> + +#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',') + +#define MAXDVIPAGES 1000 /* max (absolute) pages in DVI file */ +#include "seek.h" + +char *ProgName; + +/* Globals */ +char serrbuf[BUFSIZ]; /* buffer for stderr */ + +/* + * We will try to keep output lines shorter than MAXCOL characters. + */ +#define MAXCOL 75 + +/* + * We use the following structure to keep track of fonts we have seen. + * The final DVI file lists only the fonts it uses. + */ +struct fontinfo { + i32 fi_newindex; /* font number in output file */ + int fi_reallyused; /* true => used on a page we copied */ + i32 fi_checksum; /* the checksum */ + i32 fi_mag; /* the magnification */ + i32 fi_designsize; /* the design size */ + short fi_n1; /* the name header length */ + short fi_n2; /* the name body length */ + char *fi_name; /* the name itself */ +}; + + +i32 Width; /* width of page */ +i32 Height; /* height of page */ +i32 Magnification; /* Magnification of pages */ +int Modulo; /* page spec modulo */ +struct pagespec *PageSpecs; /* page specification list */ + +int SFlag; /* true => -s, silent operation */ + +struct search *FontFinder; /* maps from input indicies to fontinfo */ +i32 NextOutputFontIndex; /* generates output indicies */ +i32 CurrentFontIndex; /* current (old) index in input */ +i32 OutputFontIndex; /* current (new) index in ouput */ + +char *DVIFileName; /* name of input DVI file */ +FILE *inf; /* the input file itself */ +FILE *outf; /* the output DVI file */ + +long StartOfPage[MAXDVIPAGES]; /* The file positions of the + input pages */ + +long StartOfLastPage; /* The file position just before we + started the last page */ +long CurrentPosition; /* The current position of the file */ + +int UseThisPage; /* true => current page is selected */ + +i32 InputPageNumber; /* current absolute page in old DVI file */ +int NumberOfOutputPages; /* number of pages in new DVI file */ + +i32 Numerator; /* numerator from DVI file */ +i32 Denominator; /* denominator from DVI file */ +i32 DVIMag; /* magnification from DVI file */ + +i32 Count[10]; /* the 10 \count variables */ + +/* save some string space: we use this a lot */ +char writeerr[] = "error writing DVI file"; +#ifndef KPATHSEA +char *malloc(), *realloc(); +#endif + +#ifdef HAVE_PROTOTYPES +void specusage(void); +long scale(long whole,int num,int den,long sf); +struct pagespec * newspec(void); +int parseint(char **sp ); +long parsedimen(char **sp ); +struct pagespec * ParseSpecs(char *str,int make); +long singledimen(char *str); +void message(int space,char *str,int len); +void BeginPage(int really); +void DviEndPage(int really); +void PostAmbleFontEnumerator(char *addr,long key); +void HandlePostAmble(void); +void WriteFont(struct fontinfo *fi); +void HandlePreAmble(void); +void HandleFontDef(long strchr); +void HandleSpecial(int c,int l,long p); +void ReallyUseFont(void); +void PutFontSelector(long strchr); +int HandlePage(int first,int last,long hoffset,long voffset); +void PutEmptyPage(void); +void ScanDVIFile(void); +void HandleDVIFile(void); +#else +void specusage(); +long scale(); +struct pagespec *newspec(); +int parseint(); +long parsedimen(); +struct pagespec *ParseSpecs(); +long singledimen(); +void message(); +void BeginPage(); +void DviEndPage(); +void PostAmbleFontEnumerator(); +void HandlePostAmble(); +void WriteFont(); +void HandlePreAmble(); +void HandleFontDef(); +void HandleSpecial(); +void ReallyUseFont(); +void PutFontSelector(); +int HandlePage(); +void PutEmptyPage(); +void ScanDVIFile(); +void HandleDVIFile(); +#endif + +/* + * You may get lint warnings about sprintf's return value. + * Older versions of 4BSD have `char *sprintf()'. ANSI and + * SysV use `int sprintf()'; so ignore the warnings. + */ + +/* + * Lint gets somewhat confused over putc. + */ +#ifdef lint +#undef putc +#ifdef ultrix /* grr */ +#define putc(c, f) fputc((char)(c), f) +#else +#define putc(c, f) fputc((int)(c), f) +#endif +#endif + +void specusage() +{ + error(1, -1, "page specification error:\n\ + <pagespecs> = [modulo:][mag@]<spec>\n\ + <spec> = [-]pageno[(xoff,yoff)][,spec|+spec]\n\ + modulo>=1, 0<=pageno<modulo"); +} + +/* + * This function calculates approximately (whole + num/den) * sf. + * No need for real extreme accuracy; one ten thousandth of an + * inch should be sufficient. + * + * Assumptions: + * + * 0 <= num < den <= 10000 + * 0 <= whole + */ +i32 defaultscale = 4736286 ; +i32 scale(whole, num, den, sf) + i32 whole, sf; + int num, den; +{ + i32 v ; + + if (!sf) + sf = defaultscale ; + v = whole * sf + num * (sf / den) ; + if (v / sf != whole || v < 0 || v > 0x40000000L) + error(1, -1, "arithmetic overflow in dimension") ; + sf = sf % den ; + v += (sf * num * 2 + den) / (2 * den) ; + return (v) ; +} + +struct pagespec { + int reversed, pageno, add; + i32 xoff, yoff; + struct pagespec *next; +}; + +struct pagespec *newspec() +{ + struct pagespec *temp = (struct pagespec *)malloc(sizeof(struct pagespec)); + temp->reversed = temp->pageno = temp->add = 0; + temp->xoff = temp->yoff = 0; + temp->next = NULL; + return (temp); +} + +int parseint(sp) + char **sp; +{ + char *s = *sp; + int n = 0, neg = 0; + + if (*s == '-') { + neg = 1; + s++; + } + for (; isdigit(*s); s++) + n = n*10 + (*s-'0'); + if (*sp == s) specusage(); + *sp = s; + return (neg ? -n : n); +} + +i32 parsedimen(sp) + char **sp; +{ + i32 whole = 0; + int num = 0, den = 1, neg = 0; + i32 fac = 0L; + char *s = *sp; + + if (*s == '-') { + neg = 1; + *sp = ++s; + } + for (; isdigit(*s); s++) + whole = whole*10 + (*s-'0'); + + if (*s == '.') { + *sp = ++s; + for (; isdigit(*s); s++) { + if (den < 10000) { /* limit precision for scale to work */ + num = num*10 + (*s-'0'); + den *= 10; + } + } + } + if (*sp == s) specusage(); + *sp = s; + + /* + * Allowed units are `in', `cm', `mm', `pt', `sp', `cc', `dd', and `pc'; + * must be in lower case. + */ + if (*s == 'c' && s[1] == 'm') { + /* centimeters need to be scaled by 72.27 * 216 / 2.54, or 1 864 680 */ + fac = 1864680L ; + s += 2; + } else if (*s == 'p' && s[1] == 't') { + /* real points need to be scaled by 65536 */ + fac = 65536L ; + s += 2; + } else if (*s == 'p' && s[1] == 'c') { + /* picas need to be scaled by 65536 * 12, or 786 432 */ + fac = 786432L ; + s += 2; + } else if (*s == 'm' && s[1] == 'm') { + /* millimeters need to be scaled by 72.27 * 216 / 25.4, or 186 468 */ + fac = 186468L ; + s += 2; + } else if (*s == 's' && s[1] == 'p') { + /* scaled points are already taken care of; simply round */ + fac = 1L ; + s += 2; + } else if (*s == 'b' && s[1] == 'p') { + /* big points need to be scaled by 72.27 * 65536 / 72, or 65782 */ + fac = 65782L ; + s += 2; + } else if (*s == 'd' && s[1] == 'd') { + /* didot points need to be scaled by 65536 * 1238 / 1157, or 70124 */ + fac = 70124L ; + s += 2; + } else if (*s == 'c' && s[1] == 'c') { + /* cicero need to be scaled by 65536 * 1238 / 1157 * 12, or 841 489 */ + fac = 841489L ; + s += 2; + } else if (*s == 'i' && s[1] == 'n') { + /* inches need to be scaled by 72.27 * 65536, or 4 736 286 */ + fac = 4736286L ; + s += 2; + } else if (*s == 'w') { + fac = Width; + s++; + } else if (*s == 'h') { + fac = Height; + s++; + } + whole = scale(whole, num, den, fac) ; + *sp = s; + return (neg ? -whole : whole); +} + +struct pagespec *ParseSpecs(str, make) + char *str; + int make; +{ + struct pagespec *head, *tail; + int other = 0; + int num = -1; + struct pagespec spare; + + if (make) + head = tail = newspec(); + else + head = tail = &spare; + while (*str) { + if (isdigit(*str)) { + num = parseint(&str); + } else { + switch (*str++) { + case ':': + if (other || head != tail || num < 1) specusage(); + Modulo = num; + num = -1; + break; + case '@': + if (other || head != tail || num < 1) specusage(); + Magnification = num; + num = -1; + break; + case '-': + tail->reversed = !tail->reversed; + other = 1; + break; + case '(': + tail->xoff += parsedimen(&str); + if (*str++ != ',') specusage(); + tail->yoff += parsedimen(&str); + if (*str++ != ')') specusage(); + other = 1; + break; + case '+': + tail->add = 1; + case ',': + if (num < 0 || num >= Modulo) specusage(); + tail->pageno = num; + if (make) { + tail->next = newspec(); + tail = tail->next; + } + num = -1; + other = 1; + break; + default: + specusage(); + } + } + } + if (num >= Modulo) + specusage(); + else if (num >= 0) + tail->pageno = num; + return (head); +} + +i32 singledimen(str) + char *str; +{ + i32 num = parsedimen(&str); + if (*str) return (0); + return (num); +} + +/* + * Print a message to stderr, with an optional leading space, and handling + * long line wraps. + */ +void +message(space, str, len) + int space; + register char *str; + register int len; +{ + static int beenhere; + static int col; + + if (!beenhere) + space = 0, beenhere++; + if (len == 0) + len = strlen(str); + col += len; + if (space) { + if (col >= MAXCOL) + (void) putc('\n', stderr), col = len; + else + (void) putc(' ', stderr), col++; + } + while (--len >= 0) + (void) putc(*str++, stderr); + (void) fflush(stderr); +} + +/* + * Start a page (process a DVI_BOP). + */ +void +BeginPage(really) + int really; +{ + register i32 *i; + + OutputFontIndex = -1; /* new page requires respecifying font */ + for (i = Count; i < &Count[10]; i++) + fGetLong(inf, *i); + (void) GetLong(inf); /* previous page pointer */ + + if (!UseThisPage || !really) + return; + + putbyte(outf, DVI_BOP); + for (i = Count; i < &Count[10]; i++) + PutLong(outf, *i); + PutLong(outf, StartOfLastPage); + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 45; /* we just wrote this much */ + + if (!SFlag) { /* write nice page usage messages */ + register int z = 0; + register int mlen = 0; + char msg[80]; + + (void) sprintf(msg, "[%ld", (long)Count[0]); + mlen = strlen(msg); + for (i = &Count[1]; i < &Count[10]; i++) { + if (*i == 0) { + z++; + continue; + } + while (--z >= 0) + msg[mlen++] = '.', msg[mlen++] = '0'; + z = 0; + (void) sprintf(msg + mlen, ".%ld", (long)*i); + mlen += strlen(msg + mlen); + } + message(1, msg, mlen); + } +} + +/* + * End a page (process a DVI_EOP). + */ +void +EndPage(really) + int really; +{ + + if (!UseThisPage || !really) + return; + if (!SFlag) + message(0, "]", 1); + putbyte(outf, DVI_EOP); + if (ferror(outf)) + error(1, -1, writeerr); + CurrentPosition++; + NumberOfOutputPages++; +} + +/* + * For each of the fonts used in the new DVI file, write out a definition. + */ +/* ARGSUSED */ +void +PostAmbleFontEnumerator(addr, key) + char *addr; + i32 key; +{ + + if (((struct fontinfo *)addr)->fi_reallyused) + WriteFont((struct fontinfo *)addr); +} + +void +HandlePostAmble() +{ + register i32 c; + + (void) GetLong(inf); /* previous page pointer */ + if (GetLong(inf) != Numerator) + GripeMismatchedValue("numerator"); + if (GetLong(inf) != Denominator) + GripeMismatchedValue("denominator"); + if (GetLong(inf) * Magnification / 1000 != DVIMag) + GripeMismatchedValue("\\magnification"); + + putbyte(outf, DVI_POST); + PutLong(outf, StartOfLastPage); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + c = GetLong(inf); + PutLong(outf, c); /* tallest page height */ + c = GetLong(inf); + PutLong(outf, c); /* widest page width */ + c = GetWord(inf)+1; + PutWord(outf, c); /* DVI stack size */ + PutWord(outf, NumberOfOutputPages); + StartOfLastPage = CurrentPosition; /* point at post */ + CurrentPosition += 29; /* count all those `put's */ +#ifdef notdef + (void) GetWord(inf); /* skip original number of pages */ +#endif + + /* + * just ignore all the incoming font definitions; we are done with + * input file + */ + + /* + * run through the FontFinder table and dump definitions for the + * fonts we have used. + */ + SEnumerate(FontFinder, PostAmbleFontEnumerator); + + putbyte(outf, DVI_POSTPOST); + PutLong(outf, StartOfLastPage); /* actually start of postamble */ + putbyte(outf, DVI_VERSION); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + putbyte(outf, DVI_FILLER); + CurrentPosition += 10; + while (CurrentPosition & 3) { + putbyte(outf, DVI_FILLER); + CurrentPosition++; + } + if (ferror(outf)) + error(1, -1, writeerr); +} + +/* + * Write a font definition to the output file + */ +void +WriteFont(fi) + register struct fontinfo *fi; +{ + register int l; + register char *s; + + if (fi->fi_newindex < 256) { + putbyte(outf, DVI_FNTDEF1); + putbyte(outf, fi->fi_newindex); + CurrentPosition += 2; + } else if (fi->fi_newindex < 65536) { + putbyte(outf, DVI_FNTDEF2); + PutWord(outf, fi->fi_newindex); + CurrentPosition += 3; + } else if (fi->fi_newindex < 16777216) { + putbyte(outf, DVI_FNTDEF3); + Put3Byte(outf, fi->fi_newindex); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNTDEF4); + PutLong(outf, fi->fi_newindex); + CurrentPosition += 5; + } + PutLong(outf, fi->fi_checksum); + PutLong(outf, fi->fi_mag); + PutLong(outf, fi->fi_designsize); + putbyte(outf, fi->fi_n1); + putbyte(outf, fi->fi_n2); + l = fi->fi_n1 + fi->fi_n2; + CurrentPosition += 14 + l; + s = fi->fi_name; + while (--l >= 0) + putbyte(outf, *s++); +} + +/* + * Handle the preamble. Someday we should update the comment field. + */ +void +HandlePreAmble() +{ + register int n, c; + + c = getc(inf); + if (c == EOF) + GripeUnexpectedDVIEOF(); + if (c != DVI_PRE) + GripeMissingOp("PRE"); + if (getc(inf) != DVI_VERSION) + error(1, 0, "%s is not a DVI version %d file", + DVIFileName, DVI_VERSION); + Numerator = GetLong(inf); + Denominator = GetLong(inf); + DVIMag = GetLong(inf) * Magnification / 1000; + putbyte(outf, DVI_PRE); + putbyte(outf, DVI_VERSION); + PutLong(outf, Numerator); + PutLong(outf, Denominator); + PutLong(outf, DVIMag); + + n = UnSign8(GetByte(inf)); + CurrentPosition = 15 + n; /* well, almost */ + putbyte(outf, n); + while (--n >= 0) { + c = GetByte(inf); + putbyte(outf, c); + } +} + +int +main(argc, argv) + int argc; + register char **argv; +{ + register int c; + register char *s; + char *outname = NULL; + char *specstring = NULL; + + Width = 0; + Height = 0; + Magnification = 1000; + Modulo = 1; + + ProgName = *argv; + setbuf(stderr, serrbuf); + + while ((c = getopt(argc, argv, "i:o:w:h:q")) != EOF) { + switch (c) { + + case 'q': /* silent */ + SFlag++; + break; + + case 'i': + if (DVIFileName != NULL) + goto usage; + DVIFileName = optarg; + break; + + case 'o': + if (outname != NULL) + goto usage; + outname = optarg; + break; + + case 'w': + if (Width != 0) + goto usage; + Width = singledimen(optarg); + if (Width <= 0) + error(1, -1, "-w parameter must be > 0"); + break; + + case 'h': + if (Height != 0) + goto usage; + Height = singledimen(optarg); + if (Height <= 0) + error(1, -1, "-h parameter must be > 0"); + break; + + case '?': +usage: + (void) fprintf(stderr, "\ +Usage: %s [-q] [-i infile] [-o outfile] [-w width] [-h height] <pagespecs> [infile [outfile]]\n", + ProgName); + (void) fflush(stderr); + exit(1); + } + } + + while (optind < argc) { + s = argv[optind++]; + c = *s; + if (specstring == NULL) + (void) ParseSpecs((specstring = s), 0); + else if (DVIFileName == NULL) + DVIFileName = s; + else if (outname == NULL) + outname = s; + else + goto usage; + } + + if (specstring == NULL) + goto usage; + + if (DVIFileName == NULL) { + DVIFileName = "`stdin'"; + inf = stdin; + if (!isatty(fileno(inf))) + SET_BINARY(fileno(inf)); + } else if ((inf = fopen(DVIFileName, FOPEN_RBIN_MODE)) == 0) + error(1, -1, "cannot read %s", DVIFileName); + if (outname == NULL) { + outf = stdout; + if (!isatty(fileno(outf))) + SET_BINARY(fileno(outf)); + } + else if ((outf = fopen(outname, FOPEN_WBIN_MODE)) == 0) + error(1, -1, "cannot write %s", outname); + + if ((FontFinder = SCreate(sizeof(struct fontinfo))) == 0) + error(1, 0, "cannot create font finder (out of memory?)"); + + /* copy inf to TEMP file if not seekable */ + if ((inf = SeekFile(inf)) == NULL) { + error(1, 0, "can't seek file"); + } + + InputPageNumber = 0; + StartOfLastPage = -1; + HandlePreAmble(); + ScanDVIFile(); + if (fseek(inf, 16L, 1) == -1) + error(1, -1, "can't seek postamble"); + if (Height == 0) /* get height from postamble */ + Height = GetLong(inf); + else + (void) GetLong(inf); /* ignore height */ + if (Width == 0) /* get width from postamble */ + Width = GetLong(inf); + PageSpecs = ParseSpecs(specstring, 1); + + HandleDVIFile(); + HandlePostAmble(); + if (!SFlag) + (void) fprintf(stderr, "\nWrote %d page%s, %ld bytes\n", + NumberOfOutputPages, NumberOfOutputPages == 1 ? "" : "s", + (long)CurrentPosition); + return 0; +} + +/* + * Handle a font definition. + */ +void +HandleFontDef(index) + i32 index; +{ + register struct fontinfo *fi; + register int i; + register char *s; + int def = S_CREATE | S_EXCL; + + if (!UseThisPage) { + if ((fi = (struct fontinfo *)SSearch(FontFinder, index, &def)) == 0) + if (def & S_COLL) + error(1, 0, "font %ld already defined", (long)index); + else + error(1, 0, "cannot stash font %ld (out of memory?)", + (long)index); + fi->fi_reallyused = 0; + fi->fi_checksum = GetLong(inf); + fi->fi_mag = GetLong(inf); + fi->fi_designsize = GetLong(inf); + fi->fi_n1 = UnSign8(GetByte(inf)); + fi->fi_n2 = UnSign8(GetByte(inf)); + i = fi->fi_n1 + fi->fi_n2; + if ((s = malloc((unsigned)i)) == 0) + GripeOutOfMemory(i, "font name"); + fi->fi_name = s; + while (--i >= 0) + *s++ = GetByte(inf); + } else { + (void) GetLong(inf); + (void) GetLong(inf); + (void) GetLong(inf); + i = UnSign8(GetByte(inf)); + i += UnSign8(GetByte(inf)); + while (--i >= 0) + (void) GetByte(inf); + } +} + +/* + * Handle a \special. + */ +void +HandleSpecial(c, l, p) + int c; + register int l; + register i32 p; +{ + register int i; + + if (UseThisPage) { + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + break; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + break; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + break; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + break; + + default: + panic("HandleSpecial l=%d", l); + /* NOTREACHED */ + } + CurrentPosition += p; + while (--p >= 0) { + i = getc(inf); + putbyte(outf, i); + } + if (feof(inf)) + GripeUnexpectedDVIEOF(); + if (ferror(outf)) + error(1, -1, writeerr); + } else + while (--p >= 0) + (void) getc(inf); +} + +void +ReallyUseFont() +{ + register struct fontinfo *fi; + int look = S_LOOKUP; + + fi = (struct fontinfo *)SSearch(FontFinder, CurrentFontIndex, &look); + if (fi == NULL) + error(1, 0, "DVI file requested font %ld without defining it", + (long)CurrentFontIndex); + if (fi->fi_reallyused == 0) { + fi->fi_reallyused++; + fi->fi_newindex = NextOutputFontIndex++; + WriteFont(fi); + } + if (fi->fi_newindex != OutputFontIndex) { + PutFontSelector(fi->fi_newindex); + OutputFontIndex = fi->fi_newindex; + } +} + +/* + * Write a font selection command to the output file + */ +void +PutFontSelector(index) + i32 index; +{ + + if (index < 64) { + putbyte(outf, index + DVI_FNTNUM0); + CurrentPosition++; + } else if (index < 256) { + putbyte(outf, DVI_FNT1); + putbyte(outf, index); + CurrentPosition += 2; + } else if (index < 65536) { + putbyte(outf, DVI_FNT2); + PutWord(outf, index); + CurrentPosition += 3; + } else if (index < 16777216) { + putbyte(outf, DVI_FNT3); + Put3Byte(outf, index); + CurrentPosition += 4; + } else { + putbyte(outf, DVI_FNT4); + PutLong(outf, index); + CurrentPosition += 5; + } +} + +/* + * The following table describes the length (in bytes) of each of the DVI + * commands that we can simply copy, starting with DVI_SET1 (128). + */ +char oplen[128] = { + 0, 0, 0, 0, /* DVI_SET1 .. DVI_SET4 */ + 9, /* DVI_SETRULE */ + 0, 0, 0, 0, /* DVI_PUT1 .. DVI_PUT4 */ + 9, /* DVI_PUTRULE */ + 1, /* DVI_NOP */ + 0, /* DVI_BOP */ + 0, /* DVI_EOP */ + 1, /* DVI_PUSH */ + 1, /* DVI_POP */ + 2, 3, 4, 5, /* DVI_RIGHT1 .. DVI_RIGHT4 */ + 1, /* DVI_W0 */ + 2, 3, 4, 5, /* DVI_W1 .. DVI_W4 */ + 1, /* DVI_X0 */ + 2, 3, 4, 5, /* DVI_X1 .. DVI_X4 */ + 2, 3, 4, 5, /* DVI_DOWN1 .. DVI_DOWN4 */ + 1, /* DVI_Y0 */ + 2, 3, 4, 5, /* DVI_Y1 .. DVI_Y4 */ + 1, /* DVI_Z0 */ + 2, 3, 4, 5, /* DVI_Z1 .. DVI_Z4 */ + 0, /* DVI_FNTNUM0 (171) */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 172 .. 179 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 180 .. 187 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 188 .. 195 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 196 .. 203 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 204 .. 211 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 212 .. 219 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 220 .. 227 */ + 0, 0, 0, 0, 0, 0, 0, /* 228 .. 234 */ + 0, 0, 0, 0, /* DVI_FNT1 .. DVI_FNT4 */ + 0, 0, 0, 0, /* DVI_XXX1 .. DVI_XXX4 */ + 0, 0, 0, 0, /* DVI_FNTDEF1 .. DVI_FNTDEF4 */ + 0, /* DVI_PRE */ + 0, /* DVI_POST */ + 0, /* DVI_POSTPOST */ + 0, 0, 0, 0, 0, 0, /* 250 .. 255 */ +}; + +int +HandlePage(first, last, hoffset, voffset) + int first, last; + i32 hoffset, voffset; +{ + register int c, l; + register i32 p; + register int CurrentFontOK = 0; + int doingpage = 0; + + /* Only way out is via "return" statement */ + for (;;) { + c = getc(inf); /* getc() returns unsigned values */ + if (DVI_IsChar(c)) { + /* + * Copy chars, note font usage, but ignore if + * page is not interesting. + */ + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + CurrentPosition++; + continue; + } + if (DVI_IsFont(c)) { /* note font change */ + CurrentFontIndex = c - DVI_FNTNUM0; + CurrentFontOK = 0; + continue; + } + if (c == EOF) + GripeUnexpectedDVIEOF(); + if ((l = (oplen - 128)[c]) != 0) { /* simple copy */ + if (!UseThisPage) { + while (--l > 0) + (void) getc(inf); + continue; + } + CurrentPosition += l; + putbyte(outf, c); + while (--l > 0) { + c = getc(inf); + putbyte(outf, c); + } + if (ferror(outf)) + error(1, -1, writeerr); + continue; + } + if ((l = DVI_OpLen(c)) != 0) { + /* + * Handle other generics. + * N.B.: there should only be unsigned parameters + * here (save SGN4), for commands with negative + * parameters have been taken care of above. + */ + switch (l) { + + case DPL_UNS1: + p = getc(inf); + break; + + case DPL_UNS2: + fGetWord(inf, p); + break; + + case DPL_UNS3: + fGet3Byte(inf, p); + break; + + case DPL_SGN4: + fGetLong(inf, p); + break; + + default: + panic("HandleDVIFile l=%d", l); + } + + /* + * Now that we have the parameter, perform the + * command. + */ + switch (DVI_DT(c)) { + + case DT_SET: + case DT_PUT: + if (!UseThisPage) + continue; + if (!CurrentFontOK) { + ReallyUseFont(); + CurrentFontOK++; + } + putbyte(outf, c); + switch (l) { + + case DPL_UNS1: + putbyte(outf, p); + CurrentPosition += 2; + continue; + + case DPL_UNS2: + PutWord(outf, p); + CurrentPosition += 3; + continue; + + case DPL_UNS3: + Put3Byte(outf, p); + CurrentPosition += 4; + continue; + + case DPL_SGN4: + PutLong(outf, p); + CurrentPosition += 5; + continue; + } + + case DT_FNT: + CurrentFontIndex = p; + CurrentFontOK = 0; + continue; + + case DT_XXX: + HandleSpecial(c, l, p); + continue; + + case DT_FNTDEF: + HandleFontDef(p); + continue; + + default: + panic("HandleDVIFile DVI_DT(%d)=%d", + c, DVI_DT(c)); + } + continue; + } + + switch (c) { /* handle the few remaining cases */ + + case DVI_BOP: + if (doingpage) + GripeUnexpectedOp("BOP (during page)"); + BeginPage(first); + if (UseThisPage) { + if (!last) { + putbyte(outf, DVI_PUSH); + CurrentPosition++; + } + if (hoffset != 0) { + putbyte(outf, DVI_RIGHT4) ; + PutLong(outf, hoffset) ; + CurrentPosition += 5; + } + if (voffset != 0) { + putbyte(outf, DVI_DOWN4) ; + PutLong(outf, voffset) ; + CurrentPosition += 5; + } + } + doingpage = 1; + break; + + case DVI_EOP: + if (!doingpage) + GripeUnexpectedOp("EOP (outside page)"); + if (!last && UseThisPage) { + putbyte(outf, DVI_POP); + CurrentPosition++; + } + EndPage(last); + doingpage = 0; + return(1); + + case DVI_PRE: + GripeUnexpectedOp("PRE"); + /* NOTREACHED */ + + case DVI_POST: + if (doingpage) + GripeUnexpectedOp("POST (inside page)"); + return(0); + + case DVI_POSTPOST: + GripeUnexpectedOp("POSTPOST"); + /* NOTREACHED */ + + default: + GripeUndefinedOp(c); + /* NOTREACHED */ + } + } +} + +/* write an empty page to fill out space */ +void +PutEmptyPage() +{ + int i; + + putbyte(outf, DVI_BOP); + PutLong(outf, -1L); + for (i = 1; i < 10; i++) /* set all sub counts to 0 */ + PutLong(outf, 0L); + PutLong(outf, StartOfLastPage); + putbyte(outf, DVI_EOP); + if (!SFlag) { /* write nice page usage messages */ + char *msg = "[*]"; + message(1, msg, strlen(msg)); + } + if (ferror(outf)) + error(1, -1, writeerr); + + StartOfLastPage = CurrentPosition; + CurrentPosition += 46; /* we just wrote this much */ + NumberOfOutputPages++; +} + +/* + * Here we scan the input DVI file and record pointers to the pages. + */ +void +ScanDVIFile() +{ + UseThisPage = 0; + + StartOfPage[InputPageNumber] = ftell(inf); + while (HandlePage(0, 0, 0, 0)) { /* scan DVI file */ + StartOfPage[++InputPageNumber] = ftell(inf); + } +} + +/* + * Here we read the input DVI file and write relevant pages to the + * output DVI file. We also keep track of font changes, handle font + * definitions, and perform some other housekeeping. + */ +void +HandleDVIFile() +{ + int CurrentPage, ActualPage, MaxPage; + + UseThisPage = 1; + + MaxPage = ((InputPageNumber+Modulo-1)/Modulo)*Modulo; + + for (CurrentPage = 0; CurrentPage < MaxPage; CurrentPage += Modulo) { + int add_last = 0; + struct pagespec *ps; + for (ps = PageSpecs; ps != NULL; ps = ps->next) { + int add_next = ps->add; + if (ps->reversed) + ActualPage = MaxPage-CurrentPage-Modulo+ps->pageno; + else + ActualPage = CurrentPage+ps->pageno; + if (ActualPage < InputPageNumber) { + if (fseek(inf, StartOfPage[ActualPage], 0) == -1) + error(1, -1, + "can't seek page %d", ActualPage+1); + HandlePage(!add_last, !add_next, ps->xoff, ps->yoff); + } else if (!add_last && !add_next) + PutEmptyPage(); + add_last = add_next; + } + } + if (fseek(inf, StartOfPage[InputPageNumber]+1, 0) == -1) + error(1, -1, "can't seek last page"); +} diff --git a/Build/source/texk/seetexk/dvitodvi.man b/Build/source/texk/seetexk/dvitodvi.man new file mode 100644 index 00000000000..549b5a5e8c7 --- /dev/null +++ b/Build/source/texk/seetexk/dvitodvi.man @@ -0,0 +1,137 @@ +.TH DVITODVI 1 +.SH NAME +dvitodvi \- rearrange pages in a DVI file +.SH SYNOPSIS +.B dvitodvi +[ +.B \-q +] [ +.B \-i +.I infile +] [ +.B \-o +.I outfile +] +[ +.B \-w\fIwidth\fR +] +[ +.B \-h\fIheight\fR +] +.I pagespecs +[ +.I infile +[ +.I outfile +] ] +.SH DESCRIPTION +.I Dvitodvi +rearranges pages from a DVI file, creating a new DVI file. +.I Dvitodvi +can be used to perform a large number of arbitrary re-arrangements of +Documents, including arranging for printing 2-up, 4-up, booklets, reversing, +selecting front or back sides of documents, scaling, etc. +.PP +.I pagespecs +follow the syntax: +.RS +.TP 12 +.I pagespecs +.I = [modulo:][mag@]specs +.TP +.I specs +.I = spec[+specs][,specs] +.TP +.I spec +.I = [-]pageno[(xoff,yoff)] +.RE +.sp +.I modulo +is the number of pages in each block. The value of +.I modulo +should be greater than 0; the default value is 1. +The optional +.I mag +parameter adjusts the file's magnification by the magnification specified. The +magnification and modulo can be specified in reverse order if desired. +.I specs +are the page specifications for the pages in each block. The value of the +.I pageno +in each +.I spec +should be between 0 (for the first page in the block) and \fImodulo\fR-1 +(for the last page in each block) inclusive. +The optional dimensions +.I xoff +and +.I yoff +shift the page by the specified (positive) amount. +.I xoff +and +.I yoff +are in PostScript's points, but may be followed by the units +.B "cm" +or +.B "in" +to convert to centimetres or inches, or the flag +.B "w" +or +.B "h" +to specify as a multiple of the width or height. +If the optional minus sign is specified, the page is relative to the end of +the document, instead of the start. + +If page \fIspec\fRs are separated by +.B \+ +the pages will be merged into one page; if they are separated by +.B \, +they will be on separate pages. +If there is only one page specification, with +.I pageno +zero, the \fIpageno\fR may be omitted. +.PP +The +.I \-w +option gives the width which is used by the +.B "w" +dimension specifier, and the +.I \-h +option gives the height which is used by the +.B "h" +dimension specifier. These dimensions are also used (after scaling) to set the +clipping path for each page. +.PP +Dvitodvi normally prints the page numbers of the pages re-arranged; the +.I \-q +option suppresses this. +.SH EXAMPLES +This section contains some sample re-arrangements. To put two pages on one +sheet (of landscaped A3 paper), the pagespec to use is: +.sp +.ce +2:0+1(21cm,0) +.sp +To reduce an A3 page to A4 size, the pagespec to use is: +.sp +.ce +700@(-.3in,-.3in) +.sp +To select all of the odd pages in reverse order, use: +.sp +.ce +2:-0 +.sp +.SH AUTHOR +Angus Duggan, from dviselect(1), by +Chris Torek, University of Maryland +.SH "SEE ALSO" +dviconcat(1), dvibook(1), dviselect(1), latex(1), tex(1) +.br +.I "MC-TeX User's Guide" +.br +.I "The TeXbook" +.SH BUGS +.I Dvitodvi +does not adjust some of the parameters in the postamble. This may be a problem +if these values are used to size certain structures in the output +conversion programs. diff --git a/Build/source/texk/seetexk/error.c b/Build/source/texk/seetexk/error.c new file mode 100644 index 00000000000..406bf03d98d --- /dev/null +++ b/Build/source/texk/seetexk/error.c @@ -0,0 +1,188 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/error.c,v 2.8 89/08/22 21:49:12 chris Exp $"; +#endif + +/* + * Print an error message with an optional system error number, and + * optionally quit. + * + */ +#include <stdio.h> + +#include <c-auto.h> +#include "types.h" /* for HAVE_VPRINTF */ +#include "error.h" + +#if defined(lint) && !defined(LINT_ANYWAY) + +/* ARGSUSED */ +void SetErrorTrap(fn) void (*fn)(); {;} + +/* VARARGS3 ARGSUSED */ +void error(quit, e, fmt) int quit, e; char *fmt; {;} + +/* VARARGS1 ARGSUSED */ +void panic(fmt) char *fmt; { exit(1); /* NOTREACHED */ } + +#else /* lint */ + +extern char *ProgName; /* program name from argv[0] */ + +#include <errno.h> +#ifndef errno +extern int errno; +#endif + +static FILE *trap_file; /* error diversion file, if any */ +static void (*trap_fn)(); /* trap function */ +static char *trap_buf; /* buffer for trapped error strings */ +static int trap_size; /* size of trap_buf */ + +#ifndef KPATHSEA +extern char *malloc(), *realloc(); +#endif + +extern int MakeRWTempFile(); + + +#if !defined (HAVE_STRERROR) && !defined (strerror) +static char * +strerror (errnum) + int errnum; +{ + extern char *sys_errlist[]; + extern int sys_nerr; + + return 0 < errnum && errnum <= sys_nerr + ? sys_errlist[errnum] : "Unknown system error"; +} +#endif /* not HAVE_STRERROR && not strerror */ + +/* + * Read a trapped error into trap_buf. + * Return a pointer to the (NUL-terminated) text. + * If something goes wrong, return something else printable. + */ +static char * +readback() +{ + int nbytes = ftell(trap_file) + 1; + + if (nbytes > trap_size) { + if (trap_buf == NULL) + trap_buf = malloc((unsigned)nbytes); + else + trap_buf = realloc(trap_buf, (unsigned)nbytes); + if (trap_buf == NULL) { + trap_size = 0; + return ("Ouch! Lost error text: out of memory?"); + } + } + rewind(trap_file); /* now can read */ + nbytes = fread(trap_buf, 1, nbytes, trap_file); + if (nbytes < 0) + return ("Ouch! Trouble reading error text!"); + trap_buf[nbytes] = 0; + return (trap_buf); +} + +/* + * Print an error message to the error output (either stderr, or + * if trapping errors, to the error trap file). We precede this + * with the program's name and an optional string (a0), then use + * the format and variable argument list, then append an optional + * Unix error string. Finally, if errors are being trapped, we + * pass the error text and the quit flag to the trap function. + * + * In the interest of `look and feel', if errors are being trapped, + * the program name is omitted. + */ +static void +verror(quit, a0, fmt, l, e) + char *a0, *fmt; + va_list l; + int e; +{ + register FILE *fp = trap_file; + + /* print to the trap file, if any, else stderr */ + if ((fp = trap_file) != NULL) + rewind(fp); /* now can write */ + else { + fp = stderr; + (void) fflush(fp); + } + if (trap_file == NULL) + (void) fprintf(fp, "%s: ", ProgName); + if (a0) + (void) fprintf(fp, "%s", a0); + (void) vfprintf(fp, fmt, l); + if (e) + (void) fprintf(fp, ": %s", strerror(e)); + (void) putc('\n', fp); + (void) fflush(fp); + if (trap_file != NULL) + (*trap_fn)(quit, readback()); + if (quit) + exit(quit); +} + +/* + * Print an error message and optionally quit. + */ +void error PVAR3C(int, quit, int, e, const char *, fmt, l) +{ + if (e < 0) + e = errno; + verror(quit, (char *)NULL, fmt, l, e); + va_end(l); +}} +/* + * Panic (print to stderr and abort). + */ +void panic PVAR1C(const char *, fmt, l) +{ + verror(0, "panic: ", fmt, l, 0); + va_end(l); + abort(); +}} + +/* + * Enable error trapping: register the function fn as the trapper. + * If fn is NULL, stop trapping. + */ +void +SetErrorTrap(fn) + void (*fn)(int, char *); +{ + int tempfd; + char fname[BUFSIZ]; + + /* shut down any existing error trap */ + if (trap_file) { + (void) fclose(trap_file); + trap_file = NULL; + } + if ((trap_fn = fn) == NULL) + return; + /* begin trapping */ + if ((tempfd = MakeRWTempFile(fname)) < 0) + error(1, -1, "cannot create temporary file %s", fname); + if (trap_size == 0) { + trap_buf = malloc((unsigned)(trap_size = 1000)); + if (trap_buf == 0) + error(1, -1, + "cannot get space for error buffer"); + } + if ((trap_file = fdopen(tempfd, "r+")) == NULL) + error(1, -1, "cannot get stdio file for error trap"); +} + +#endif /* lint */ diff --git a/Build/source/texk/seetexk/error.h b/Build/source/texk/seetexk/error.h new file mode 100644 index 00000000000..58491f8ae43 --- /dev/null +++ b/Build/source/texk/seetexk/error.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Errors. + */ + +#include <kpathsea/config.h> +#include <kpathsea/c-vararg.h> + +void error PVAR3H(int quit, int e, const char *fmt); +void panic PVAR1H(const char *fmt); + +void SetErrorTrap(void (*fn)(int quit, char *text)); diff --git a/Build/source/texk/seetexk/findpost.c b/Build/source/texk/seetexk/findpost.c new file mode 100644 index 00000000000..2f2f8d99303 --- /dev/null +++ b/Build/source/texk/seetexk/findpost.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/findpost.c,v 2.3 89/08/22 21:50:11 chris Exp $"; +#endif + +/* + * FindPostAmble - Find the postamble of a DVI file. + * + * N.B.: This routine assumes that ftell() returns byte offsets, + * not magic cookies. + */ + +#include <stdio.h> +#include "types.h" +#include "dvicodes.h" +#include "fio.h" +#include "num.h" + +/* + * The end of the file consists of a four-byte postamble pointer, + * followed by the DVI_VERSION byte, followed by at least four + * bytes of DVI_FILLER, and at least enough bytes to make the file + * size a multiple of four. Normally, this would be between 4 and 7 + * inclusive, but some versions of TeX append huge amounts of padding. + */ +#define POSTSIZE 512 /* how many bytes to read at a time */ + +#ifndef WIN32 +long ftell(); /* should be declared in stdio.h */ +#endif + +FindPostAmble(f) + register FILE *f; +{ + register long offset; + register char *p; + register int i; + register i32 n; + char postbuf[POSTSIZE]; + + /* + * Working backwards from end-of-file, read POSTSIZE bytes. + * Keep looking until we find something or run out of filler. + */ + fseek(f, 0L, 2); + offset = ftell(f); + do { + if ((offset -= POSTSIZE) < 0L) + offset = 0L; /* no negative fseeks please */ + fseek(f, offset, 0); + if ((i = fread(postbuf, sizeof(char), POSTSIZE, f)) <= 0) + break; + for (p = postbuf + i; --i >= 0;) + if (UnSign8(*--p) != DVI_FILLER) + goto found_something; + } while (offset); + return (-1); /* ran out of filler: not a DVI file */ + + /* + * We found something other than a filler byte at *p (which is + * the same as postbuf[i]). It had better be a version byte. + * If so, we want to start at the byte four bytes before that, + * and get one long; that will tell us where the postamble + * begins. + */ +found_something: + if (UnSign8(*p) != DVI_VERSION) + return (-1); /* not a DVI file */ + if ((i -= 4) >= 0) { + /* it is in the buffer, so just fish it out */ + p -= 4; + pGetLong(p, n); + } else { + if ((offset += i) < 0L) + return (-1); /* tsk */ + fseek(f, offset, 0); + fGetLong(f, n); + } + offset = n; + fseek(f, offset, 0); + return (0); /* success */ +} diff --git a/Build/source/texk/seetexk/fio.c b/Build/source/texk/seetexk/fio.c new file mode 100644 index 00000000000..b4ccf8974c1 --- /dev/null +++ b/Build/source/texk/seetexk/fio.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/fio.c,v 2.4 89/08/22 21:50:31 chris Exp $"; +#endif + +/* + * File I/O subroutines for getting bytes, words, 3bytes, and longwords. + * N.B.: these believe they are working on a DVI file. + */ + +#include <stdio.h> +#include "types.h" +#include "error.h" +#include "fio.h" + +static char eofmsg[] = "unexpected EOF, help"; + +/* for symmetry: */ +#define fGetByte(fp, r) ((r) = getc(fp)) +#define Sign32(i) (i) + +#define make(name, func, signextend) \ +i32 \ +name(fp) \ + register FILE *fp; \ +{ \ + register i32 n; \ + \ + func(fp, n); \ + if (feof(fp)) \ + error(1, 0, eofmsg); \ + return (signextend(n)); \ +} + +make(GetByte, fGetByte, Sign8) +make(GetWord, fGetWord, Sign16) +make(Get3Byte, fGet3Byte, Sign24) +make(GetLong, fGetLong, Sign32) diff --git a/Build/source/texk/seetexk/fio.h b/Build/source/texk/seetexk/fio.h new file mode 100644 index 00000000000..53f2ef8ca81 --- /dev/null +++ b/Build/source/texk/seetexk/fio.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * File I/O: numbers. + * + * We deal in fixed format numbers and (FILE *)s here. + * For pointer I/O, see pio.h. + * + * N.B.: These do the `wrong thing' at EOF. It is imperative + * that the caller add appropriate `if (feof(fp))' statements. + */ + +/* + * Get one unsigned byte. Note that this is a proper expression. + * The reset have more limited contexts, and are therefore OddLy + * CapItaliseD. + */ +#define fgetbyte(fp) getc(fp) + +/* + * Get a two-byte unsigned integer, a three-byte unsigned integer, + * or a four-byte signed integer. + */ +#define fGetWord(fp, r) ((r) = getc(fp) << 8, (r) |= getc(fp)) +#define fGet3Byte(fp,r) ((r) = getc(fp) << 16, (r) |= getc(fp) << 8, \ + (r) |= getc(fp)) +#define fGetLong(fp, r) ((r) = getc(fp) << 24, (r) |= getc(fp) << 16, \ + (r) |= getc(fp) << 8, (r) |= getc(fp)) + +/* + * Fast I/O write (and regular write) macros. + */ +#define putbyte(fp, r) ((void) putc((r), fp)) + +#define PutWord(fp, r) ((void) putc((r) >> 8, fp), \ + (void) putc((r), fp)) +#define Put3Byte(fp, r) ((void) putc((r) >> 16, fp), \ + (void) putc((r) >> 8, fp), \ + (void) putc((r), fp)) +#define PutLong(fp, r) ((void) putc((r) >> 24, fp), \ + (void) putc((r) >> 16, fp), \ + (void) putc((r) >> 8, fp), \ + (void) putc((r), fp)) + +/* + * Function types + */ +i32 GetByte(), GetWord(), Get3Byte(), GetLong(); diff --git a/Build/source/texk/seetexk/font.c b/Build/source/texk/seetexk/font.c new file mode 100644 index 00000000000..dbaee944e4a --- /dev/null +++ b/Build/source/texk/seetexk/font.c @@ -0,0 +1,562 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /homes/grunwald/Src/SeeTeX/libtex/RCS/font.c,v 1.2 1992/07/22 16:26:02 grunwald Exp grunwald $"; +#endif + +/* + * Routines for working with fonts. In particular, the configuration + * dependent code is here. + * + * Specific fonts (GF, PXL, etc.) have functions in separate files. + */ + +#include <stdio.h> +#include <errno.h> +#include <ctype.h> +#include "types.h" +#include "conv.h" +#include "error.h" +#include "font.h" + +/* + * Define the default configuration file. + * Also define the maximum path name length. + */ +#ifndef FONTDESC +/* #define FONTDESC "/usr/local/lib/tex/fontdesc" */ + you must define FONTDESC in the Makefile +#endif + +#define PATHLEN 1024 + +/* + * A font configuration. The font list is ordered. + * + * A specifier is typically a particular print engine, since + * different engines need slightly different fonts. + */ +struct fontconf { + struct fontconf *fc_next; + struct fontops *fc_ops; + char *fc_path; /* path, with metacharacters */ + char *fc_spec; /* specifier */ + int fc_slop; /* slop value */ +}; + +/* + * EQ is a fast way to check for string equivalence. + */ +#define EQ(a, b) (*(a) == *(b) && strcmp(a, b) == 0) + +/* + * Private variables and functions. + */ +static int didinit; /* true => initialised already */ +static char *cfname; /* config file name, for errors */ +static int cfline; /* config file line, likewise */ +static struct fontops *fontops;/* font operations code: list head */ +static struct fontconf *fonts; /* font list */ +static struct fontconf **nextfc;/* used during initialisation */ +static char spec_any[] = "*"; /* the `anything' specifier */ + +static void readconf(), badcf(), setfenv(), setfont(); +static struct font *getafont(); + +/* + * Imports. + */ +extern int errno; +char *getenv(), *malloc(), *strncpy(), *strsave(); + +/* + * You may get warnings from lint about sprintf(), which is of type + * `char *' in early 4BSD releases. Ignore the warning. + */ + +/* + * Here, alas, we know about all the kinds of fonts. + * This also means that every DVI interpreter pulls in + * the full set of font manipulation routines. + * + * PERHAPS THIS SHOULD BE CONFIGURABLE. + */ +#define ADDFONT(x) { \ + extern struct fontops x; \ + x.fo_next = fontops; \ + fontops = &x; \ +} + +void +fontinit(file) + char *file; +{ + + if (didinit) { + /* + * Could free the old configuration and fire up + * a new one, but for now . . . + */ + error(1, 0, "attempt to reinit fonts"); + /* NOTREACHED */ + } + didinit++; + ADDFONT(invisops); + ADDFONT(tfmops); + ADDFONT(blankops); + ADDFONT(boxops); + ADDFONT(pxlops); + ADDFONT(gfops); + ADDFONT(pkops); + nextfc = &fonts; + if (file == NULL) + if ((file = getenv(CONFENV)) == NULL) + file = FONTDESC; + readconf(file); +} + +/* + * Find a font's operations, given its name. + */ +static struct fontops * +findops(name) + register char *name; +{ + register struct fontops *fo; + + for (fo = fontops; fo != NULL; fo = fo->fo_next) + if (EQ(fo->fo_name, name)) + return (fo); + return (NULL); +} + +/* + * Read the named configuration file. The file is split into + * lines, and lines are split into words; if the first word is + * "font", this is a fontconf, and we read the remainder of the + * words and make a fontconf entry. + */ +static void +readconf(name) + char *name; +{ + register FILE *f; /* config file */ + register int c; /* char and word counter */ + int isenv; /* true => doing `fontenv', not `font' */ + char *env; /* value from getenv() */ + struct fontconf proto; /* prototype fontconf */ + char *v[20]; /* word vector */ + char line[BUFSIZ]; /* input line */ + + if ((f = fopen(name, "r")) == NULL) + error(1, -1, "cannot read font configuration file \"%s\"", + name); + cfname = name; + cfline = 0; + while (fgets(line, sizeof (line), f) != NULL) { + cfline++; + if ((c = strlen(line)) > 0) { + if (line[--c] != '\n') + badcf("line too long"); + line[c] = 0; + } + if ((c = split(line, v, sizeof v / sizeof *v)) < 0) + badcf("too many words"); + /* skip things that are not fonts */ + if (c == 0) + continue; + if (EQ(v[0], "font")) + isenv = 0; + else if (EQ(v[0], "fontenv")) + isenv = 1; + else + continue; + switch (c) { + case 1: + badcf("missing font typename"); + /* NOTREACHED */ + case 2: + badcf("missing font spec (engine)"); + /* NOTREACHED */ + case 3: + badcf("missing slop value"); + /* NOTREACHED */ + case 4: + badcf(isenv ? "need environment variable" : + "need pathname"); + /* NOTREACHED */ + case 5: + if (isenv) + badcf("need suffix"); + break; + case 6: + if (isenv) + break; + default: + error(0, 0, + "%s, line %d: warning: %d extra word(s) ignored", + cfname, cfline, c - 5); + break; + } + if ((proto.fc_ops = findops(v[1])) == NULL) { + error(0, 0, + "\"%s\", line %d: unknown font type \"%s\" ignored", + cfname, cfline, v[1]); + continue; + } + + /* + * For fontenv, if the environment variable is not actually + * set in the environment, just skip over this line. + */ + + /* Debugging (LOG) */ + printf(" texsunLOG: "); + printf(v[0]); + printf(" ."); + printf(v[1]); + printf(" "); + if (isenv) + printf("'"); + printf(v[4]); + if (isenv) + printf("'"); + printf(" does:\n"); + + if (isenv && (env = getenv(v[4])) == NULL) + continue; + proto.fc_next = NULL; + proto.fc_spec = EQ(v[2], spec_any) ? NULL : strsave(v[2]); + proto.fc_slop = atoi(v[3]); + if (proto.fc_slop < 0) /* quietly enforce proper slops */ + proto.fc_slop = 0; + if (isenv) { + printf(" = "); + printf(env); + printf("\n"); + setfenv(&proto, env, v[5]); + } + else + setfont(&proto, strsave(v[4])); + } +} + +/* + * Handle fontenv lines by appending as many configuration entries + * as there are components in the given environment variable. + */ +static void +setfenv(pfc, env, suf) + struct fontconf *pfc; + char *env, *suf; +{ + register char *s, *t; + register int len, suflen = strlen(suf); + register char *mem, *slash; + char *munch = strsave(env); /* a copy we can write on */ + struct fontops *fo; + + /* + * Loop over the path. Turn `foo' into `foo/<suf1><suf2>'; + * turn an empty string into just <suf1><suf2>. Put these + * names in fresh memory and set them up as places to search. + */ + + for (s = munch; (t = s) != NULL; s = t) { + for (;;) { + if (*t == ':') { + *t++ = 0; + len = t - s; /* includes trailing NUL */ + break; + } + if (*t++ == 0) { + len = t - s; /* includes trailing NUL */ + t = NULL; + break; + } + } + if (len != 0) { + slash = "/"; + len++; + } else + slash = ""; + if ((mem = malloc(len + suflen)) == NULL) + error(1, -1, "out of memory while saving $%s", env); + (void) sprintf(mem, "%s%s%s", s, slash, suf); + setfont(pfc, mem); + } + free(munch); +} + +/* + * Turn a prototype fontconf into a real one. + */ +static void +setfont(pfc, path) + struct fontconf *pfc; + char *path; +{ + register struct fontconf *fc; + + if ((fc = (struct fontconf *)malloc(sizeof(*fc))) == NULL) + error(1, -1, "out of memory for font configuration (sorry)"); + *fc = *pfc; + fc->fc_path = path; + *nextfc = fc; + nextfc = &fc->fc_next; + + printf(" texsunLOG: scanning "); + printf(path); + printf("\n"); + /* message for found path (logging) */ +} + +/* + * Complain about a problem in the configuration file. + */ +static void +badcf(why) + char *why; +{ + + error(1, 0, "\"%s\", line %d: %s", cfname, cfline, why); + /* NOTREACHED */ +} + +/* + * Copy string s into buffer buf, dropping off any numerical suffix. + * E.g., cmr7 and cmr10 become cmr. (This is the `%b' operator.) + */ +static void +basify(s, buf, size) + char *s, *buf; + int size; +{ + register char *p, *endp; + register int n; + + for (p = s; *p; p++) + if (!isdigit(*p)) + endp = p; + if ((n = endp + 1 - s) >= size) + error(1, 0, "font name `%s' too long for %%b (sorry)", s); + (void) strncpy(buf, s, n); + buf[n] = 0; +} + +/* + * Turn a prototype path, name, and magnification into a full + * path (expand %f, %m, %b). + */ +static void +pave(result, proto, name, mag) + char *result, *proto, *name; + int mag; +{ + register int c; + register char *s, *d, *p; + char num[30], fontbase[256]; + + d = result; + p = proto; + s = NULL; + num[0] = 0; /* will need changing for other bases */ + fontbase[0] = 0; + + while (p != NULL) { + /* + * If sourcing from s, take its next character, and + * insert it directly. Otherwise take the next path + * character and interpret it. + */ + if (s != NULL) { + if ((c = *s++) == 0) { + s = NULL; + continue; + } + goto put; + } + if ((c = *p++) == 0) + p = NULL; + if (c != '%') + goto put; + + switch (c = *p++) { + + case 'b': + if (fontbase[0] == 0) + basify(name, fontbase, sizeof(fontbase)); + s = fontbase; + continue; + + case 'f': + case 'n': + case 's': + s = name; + continue; + + case 'd': + case 'm': + if (num[0] == 0) + (void) sprintf(num, "%d", mag); + s = num; + continue; + + case 0: + c = '%'; + p--; + /* FALLTHROUGH */ + } +put: + if (d - result >= PATHLEN) + error(1, 0, "font path `%s' too long (sorry)", proto); + *d++ = c; + } +} + +/* + * Given a font name and size, return the first font that fits, along + * with its name (via fname). If we cannot find such a font, we set + * *fname to point to a `canonical' example font name, unless there are + * are no fonts for the device, in which case we set *fname to NULL. + */ +struct font * +GetFont(nm, dvimag, dvidsz, dev, fname) + char *nm; + i32 dvimag, dvidsz; + char *dev, **fname; +{ + + return (getafont(nm, dvimag, dvidsz, dev, fname, 1)); +} + +/* + * Same as GetFont, but caller promises never to ask for rasters. + */ +struct font * +GetRasterlessFont(nm, dvimag, dvidsz, dev, fname) + char *nm; + i32 dvimag, dvidsz; + char *dev, **fname; +{ + + return (getafont(nm, dvimag, dvidsz, dev, fname, 0)); +} + +/* + * NEED TO THINK ABOUT gf NAMING CONVENTIONS HERE: ARE THEY LIKE pxl? + * WHAT ABOUT OTHERS? + */ +static struct font * +getafont(nm, dvimag, dvidsz, dev, fname, wantrast) + char *nm; + i32 dvimag, dvidsz; + char *dev, **fname; + int wantrast; +{ + register int slop, fmag; + register struct font *f; + register struct fontconf *fc; + register struct fontops *fo; + register char *path; + int fd, scaled; + double mag; + static char firstpath[PATHLEN], laterpath[PATHLEN]; + + if (!didinit) + fontinit((char *)NULL); + + /* + * The equation below means, approximately, `the font is + * magnified by the ratio of the actual size dvimag to the + * design size dvidsz, and then further scaled by the + * global magnification.' We multiply this by the printer's + * resolution in dots per inch, then use the per-font + * conversion factor to convert a dots-per-inch value to + * a font name `%m' magnification (extension). + */ + mag = (double) dvimag / (double) dvidsz; + scaled = mag * 1000.0 + 0.5; + mag *= Conversion.c_mag * Conversion.c_dpi; + + path = firstpath; /* no canonical font name yet */ + for (fc = fonts; fc != NULL; fc = fc->fc_next) { + if (dev != NULL && fc->fc_spec != NULL && + !EQ(dev, fc->fc_spec)) + continue; + /* + * Fake fonts are ignored unless there is already + * `canonical' real font. The first non-fake font + * is the `canonical' one. + */ + fo = fc->fc_ops; + if (path == firstpath && fo->fo_fakefont) + continue; + fmag = mag * fo->fo_dpitomag + 0.5; + for (slop = 0; slop <= fc->fc_slop; slop++) { + pave(path, fc->fc_path, nm, fmag + slop); + if ((fd = open(path, 0)) >= 0) + goto found; + path = laterpath; /* tried at least one now */ + if (slop) { + pave(path, fc->fc_path, nm, fmag - slop); + if ((fd = open(path, 0)) >= 0) + goto found; + } + } + } + + /* not found */ + if (path == firstpath) { + *fname = NULL; + errno = ENXIO; + } else { + *fname = firstpath; + errno = ENOENT; + } + return (NULL); + +found: + *fname = path; + + /* allocate space for the per-font info, and read it in */ + f = (struct font *)malloc(sizeof *f); + if (f == NULL) { + errno = ENOMEM; + return (NULL); + } + f->f_flags = wantrast ? FF_RASTERS : 0; + f->f_ops = fc->fc_ops; + f->f_path = strsave(path); + f->f_font = strsave(nm); + f->f_dvimag = dvimag; + f->f_dvidsz = dvidsz; + f->f_scaled = scaled; + f->f_pspace = f->f_dvimag / 6; /* a three-unit "thin space" */ + f->f_nspace = -4 * f->f_pspace; + f->f_vspace = 5 * f->f_pspace; + errno = 0; + if ((*f->f_ops->fo_read)(f, fd)) { + int e = errno; /* paranoid */ + + free(f->f_path); + free(f->f_font); + free((char *)f); + errno = e; + return (NULL); + } + if (f->f_ops->fo_fakefont) { + error(0, 0, "Warning: no font for %s", Font_TeXName(f)); + if (firstpath[0]) + error(0, 0, "(wanted, e.g., \"%s\")", firstpath); + error(0, 0, "I will substitute %s for the missing glyphs", + f->f_ops->fo_fakefont == 1 ? "boxes" : "white space"); + } + return (f); +} + diff --git a/Build/source/texk/seetexk/font.h b/Build/source/texk/seetexk/font.h new file mode 100644 index 00000000000..2998bcf50b6 --- /dev/null +++ b/Build/source/texk/seetexk/font.h @@ -0,0 +1,301 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Font file information, readers, etc. + */ + +#ifndef _MCTEX_TYPES_ +#include "types.h" +#endif + +/* + * First, font independent information: per glyph info, and per font + * info. + */ +struct glyph { + short g_flags; /* see below */ + /* + * The following cannot be used with GetRasterlessFont + */ + short g_rotation; /* see below */ + char *g_raster; /* raster, if known */ + /* + * These, however, do come with rasterless fonts, + * even though they relate only to the raster. + */ + i32 g_height; /* height of bounding box */ + i32 g_width; /* width of bounding box */ + i32 g_yorigin; /* y origin (>= 0 -> within box) */ + i32 g_xorigin; /* x origin (>= 0 -> within box) */ + /* + * These of course come with every font. + */ + i32 g_rawtfmwidth; /* raw TFM width (in FIXes) */ + i32 g_tfmwidth; /* TFM width in scaled points */ + /* + * The X and Y escapements come from PK and GF fonts. + * They are in scaled pixels (65536 scaled pixels = 1 pixel). + * If they are not defined by the font, these are set to + * NO_ESCAPEMENT. + */ + i32 g_xescapement; /* x escapement (`chardx') */ + i32 g_yescapement; /* y escapement (`chardy') */ +#define NO_ESCAPEMENT ((i32)0x89abcdef) + /* + * This is provided purely for DVI to device conversion programs. + */ + int g_pixwidth; /* width in pixels */ + /* + * Mainly for internal use, index is the glyph index within the + * font. That is, f->f_gly[i]->g_index == i. + */ + int g_index; /* character index */ + /* + * g_details and g_integer are purely for the font reading + * subroutines to use however they will. g_next makes lists + * of glyphs while the glyphs are free. + */ + union { /* various options */ + char *g_details; /* details: arbitrary */ + i32 g_integer; /* 32 bit integer */ + struct glyph *g_next; /* linked list */ + } g_un; +}; + +/* + * Glyph flags. + */ +#define GF_VALID 0x0001 /* glyph is `real' */ +#define GF_SEEN 0x0002 /* glyph has been encountered/loaded */ + +#define GF_USR0 0x0100 /* reserved to user code */ +#define GF_USR1 0x0200 /* reserved to user code */ +#define GF_USR2 0x0400 /* reserved to user code */ +#define GF_USR3 0x0800 /* reserved to user code */ + +/* + * Rotations are in quarter-pi steps, counterclockwise of course. + * This order must be maintained; see rotate.c. + */ +#define ROT_NORM 0 /* no rotation: `normal' position */ +#define ROT_LEFT 1 /* 1/4 turn counterclockwise */ +#define ROT_DOWN 2 /* 1/2 turn, i.e., upside-down */ +#define ROT_RIGHT 3 /* 3/4 turn ccw, or 1/4 turn cw */ + +struct font { + int f_flags; /* see below */ + struct fontops *f_ops; /* operations */ + /* + * f_un is provided for DVI drivers, which typically need + * some way to translate DVI font numbers into local values. + * Most seem to need integers. + */ + union { + int f_int; /* value if int */ + i32 f_i32; /* value if i32 */ + char *f_ptr; /* value if pointer */ + } f_un; +#ifdef notdef + /* for LRU cacheing; not yet implemented */ + i32 f_lastuse; +#endif + /* + * f_details is provided for font reading subroutines. + * It is intended to be cast to a pointer to a structure + * that is allocated by those routines, and used to keep + * track of whatever information those routines need to + * determine glyph boxes and (if asked for) rasters. + */ + char *f_details; /* type dependent stuff */ + /* + * f_path is the full pathname to the font file, filled in + * by GetFont and GetRasterlessFont. Note that since we + * hold on to the path until the font is freed, it should be + * possible to cache glyph accesses on memory-poor machines. + */ + char *f_path; /* font file pathname */ + /* + * f_dvimag and f_dvidsz are the magnification and design size + * values from the DVI file. f_font and f_scaled correspond to + * TeX's idea of the proper name for the font (e.g., `cmr10', + * `cmbx10 scaled 1440'). (Note that f_scaled is just the + * ratio of f_dvimag and f_dvidsz; you could save a bit of memory + * by eliminating it and altering the routine Font_TeXName()). + * f_design_size is the font's design size, or 0 for fake (TFM) + * fonts. f_checksum should be set by the font reading routines + * to the font checksum. If the value is nonzero, it will be + * compared to the checksum in the DVI file. + */ + i32 f_dvimag; /* magnification from DVI file */ + i32 f_dvidsz; /* design size from DVI file */ + char *f_font; /* TeX's name for the font */ + int f_scaled; /* the ratio of dvimag to dvidsz, x1000 */ + i32 f_design_size; /* font design size */ + i32 f_checksum; /* font checksum, or 0 */ + /* + * The three values f_pspace, f_nspace, and f_vspace correspond + * to the amount of positive, negative, and vertical space that + * limits `kerning' (if horizontal) or `in-line motion' (vertical). + * f_pspace is equal to 1/6 of f_dvimag, and f_nspace and f_vspace + * are -4 and 5 times this value respectively. DVItype puts it + * this way (slightly edited): + * + * Rounding to the nearest pixel is best done in [this] + * manner ... so as to be inoffensive to the eye: When [a] + * horizontal motion is small, like a kern, [the device + * position] changes by rounding the kern; but when the + * motion is large, [the device position] changes by rounding + * the [DVI position] so that accumulated rounding errors + * disappear. We allow a larger space in the negative + * direction than in the positive one, because TeX makes + * comparatively large backspaces when it positions accents. + * + * Vertical motion is done similarly, but with the threshold + * between ``small'' and ``large'' increased by a factor of + * five. The idea is to make fractions like ``$1\over2$'' + * round consistently, but to absorb accumulated rounding + * errors in the baseline-skip moves. + * + * There is, however, an exception: + * + * A sequence of consecutive rules, or consecutive characters + * in a fixed-width font whose width is not an integer number + * of pixels, can cause [the device position] to drift far + * away from a correctly rounded value. + * + * The drift correction is applied after every horizontal or + * vertical motion, including any resulting from printing a + * character. + */ + i32 f_pspace; /* limit on positive kerns */ + i32 f_nspace; /* limit on negative kerns */ + i32 f_vspace; /* limit on vertical `kerns' */ + + /* + * If set, f_hppp and f_vppp tell how many pixels there are + * per scaled point in the font. For instance, a 300 dpi font + * has 300pixels/1inch * 1inch/72.27pt * 65536pt/1sp ~= + * 272046 pixels/sp. + * + * If they are zero, the font does not tell us. + */ + i32 f_hppp; /* horizontal pixels per point */ + i32 f_vppp; /* vertical pixels per point */ + /* + * f_lowch and f_highch bound the region in which f_gly + * indicies are valid. Specificially, f_gly[i] may be + * read or written if and only if i is in the half-open + * interval [f_lowch..f_highch). f_gly is an array of + * pointers to glyph structures. The structures themselves + * are not allocated until requested. + * + * f_glybase is the actual return from malloc(), since it + * is theoretically possible for f_gly-f_lowch to become + * NULL. + */ + int f_lowch; /* first character */ + int f_highch; /* last character, plus 1 */ + struct glyph **f_gly; /* glyphs */ + struct glyph **f_glybase; +}; + +/* + * Macros for rounding DVI and device motions per DVItype rules. + */ +#define F_SMALLH(f, m) ((m) < (f)->f_pspace && (m) > (f)->f_nspace) +#define F_SMALLV(f, m) ((m) < (f)->f_vspace && -(m) < (f)->f_vspace) + +/* + * Font flags. + */ +#define FF_RASTERS 0x0001 /* font has rasters */ +#define FF_USR0 0x0100 /* reserved to user code */ +#define FF_USR1 0x0200 /* reserved to user code */ +#define FF_USR2 0x0400 /* reserved to user code */ +#define FF_USR3 0x0800 /* reserved to user code */ + +/* + * Operations on fonts. + * + * The `fo_dpitomag' field is used as a multiplier for a desired + * resolution in dots per inch. The result of the multiplication + * is converted to a font name by multipying by 1000.0 and rounding. + * The idea is that PXL files will have a multiplier of 5.0, and + * others will have a multiplier of 1.0. This suffices for the + * present, at any rate; in the future, this field may be replaced + * with something more general. + * + * N.B.: more operations may be added as they are discovered to be + * useful. + */ +struct fontops { + char *fo_name; /* name, e.g., "gf" */ + int fo_fakefont; /* 1="box", 2="blank"; else 0 */ + double fo_dpitomag; /* multiplier */ + int (*fo_read)(); /* open and read the font itself */ + int (*fo_getgly)(); /* obtain specified glyphs (range) */ +#ifdef notdef + void (*fo_freegly)(); /* release specified glyphs */ +#endif + int (*fo_rasterise)(); /* rasterise specified glyphs */ + void (*fo_freefont)(); /* discard font (free details) */ + struct fontops *fo_next; /* purely for font.c */ +}; + +/* + * Return a pointer to the glyph information for character `c' in + * font `f'. + */ +#define GLYPH(f, c) \ + ((c) < (f)->f_lowch || (c) >= (f)->f_highch ? (struct glyph *)0 : \ + ((f)->f_gly[c] ? (f)->f_gly[c] : GetGlyph(f, (int)(c)))) + +/* + * True iff glyph `g' is valid. Useful for checking return values + * from GLYPH(). + */ +#define GVALID(g) ((g) && ((g)->g_flags & GF_VALID)) + +/* + * True iff glyph g has a raster. + */ +#define HASRASTER(g) ((g)->g_height && (g)->g_width) + +/* + * Return a pointer to the raster information for glyph `g' in font + * `f' at rotation `r'. + */ +#define RASTER(g, f, r) ((g)->g_rotation == (r) && (g)->g_raster ? \ + (g)->g_raster : GetRaster(g, f, r)) + +/* + * Function types. + */ +struct font *GetFont(), *GetRasterlessFont(); +struct glyph *GetGlyph(); +char *GetRaster(); +void FreeFont(); +void FreeGlyph(); +void FreeRaster(); +char *Font_TeXName(); +double DMagFactor(); /* from magfactor.c */ +void fontinit(); + +/* + * Normally from stdio.h + */ +#ifndef NULL +#define NULL 0 +#endif + +/* + * The following environment variable overrides the default font + * configuration file. That default is used when fontinit() is not + * called, or is passed a null pointer. + */ +#define CONFENV "TEXFONTDESC" diff --git a/Build/source/texk/seetexk/font_subr.c b/Build/source/texk/seetexk/font_subr.c new file mode 100644 index 00000000000..1d8f698d1d6 --- /dev/null +++ b/Build/source/texk/seetexk/font_subr.c @@ -0,0 +1,253 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/font_subr.c,v 2.8 89/10/30 04:08:52 chris Exp $"; +#endif + +/* + * Subroutines common to all fonts. + */ + +#include "types.h" +#include "error.h" +#include "font.h" + +static struct glyph *freeglyphs; + +#if !defined( WIN32 ) && !defined( _AMIGA ) +char *malloc(); +extern errno; +#endif + +/* + * Set up the font structures to note that a font has glyphs in + * the half-open interval [low, high). + * + * SHOULD I ALLOW ADDITIONS TO THE RANGE VIA SUBSEQUENT CALLS TO + * FontHasGlyphs? + */ +FontHasGlyphs(f, low, high) + register struct font *f; + register int low, high; +{ + register struct glyph **gp; + + /* record bounds */ + f->f_lowch = low; + f->f_highch = high; + + /* + * Allocate space for all the glyph pointers, and set + * them all to NULL. + */ + if (low >= high) /* no glyphs */ + gp = NULL; + else { + gp = (struct glyph **) malloc((unsigned) (high - low) * + sizeof (*gp)); + if (gp == NULL) + return (-1); + } + f->f_glybase = gp; + f->f_gly = gp - low; + while (++low <= high) + *gp++ = NULL; + return (0); +} + +/* + * AllocGlyph allocates a new glyph. ReleaseGlyph puts one onto the free + * list. We maintain a local list of free glyphs. + */ +#define ReleaseGlyph(g) \ + ((g)->g_un.g_next = freeglyphs, freeglyphs = (g)) + +static struct glyph * +AllocGlyph(n) + int n; +{ + register struct glyph *g; + register int i; + + if ((g = freeglyphs) == NULL) { + g = (struct glyph *) malloc((unsigned) (128 * sizeof (*g))); + if (g == NULL) + error(1, errno, "out of glyph memory"); + g += (i = 128); + while (--i >= 0) { + g--; + ReleaseGlyph(g); + } + } + freeglyphs = g->g_un.g_next; + g->g_flags = 0; + g->g_raster = NULL; + g->g_index = n; + g->g_xescapement = NO_ESCAPEMENT;/* default, if not set by font */ + g->g_yescapement = NO_ESCAPEMENT; + return (g); +} + +/* + * Free one glyph. + */ +void +FreeGlyph(f, g) + struct font *f; + register struct glyph *g; +{ + int n = g->g_index; + +#ifdef notdef + (*f->f_ops->fo_freegly)(f, n, n); +#endif + if (g->g_raster != NULL) + free(g->g_raster); + ReleaseGlyph(g); + f->f_gly[n] = NULL; +} + +/* + * Free a font. + */ +void +FreeFont(f) + register struct font *f; +{ + register struct glyph *g; + register int i; + +#ifdef notdef + (*f->f_ops->fo_freegly)(f, f->f_lowch, f->f_highch); +#endif + for (i = f->f_lowch; i < f->f_highch; i++) { + if ((g = f->f_gly[i]) == NULL) + continue; + if (g->g_raster != NULL) + free(g->g_raster); + ReleaseGlyph(g); + } + if (f->f_glybase != NULL) + free((char *)f->f_glybase); + (*f->f_ops->fo_freefont)(f); + free(f->f_path); + free(f->f_font); + free((char *)f); +} + +/* + * Get glyph `c' in font `f'. We pull in a few adjacent glyphs here + * under the (perhaps naive) assumption that things will go faster + * that way. + * + * TODO: + * try different adjacency values + * make adjacency a font attribute? (or an op) + */ +#define ADJ 4 /* must be a power of 2 */ +#define GET_ADJ(c, l, h) ((h) = ADJ + ((l) = (c) & ~(ADJ - 1))) + +struct glyph * +GetGlyph(f, c) + register struct font *f; + int c; +{ + register int i, h, l; + + GET_ADJ(c, l, h); + if (l < f->f_lowch) + l = f->f_lowch; + if (h > f->f_highch) + h = f->f_highch; + if (l >= h) + return (NULL); + for (i = l; i < h; i++) + if (f->f_gly[i] == NULL) + f->f_gly[i] = AllocGlyph(i); + + if ((*f->f_ops->fo_getgly)(f, l, h)) { + /* + * I do not know what to do about this just yet, so: + */ + panic("getgly fails and I am confused ... help!"); + } + + /* + * Apply the appropriate scale factor to the TFM widths. + * This makes them come out in scaled points, instead of FIXes. + */ + ScaleGlyphs(f, l, h); /* ??? */ + + return (f->f_gly[c]); +} + +/* + * Get the raster for glyph g in font f at rotation r. + */ +char * +GetRaster(g, f, r) + register struct glyph *g; + register struct font *f; + int r; +{ + int l, h; + + /* abort if caller did not ask for rasters in advance */ + if ((f->f_flags & FF_RASTERS) == 0) + panic("GetRaster(%s)", f->f_path); + + /* + * If there is no raster, get one. Blank characters, + * however, never have rasters. + */ + if (g->g_raster == NULL) { + if (!HASRASTER(g)) + return (NULL); + /* + * THE FOLLOWING DEPENDS ON THE ADJACENCY MATCHING THAT IN + * GetGlyph() ABOVE. + */ + GET_ADJ(g->g_index, l, h); + if (l < f->f_lowch) + l = f->f_lowch; + if (h > f->f_highch) + h = f->f_highch; + if ((*f->f_ops->fo_rasterise)(f, l, h)) + error(1, 0, "rasterise fails (out of memory?)"); + } + if (g->g_rotation != r) + SetRotation(g, r); + return (g->g_raster); +} + +void +FreeRaster(g) + struct glyph *g; +{ + + if (g->g_raster) { + free((g)->g_raster); + g->g_raster = NULL; + } +} + +/* + * Return a TeX-style font name, including scale factor. + * SHOULD I BOTHER WITH \magstep STYLE NAMES? + */ +char * +Font_TeXName(f) + register struct font *f; +{ + static char result[200]; + + if (f->f_scaled == 1000) + return (f->f_font); + (void) sprintf(result, "%s scaled %d", f->f_font, f->f_scaled); + return (result); +} diff --git a/Build/source/texk/seetexk/getopt.c b/Build/source/texk/seetexk/getopt.c new file mode 100644 index 00000000000..258d91f3d9f --- /dev/null +++ b/Build/source/texk/seetexk/getopt.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * getopt - get option letter from argv + * (From Henry Spencer @ U of Toronto Zoology, slightly edited) + */ + +#include <stdio.h> + +char *optarg; /* Global argument pointer. */ +int optind; /* Global argv index. */ + +static char *scan; /* Private scan pointer. */ +#if defined( WIN32 ) || defined( _AMIGA ) +#include <string.h> +#define index strchr +#else +extern char *index(); +#endif + +int +getopt(argc, argv, optstring) + register int argc; + register char **argv; + char *optstring; +{ + register int c; + register char *place; + + optarg = NULL; + if (scan == NULL || *scan == 0) { + if (optind == 0) + optind++; + if (optind >= argc || argv[optind][0] != '-' || + argv[optind][1] == 0) + return (EOF); + if (strcmp(argv[optind], "--") == 0) { + optind++; + return (EOF); + } + scan = argv[optind] + 1; + optind++; + } + c = *scan++; + place = index(optstring, c); + + if (place == NULL || c == ':') { + fprintf(stderr, "%s: unknown option -%c\n", argv[0], c); + return ('?'); + } + place++; + if (*place == ':') { + if (*scan != '\0') { + optarg = scan; + scan = NULL; + } else { + if (optind >= argc) { + fprintf(stderr, + "%s: missing argument after -%c\n", + argv[0], c); + return ('?'); + } + optarg = argv[optind]; + optind++; + } + } + return (c); +} diff --git a/Build/source/texk/seetexk/gfclass.c b/Build/source/texk/seetexk/gfclass.c new file mode 100644 index 00000000000..207b58ef7e4 --- /dev/null +++ b/Build/source/texk/seetexk/gfclass.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/gfclass.c,v 2.3 89/08/22 21:52:30 chris Exp $"; +#endif + +/* + * gfclass - GF code classification tables. + */ + +#include "gfclass.h" + +/* shorthand---in lowercase for contrast (read on!) */ +#define three(x) x, x, x +#define four(x) x, x, x, x +#define five(x) four(x), x +#define six(x) four(x), x, x +#define eight(x) four(x), four(x) +#define sixteen(x) eight(x), eight(x) +#define thirty_two(x) sixteen(x), sixteen(x) +#define sixty_four(x) thirty_two(x), thirty_two(x) +#define one_twenty_eight(x) sixty_four(x), sixty_four(x) +#define one_sixty_five(x) one_twenty_eight(x), thirty_two(x), five(x) + +/* + * Length of the single (or first) operand, if any. + */ +char gf_oplen[256] = { + sixty_four(GPL_NONE), /* GF_PAINT_0 through GF_PAINT_63 */ + GPL_UNS1, /* GF_PAINT1 */ + GPL_UNS2, /* GF_PAINT2 */ + GPL_UNS3, /* GF_PAINT3 */ + GPL_NONE, /* GF_BOC */ + GPL_NONE, /* GF_BOC1 */ + GPL_NONE, /* GF_EOC */ + GPL_NONE, /* GF_SKIP0 */ + GPL_UNS1, /* GF_SKIP1 */ + GPL_UNS2, /* GF_SKIP2 */ + GPL_UNS3, /* GF_SKIP3 */ + one_sixty_five(GPL_NONE),/* GF_NEW_ROW_0 through GF_NEW_ROW_164 */ + GPL_UNS1, /* GF_XXX1 */ + GPL_UNS2, /* GF_XXX2 */ + GPL_UNS3, /* GF_XXX3 */ + GPL_SGN4, /* GF_XXX4 */ + GPL_SGN4, /* GF_YYY */ + GPL_NONE, /* GF_NOP */ + GPL_NONE, /* GF_CHAR_LOC */ + GPL_NONE, /* GF_CHAR_LOC0 */ + GPL_NONE, /* GF_PRE */ + GPL_NONE, /* GF_POST */ + GPL_NONE, /* GF_POSTPOST */ + six(GPL_NONE) /* 250 through 255 */ +}; + +/* + * Types of the various opcodes. + */ +char gf_gt[256] = { + sixty_four(GT_PAINT0), /* GF_PAINT_0 through GF_PAINT_63 */ + three(GT_PAINT), /* GF_PAINT1 through GF_PAINT3 */ + GT_BOC, /* GF_BOC */ + GT_BOC1, /* GF_BOC1 */ + GT_EOC, /* GF_EOC */ + GT_SKIP0, /* GF_SKIP0 */ + three(GT_SKIP), /* GF_SKIP1 through GF_SKIP3 */ + one_sixty_five(GT_NEW_ROW),/* GF_NEW_ROW_0 throgh GF_NEW_ROW_164 */ + four(GT_XXX), /* GF_XXX1 through GF_XXX4 */ + GT_YYY, /* GF_YYY */ + GT_NOP, /* GF_NOP */ + GT_CHAR_LOC, /* GF_CHAR_LOC */ + GT_CHAR_LOC0, /* GF_CHAR_LOC0 */ + GT_PRE, /* GF_PRE */ + GT_POST, /* GF_POST */ + GT_POSTPOST, /* GF_POSTPOST */ + six(GT_UNDEF) /* 250 through 255 */ +}; diff --git a/Build/source/texk/seetexk/gfclass.h b/Build/source/texk/seetexk/gfclass.h new file mode 100644 index 00000000000..dd43f8254aa --- /dev/null +++ b/Build/source/texk/seetexk/gfclass.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * GF classification codes + */ + +/* + * Predicate for simple paint commands. This is presumably the most + * common GF operation; it may be profitable to check for this before + * switching out on the command type. + */ +#define GF_IsPaint(c) ((c) < 64) + +/* + * Symbolic names for command `types', as returned by the macro + * GT_TYPE(int c). + */ +#define GT_PAINT0 0 /* paint without parameter */ +#define GT_PAINT 1 /* paint with parameter */ +#define GT_BOC 2 /* long BOC */ +#define GT_BOC1 3 /* short BOC */ +#define GT_EOC 4 /* EOC */ +#define GT_SKIP0 5 /* parameterless SKIP */ +#define GT_SKIP 6 /* parmeterised SKIP */ +#define GT_NEW_ROW 7 /* NEW_ROW_n */ +#define GT_XXX 8 /* XXXn */ +#define GT_YYY 9 /* YYY */ +#define GT_NOP 10 /* no op */ +#define GT_CHAR_LOC 11 /* CHAR_LOC */ +#define GT_CHAR_LOC0 12 /* abbreviated CHAR_LOC */ +#define GT_PRE 13 +#define GT_POST 14 +#define GT_POSTPOST 15 +#define GT_UNDEF 16 + +/* + * Symbolic names for parameter lengths, obtained via the macro + * GT_OpLen(int c). + */ +#define GPL_NONE 0 /* no parameter, or too complex */ +#define GPL_UNS1 1 /* one one-byte parameter in 0..255 */ +#define GPL_UNS2 2 /* one two-byte parameter in 0..65535 */ +#define GPL_UNS3 3 /* one three-byte parameter in 0..16777215 */ +#define GPL_SGN4 4 /* one four-byte signed parameter */ +/* + * there are no unsigned four byte parameters, and no shorter signed + * parameters + */ + +#define GF_OpLen(code) (gf_oplen[code]) +#define GF_TYPE(code) (gf_gt[code]) +extern char gf_oplen[]; +extern char gf_gt[]; diff --git a/Build/source/texk/seetexk/gfcodes.h b/Build/source/texk/seetexk/gfcodes.h new file mode 100644 index 00000000000..beab1c54ea7 --- /dev/null +++ b/Build/source/texk/seetexk/gfcodes.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * GF (generic font) opcodes. + */ + +#define GF_PAINT_0 0 /* paint with `d' = 0 */ + /* ... through PAINT_63, d = 63 */ +#define GF_PAINT1 64 /* paint, with a one-byte parameter */ +#define GF_PAINT2 65 /* paint, with a two-byte parameter */ +#define GF_PAINT3 66 /* paint, with a three-byte parameter */ +#define GF_BOC 67 /* beginning of character */ +#define GF_BOC1 68 /* compressed form of BOC */ +#define GF_EOC 69 /* end of character */ +#define GF_SKIP0 70 /* finish this row, begin next with white */ +#define GF_SKIP1 71 /* finish row, one byte parameter */ +#define GF_SKIP2 72 +#define GF_SKIP3 73 +#define GF_NEW_ROW_0 74 /* begin a new row, ready to blacken */ +#define GF_NEW_ROW_1 75 /* begin a new row, but one col. from left */ + /* through GF_NEW_ROW_164 */ +#define GF_XXX1 239 /* special (interpreter dependent) command */ +#define GF_XXX2 240 /* like XXX1, but two byte length parameter */ +#define GF_XXX3 241 +#define GF_XXX4 242 +#define GF_YYY 243 /* takes four byte parameter, otherwise nop */ + /* (generated by METAFONT for numspecial) */ +#define GF_NOP 244 /* no op */ +#define GF_CHAR_LOC 245 /* character locator */ +#define GF_CHAR_LOC0 246 /* abbreviated form of CHAR_LOC */ +#define GF_PRE 247 /* introduces preamble */ +#define GF_POST 248 /* introduces postamble */ +#define GF_POSTPOST 249 /* marks end of postamble */ + + /* codes 250 through 255 are undefined */ + +#define GF_ID 131 /* identifies this revision of GF */ + +#define GF_FILLER 223 /* filler bytes at end of GF file */ diff --git a/Build/source/texk/seetexk/gffont.c b/Build/source/texk/seetexk/gffont.c new file mode 100644 index 00000000000..85301b03c53 --- /dev/null +++ b/Build/source/texk/seetexk/gffont.c @@ -0,0 +1,946 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/gffont.c,v 2.9 89/09/02 17:16:17 chris Exp $"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "types.h" +#include "error.h" +#include "font.h" +#include "gfcodes.h" +#include "gfclass.h" +#include "num.h" + +/* + * GF font operations. + * + * GF files may be compact, but this code surely is not! + * + * TODO: + * think about fonts with characters outside [0..255] + * find some way to free gf body when done + */ +static int gf_read(), gf_getgly(), gf_rasterise(); +static void gf_freefont(); + +struct fontops gfops = + { "gf", 0, 1.0, gf_read, gf_getgly, gf_rasterise, gf_freefont }; + +/* + * Local info. + */ + +/* + * A bounding box. The names follow those in the GF documentation. + */ +struct bounds { + i32 min_m, max_m; /* min and max `m' (colunm) values */ + i32 min_n, max_n; /* min and max `n' (row) values */ +}; + +/* + * char_loc is one `character locator' from a GF file, save for the + * `character residue', which we need not. + */ +struct char_loc { + i32 cl_dx; /* x escapement (scaled pixels) */ + i32 cl_dy; /* y escapement (scaled pixels) */ + i32 cl_w; /* TFM width */ + i32 cl_p; /* pointer to BOC (or specials) */ +}; + +/* + * GF details include: + * -> the main body of the GF file (all bytes save pre- and post-amble); + * -> global box boundaries; + * and character locators, addressed by `character residue'. Empty + * slots are indicated by a -1 `pointer'. + */ +struct gf_details { + char *gd_body; /* GF body */ + char *gd_base; /* == gd_body - preamble_size */ + struct bounds gd_gb; /* global boundaries */ + struct char_loc gd_cl[256]; /* character locators */ +}; + +/* + * Get the gf_details from font f. + */ +#define ftogd(f) ((struct gf_details *)(f)->f_details) + +#if !defined( WIN32 ) && !defined( _AMIGA ) +extern int errno; +extern char *malloc(); +#endif +char *copyit(); + +/* + * This code mimicks findpost.c. + */ +#define POSTSIZE 512 + +/* + * Find the GF postamble. Store the offsets of the POST and POSTPOST + * opcodes through postp and postpostp. + */ +static int +findGFpostamble(fd, postp, postpostp) + int fd; + long *postp, *postpostp; + +{ + register long offset; + register char *p; + register int i; + register i32 n; + char postbuf[POSTSIZE]; + + offset = lseek(fd, 0L, 2); + do { + + if ((offset -= POSTSIZE) < 0L) + offset = 0L; + (void) lseek(fd, offset, 0); + i = read(fd, postbuf, POSTSIZE); + if (i <= 0) + break; + for (p = postbuf + i; --i >= 0;) + if (UnSign8(*--p) != GF_FILLER) + goto found_something; + } while (offset); + return (-1); /* ran out of filler */ + +found_something: + if (UnSign8(*p) != GF_ID) + return (-1); /* not a GF file */ + offset += i; /* this is the offset of *p */ + *postpostp = offset - 5;/* POSTPOST should be here */ + /* we need 4 bytes for the pointer */ + if (i >= 4) + p -= 4; + else { + offset -= 4; + if (offset < 0L) + return (-1); /* tsk */ + (void) lseek(fd, offset, 0); + if (read(fd, p = postbuf, 4) != 4) + return (-1); + } + /* + * p now points to the postamble pointer. Get it and + * seek to the postamble, also saving the offset. + */ + pGetLong(p, n); + *postp = offset = n; + (void) lseek(fd, offset, 0); + return (0); /* made it */ +} + +/* + * Read a GF file. + */ +static int +gf_read(f, fd) + register struct font *f; + int fd; +{ + register struct gf_details *gd; + register char *p; + register struct char_loc *cl; + register int i; + int presize, postsize, bodysize, firstc, lastc; + char *postamble; + long postaddr, postpostaddr; + i32 lasteoc; + char *problem = NULL; + struct stat st; + char b[4]; + int saverr; + + gd = NULL; /* prepare for failure */ + postamble = NULL; + + /* + * The file had best be at least 50 bytes long. A + * `completely empty' GF file might consist of a PRE, a GF_ID, + * no comment (one zero byte), then: POST, pointer to last + * EOC, design size, checksum, hppp, vppp, min_m, max_m, + * min_n, max_n, POSTPOST, pointer to POST, GF_ID, and four + * FILLERs. + */ + (void) fstat(fd, &st); + if (st.st_size < 50) { /* too small to be a GF file */ + problem = "file is too short"; + goto fail; + } + + /* + * Read the very beginning and pick up the preamble size. + */ + if (read(fd, b, 4) != 4) + goto fail; + if (UnSign8(b[0]) != GF_PRE) { + problem = "file does not begin with PRE"; + goto fail; + } + i = UnSign8(b[1]); + if (i != GF_ID) + error(0, 0, "Warning: strange GF id (%d) in \"%s\"", i, + f->f_path); + presize = 3 + UnSign8(b[2]); + + /* + * Find the postamble, allocate space, and read it in. + */ + if (findGFpostamble(fd, &postaddr, &postpostaddr)) { + problem = "cannot find postamble"; + goto fail; + } + postsize = postpostaddr - postaddr + 1; + if ((p = malloc(postsize)) == NULL) + goto fail; + if (read(fd, p, postsize) != postsize) + goto fail; + postamble = p; + + /* + * Make sure we found it. + */ + if (pgetbyte(p) != GF_POST) { + problem = "no GF_POST at postamble"; + goto fail; + } + if (UnSign8(postamble[postsize - 1]) != GF_POSTPOST) { + problem = "no GF_POSTPOST after postamble"; + goto fail; + } + + /* + * Looks okay. Allocate detail space and poke through the postamble. + */ + if ((gd = (struct gf_details *) malloc(sizeof (*gd))) == NULL) + goto fail; + gd->gd_body = NULL; + + pGetLong(p, lasteoc); /* actually one past last EOC */ + pGetLong(p, f->f_design_size); + pGetLong(p, f->f_checksum); + pGetLong(p, f->f_hppp); + pGetLong(p, f->f_vppp); + + pGetLong(p, gd->gd_gb.min_m); + pGetLong(p, gd->gd_gb.max_m); + pGetLong(p, gd->gd_gb.min_n); + pGetLong(p, gd->gd_gb.max_n); + + /* + * Zap all the character locators, then read those that are + * defined in the postamble. Remember the first and last + * characters so that we know which glyphs are defined. Lastc + * is actually the last-plus-one'th character. + */ + for (cl = gd->gd_cl, i = 256; --i >= 0; cl++) + cl->cl_p = -1; + firstc = 256; + lastc = 0; + for (;;) { + i32 dx, dy; + + switch (pgetbyte(p)) { + + case GF_CHAR_LOC: + i = pgetbyte(p); + pGetLong(p, dx); + pGetLong(p, dy); + goto merge; + + case GF_CHAR_LOC0: + i = pgetbyte(p); + dx = ((i32) pgetbyte(p)) << 16; + dy = 0; +merge: + if (i < firstc) + firstc = i; + if (i >= lastc) + lastc = i + 1; + cl = &gd->gd_cl[i]; + cl->cl_dx = dx; + cl->cl_dy = dy; + pGetLong(p, cl->cl_w); + pGetLong(p, cl->cl_p); + break; + + case GF_POSTPOST: + goto done; + + default: + error(0, 0, "I do not understand %d here", + UnSign8(p[-1])); + problem = "unexpected opcode in postamble"; + goto fail; + } + } +done: + free(postamble); + postamble = NULL; /* all done with it */ + + /* + * Alas, we need the instructions whether or not we need + * the rasters, since the raster bounding box information + * can only be properly determined by converting the rasters. + * Compute the size of the main body of the GF file, then + * read it in. + */ + bodysize = lasteoc - presize; + if ((gd->gd_body = malloc(bodysize + 1)) == NULL) + goto fail; + (void) lseek(fd, (long) presize, 0); + if (read(fd, gd->gd_body, bodysize) != bodysize) + goto fail; + /* + * The next byte might be a special, so we just + * arbitrarily stuff in a POST. + */ + gd->gd_body[bodysize] = GF_POST; + gd->gd_base = gd->gd_body - presize; + + f->f_details = (char *)gd; + if (FontHasGlyphs(f, firstc, lastc)) + goto fail2; + (void) close(fd); + return (0); + +fail: + if (problem == NULL) + error(0, errno, "trouble reading \"%s\"", f->f_path); + else { + error(0, 0, "%s", problem); + error(0, 0, "(are you sure \"%s\" is a GF file?)", f->f_path); + } + errno = 0; +fail2: + saverr = errno; + if (postamble != NULL) + free(postamble); + if (gd != NULL) { + if (gd->gd_body != NULL) + free(gd->gd_body); + free((char *) gd); + } + (void) close(fd); + errno = saverr; + return (-1); +} + +/* + * Some global variables, used while building rasters. (These are + * referenced also in copyit(), so must be global. Fortunately, no + * one yet requires the font routines to be re-entrant.) + */ +static char *buildraster; /* raster being built */ +static int buildsize; /* size of buildraster (bytes) */ + +static struct bounds tempb; /* bounds used during buildraster */ +static struct bounds ob; /* observed bounds */ + +/* + * Bit tables: `left' and `right' bits. lbits[b] has all the bits + * that are to the left of bit b set; rbits[b] has all the bits + * that are to the right of bit b set, as well as bit b itself. + */ +static char lbits[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; +static char rbits[] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; + +/* + * The magic address `nullraster' is known in getgly() as a valid + * but empty raster, and changed there to NULL. A NULL return from + * drawchar indicates failure; we need something to distinguish the + * empty raster. + */ +static char nullraster[1]; + +/* + * `Inline functions': + * -> convert a bit number to a byte number (round down); + * -> convert a number of bits to a number of bytes (round up); + * and convert a bit to a bit index. + */ +#define btoby(b) ((b) >> 3) +#define btonb(b) (((b) + 7) >> 3) +#define btobi(b) ((b) & 7) + +/* + * Helper function for getgly: build the raster, and compute its + * minimal bounding box. Called with `p' pointing past the backpointer + * field of the BOC command (i.e., at min_m or del_m). `abbrev' is true + * iff this was a BOC1. `globalb' are the global bounds from the GF file, + * whose name is pointed to by gfname. + */ +static char * +drawchar(p, abbrev, globalb, gfname) + register char *p; + int abbrev; + struct bounds globalb; + char *gfname; +{ + register i32 m; /* m register (column) */ + register char *colp; /* pointer to byte corresponding to m */ + register int c; /* temporary */ + register i32 i; /* temporary */ + register int black; /* true when paint_switch==black */ + register i32 n; /* n register (row) */ + int stride; /* multiplier to convert linear to 2d array */ + int wrotethisrow; /* true iff we wrote in the current row */ + char *virtrast; /* virtual origin version of buildraster */ + int mustcopy; /* true if we must copy the built raster */ + struct bounds gb; /* bounds from the GF file */ + + /* get the bounds */ + if (abbrev) { + c = pgetbyte(p);/* del_m */ + gb.min_m = (gb.max_m = pgetbyte(p)) - c; + c = pgetbyte(p);/* del_n */ + gb.min_n = (gb.max_n = pgetbyte(p)) - c; + } else { + pGetLong(p, gb.min_m); + pGetLong(p, gb.max_m); + pGetLong(p, gb.min_n); + pGetLong(p, gb.max_n); + } + + /* + * Trim the GF bounds according to the global bounds. We + * use the trimmed values to allocate the build space. + */ + tempb = gb; +#define GB_ADJ(field, cmp) \ + if (tempb.field cmp globalb.field) \ + tempb.field = globalb.field + GB_ADJ(min_m, <); + GB_ADJ(max_m, >); + GB_ADJ(min_n, <); + GB_ADJ(max_n, >); +#undef GB_ADJ + + /* + * First check for completely empty characters---that is, + * those where min > max. The space in cmtex10, for instance, + * could be a completely empty character, but for some reason + * METAFONT declares cmtex10 space as [0..0][0..0]. + * Nonetheless, we will not assume that [0..-1][0..0] or + * the like are impossible. + */ + if (tempb.min_m > tempb.max_m || tempb.min_n > tempb.max_n) + return (nullraster); + + /* + * Compute the distance between rows (the number of bytes per + * column), then make sure there is room in the build space + * for [min_n..max_n] of these, possibly by allocating a new raster. + */ + stride = btonb(tempb.max_m - tempb.min_m + 1); + c = stride * (tempb.max_n - tempb.min_n + 1); + if (c > buildsize) { + if (buildraster != NULL) + free(buildraster); + if ((buildraster = malloc(c)) == NULL) { + buildsize = 0; + return (NULL); + } + buildsize = c; + } + + /* + * If we are using an old raster that is too big, remember to + * scrunch it down later. + */ + mustcopy = buildsize > c; + + /* clear the raster to white */ + bzero(buildraster, c); + + /* + * Make a virtual origin raster pointer. The virtual origin is + * where raster[0][0] is, whether or not there is a raster[0][0]. + * Normally, this would be + * &buildraster[-gb.min_n * stride - btoby(gb.min_m)], + * but it is complicated by two things. Firstly, we would like + * n==max_n to be the bottommost point in the raster (low + * addresses), and n==min_n to be the topmost (high addresses). + * In other words, we need to reflect the n (Y) values about + * the X axis: negate them. Secondly, the raster we create + * must be `flush left'. That is, somewhere along its rows, + * bit 0x80 must be set at the left edge of one of its columns. + * We need to subtract away the minimum bit index before + * calculating bit values. This cannot really be done in + * advance, since we cannot address bits directly. + */ + virtrast = &buildraster[gb.max_n * stride]; + + /* + * Set up the bounds-trimming variables. We could do this by + * simply setting the observed min point to a very large number, + * and the observed max point to a very small number, but this + * way we need not come up with extreme numbers (which might not + * be portable). + * + * If at least one pixel is blackened, the observed bounds will + * become the correct bounds in the code below, and we will have + * min<=max; but if no pixels are blackened, we arrange to have + * min>max, so we have to check for that again later. + * + * This would be `min = max + 1' and `max = min - 1', but for + * efficiency, the observed m bounds are kept offset by gb.min_m + * until we finish drawing the character. + */ + ob.min_m = tempb.max_m + 1 - gb.min_m; + ob.max_m = tempb.min_m - 1 - gb.min_m; + ob.min_n = tempb.max_n + 1; + ob.max_n = tempb.min_n - 1; + wrotethisrow = 0; + +#define FIX_N_BOUNDS() { \ + if (wrotethisrow) { \ + c = -n; /* recall that n is reflected about X axis */ \ + if (c < ob.min_n) \ + ob.min_n = c; \ + if (c > ob.max_n) \ + ob.max_n = c; \ + wrotethisrow = 0; \ + } \ +} + + /* + * Initialise state variables: m = min_m, n = max_n, + * paint_switch = white. + */ + m = 0; /* gb.min_m - gb.min_m */ + n = -gb.max_n; /* reflected */ + colp = &virtrast[n * stride]; +if (colp != buildraster) +panic("gffont drawchar colp != buildraster"); + black = 0; + + /* + * Now interpret the character. + * `for (;;)' pushes everything off the right edge, alas. + */ +more: + c = pgetbyte(p); + if (GF_IsPaint(c)) /* faster? */ + goto paint; + switch (GF_OpLen(c)) { + + case GPL_NONE: + break; + + case GPL_UNS1: + i = pgetbyte(p); + break; + + case GPL_UNS2: + pGetWord(p, i); + break; + + case GPL_UNS3: + pGet3Byte(p, i); + break; + + case GPL_SGN4: + pGetLong(p, i); + break; + + default: + panic("gffont drawchar GF_OpLen(%d) = %d", c, GF_OpLen(c)); + /* NOTREACHED */ + } + + switch (GF_TYPE(c)) { + + case GT_PAINT0: +paint: + i = c - GF_PAINT_0; + /* FALLTHROUGH */ + + case GT_PAINT: + /* + * Paint `i' bits in the current row at columns [m..m+i). + */ + if (i && black) { + /* remember to adjust n bounds later */ + wrotethisrow = 1; + /* adjust minimum m bound */ + if (m < ob.min_m) + ob.min_m = m; + + /* + * Finish the partial byte at colp. There are 8-k + * bits to set to finish it, where k is the bit + * index value from m. If we need to set fewer + * than 8-k bits, set them now and skip the rest + * of this. + */ + c = 8 - btobi(m); + if (i < c) { /* cannot finish it off */ + *colp |= UnSign8(lbits[i]) >> btobi(m); + m += i; + } else { /* finish it off */ + *colp++ |= rbits[btobi(m)]; + i -= c; + m += c; + + /* + * Update m to reflect having written the + * remaining i bits, then write them. + * First write all the full bytes, then + * start a partial byte with whatever + * is left over, if anything. + */ + m += i; + i >>= 3; + while (--i >= 0) + *colp++ = 0xff; + *colp |= lbits[btobi(m)]; + } + + /* adjust maximum m bound */ + if (m > ob.max_m) + ob.max_m = m; + } else { + /* + * Add the bit index so that we round up whenever + * this fills the partial byte at colp. + */ + colp += (i + btobi(m)) >> 3; + m += i; + } + black = !black; + break; + + case GT_EOC: /* all done */ + FIX_N_BOUNDS(); + goto done; + + case GT_SKIP0: /* skip no rows */ + i = 0; + /* FALLTHROUGH */ + + case GT_SKIP: /* skip some rows, draw white */ + m = 0; + black = 0; + goto skip_or_new_row; + + case GT_NEW_ROW: /* next row near left col, draw black */ + m = c - GF_NEW_ROW_0; + black = 1; + i = 0; /* n offset is 1: skip no rows */ +skip_or_new_row: + FIX_N_BOUNDS(); + n += i + 1; /* += because reflected */ + colp = &virtrast[n * stride + btoby(m)]; + break; + + case GT_XXX: /* special */ + p += i; + break; + + case GT_YYY: /* numspecial */ + break; + + case GT_NOP: /* dull */ + break; + + case GT_BOC: /* should not appear */ + case GT_BOC1: + case GT_CHAR_LOC: + case GT_CHAR_LOC0: + case GT_PRE: + case GT_POST: + case GT_POSTPOST: + case GT_UNDEF: + error(0, 0, "unexpected GF opcode %d", c); + error(1, 0, "bad GF file \"%s\"", gfname); + /* NOTREACHED */ + + default: + panic("gffont drawchar GF_TYPE(%d) = %d", c, GF_TYPE(c)); + /* NOTREACHED */ + } + goto more; + +done: + /* + * The observed bounds `m' values are both off by gb.min_m, so + * fix them now. + */ + ob.min_m += gb.min_m; + ob.max_m += gb.min_m; + + /* as noted above, we have to make sure there were some points */ + if (ob.min_m > ob.max_m) + return (nullraster); +if (ob.min_n > ob.max_n) +panic("gffont min>max: n but not m"); + + /* + * If we used too much memory for the raster, copy it now. + */ + if (mustcopy || tempb.min_n != ob.min_n || tempb.max_n != ob.max_n || + btonb(ob.max_m - ob.min_m + 1) != stride) + return (copyit()); + + /* + * If the left column bounds match, just move the raster in place. + */ + if (tempb.min_m == ob.min_m) { + p = buildraster; + buildraster = NULL; + buildsize = 0; + return (p); + } + + /* + * The raster must be copied, but only because it is not + * `left justified'. + * + * CONSIDER DEFERRING THIS PHASE UNTIL THE RASTER IS USED + */ + return (copyit()); +} + +/* + * Copy the built raster to newly allocated space. + * We may need to shift all the bits left as well. + */ +char * +copyit() +{ + register char *o, *p; + register int i, oldoff, newoff; + char *n; + + /* + * Compute the observed minimum stride. + */ + newoff = btonb(ob.max_m - ob.min_m + 1); + n = malloc((unsigned)(newoff * (ob.max_n - ob.min_n + 1))); + if ((p = n) == NULL) + return (NULL); + + /* + * Compute the old stride. + */ + oldoff = btonb(tempb.max_m - tempb.min_m + 1); +if (oldoff < newoff) +panic("gffont copyit oldoff < newoff"); + + /* + * Point at the old raster, then add the offset to the first + * written row, and then the offset to the first written column. + */ + o = buildraster; + o += (ob.max_n - tempb.max_n) * oldoff; + i = ob.min_m - tempb.min_m; + o += btoby(i); + + /* + * Now copy each row, doing shifting if required. + */ + if ((i = btobi(i)) != 0) { /* must shift, alas */ + register int r = 8 - i, j, k; + + oldoff -= newoff; + for (k = ob.max_n; k >= ob.min_n; k--) { + for (j = newoff; --j > 0;) { + *p = *o++ << i; + *p++ |= UnSign8(*o) >> r; + } + /* last byte is special: no rightward bits */ + *p++ = *o++ << i; + o += oldoff; + } + } else if (oldoff > newoff) { /* compressing columns */ + for (i = ob.max_n; i >= ob.min_n; i--) { + bcopy(o, p, newoff); + o += oldoff; + p += newoff; + } + } else /* just squeezing out extra rows */ + bcopy(o, p, newoff * (ob.max_n - ob.min_n + 1)); + + /* finally, return the copy */ + return (n); +} + +/* + * Obtain the specified range of glyphs. + */ +static int +gf_getgly(f, l, h) + register struct font *f; + int l, h; +{ + register struct glyph *g; + register struct char_loc *cl; + register char *p; + register i32 c; + register int i; + register i32 thisboc; + int abbrev; + struct gf_details *gd = ftogd(f); + + /* + * For each glyph, make sure there exists an instance of that + * character residue. Go find the actual glyph (which may be + * arbitrarily far down a chain of pointers) and get its info. + */ + for (cl = &gd->gd_cl[i = l]; i < h; i++, cl++) { + g = f->f_gly[i]; + thisboc = cl->cl_p; + + /* + * Screw around locating the character for real. + */ + while (thisboc != -1) { + p = gd->gd_base + thisboc; +skip: + c = pgetbyte(p); + switch (GF_TYPE(c)) { + + case GT_XXX: + switch (GF_OpLen(c)) { + + case GPL_UNS1: + c = pgetbyte(p); + break; + + case GPL_UNS2: + pGetWord(p, c); + break; + + case GPL_UNS3: + pGet3Byte(p, c); + break; + + case GPL_SGN4: + pGetLong(p, c); + break; + + default: + panic("gf_getgly GF_OpLen(%d) = %d", + c, GF_OpLen(c)); + /* NOTREACHED */ + } + p += c; + goto skip; + + case GT_YYY: + p += 4; + goto skip; + + case GT_BOC: + abbrev = 0; + pGetLong(p, c); + break; + + case GT_BOC1: + abbrev = 1; + c = pgetbyte(p); + break; + + default: + error(0, 0, "GF code %d; I expected BOC", c); + error(1, 0, "bad GF file \"%s\"", f->f_path); + /* NOTREACHED */ + } + /* + * Found a BOC. If it is the right character, + * go handle it. + */ + if (c == i) + goto handleit; + if ((c & 255) != i) { + error(0, 0, "%d != %d mod 256", c, i); + error(1, 0, "Bad GF file \"%s\"", f->f_path); + } + /* + * Follow the backpointer. + */ + if (abbrev) + thisboc = -1; + else + pGetLong(p, thisboc); + } + + /* + * If we get here, the glyph is not valid after all. + */ + continue; + + /* + * The glyph is okay. Set it up. + */ +handleit: + g->g_flags = GF_VALID; + g->g_xescapement = cl->cl_dx; + g->g_yescapement = cl->cl_dy; + g->g_rawtfmwidth = cl->cl_w; + if (!abbrev) + p += 4; /* skip backpointer */ + if ((p = drawchar(p, abbrev, gd->gd_gb, f->f_path)) == NULL) + return (-1); /* ??? */ + if (p == nullraster) { + /* min > max, hence max-min+1 <= 0; we want 0 */ + g->g_height = 0; + g->g_width = 0; + g->g_yorigin = 0; + g->g_xorigin = 0; + g->g_raster = NULL; + } else { + /* set height &c based on observed bounds */ + g->g_height = ob.max_n - ob.min_n + 1; + g->g_width = ob.max_m - ob.min_m + 1; + g->g_yorigin = ob.max_n; + g->g_xorigin = -ob.min_m; + g->g_raster = p; + } + g->g_rotation = ROT_NORM; + } + return (0); +} + +/* + * Obtain rasters for the specified glyphs. We did this above, while + * adjusting the bounding boxes, so this routine should never get called. + */ +static int +gf_rasterise(f, l, h) + struct font *f; + int l, h; +{ + + panic("gf_rasterise(%s, %d, %d)", f->f_path, l, h); +} + +/* + * Discard the font details. + */ +static void +gf_freefont(f) + struct font *f; +{ + struct gf_details *gd; + + if ((gd = ftogd(f)) != NULL) { + free(gd->gd_body); + free((char *) gd); + } +} diff --git a/Build/source/texk/seetexk/gripes.h b/Build/source/texk/seetexk/gripes.h new file mode 100644 index 00000000000..87ebbb18b9e --- /dev/null +++ b/Build/source/texk/seetexk/gripes.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Declarations for the various gripes. + */ + +void GripeOutOfMemory(), GripeCannotGetFont(), GripeDifferentChecksums(); +void GripeMissingFontsPreventOutput(), GripeNoSuchFont(); +void GripeFontAlreadyDefined(), GripeUnexpectedDVIEOF(), GripeUnexpectedOp(); +void GripeMissingOp(), GripeCannotFindPostamble(), GripeMismatchedValue(); +void GripeUndefinedOp(), GripeBadGlyph(); diff --git a/Build/source/texk/seetexk/gripes0.c b/Build/source/texk/seetexk/gripes0.c new file mode 100644 index 00000000000..b80239896d5 --- /dev/null +++ b/Build/source/texk/seetexk/gripes0.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/gripes0.c,v 2.5 89/09/01 13:52:38 chris Exp $"; +#endif + +/* + * Common errors (`gripes'). + */ + +#include <stdio.h> +#include "types.h" +#include "error.h" +#include "gripes.h" + +#ifndef WIN32 +extern errno; +#endif + +/* + * Cannot allocate memory. + */ +void +GripeOutOfMemory(n, why) + int n; + char *why; +{ + + error(1, -1, "ran out of memory allocating %d bytes for %s", n, why); + /* NOTREACHED */ +} + +/* + * Cannot get a font. + * RETURNS TO CALLER + */ +void +GripeCannotGetFont(name, mag, dsz, dev, fullname) + char *name; + i32 mag, dsz; + char *dev, *fullname; +{ + int e = errno; + char scale[40]; + + if (mag == dsz) /* no scaling */ + scale[0] = 0; + else + (void) sprintf(scale, " scaled %d", + (int) ((double) mag / (double) dsz * 1000.0 + .5)); + + error(0, e, "no font for %s%s", name, scale); + if (fullname) + error(0, 0, "(wanted, e.g., \"%s\")", fullname); + else { + if (dev) + error(1, 0, "(there are no fonts for the %s engine!)", + dev); + else + error(1, 0, "(I cannot find any fonts!)"); + /* NOTREACHED */ + } +} + +/* + * Font checksums do not match. + * RETURNS TO CALLER + */ +void +GripeDifferentChecksums(font, tfmsum, fontsum) + char *font; + i32 tfmsum, fontsum; +{ + + error(0, 0, "\ +WARNING: TeX and I have different checksums for font\n\ +\t\"%s\"\n\ +\tPlease notify your TeX maintainer\n\ +\t(TFM checksum = 0%lo, my checksum = 0%lo)", + font, (long)tfmsum, (long)fontsum); +} + +/* + * A font, or several fonts, are missing, so no output. + */ +void +GripeMissingFontsPreventOutput(n) + int n; +{ + static char s[2] = {'s', 0}; + + error(1, 0, "%d missing font%s prevent%s output (sorry)", n, + n > 1 ? s : &s[1], n == 1 ? s : &s[1]); + /* NOTREACHED */ +} diff --git a/Build/source/texk/seetexk/gripes1.c b/Build/source/texk/seetexk/gripes1.c new file mode 100644 index 00000000000..cd31a2f2b5d --- /dev/null +++ b/Build/source/texk/seetexk/gripes1.c @@ -0,0 +1,161 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/gripes1.c,v 1.1 89/08/22 21:54:19 chris Exp $"; +#endif + +/* + * Gripes having to do with DVI files. + */ + +#include <stdio.h> +#include "types.h" +#include "error.h" +#include "font.h" +#include "gripes.h" + +extern char *DVIFileName; + +static char * +dfn() +{ + + return (DVIFileName ? DVIFileName : "the input"); +} + +/* + * Save string space by declaring these here. + */ +#if __STDC__ >= 1 +static const char dfl[] = "DVI file"; +static const char areyousure[] = "(are you sure %s is a %s?)"; +#else +static char dfl[] = "DVI file"; +static char areyousure[] = "(are you sure %s is a %s?)"; +#endif + +/* + * DVI file requests a font it never defined. + */ +void +GripeNoSuchFont(n) + i32 n; +{ + + error(0, 0, "%s wants font %ld, which it never defined", dfl, (long)n); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * DVI file redefines a font. + */ +void +GripeFontAlreadyDefined(n) + i32 n; +{ + + error(0, 0, "%s redefines font %ld", dfl, n); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * Unexpected end of DVI file. + */ +void +GripeUnexpectedDVIEOF() +{ + + GripeUnexpectedOp("end of file"); + /* NOTREACHED */ +} + +/* + * Unexpected DVI opcode. + */ +void +GripeUnexpectedOp(s) + char *s; +{ + + error(0, 0, "unexpected %s in %s", s, dfl); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * Missing DVI opcode. + */ +void +GripeMissingOp(s) + char *s; +{ + + error(0, 0, "missing %s in %s", s, dfl); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * Cannot find DVI postamble. + */ +void +GripeCannotFindPostamble() +{ + + error(0, 0, "cannot find postamble"); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * Inconsistent DVI value. + */ +void +GripeMismatchedValue(s) + char *s; +{ + + error(0, 0, "mismatched %s in %s", s, dfl); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * Undefined DVI opcode. + */ +void +GripeUndefinedOp(n) + int n; +{ + + error(0, 0, "undefined DVI opcode %d", n); + error(1, 0, areyousure, dfn(), dfl); + /* NOTREACHED */ +} + +/* + * DVI file requests glyph that is not in some font, or + * when no font is set for this page. + * + * RETURNS TO CALLER + */ +void +GripeBadGlyph(c, f) + i32 c; + struct font *f; +{ + + if (f->f_path == NULL) { + error(0, 0, "bad %s: char without setfont", dfl); + error(1, 0, "(try checking %s with dvitype)", dfn()); + /* NOTREACHED */ + } + error(0, 0, "there is no character %ld in %s!", (long)c, f->f_path); +} diff --git a/Build/source/texk/seetexk/magfactor.c b/Build/source/texk/seetexk/magfactor.c new file mode 100644 index 00000000000..f0419d4aa81 --- /dev/null +++ b/Build/source/texk/seetexk/magfactor.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Convert a magnification factor to floating point. This is used in + * conjunction with the FONT_SLOP stuff to try to get the file names + * right, and may also be used by DVI reading programs to get slightly + * more accurate values for (mag/1000.0). + */ +double +DMagFactor(mag) + int mag; +{ + + switch (mag) { + + case 1095: /* stephalf */ + return (1.095445); + + case 1315: /* stepihalf */ + return (1.314534); + + case 2074: /* stepiv */ + return (2.0736); + + case 2488: /* stepv */ + return (2.48832); + + case 2986: /* stepiv */ + return (2.985984); + + default: /* remaining mags have been ok */ + return ((double) mag / 1000.); + } + /* NOTREACHED */ +} diff --git a/Build/source/texk/seetexk/num.h b/Build/source/texk/seetexk/num.h new file mode 100644 index 00000000000..80e03188df8 --- /dev/null +++ b/Build/source/texk/seetexk/num.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Pointer I/O: numbers. + * + * We deal in fixed format numbers and pointers here. + * For file I/O, see fio.h. + */ + +/* + * Get one unsigned byte. Note that this is a proper expression. + * The rest have more limited contexts, and are therefore OddLy + * CapItaliseD. + */ +#define pgetbyte(p) UnSign8(*(p)++) + +/* + * Get a two-byte unsigned integer, a three-byte unsigned integer, + * or a four-byte signed integer. + */ +#define pGetWord(p, r) ((r) = UnSign8(*(p)++) << 8, \ + (r) |= UnSign8(*(p)++)) +#define pGet3Byte(p,r) ((r) = UnSign8(*(p)++) << 16, \ + (r) |= UnSign8(*(p)++) << 8, \ + (r) |= UnSign8(*(p)++)) +#define pGetLong(p, r) ((r) = UnSign8(*(p)++) << 24, \ + (r) |= UnSign8(*(p)++) << 16, \ + (r) |= UnSign8(*(p)++) << 8, \ + (r) |= UnSign8(*(p)++)) + +/* + * ADD pputbyte, pPutWord, pPut3Byte, pPutLong HERE IF THEY PROVE + * USEFUL. (But then must consider changing PutWord &c in fio.h.) + */ diff --git a/Build/source/texk/seetexk/pkfont.c b/Build/source/texk/seetexk/pkfont.c new file mode 100644 index 00000000000..f5ccdb14159 --- /dev/null +++ b/Build/source/texk/seetexk/pkfont.c @@ -0,0 +1,731 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/pkfont.c,v 2.10 89/08/22 21:54:49 chris Exp $"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "types.h" +#include "error.h" +#include "font.h" +#include "num.h" + +/* + * PK font operations. + * + * The spelling `nybble' is a concession to the authors of the PK format. + */ +static int pk_read(), pk_getgly(), pk_rasterise(); +static void pk_freefont(); + +struct fontops pkops = + { "pk", 0, 1.0, pk_read, pk_getgly, pk_rasterise, pk_freefont }; + +/* + * Local info. + */ + +/* + * Commands. + */ +#define PK_XXX1 240 /* 1 byte special */ +#define PK_XXX2 241 /* 2 byte special */ +#define PK_XXX3 242 /* 3 byte special */ +#define PK_XXX4 243 /* 4 byte special */ +#define PK_YYY 244 /* METAFONT numspecial */ +#define PK_POST 245 /* marks postamble */ +#define PK_NO_OP 246 /* do nothing */ +#define PK_PRE 247 /* marks preamble */ + /* 248..255 undefined */ +#define PK_IsUndef(c) ((c) > PK_PRE) + +#define PK_ID 89 /* marks this brand of PK file */ + +/* + * Information about a character packet. + */ +struct cp { + char *cp_packet; /* the beginning of the packet */ + int cp_type; /* decoded pre type, see below */ +}; + +#define CP_SHORT 0 /* short preamble */ +#define CP_EXT_SHORT 1 /* extended short preamble */ +#define CP_LONG 2 /* long preamble */ + +/* + * The PK details include: + * -> a pointer to the next byte to fetch; + * -> the most recent byte fetched (when we are using nextnyb()); + * -> a flag indicating that we have used nybble 0 (bits 4..7) and + * should use nybble 1 next; + * -> the base address of the memory allocated for the PK file; + * -> the value of dyn_f (during character translation); + * -> the repeat count (during rasterisation); + * -> the lowest glyph number that is legal; + * -> the highest glyph number that is legal; + * -> glyph instructions for the standard glyphs; + * -> glyph instructions for more (nonstandard) glyphs; + * and the number of glyphs left unrasterised. + */ +struct pk_details { + char *pk_ptr; /* next byte to fetch */ + int pk_c; /* most recent byte fetched, if nybbling */ + int pk_1nyb; /* true => nybble 1 is next (bits 0..3) */ + char *pk_base; /* base of allocated memory */ + int pk_dyn_f; /* the dyn_f value */ + int pk_repeat; /* the repeat count */ + int pk_minc; /* minimum character value */ + int pk_maxc; /* maximum character value */ +#define MAXSTD 256 /* maximum `standard' character value */ + int pk_gleft; /* number of valid glyphs left uninterpreted */ + struct cp pk_cpack[MAXSTD]; /* for characters in [0..MAXSTD) */ + struct cp *pk_morec; /* for characters in [MAXSTD..maxc] */ +}; + +/* + * Fetch the next byte from the PK file. + */ +#define nextbyte(pk) pgetbyte((pk)->pk_ptr) + +/* + * PK packed number encoding. Nybbles in [1..dyn_f] represent themselves. + * Values in (dyn_f..13] are two-nybble values, and represent values + * dyn_f+1 through (13-dyn_f+1)*16+15. Zero marks a long number; 14 and + * 15 specify repeat counts instead (which are another packed number). + * Note that we cannot represent the number zero as a packed number. + */ +#define PK_LONGNUM 0 /* a `long number' */ +#define PK_REPEAT 14 /* set repeat count */ +#define PK_REPEAT1 15 /* set repeat to 1 */ + +/* + * Get the next nybble. This is an expression rendition of + * if (--pk->pk_1nyb < 0) { + * pk->pk_1nyb = 1; + * pk->pk_c = nextbyte(pk); + * return (pk->pk_c >> 4); + * } else + * return (pk->pk_c & 0xf); + */ +#define nextnyb(pk) \ + (--(pk)->pk_1nyb < 0 ? \ + ((pk)->pk_1nyb = 1, ((pk)->pk_c = nextbyte(pk)) >> 4) : \ + (pk)->pk_c & 0xf) + +/* + * Get the pk_details from font f. + */ +#define ftopk(f) ((struct pk_details *)(f)->f_details) + +static int scan_characters(); + +#if !defined( WIN32 ) && !defined( _AMIGA ) +extern int errno; +char *malloc(); +#endif + +/* + * PK subroutines. + */ + +/* + * Unpack a packed number. + */ +static int +pk_unpack(pk) + register struct pk_details *pk; +{ + register int i, j; + +top: + if ((i = nextnyb(pk)) == PK_LONGNUM) { +#if PK_LONGNUM != 0 /* this may be silly, but . . . */ + i = 0; +#endif + /* + * Expand a long number. There are one fewer leading + * zeros than there are nonzero digits to obtain, so + * count up the leading zeros, add one, and get that + * many digits. (The `digits' are hexadecimal values.) + */ + do { + i++; + } while ((j = nextnyb(pk)) == 0); + while (--i >= 0) { + j <<= 4; + j += nextnyb(pk); + } + return (j - 15 + (13 - pk->pk_dyn_f) * 16 + pk->pk_dyn_f); + } + if (i <= pk->pk_dyn_f) + return (i); + if (i < PK_REPEAT) + return ((i - pk->pk_dyn_f - 1) * 16 + nextnyb(pk) + + pk->pk_dyn_f + 1); + + /* + * There is a repeat count, either one or a packed number. + * Get it first, then start over. (tail recursion) + */ + if (i == PK_REPEAT) + pk->pk_repeat = pk_unpack(pk); + else + pk->pk_repeat = 1; + goto top; +} + +/* + * Skip over special commands (PK_XXX?, PK_YYY). + */ +static void +skip_specials(f) + struct font *f; +{ + struct pk_details *pk = ftopk(f); + register char *p = pk->pk_ptr; + register i32 i; + + for (;;) { + switch (UnSign8(*p++)) { + + case PK_XXX1: + i = UnSign8(*p++); + p += i; + break; + + case PK_XXX2: + pGetWord(p, i); + p += i; + break; + + case PK_XXX3: + pGet3Byte(p, i); + p += i; + break; + + case PK_XXX4: + pGetLong(p, i); + p += i; + break; + + case PK_YYY: + p += 4; + break; + + case PK_NO_OP: + break; + + case PK_PRE: + error(1, 0, "unexpected PK_PRE in \"%s\"", f->f_path); + break; + + default: + p--; + if (PK_IsUndef(UnSign8(*p))) + error(1, 0, "invalid opcode %d in \"%s\"", + f->f_path); + pk->pk_ptr = p; + return; + } + } +} + +/* + * Read a PK file. + */ +static int +pk_read(f, fd) + register struct font *f; + int fd; +{ + register struct pk_details *pk; + register char *p; + int i, minc; + struct stat st; + char *reason; + + pk = NULL; /* prepare for failure */ + reason = NULL; + (void) fstat(fd, &st); + if (st.st_size < 4) { /* ??? */ + reason = "file is too small"; + goto fail; + } + if ((pk = (struct pk_details *)malloc(sizeof (*pk))) == NULL) + goto fail; + pk->pk_morec = NULL; + if ((pk->pk_base = malloc(st.st_size)) == NULL) + goto fail; + if (read(fd, pk->pk_base, st.st_size) != st.st_size) + goto fail; + pk->pk_ptr = pk->pk_base; + if (nextbyte(pk) != PK_PRE) { + reason = "file does not begin with PK_PRE"; + goto fail; + } + if (nextbyte(pk) != PK_ID) { + reason = "bad PK_ID"; + goto fail; + } + i = nextbyte(pk); + p = pk->pk_ptr + i; /* skip comment */ + pGetLong(p, f->f_design_size); + pGetLong(p, f->f_checksum); + pGetLong(p, f->f_hppp); + pGetLong(p, f->f_vppp); + pk->pk_ptr = p; + + f->f_details = (char *)pk; + + /* scan the characters, fail if necessary */ + if (scan_characters(f, &reason)) + goto fail; + + /* ignore the postamble */ + + /* COMPRESS pk->pk_base DATA? */ + + if (FontHasGlyphs(f, pk->pk_minc, pk->pk_maxc + 1)) + goto fail; + (void) close(fd); + return (0); + +fail: + if (reason) { + error(0, 0, "%s", reason); + error(0, 0, "(are you sure %s is a PK file?)", f->f_path); + errno = 0; + } + if (pk != NULL) { + if (pk->pk_base != NULL) + free(pk->pk_base); + if (pk->pk_morec != NULL) + free((char *)pk->pk_morec); + free((char *)pk); + } + (void) close(fd); + return (-1); +} + +/* + * Scan through the characters in the PK file, and set the offsets + * and preamble types for each of the character packets. + */ +static int +scan_characters(f, reason) + struct font *f; + char **reason; +{ + register struct pk_details *pk = ftopk(f); + register i32 c, pl; + register char *p; + register struct cp *cp; + int type; + +#ifdef lint + /* reason will be used someday ... I think */ + reason = reason; +#endif + + /* set up the minimisers and the glyph count */ + pk->pk_minc = 1; + pk->pk_maxc = 0; + pk->pk_gleft = 0; + + /* mark all character packets as untouched */ + for (cp = pk->pk_cpack, c = MAXSTD; --c >= 0; cp++) + cp->cp_packet = NULL; + + /* + * Loop through the packets until we reach a POST, skipping + * the glyph instructions themselves after each definition, + * and specials (if any) before each. + */ + for (;; pk->pk_ptr = p + pl) { + skip_specials(f); + p = pk->pk_ptr; + if ((c = pgetbyte(p)) == PK_POST) + break; /* whoops, done after all */ + + /* + * Look at the low three bits to decide preamble size. + * A value of 7 is a `long preamble'; 4, 5, and 6 are + * `extended short preambles'; and 0, 1, 2, and 3 are + * `short preambles'. + * + * We ignore most of the preamble, reading only the + * `packet length' and the character code at this time. + */ + switch (c & 7) { + + case 7: /* long */ + type = CP_LONG; + pGetLong(p, pl); + pGetLong(p, c); + break; + + case 6: + case 5: + case 4: /* extended short */ + type = CP_EXT_SHORT; + pGetWord(p, pl); + pl += (c & 3) << 16; + c = pgetbyte(p); + break; + + default: /* short */ + type = CP_SHORT; + pl = ((c & 3) << 8) + pgetbyte(p); + c = pgetbyte(p); + break; + } + + if (c >= MAXSTD) { + /* + * BEGIN XXX - should alloc pk_morec, but is hard + * and not now useful + */ + error(0, 0, "ignoring character %d in \"%s\"", + f->f_path); + error(0, 0, "because some darn programmer was lazy!"); + continue; + /* END XXX */ + } else + cp = &pk->pk_cpack[c]; + + cp->cp_packet = pk->pk_ptr; + cp->cp_type = type; + + /* adjust range */ + if (c < pk->pk_minc) + pk->pk_minc = c; + if (c > pk->pk_maxc) + pk->pk_maxc = c; + + pk->pk_gleft++; /* and count the glyph */ + } + return (0); /* no problems */ +} + +/* + * Obtain the specified range of glyphs. + */ +static int +pk_getgly(f, l, h) + register struct font *f; + int l, h; +{ + register struct pk_details *pk = ftopk(f); + register char *p; + register struct glyph *g; + register int i; + register struct cp *cp; + + if (pk == NULL) + panic("pk_getgly(%s)", f->f_path); + for (i = l; i < h; i++) { + if (i < MAXSTD) + cp = &pk->pk_cpack[i]; + else { + if (i > pk->pk_maxc) + panic("pk_getgly(%s, %d)", f->f_path, i); + cp = &pk->pk_morec[i - MAXSTD]; + } + p = cp->cp_packet; + if (p == NULL) /* glyph is not valid */ + continue; + g = f->f_gly[i]; + p++; /* skip flag */ + switch (cp->cp_type) { + + case CP_LONG: + p += 8; /* skip packet len, character code */ + pGetLong(p, g->g_rawtfmwidth); + pGetLong(p, g->g_xescapement); + pGetLong(p, g->g_yescapement); + pGetLong(p, g->g_width); + pGetLong(p, g->g_height); + pGetLong(p, g->g_xorigin); + pGetLong(p, g->g_yorigin); + break; + + case CP_EXT_SHORT: { + i32 dm; + + p += 3; /* skip packet len, character code */ + pGet3Byte(p, g->g_rawtfmwidth); + pGetWord(p, dm); + g->g_xescapement = dm << 16; + g->g_yescapement = 0; + pGetWord(p, g->g_width); + pGetWord(p, g->g_height); + pGetWord(p, g->g_xorigin); + g->g_xorigin = Sign16(g->g_xorigin); + pGetWord(p, g->g_yorigin); + g->g_yorigin = Sign16(g->g_yorigin); + break; + } + + case CP_SHORT: + p += 2; /* skip packet len, character code */ + pGet3Byte(p, g->g_rawtfmwidth); + g->g_xescapement = pgetbyte(p) << 16; + g->g_yescapement = 0; + g->g_width = pgetbyte(p); + g->g_height = pgetbyte(p); + g->g_xorigin = pgetbyte(p); + g->g_xorigin = Sign8(g->g_xorigin); + g->g_yorigin = pgetbyte(p); + g->g_yorigin = Sign8(g->g_yorigin); + break; + } + g->g_flags = GF_VALID; + g->g_un.g_details = p; + } + return (0); +} + +/* + * Bit masks for pk_rasterise(). + */ +static char bmask[8] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe}; +static char rbits[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; + +/* + * Obtain rasters for the specified glyphs. + */ +static int +pk_rasterise(f, l, h) + struct font *f; + int l, h; +{ + struct pk_details *pk0; + struct glyph *g0; + char *p0, *rp0; + int flag, ii; + + if ((pk0 = ftopk(f)) == NULL) + panic("pk_rasterise(%s)", f->f_path); + for (ii = l; ii < h; ii++) { + { + register struct glyph *g; + register char *p; + register int i; + + g = f->f_gly[i = ii]; + if ((g->g_flags & GF_VALID) == 0) + continue; /* no glyph */ + if (!HASRASTER(g)) /* empty raster */ + goto done; + + /* + * Allocate a raster. + */ + rp0 = malloc(((g->g_width + 7) >> 3) * g->g_height); + if ((g->g_raster = rp0) == NULL) + return (-1);/* ??? */ + g->g_rotation = ROT_NORM; + + /* + * Pick up the flag byte, then start at the real + * packet, which we saved in g_details. + */ + if (i < MAXSTD) + p = pk0->pk_cpack[i].cp_packet; + else + p = pk0->pk_morec[i - MAXSTD].cp_packet; + flag = UnSign8(*p); + p0 = g->g_un.g_details; + g0 = g; + } + if ((pk0->pk_dyn_f = flag >> 4) == 14) { + register char *p = p0, *rp = rp0; + register int j, ls, rs, i, w; + + /* + * Expand a bit-packed representation. + * If we get lucky, it is byte packed and + * we can just copy it over. + */ + i = g0->g_height; + j = g0->g_width; + if ((j & 7) == 0) { + bcopy(p, rp, i * (j >> 3)); + goto done; + } + + /* + * No such luck. + */ + w = j; + ls = 0; + while (--i >= 0) { + rs = 8 - ls; + /* know j always != 8 */ + for (j = w; j > 8; j -= 8) { + *rp = *p++ << ls; + *rp++ |= UnSign8(*p) >> rs; + } + + /* + * We need j more bits; there are rs + * bits available at *p. Ask for j, + * which gets min(j, rs). + */ + *rp++ = (*p << ls) & bmask[j]; + /* account for j bits */ + ls += j; ls &= 7; + /* then adjust j based on rs */ + j -= rs; + /* still need j more bits */ + if (j < 0) /* got them all */ + continue; + p++; + if (j == 0) /* there were just enough */ + continue; + /* take j more bits */ + rp[-1] |= UnSign8(*p & bmask[j]) >> rs; + } + } else { + register struct pk_details *pk = pk0; + register int on = flag & 8 ? 0xff : 0; + register char *rowp; /* pointer into this row */ + register int j; /* trimmed run count */ + register int k; /* misc */ + register int b; /* bit index in current col */ + register int i; /* run count */ + register int colsleft; /* columns left this row */ + register int rowsleft; /* rows left */ + static char *row; /* a one-row buffer */ + static int rowsize; /* and its size in bytes */ + int wb; /* row width in bytes */ + + wb = (g0->g_width + 7) >> 3; + if (rowsize < wb) { /* get more row space */ + if (row) + free(row); + /* keep a slop byte */ + row = malloc((unsigned) (wb + 1)); + if (row == NULL) + return (-1); /* ??? */ + rowsize = wb; + } + bzero(row, wb); + rowsleft = g0->g_height; + colsleft = g0->g_width; + pk->pk_repeat = 0; + pk->pk_ptr = p0; + pk->pk_1nyb = 0; /* start on nybble 0 */ + rowp = row; + b = 0; + while (rowsleft > 0) { /* do all rows */ + /* EXPAND IN LINE? */ + i = pk_unpack(pk); + /* + * Work until the run count is exhausted + * (or at least pretty tired). + * + * (Okay, so the joke is stolen!) + */ + while ((j = i) > 0) { + /* + * If the count is more than the + * rest of this row, trim it down. + */ + if (j > colsleft) + j = colsleft; + i -= j; /* call them done */ + /* + * We need k=8-b bits to finish + * up the current byte. If we + * can finish it, do so; the proper + * bits to set are in rbits[k]. + */ + if (j >= (k = 8 - b)) { + j -= k; + colsleft -= k; + *rowp++ |= on & rbits[k]; + b = 0; + } + /* + * Set any full bytes. + */ + while (j >= 8) { + *rowp++ = on; + j -= 8; + colsleft -= 8; + } + /* + * Finally, begin a new byte, or + * add to the current byte, with + * j more bits. We know j <= 8-b. + * (If j==0, we may be writing on + * our slop byte, which is why we + * keep one around....) + */ +if (j > 8-b) panic("pk_rasterise j>8-b"); + *rowp |= (on & bmask[j]) >> b; + colsleft -= j; + b += j; b &= 7; + if (colsleft == 0) { + pk->pk_repeat++; + rowsleft -= pk->pk_repeat; + while (--pk->pk_repeat >= 0) { + bcopy(row, rp0, wb); + rp0 += wb; + } +if (rowsleft == 0 && i) panic("pk_rasterise leftover bits"); + pk->pk_repeat = 0; + rowp = row; + colsleft = g0->g_width; + bzero(row, wb); + b = 0; + } + } + on = 0xff - on; + } + } + +done: + /* + * Successfully converted another glyph. + */ + pk0->pk_gleft--; + } + +if (pk0->pk_gleft < 0) +panic("%s: gleft==%d", f->f_path, pk0->pk_gleft); + if (pk0->pk_gleft == 0) { + free(pk0->pk_base); + if (pk0->pk_morec != NULL) + free((char *) pk0->pk_morec); + free((char *) pk0); + f->f_details = NULL; + } + return (0); +} + +/* + * Discard the font details. + */ +static void +pk_freefont(f) + struct font *f; +{ + register struct pk_details *pk = ftopk(f); + + if (pk != NULL) { + free(pk->pk_base); + if (pk->pk_morec != NULL) + free((char *) pk->pk_morec); + free((char *) pk); + } +} diff --git a/Build/source/texk/seetexk/postamble.h b/Build/source/texk/seetexk/postamble.h new file mode 100644 index 00000000000..6931b46d409 --- /dev/null +++ b/Build/source/texk/seetexk/postamble.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* Definitions for ScanPostAmble */ + +/* + * ScanPostAmble reads the postamble of a DVI file from the (stdio) + * file specified in its first argument. It is handed two pointers to + * functions. The first (ScanPostAmble's second argument) is called + * after the header information has been read, and given a pointer to a + * PostAmbleInfo structure. It is the job of this function to extract the + * required information from this structure (which is deallocated when + * ScanPostAmble returns). + * + * The second function is called once for each font definition occurring in + * the postamble, and is given a pointer to a PostAmbleFont structure. This + * function should do whatever the device needs to read the actual font. + * + * If the DVI file appears malformed, ScanPostAmble will print an error + * message and exit. (Drastic, perhaps, but effective.) + */ + +struct PostAmbleInfo { + i32 pai_PrevPagePointer; /* previous page pointer */ + i32 pai_Numerator; /* numerator from dvi file */ + i32 pai_Denominator; /* denominator from dvi file*/ + i32 pai_DVIMag; /* \magnification */ + i32 pai_TallestPageHeight; /* height of tallest page */ + i32 pai_WidestPageWidth; /* width of widest page */ + int pai_DVIStackSize; /* DVI stack size required */ + int pai_NumberOfPages; /* total number of pages in DVI file */ +}; + +struct PostAmbleFont { + char *paf_name; /* name of font (null terminated) */ + int paf_n1; /* length of first part of name */ + int paf_n2; /* length of second part of name */ + i32 paf_DVIFontIndex; /* font index number */ + i32 paf_DVIChecksum; /* checksum from DVI file */ + i32 paf_DVIMag; /* "at size" */ + i32 paf_DVIDesignSize; /* design size of font */ +}; + +int ScanPostAmble(); diff --git a/Build/source/texk/seetexk/pxlfont.c b/Build/source/texk/seetexk/pxlfont.c new file mode 100644 index 00000000000..3d3e40cbf8a --- /dev/null +++ b/Build/source/texk/seetexk/pxlfont.c @@ -0,0 +1,306 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/pxlfont.c,v 2.5 89/08/22 21:55:34 chris Exp $"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include "types.h" +#include "error.h" +#include "font.h" +#include "fio.h" + +/* + * PXL font operations. + */ +static int pxl_read(), pxl_getgly(), pxl_rasterise(); +static void pxl_freefont(); + +struct fontops pxlops = + { "pxl", 0, 5.0, pxl_read, pxl_getgly, pxl_rasterise, pxl_freefont }; + +/* + * Local info. + */ +#define PXLID 1001 /* ID denoting PXL files */ +#define TAILSIZE (517 * 4) /* size of pxl tail info */ + +/* + * pc describes one PXL character information block. + */ +struct pc { + i16 pc_width; /* character width (pixels) */ + i16 pc_height; /* character height (pixels) */ + i16 pc_xoffset; /* X offset of reference point */ + i16 pc_yoffset; /* Y offset of reference point */ + i32 pc_rastoff; /* raster offset */ + i32 pc_TFMwidth; /* TFM width (FIXes) */ +}; + +/* + * pxl_details are the PXL-specific font details. + * + * We keep track of the number of characters converted to internal + * glyph form, and when all have been done, we discard the now- + * useless details. + */ +struct pxl_details { + int pd_nconv; /* number of characters converted */ + char *pd_ras; /* raster space, until converted */ + struct pc pd_pc[128]; /* `font directory' */ +}; + +/* + * Get the pxl_details from font f. + */ +#define ftopd(f) ((struct pxl_details *) (f)->f_details) + +extern errno; +#ifndef KPATHSEA +char *malloc(); +#endif + +/* + * Read a PXL file. + */ +static int +pxl_read(f, fd) + struct font *f; + int fd; +{ + register struct pxl_details *pd; + register FILE *fp; + register struct pc *pc; + register int i; + int saverr; + i32 pxlid; + struct stat st; + + fp = NULL; + if ((pd = (struct pxl_details *)malloc(sizeof (*pd))) == 0) + goto fail; + pd->pd_ras = 0; + + /* + * There should be 4n bytes, with an absolute minimum of TAILSIZE+4 + * (+4 for the initial PXLID). + */ + (void) fstat(fd, &st); + if ((st.st_size & 3) != 0 || st.st_size < (TAILSIZE + 4)) { + errno = EINVAL; + goto fail; + } + + /* + * Set up the raster pointer (if we need rasters). + */ + if (f->f_flags & FF_RASTERS) { + i = st.st_size - (TAILSIZE + 4); + if (i != 0) { + if ((pd->pd_ras = malloc((unsigned) i)) == 0) + goto fail; + (void) lseek(fd, 4L, 0); + if (read(fd, pd->pd_ras, i) != i) + goto fail; + } + } + + /* + * Read the glyph information. + */ + errno = 0; /* try to make errno meaningful */ + if ((fp = fdopen(fd, "r")) == NULL) { + if (errno == 0) + errno = EMFILE; + goto fail; + } + (void) fseek(fp, (long) -TAILSIZE, 2); + for (i = 128, pc = pd->pd_pc; --i >= 0; pc++) { + fGetWord(fp, pc->pc_width); + fGetWord(fp, pc->pc_height); + fGetWord(fp, pc->pc_xoffset); + fGetWord(fp, pc->pc_yoffset); + fGetLong(fp, pc->pc_rastoff); + fGetLong(fp, pc->pc_TFMwidth); + } + f->f_checksum = GetLong(fp); + (void) GetLong(fp); /* mag */ + f->f_design_size = GetLong(fp); /* designsize */ + f->f_hppp = 0; /* ??? maybe 200? */ + f->f_vppp = 0; + (void) GetLong(fp); /* dirpointer */ + pxlid = GetLong(fp); + if (pxlid != PXLID) + error(0, 0, "Warning: strange PXL id (%d) in \"%s\"", + pxlid, f->f_path); + + f->f_details = (char *)pd; + if (FontHasGlyphs(f, 0, 128)) + goto fail; + (void) fclose(fp); + pd->pd_nconv = 0; + return (0); + +fail: + saverr = errno; + if (pd) { + if (pd->pd_ras) + free(pd->pd_ras); + free((char *)pd); + } + if (fp) + (void) fclose(fp); + else + (void) close(fd); + errno = saverr; + return (-1); +} + +/* + * Obtain the specified range of glyphs. + */ +static int +pxl_getgly(f, l, h) + register struct font *f; + int l; + register int h; +{ + register struct glyph *g; + register struct pc *pc; + register int i; + struct pxl_details *pd; + + if ((pd = ftopd(f)) == NULL) + error(1, 0, "pxl_getgly details==0: cannot happen"); + /* + * By definition, all 128 glyphs are valid. Just copy the + * PXL information. + */ + for (pc = &pd->pd_pc[i = l]; i < h; i++, pc++) { + g = f->f_gly[i]; + g->g_flags = GF_VALID; + g->g_height = pc->pc_height; + g->g_width = pc->pc_width; + g->g_yorigin = pc->pc_yoffset; + g->g_xorigin = pc->pc_xoffset; + g->g_rawtfmwidth = pc->pc_TFMwidth; + } + return (0); +} + +/* + * Helper function for rasterise: return a pointer to a converted + * (malloc()ed and minimised) raster. + */ +static char * +makeraster(h, w, rp) + register int h, w; + register char *rp; +{ + register char *cp; + register int i, o; + char *rv; + + /* + * The height and width values are in bits. Convert width to + * bytes, rounding up. The raw raster (at rp) is almost what + * we want, but not quite: it has `extra' bytes at the end of + * each row, to pad out to a multiple of four bytes. + */ + w = (w + 7) >> 3; + o = (4 - w) & 3; /* offset (number of `extra' bytes) */ + if ((cp = malloc((unsigned) (h * w))) == NULL) + return (NULL); + if (o == 0) { + /* + * The raster fits exactly; just copy it to the allocated + * memory space. (We must copy anyway, so that glyphs + * can be freed, e.g., after rotation.) + */ + bcopy(rp, cp, h * w); + return (cp); + } + rv = cp; + while (--h >= 0) { + /* + * Copy each row, then skip over the extra stuff. + */ + for (i = w; --i >= 0;) + *cp++ = *rp++; + rp += o; + } + return (rv); +} + +/* + * Obtain rasters for the specified glyphs. + */ +static int +pxl_rasterise(f, l, h) + register struct font *f; + int l; + register int h; +{ + register struct glyph *g; + register struct pc *pc; + register int i; + register struct pxl_details *pd; + + if ((pd = ftopd(f)) == NULL) + error(1, 0, "pxl_rasterise details==0: cannot happen"); + if (pd->pd_ras == NULL) + error(1, 0, "pxl_rasterise pd_ras==NULL: cannot happen"); + for (pc = &pd->pd_pc[i = l]; i < h; i++, pc++) { + g = f->f_gly[i]; + if (pc->pc_rastoff == 0) { + /* + * g should not claim a raster, since it has none. + */ + if (HASRASTER(g)) + error(1, 0, "bad PXL glyph %d in \"%s\"", + g->g_index, f->f_path); + } else { + g->g_raster = makeraster(pc->pc_height, pc->pc_width, + pd->pd_ras + ((pc->pc_rastoff - 1) << 2)); + if (g->g_raster == NULL) + return (-1); /* ??? */ + g->g_rotation = ROT_NORM; + } + } + + /* + * If we have converted all the characters, dump the + * pre-conversion rasters. In fact, dump everything. + */ + pd->pd_nconv += h - l; + if (pd->pd_nconv == 128) { + free(pd->pd_ras); + free((char *)pd); + f->f_details = NULL; + } + return (0); +} + +/* + * Discard the font details. + */ +static void +pxl_freefont(f) + struct font *f; +{ + struct pxl_details *pd; + + if ((pd = ftopd(f)) != NULL) { + if (pd->pd_ras != NULL) + free(pd->pd_ras); + free((char *)pd); + } +} diff --git a/Build/source/texk/seetexk/rotate.c b/Build/source/texk/seetexk/rotate.c new file mode 100644 index 00000000000..757a479f291 --- /dev/null +++ b/Build/source/texk/seetexk/rotate.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/rotate.c,v 2.4 89/08/22 21:56:05 chris Exp $"; +#endif + +/* + * Routines to generate rotated bitmaps given unrotated inputs. + * + * The rotated bitmap is indistinguishable from the unrotated one (aside + * from being rotated of course!). + */ + +#include "types.h" +#include "error.h" +#include "font.h" + +static void RotateClockwise(); + +#if !defined( WIN32 ) && !defined( _AMIGA ) +extern int errno; +char *malloc(); +#endif + +/* + * Rounding, but by powers of two only. + */ +#define ROUND(n,r) (((n) + ((r) - 1)) & ~((r) - 1)) + +/* + * Set the rotation of glyph g to r. + */ +void SetRotation(g, r) + register struct glyph *g; + int r; +{ + + if (r < ROT_NORM || r > ROT_RIGHT) + error(1, 0, "bad rotation value %d", r); + + /* + * The null glyph is trivial to rotate by any amount. + * + * Note that this assumes that any raster has been obtained + * BEFORE calling SetRotation()! + */ + if (g->g_raster == NULL) { + g->g_rotation = r; + return; + } + + /* + * This is hardly efficient, but it *is* expedient.... + */ + while (g->g_rotation != r) { + RotateClockwise(g); + g->g_rotation = (g->g_rotation - 1) & 3; + } +} + +/* + * Rotation by 1/4 turn clockwise (from ROT_NORM to ROT_RIGHT, e.g.). + */ +static void +RotateClockwise(glyph) + struct glyph *glyph; +{ + register char *nrast; /* new raster */ + register char *orast; /* old raster */ + register int oheight; /* old raster height, new raster width */ + register int owidth; /* old raster width, new raster height */ + unsigned int size; /* size of new raster (in bytes) */ + int nplus; /* offset between rows in nrast */ + + /* + * First, get a new raster. + */ + { + register struct glyph *g = glyph; + register int t; + + oheight = g->g_height; + owidth = g->g_width; + + /* + * Offset is (new width) rounded to bytes. + */ + nplus = ROUND(oheight, 8) >> 3; + + /* + * Size of new raster is (new height) * (new rounded width, + * in bytes). + */ + size = nplus * owidth; + if ((nrast = malloc(size)) == NULL) + error(1, errno, "out of memory"); + bzero(nrast, size); + + /* + * New y origin is old x origin; new x origin is old height + * minus old y origin - 1. + */ + t = g->g_yorigin; + g->g_yorigin = g->g_xorigin; + g->g_xorigin = oheight - t - 1; + + /* While we are at it, exchange height & width... */ + g->g_height = owidth; + g->g_width = oheight; + + /* and grab a pointer to the old raster. */ + orast = g->g_raster; + } + + /* + * Now copy bits from the old raster to the new one. The mapping + * function is + * + * for i in [0..height) + * for j in [0..width) + * new[j, height-i-1] = old[i, j] + * + * Thus i maps to height-i-1 and (since we have to do our own 2 + * dimensional array indexing) j to nplus*j. We call the mapped + * variables mapi and mapj, and, since we scan sequentially through + * the old raster, can discard the original i and j. + */ + { + register int mapj, c, k, mapi; + + mapi = oheight; + owidth *= nplus; + while (--mapi >= 0) { + k = 7; + for (mapj = 0; mapj < owidth; mapj += nplus) { + if (++k == 8) /* get another byte */ + c = *orast++, k = 0; + if (c & 0x80) /* old[i,j] was set */ + nrast[mapj + (mapi >> 3)] |= + 1 << (7 - (mapi & 7)); + c <<= 1; + } + } + } + + /* + * Finally, free the storage associated with the original raster. + */ + free(glyph->g_raster); + glyph->g_raster = nrast; +} diff --git a/Build/source/texk/seetexk/rstfont.c b/Build/source/texk/seetexk/rstfont.c new file mode 100644 index 00000000000..589e9417507 --- /dev/null +++ b/Build/source/texk/seetexk/rstfont.c @@ -0,0 +1,301 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + * + * The code in this file was partially derived from another version by + * Tim Morgan at UCI. + * + * TODO: + * test + */ + +#ifndef lint +static char rcsid[] = "$Header$"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include "types.h" +#include "error.h" +#include "font.h" +#include "fio.h" + +/* + * RST (Imagen's font format) font operations. + */ +static int rst_read(), rst_getgly(), rst_rasterise(); +static void rst_freefont(); + +#ifdef UCI +#define D 1.0 /* I think */ +#else +#define D 150.0 +#endif + +struct fontops rstops = + { "rst", 0, D, rst_read, rst_getgly, rst_rasterise, rst_freefont }; + +#undef D + +/* + * Local info. + */ +#define FILEMARK_SIZE 8 /* header `file mark' bytes to skip */ + +/* + * rc describes one RST character information block. + */ +struct rc { + i16 rc_height; /* character height (pixels) */ + i16 rc_width; /* character width (pixels) */ + i16 rc_yoffset; /* Y offset of reference point */ + i16 rc_xoffset; /* X offset of reference point */ + i32 rc_rastoff; /* raster offset */ + i32 rc_TFMwidth; /* TFM width */ +}; + +/* + * rst_details are the RST-specific font details. + * + * We keep track of the number of characters converted to internal + * glyph form, and when all have been done, we discard the now- + * useless details. + */ +struct rst_details { + int rd_unconv; /* number of characters unconverted */ + struct rc *rd_rc; /* `font directory' */ + char *rd_ras; /* raster space, until converted */ + long rd_rastbase; /* adjust rc_rastoff by rastbase */ +}; + +/* + * Get the rst_details from font f. + */ +#define ftord(f) ((struct rst_details *)(f)->f_details) + +#if !defined( WIN32 ) && !defined( _AMIGA ) +extern errno; +char *malloc(); +long ftell(); +#endif + +/* + * Read an RST file. + */ +static int +rst_read(f, fd) + struct font *f; + int fd; +{ + register struct rst_details *rd; + register FILE *fp; + register struct rc *rc; + register int i; + int saverr; + long presize, diroff; + i32 firstgly, lastgly; + + fp = NULL; + if ((rd = (struct rst_details *)malloc(sizeof *rd)) == 0) + goto fail; + rd->rd_ras = 0; + rd->rd_rc = 0; + + /* + * Read the header. + */ + errno = 0; /* try to make errno meaningful */ + if ((fp = fdopen(fd, "r")) == NULL) { + if (errno == 0) + errno = EMFILE; + goto fail; + } + (void) fseek(fp, (long)FILEMARK_SIZE, 0); + fGetWord(fp, presize); /* bytes in preamble (from FILEMARK_SIZE+2) */ + presize += 2 + FILEMARK_SIZE; + i = getc(fp); /* version */ + if (i != 0) { + error(0, 0, "Warning: strange RST version (%d) in \"%s\"", i, + f->f_path); + errno = EINVAL; + goto fail; + } + fGet3Byte(fp, diroff); /* offset to glyph directory */ + fGetWord(fp, firstgly); /* first glyph */ + fGetWord(fp, lastgly); /* last glyph (inclusive) */ + lastgly++; /* make it exclusive */ + + (void) GetLong(fp); /* mag */ + fGetLong(fp, f->f_design_size); + /* interline, interword, rotation, charadv, lineadv */ + (void) fseek(fp, (long)(4 + 4 + 2 + 1 + 1), 1); + fGetLong(fp, f->f_checksum); + f->f_hppp = 0; /* ??? */ + f->f_vppp = 0; + + /* + * Read the glyph directory. + */ + i = lastgly - firstgly; + rd->rd_rc = (struct rc *)malloc((unsigned) (i * sizeof(*rc))); + if (rd->rd_rc == 0) + goto fail; + (void) fseek(fp, presize, 0); + for (rc = rd->rd_rc; --i >= 0; rc++) { + fGetWord(fp, rc->rc_height); + fGetWord(fp, rc->rc_width); + fGetWord(fp, rc->rc_yoffset); + fGetWord(fp, rc->rc_xoffset); + fGetLong(fp, rc->rc_TFMwidth); + fGet3Byte(fp, rc->rc_rastoff); + } + + /* + * Set up the raster pointer (if we need rasters). + */ + if (f->f_flags & FF_RASTERS) { + struct stat st; + + rd->rd_rastbase = ftell(fp); + /* back to unbuffered I/O */ + (void) fstat(fd, &st); + i = st.st_size - presize - 15 * (lastgly - firstgly); + if (i < 0) + error(1, 0, "calculated raster size < 0 for \"%s\"", + f->f_path); + if (i != 0) { + if ((rd->rd_ras = malloc((unsigned) i)) == 0) + goto fail; + (void) lseek(fd, rd->rd_rastbase, 0); + if (read(fd, rd->rd_ras, i) != i) + goto fail; + } + } + + f->f_details = (char *) rd; + if (FontHasGlyphs(f, firstgly, lastgly)) + goto fail; + + (void) fclose(fp); + rd->rd_unconv = lastgly - firstgly; + return (0); + +fail: + saverr = errno; + if (rd) { + if (rd->rd_rc) + free((char *)rd->rd_rc); + if (rd->rd_ras) + free(rd->rd_ras); + free((char *) rd); + } + if (fp) + (void) fclose(fp); + else + (void) close(fd); + errno = saverr; + return (-1); +} + +/* + * Obtain the specified range of glyphs. + */ +static int +rst_getgly(f, l, h) + register struct font *f; + int l; + register int h; +{ + register struct glyph *g; + register struct rc *rc; + register int i; + struct rst_details *rd; + + if ((rd = ftord(f)) == NULL) + panic("rst_getgly"); + + /* + * By definition, all glyphs are valid. Just copy the + * RST information. + */ + for (rc = &rd->rd_rc[(i = l) - f->f_lowch]; i < h; i++, rc++) { + g = f->f_gly[i]; + g->g_flags = GF_VALID; + g->g_height = rc->rc_height; + g->g_width = rc->rc_width; + g->g_yorigin = rc->rc_yoffset; + g->g_xorigin = rc->rc_xoffset; + g->g_rawtfmwidth = rc->rc_TFMwidth; + } + return (0); +} + +/* + * Obtain rasters for the specified glyphs. + */ +static int +rst_rasterise(f, l, h) + register struct font *f; + int l; + register int h; +{ + register struct glyph *g; + register struct rc *rc; + register struct rst_details *rd; + register int i; + unsigned sz; + + if ((rd = ftord(f)) == NULL) + panic("rst_rasterise details==0"); + if (rd->rd_ras == NULL) + panic("rst_rasterise rd_ras==NULL"); + for (rc = &rd->rd_rc[(i = l) - f->f_lowch]; i < h; i++, rc++) { + g = f->f_gly[i]; + if (!HASRASTER(g)) + continue; + if (rc->rc_rastoff == 0) { + error(1, 0, "bad RST glyph %d in \"%s\"", + g->g_index, f->f_path); + } else { + sz = ((g->g_width + 7) >> 3) * g->g_height; + if ((g->g_raster = malloc(sz)) == NULL) + return (-1); /* ??? */ + g->g_rotation = ROT_NORM; + bcopy(rd->rd_ras + rc->rc_rastoff - rd->rd_rastbase, + g->g_raster, sz); + } + } + + /* + * If we have converted all the characters, dump the + * pre-conversion rasters. In fact, dump everything. + */ + rd->rd_unconv -= h - l; + if (rd->rd_unconv == 0) { + free((char *)rd->rd_rc); + free(rd->rd_ras); + free((char *)rd); + f->f_details = NULL; + } + return (0); +} + +/* + * Discard the font details. + */ +static void +rst_freefont(f) + struct font *f; +{ + struct rst_details *rd; + + if ((rd = ftord(f)) != NULL) { + free((char *)rd->rd_rc); + free(rd->rd_ras); + free((char *)rd); + } +} diff --git a/Build/source/texk/seetexk/scaletfm.c b/Build/source/texk/seetexk/scaletfm.c new file mode 100644 index 00000000000..f6444d5d369 --- /dev/null +++ b/Build/source/texk/seetexk/scaletfm.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/scaletfm.c,v 3.2 89/11/23 16:34:43 chris Exp $"; +#endif + +#include "types.h" +#include "error.h" +#include "font.h" + +/* + * From DVITYPE.WEB: + * + * ``The most important part of in_TFM is the width computation, which + * involvles multiplying the relative widths in the TFM file by the scaling + * factor in the DVI file. This fixed-point multiplication must be done with + * precisely the same accuracy by all DVI-reading programs, in order to + * validate the assumptions made by DVI-writing programs like \TeX 82. + * + * Let us therefore summarize what needs to be done. Each width in a TFM + * file appears as a four-byte quantity called a fix_word. A fix_word whose + * respective bytes are (a,b,c,d) represents the number + * + * {{ b * 2^{-4} + c * 2^{-12} + d * 2^{-20}, if a = 0; + * x = {{ + * {{ -16 + b * 2^{-4} + c * 2^{-12} + d * 2^{-20}, if a = 255. + * + * (No other choices of a are allowed, since the magnitude of a TFM dimension + * must be less than 16.) We want to multiply this quantity by the integer + * z, which is known to be less than 2^{27}. Let \alpha = 16z. If z < + * 2^{23}, the individual multiplications b * z, c * z, d * z cannot + * overflow; otherwise we will divide z by 2, 4, 8, or 16, to obtain a + * multiplier less than 2^{23}, and we can compensate for this later. If z + * has thereby been replaced by z' = z/2^e, let \beta = 2^{4-e}; we shall + * compute + * + * \lfloor (b + c * 2^{-8} + d * 2^{-16})z' / \beta \rfloor + * + * if a = 0, or the same quantity minus \alpha if a = 255. This calculation + * must be done exactly, for the reasons stated above; the following program + * does the job in a system-independent way, assuming that arithmetic is + * exact on numbers less than 2^{31} in magnitude.'' + */ +#define ZLIM ((i32)1 << 23) /* z must be < zlim */ + +/* + * Scale the single TFM width t by z. + */ +i32 +ScaleOneWidth(t, z) + register i32 t, z; +{ + register i32 alpha, log2beta; + register int a0; + + /* First compute \alpha, \beta, and z': */ + alpha = 16 * z; + log2beta = 4; + while (z >= ZLIM) { + z >>= 1; + log2beta--; + } + + /* The four values 'a', 'b', 'c', and 'd' are fields within t: */ +#define a (UnSign8(t >> 24)) +#define b (UnSign8(t >> 16)) +#define c (UnSign8(t >> 8)) +#define d (UnSign8(t)) + if (t) { + a0 = a; + t = (((((d * z) >> 8) + c * z) >> 8) + b * z) >> log2beta; + if (a0) { + if (a0 != 255) + error(0, 0, "bad TFM width! [ScaleOneWidth]"); + t -= alpha; + } + } + return (t); +} + +/* + * Scale a set of glyphs [l..h) in font f according to f->f_dvimag + * (that is, set g_tfmwidth from g_rawtfmwidth). + */ +ScaleGlyphs(f, l, h) + register struct font *f; + int l, h; +{ + register int i, a0; + register i32 t, z, alpha, log2beta; + + z = f->f_dvimag; + alpha = 16 * z; + log2beta = 4; + while (z >= ZLIM) { + z >>= 1; + log2beta--; + } + + for (i = l; i < h; i++) { + if ((t = f->f_gly[i]->g_rawtfmwidth) != 0) { + a0 = a; + t = (((((d * z) >> 8) + c * z) >> 8) + b * z) >> + log2beta; + if (a0) { + if (a0 != 255) + error(0, 0, + "\"%s\", glyph %d: bad TFM width", + f->f_path, i); + t -= alpha; + } + } + f->f_gly[i]->g_tfmwidth = t; + } +} diff --git a/Build/source/texk/seetexk/scanpost.c b/Build/source/texk/seetexk/scanpost.c new file mode 100644 index 00000000000..f71b33c9b5c --- /dev/null +++ b/Build/source/texk/seetexk/scanpost.c @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/local/src/SeeTeX/libtex/RCS/scanpost.c,v 1.2 90/07/10 14:33:23 grunwald Exp Locker: grunwald $"; +#endif + +/* + * ScanPostAmble - read a DVI postamble. + */ + +#include <stdio.h> +#include "types.h" +#include "dvicodes.h" +#include "fio.h" +#include "gripes.h" +#include "postamble.h" + +ScanPostAmble(f, headerfunc, fontfunc) + register FILE *f; + void (*headerfunc)(); + register void (*fontfunc)(); +{ + register int n; + register char *s; + char name[512]; + + if (FindPostAmble(f)) { + GripeCannotFindPostamble(); + return(1); + } + if (GetByte(f) != Sign8(DVI_POST)) { + GripeMissingOp("POST"); + return(1); + } + + /* Read the postamble info stuff. */ + { + struct PostAmbleInfo pai; + register struct PostAmbleInfo *p = &pai; + + p->pai_PrevPagePointer = GetLong(f); + p->pai_Numerator = GetLong(f); + p->pai_Denominator = GetLong(f); + p->pai_DVIMag = GetLong(f); + p->pai_TallestPageHeight = GetLong(f); + p->pai_WidestPageWidth = GetLong(f); + p->pai_DVIStackSize = GetWord(f); + p->pai_NumberOfPages = GetWord(f); + + (*headerfunc)(p); + } + + /* Now read all the font definitions. */ + { + struct PostAmbleFont paf; + register struct PostAmbleFont *p = &paf; + int c; + + for (;;) { + if ((c = getc(f)) == EOF) + GripeUnexpectedDVIEOF(); + switch (c) { + + case DVI_NOP: + break; + + case DVI_FNTDEF1: + p->paf_DVIFontIndex = UnSign8(getc(f)); + break; + + case DVI_FNTDEF2: + p->paf_DVIFontIndex = UnSign16(GetWord(f)); + break; + + case DVI_FNTDEF3: + p->paf_DVIFontIndex = UnSign24(Get3Byte(f)); + break; + + case DVI_FNTDEF4: + p->paf_DVIFontIndex = GetLong(f); + break; + + case DVI_POSTPOST: + return(0); + + default: + GripeMissingOp("POSTPOST"); + return(1); + /*NOTREACHED*/ + } + p->paf_DVIChecksum = GetLong(f); + p->paf_DVIMag = GetLong(f); + p->paf_DVIDesignSize = GetLong(f); + p->paf_n1 = UnSign8(getc(f)); + p->paf_n2 = UnSign8(getc(f)); + p->paf_name = name; /* never trust people not to + clobber it */ + n = p->paf_n1 + p->paf_n2; + s = name; + while (--n >= 0) + *s++ = GetByte(f); + *s = 0; + (*fontfunc)(p); + } + } +} diff --git a/Build/source/texk/seetexk/sdecode.c b/Build/source/texk/seetexk/sdecode.c new file mode 100644 index 00000000000..02fe746da08 --- /dev/null +++ b/Build/source/texk/seetexk/sdecode.c @@ -0,0 +1,689 @@ +/* + * Copyright (c) 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/sdecode.c,v 3.4 89/11/06 15:01:07 chris Exp $"; +#endif + +#include <stdio.h> +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "types.h" +#include "error.h" +#include "sdecode.h" + +static char cclass[256]; /* XXX assumes 8-bit char */ +#define CCL_SPACE 0x01 /* white space */ +#define CCL_SEMI 0x02 /* `semicolon' (statement separator) */ +#define isstopc(c) (cclass[c] != 0) /* both space and semi char */ +static int sdset; /* flag says whether cclass[] set up */ + +static void args(), badarg(); +static int scan(struct decode_info *di, char **fmt, ...), scan_i(), scan_d(); + +extern char *strsave(); + +extern char *DVIFileName; + +#ifndef BLOCK_COPY +/* + * Copy the text at `src' `downward' in memory for `len' bytes. + * This is like strcpy or memcpy, but handles one direction of + * overlap (when dst < src). + */ +static void +movedown(src, dst, len) + register char *src, *dst; + register int len; +{ + + while (--len >= 0) + *dst++ = *src++; +} +#endif + +/* + * We have a number of states to do word interpretation. Outside words, + * we skip blanks and `semicolons'. The first non-blank, non-`semi' enters + * WORD state; in WORD state, double quote characters switch to + * QUOTE state, after which another double quote switches back to + * WORD state, and blanks and `semi' end WORD state, switching to DONE. + * While in WORD or QUOTE states, `c produces c for all characters c; + * to do this, we use two more states. + */ +#define S_DULL 0 /* not in a word */ +#define S_WORD 1 /* in a word */ +#define S_QUOTE 2 /* inside "" in a word */ +#define S_BKQT1 3 /* not in "", but just read one ` */ +#define S_BKQT2 4 /* in "", but just read one ` */ +#define S_DONE 5 /* found end of word */ + +/* + * Structure used to communicate between the various functions. + */ +struct decode_info { + /* data used to read from input file */ + int di_nch; /* number of characters remaining in buffer */ + char *di_cp; /* next character to be read from buffer */ + long di_nfilech; /* number of characters remaining in file */ + FILE *di_file; /* the file itself */ + + /* information used and/or returned by the canon routine */ + int di_lexstate; /* lexical state */ + int di_call; /* set when we reach terminating `semicolon' */ + + /* information used more globally */ + char *di_word; /* last word from word() */ + char *di_kw; /* the keyword */ + int di_bkw; /* true iff keyword is in static buffer */ +}; + +/* + * `Edit' the text in the buffer in-place. + * Return the count of characters resulting from the edit (e.g., + * from `foo`"bar' the count would be 7). + * Set di_call if we reach state S_DONE by encountering a `semicolon'. + * The edited text begins wherever di_cp points. + * We begin the edit in the state given by di_lexstate. + */ +static int +canon(di) + register struct decode_info *di; +{ + register int state, c, n; + register char *cp, *outp, *s; + + state = di->di_lexstate; + n = di->di_nch; + cp = outp = di->di_cp; + while (--n >= 0) { + c = *cp++; + switch (state) { + + case S_DULL: + if (isstopc(c)) + continue; + state = S_WORD; + /* FALLTHROUGH */ + + case S_WORD: + if (c == '"') { + state = S_QUOTE; + continue; + } + if (c == '`') { + state = S_BKQT1; + continue; + } + /* look for `semicolon' (call) characters */ + if (cclass[c] & CCL_SEMI) + di->di_call = 1; + if (isstopc(c)) { + state = S_DONE; + goto done; + } + break; + + case S_QUOTE: + if (c == '`') { + state = S_BKQT2; + continue; + } + if (c == '"') { + state = S_WORD; + continue; + } + break; + + case S_BKQT1: + state = S_WORD; + break; + + case S_BKQT2: + state = S_QUOTE; + break; + + default: + panic("sdecode canon"); + /* NOTREACHED */ + } + *outp++ = c; + } + n = 0; +done: + c = outp - di->di_cp; /* wrote this many chars */ + di->di_lexstate = state;/* save new state */ + di->di_nch = n; /* and new counts and pointers */ + di->di_cp = cp; + return (c); +} + +#define WDMAX BUFSIZ /* when testing, make this small */ + +/* + * Read a word from the input file. + * Returns NULL (and sets di_call) at end of \special. + * + * We gather up to WDMAX + k characters at a time into an input + * buffer, and lex them using `canon' above. The result is at most + * as long as the original text. Since a single legal word might + * be up to WDMAX bytes long, k must be at least 1 (for the trailing + * NUL). If the input word is longer, we flush the trailing part, + * using the k `extra' bytes (and again k must be at least 1). + * + * If there is a current keyword and it is in the current buffer + * (di_bkw != 0), and we have to move existing buffer text around + * or write over it with new file text, we save the keyword and + * clear di_bkw. + */ +static char * +word(di, quietly) + register struct decode_info *di; + int quietly; +{ + register int n; + register char *p; + register int len, trunc = 0; + static char inbuf[WDMAX + 20]; /* k=20 */ + + len = 0; /* no word bytes yet */ + p = di->di_cp; /* where canon() writes (nil if first time) */ + di->di_lexstate = S_DULL; + /* + * Loop invariants: + * len is in [0..WDMAX) + * di_lexstate != S_DONE + */ + do { + /* if the buffer is empty, refill it */ + if (di->di_nch == 0) { + /* compute remaining buffer space */ + n = sizeof inbuf - len; + /* read n bytes or rest of string, whichever smaller */ + if (di->di_nfilech < n && (n = di->di_nfilech) == 0) { + /* `eof': fake up a call-terminator */ + di->di_call = 1; + if (di->di_lexstate == S_DULL) + return (di->di_word = NULL); + break; /* take partial word */ + } + /* save keyword if this will clobber it */ + if (di->di_bkw) { + di->di_kw = strsave(di->di_kw); + di->di_bkw = 0; + } + /* if there is some canon text, move it to front */ + if (len && p > inbuf) { +#ifdef BLOCK_COPY + bcopy(p, inbuf, len); +#else + movedown(p, inbuf, len); +#endif + } + /* canon text is (or will be) at front now */ + p = inbuf; + di->di_cp = p + len; + if (fread(di->di_cp, 1, n, di->di_file) != n) { + if (ferror(di->di_file)) + error(1, -1, "error reading %s", + DVIFileName); + GripeUnexpectedDVIEOF(); + } + di->di_nfilech -= n; + di->di_nch = n; + } + n = canon(di); + if ((len += n) > WDMAX) { + len = WDMAX; + trunc = 1; + } + } while (di->di_lexstate != S_DONE); + p[len] = 0; + + /* + * If the word was too long (and hence truncated), complain + * (unless we are quietly skipping over the remains of a + * broken \special). + */ + if (trunc && !quietly) { + /* word was too long; complain */ + error(0, 0, +#if WDMAX > 20 + "over-long word in \\special: `%.20s...'", +#else + "over-long word in \\special: `%s...'", +#endif + p); + error(0, 0, "(truncated to %d characters)", WDMAX); + } + return (di->di_word = p); +} + +/* + * Initialise the character class table. + */ +void +SDsetclass(spaces, semis) + register char *spaces; + register char *semis; +{ + register int c; + + if (spaces == NULL) + spaces = "\b\t\n\f\r "; + if (semis == NULL) + semis = ";\n"; + + for (c = 0; c < sizeof cclass / sizeof *cclass; c++) + cclass[c] = 0; + while ((c = *spaces++) != 0) + cclass[c] |= CCL_SPACE; + while ((c = *semis++) != 0) + cclass[c] |= CCL_SEMI; + sdset = 1; +} + +/* + * Perform a binary search for the given string in the given table. + */ +static struct sdecode * +lookup(str, p, max) + register char *str; + register struct sdecode *p; + register int max; +{ + register struct sdecode *m; + register int dir; + + while (max > 0) { + /* + * Look at the median; pick the right hand one if + * there are two such entries (when `max' is even). + * Set dir positive if str is `greater than' m->sd_name, + * negative if it is `less'. If not equal, move + * left or right accordingly. When max is even and + * we move right, we have to use (max-1)/2 since we + * broke the tie towards the right. + */ + m = p + (max >> 1); + if ((dir = *str - *m->sd_name) == 0) + dir = strcmp(str, m->sd_name); + if (dir == 0) /* found */ + return (m); + if (dir > 0) { /* str > mid: move right */ + p = m + 1; + max = (max - 1) >> 1; + } else /* str < mid: move left */ + max >>= 1; + } + return (NULL); +} + +/* + * Decode a series of \special keywords. + * + * The table points to a sorted list of keywords to match. + * On a match, the appropriate function is called with appropriate + * arguments. + * + * Characters in `semi' (if not NULL) act like `statement separators'. + * For instance, decoding with semi=>";\n" means that + * + * \special{foo 1; bar 2 4^^Jbaz 3} + * + * tries to call foo(1), bar(2,4), and baz(3) (in that order). + */ +void +SDecode(fp, len, table, tsize) + FILE *fp; + register i32 len; + struct sdecode *table; + int tsize; +{ + register char *cp; + register struct sdecode *tp; + register int h; + struct decode_info di; + + /* set defaults, if necessary */ + if (!sdset) + SDsetclass((char *)NULL, (char *)NULL); + + di.di_nch = 0; + di.di_cp = NULL; + di.di_nfilech = len; + di.di_file = fp; + di.di_bkw = 0; + for (;;) { + di.di_call = 0; + if ((cp = word(&di, 0)) == NULL) + return; /* (all done) */ + tp = lookup(cp, table, tsize); + if (tp == NULL) { + error(0, 0, + "Warning: unrecognised \\special keyword `%s' ignored", cp); + /* di_call is not set, so fall through */ + } else { + di.di_kw = cp; + di.di_bkw = 1; + args(tp, &di); + if (!di.di_call) + error(0, 0, + "Warning: extra arguments to \\special `%s' ignored", di.di_kw); + if (!di.di_bkw) + free(di.di_kw); + di.di_bkw = 0; + } + /* eat extra arguments, or arguments to an unknown function */ + while (!di.di_call) + (void) word(&di, 1); + } +} + +/* + * Gather up the arguments to the given function, then (if all goes well) + * call that function with those arguments. On return, if di_call is not + * set, there were extra arguments left over. + */ +static void +args(tp, di) + register struct sdecode *tp; + register struct decode_info *di; +{ + char *fmt; + int n, room, f1; + i32 *ip, i[4]; + double d[2]; + + switch (tp->sd_args) { + + case sda_none: + (*tp->sd_fn)(tp->sd_name); + return; + + case sda_s: + fmt = "s"; + if (scan(di, &fmt)) + break; + (*tp->sd_fn)(tp->sd_name, di->di_word); + return; + + case sda_d: + fmt = "d"; + if (scan(di, &fmt, &i[0])) + break; + (*tp->sd_fn)(tp->sd_name, i[0]); + return; + + case sda_f: + fmt = "f"; + if (scan(di, &fmt, &d[0])) + break; + (*tp->sd_fn)(tp->sd_name, d[0]); + return; + + case sda_dd: + fmt = "dd"; + if (scan(di, &fmt, &i[0], &i[1])) + break; + (*tp->sd_fn)(tp->sd_name, i[0], i[1]); + return; + + case sda_ff: + fmt = "ff"; + if (scan(di, &fmt, &d[0], &d[1])) + break; + (*tp->sd_fn)(tp->sd_name, d[0], d[1]); + return; + + case sda_ddddff: + fmt = "ddddff"; + if (scan(di, &fmt, &i[0], &i[1], &i[2], &i[3], &d[0], &d[1])) + break; + (*tp->sd_fn)(tp->sd_name, i[0], i[1], i[2], i[3], d[0], d[1]); + return; + + case sda_nd: + f1 = 'd'; + goto array; + + case sda_nx: + f1 = 'x'; + goto array; + + case sda_rest: + (*tp->sd_fn)(tp->sd_name, + (i32)di->di_nch, di->di_cp, (i32)di->di_nfilech); + di->di_call = 1; + di->di_nch = 0; + di->di_nfilech = 0; + return; + + default: + panic("sdecode args(): sd_argtype"); + /* NOTREACHED */ + } + + /* + * If we get here, there is a missing or incorrect argument. + */ + badarg(*fmt, di); + return; + +array: + ip = (i32 *)malloc((unsigned)(room = 10) * sizeof(i32)); + if (ip == NULL) + goto nomem; + n = 0; + while (!di->di_call && word(di, 0) != NULL) { + if (scan_i(di->di_word, f1, &i[0])) { + badarg(f1, di); + free((char *)ip); + return; + } + if (n == room) { + room += 10; + ip = (i32 *)realloc((char *)ip, + (unsigned)room * sizeof(i32)); + if (ip == NULL) + goto nomem; + } + ip[n++] = i[0]; + } + (*tp->sd_fn)(tp->sd_name, n, ip); + free((char *)ip); + return; +nomem: + /* + * might as well stop: if malloc() failed, we will probably get + * nowhere fast anyway. + */ + error(1, -1, + "ran out of memory allocating %d bytes for \\special `%s'", + n * sizeof(i32), di->di_kw); + /* NOTREACHED */ + +} + +/* + * Complain about an argument. Scan() has set di_word to NULL if + * it was missing; otherwise it is incorrect. + */ +static void +badarg(c, di) + int c; + struct decode_info *di; +{ + char *s; + + switch (c) { + + case 'd': + s = "decimal"; + break; + + case 'f': + s = "floating"; + break; + + case 's': + s = "string"; /* must be `missing', not `bad' */ + break; + + case 'x': + s = "hexadecimal"; + break; + + default: + panic("sdecode badarg(%c)", c); + /* NOTREACHED */ + } + if (di->di_word == NULL) + error(0, 0, "missing %s argument for \\special `%s'", + s, di->di_kw); + else { + error(0, 0, "bad %s argument to \\special `%s': `%s'", + s, di->di_kw, di->di_word); + error(0, 0, "(this part of the \\special will be ignored)"); + while (!di->di_call) + (void) word(di, 1); + } +} + +#ifdef WIN32 +static int +scan(struct decode_info *di, char **fmtp, va_list ap) +{ + register int c; + char *fmt = *fmtp; + + va_start(ap, fmt); + while ((c = *fmt++) != 0) { + if (di->di_call || word(di, 0) == NULL) { + di->di_word = NULL; + goto out; + } + switch (c) { + + /* BEWARE, can only handle one string */ + case 's': /* always accepted */ + break; + + case 'd': + case 'x': + if (scan_i(di->di_word, c, va_arg(ap, i32 *))) + goto out; + break; + + case 'f': + if (scan_d(di->di_word, va_arg(ap, double *))) + goto out; + break; + + default: + panic("sdecode scan() *fmt=%c", c); + /* NOTREACHED */ + } + } + c = 0; +out: + va_end(ap); + return (c); +} + +#else +static int +scan(va_alist) + va_dcl +{ + register struct decode_info *di; + register char *fmt; + register int c; + char **fmtp; + va_list ap; + + va_start(ap); + di = va_arg(ap, struct decode_info *); + fmtp = va_arg(ap, char **); + fmt = *fmtp; + while ((c = *fmt++) != 0) { + if (di->di_call || word(di, 0) == NULL) { + di->di_word = NULL; + goto out; + } + switch (c) { + + /* BEWARE, can only handle one string */ + case 's': /* always accepted */ + break; + + case 'd': + case 'x': + if (scan_i(di->di_word, c, va_arg(ap, i32 *))) + goto out; + break; + + case 'f': + if (scan_d(di->di_word, va_arg(ap, double *))) + goto out; + break; + + default: + panic("sdecode scan() *fmt=%c", c); + /* NOTREACHED */ + } + } + c = 0; +out: + va_end(ap); + *fmtp = fmt - 1; + return (c); +} +#endif +static int +scan_i(p, c, result) + char *p; + int c; + i32 *result; +{ +#ifdef HAVE_STRTOL + char *end; + long strtol(); + + *result = strtol(p, &end, c == 'x' ? 16 : 10); + return (*end); +#else + long l; + char junk; + + if (sscanf(p, c == 'x' ? "%lx%c" : "%ld%c", &l, &junk) != 1) + return (1); + *result = l; + return (0); +#endif +} + +static int +scan_d(p, result) + char *p; + double *result; +{ +#ifdef HAVE_STRTOD + char *end; + double strtod(); + + *result = strtod(p, &end); + return (*end); +#else + char junk; + + return (sscanf(p, "%lf%c", result, &junk) != 1); +#endif +} diff --git a/Build/source/texk/seetexk/sdecode.h b/Build/source/texk/seetexk/sdecode.h new file mode 100644 index 00000000000..b0ef12ef8e9 --- /dev/null +++ b/Build/source/texk/seetexk/sdecode.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Specials consist of keyword/value groupings, with the simple syntax + * suggested by the BNF + * + * list ::= kv | list ',' kv + * kv ::= word opt_eq words + * opt_eq ::= '=' | <empty> + * words ::= word | words ' ' word + * + * `Words' include any character that is not a space, comma, or quote, + * and can include these by using quoting. Inside and outside quotes, + * `\"' produces `"'; `\\' produces `\'; and `\,' produces `,'. + * + * No single word can exceed WDMAX characters (after quotes are interpreted). + * WDMAX is defined in sdecode.c, and is typically large (>= 1024). + * + * Each special is typed according to its arguments, which are collected + * and decoded, and passed to the special function as ordinary parameters. + * All possible argument-types must be known to the special decoder. + * The function also receives its own name (from the table) as its + * first argument. + */ + +/* value argument types */ +enum sd_args { + sda_none, /* no arguments, just a flag */ + sda_s, /* one string argument (`foo abc') */ + sda_d, /* one decimal (i32) argument (`foo 2') */ + sda_f, /* one floating (double) argument (`foo 3.14') */ + sda_dd, /* two decimal arguments (`foo 3 4') */ + sda_ff, /* two floating arguments (`foo .3 .4') */ + sda_ddddff, /* four decimal args, then 2 floating args */ + sda_nd, /* array n of decimal arguments */ + sda_nx, /* array n of hex arguments (`x 1a00 d02f ...') */ + sda_rest /* fn(len1, ptr, len2); uses up rest of input */ +}; + +struct sdecode { + char *sd_name; /* keyword to match */ + enum sd_args sd_args; /* arguments to collect */ + void (*sd_fn)(); /* actual arguments depend on sd_args */ +}; + +void SDecode(/* FILE *, i32, struct sdecode *, size_t */); +void SDsetclass(/* char *spaces, char *semis */); + +#define SDsize(tab) ((int)(sizeof(tab) / sizeof(*tab))) diff --git a/Build/source/texk/seetexk/search.c b/Build/source/texk/seetexk/search.c new file mode 100644 index 00000000000..0768450787d --- /dev/null +++ b/Build/source/texk/seetexk/search.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/search.c,v 3.1 89/08/22 21:58:14 chris Exp $"; +#endif + +/* + * Key search routines (for a 32 bit key) + * + * SCreate initializes the search control area. + * + * SSearch returns the address of the data area (if found or created) + * or a null pointer (if not). The last argument controls the disposition + * in various cases, and is a ``value-result'' parameter. + * + * SEnumerate calls the given function on each data object within the + * search table. Note that no ordering is specified (though currently + * it runs in increasing-key-value sequence). + */ + +#include "types.h" +#include "search.h" + +#if vax || mc68000 || ns32000 || pyr +#define HARD_ALIGNMENT 4 +#else +#define HARD_ALIGNMENT 16 /* should suffice for most everyone */ +#endif + +static int DOffset; /* part of alignment code */ + +#ifndef KPATHSEA +char *malloc(), *realloc(); +#endif + +struct search * +SCreate(dsize) + register unsigned int dsize; +{ + register struct search *s; + + if ((s = (struct search *) malloc(sizeof *s)) == 0) + return (0); + + if (DOffset == 0) { +#ifndef HARD_ALIGNMENT + DOffset = sizeof(i32); +#else + DOffset = (sizeof(i32) + HARD_ALIGNMENT - 1) & + ~(HARD_ALIGNMENT - 1); +#endif + } + dsize += DOffset; /* tack on space for keys */ + +#ifdef HARD_ALIGNMENT + /* + * For machines with strict alignment constraints, it may be + * necessary to align the data at a multiple of some positive power + * of two. In general, it would suffice to make dsize a power of + * two, but this could be very space-wasteful, so instead we align it + * to HARD_ALIGNMENT. 64 bit machines might ``#define HARD_ALIGNMENT + * 8'', for example. N.B.: we assume that HARD_ALIGNMENT is a power + * of two. + */ + + dsize = (dsize + HARD_ALIGNMENT - 1) & ~(HARD_ALIGNMENT - 1); +#endif + + s->s_dsize = dsize; /* save data object size */ + s->s_space = 10; /* initially, room for 10 objects */ + s->s_n = 0; /* and none in the table */ + if ((s->s_data = malloc(s->s_space * dsize)) == 0) { + free((char *)s); + return (0); + } + return (s); +} + +/* + * We actually use a binary search right now - this may change. + */ +char * +SSearch(s, key, disp) + register struct search *s; + register i32 key; + int *disp; +{ + register char *keyaddr; + int itemstomove; + + *disp &= S_CREATE | S_EXCL; /* clear return codes */ + if (s->s_n) { /* look for the key */ + register int h, l, m; + + h = s->s_n - 1; + l = 0; + while (l <= h) { + m = (l + h) >> 1; + keyaddr = s->s_data + m * s->s_dsize; + if (*(i32 *) keyaddr > key) + h = m - 1; + else if (*(i32 *) keyaddr < key) + l = m + 1; + else { /* found it, now what? */ + if (*disp & S_EXCL) { + *disp |= S_COLL; + return (0); /* collision */ + } + *disp |= S_FOUND; + return (keyaddr + DOffset); + } + } + keyaddr = s->s_data + l * s->s_dsize; + } else + keyaddr = s->s_data; + + /* keyaddr is now where the key should have been found, if anywhere */ + if ((*disp & S_CREATE) == 0) + return (0); /* not found */ + + /* avoid using realloc so as to retain old data if out of memory */ + if (s->s_space <= 0) { /* must expand; double it */ + register char *new; + + if ((new = malloc((s->s_n << 1) * s->s_dsize)) == 0) { + *disp |= S_ERROR; /* no space */ + return (0); + } + keyaddr = (keyaddr - s->s_data) + new; /* relocate */ + bcopy(s->s_data, new, s->s_n * s->s_dsize); + free(s->s_data); + s->s_data = new; + s->s_space = s->s_n; + } + /* now move any keyed data that is beyond keyaddr down */ + itemstomove = s->s_n - (keyaddr - s->s_data) / s->s_dsize; + if (itemstomove) { +#ifndef BLOCK_COPY + register char *from, *to; + + from = s->s_data + s->s_n * s->s_dsize; + to = from + s->s_dsize; + while (from > keyaddr) + *--to = *--from; +#else + BLOCK_COPY(keyaddr, keyaddr + s->s_dsize, + itemstomove * s->s_dsize); +#endif + } + *disp |= S_NEW; + s->s_n++; + s->s_space--; + *(i32 *) keyaddr = key; + keyaddr += DOffset; /* now actually dataaddr */ + /* the bzero is just a frill... */ + bzero(keyaddr, s->s_dsize - DOffset); + return (keyaddr); +} + +/* + * Call function `f' for each element in the search table `s'. + */ +void +SEnumerate(s, f) + register struct search *s; + register void (*f)(); +{ + register int n; + register char *p; + + n = s->s_n; + p = s->s_data; + while (--n >= 0) { + (*f)(p + DOffset, *(i32 *)p); + p += s->s_dsize; + } +} diff --git a/Build/source/texk/seetexk/search.h b/Build/source/texk/seetexk/search.h new file mode 100644 index 00000000000..864649c8dfb --- /dev/null +++ b/Build/source/texk/seetexk/search.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* search structures and routines for 32-bit key, arbitrary data */ + +struct search { + unsigned s_dsize; /* data object size (includes key size) */ + unsigned s_space; /* space left (in terms of objects) */ + unsigned s_n; /* number of objects in the table */ + char *s_data; /* data area */ +}; + +/* returns a pointer to the search table (for future search/installs) */ +struct search *SCreate(); /* create a search table */ + +/* returns a pointer to the data object found or created */ +char *SSearch(); /* search for a data object */ + +/* clears a search table (wipes out all entries) */ +#define SClear(s) ((s)->s_space += (s)->s_n, (s)->s_n = 0) + +/* the third argument to SSearch controls operation as follows: */ +#define S_LOOKUP 0x00 /* pseudo flag */ +#define S_CREATE 0x01 /* create object if not found */ +#define S_EXCL 0x02 /* complain if already exists */ + +/* in addition, it is modified before return to hold status: */ +#define S_COLL 0x04 /* collision (occurs iff S_EXCL set) */ +#define S_FOUND 0x08 /* found (occurs iff existed already) */ +#define S_NEW 0x10 /* created (occurs iff S_CREATE && !S_EXCL) */ +#define S_ERROR 0x20 /* problem creating (out of memory) */ + +void SEnumerate(); diff --git a/Build/source/texk/seetexk/seek.c b/Build/source/texk/seetexk/seek.c new file mode 100644 index 00000000000..64c8baa7037 --- /dev/null +++ b/Build/source/texk/seetexk/seek.c @@ -0,0 +1,179 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/seek.c,v 3.1 89/08/22 21:59:04 chris Exp $"; +#endif + +/* + * SeekFile copies an input stdio file, if necessary, so that + * it produces a stdio file on which fseek() works properly. + * It returns NULL if this cannot be done; in that case, the + * input file is closed (or otherwise rendered worthless). + * + * CopyFile copies an input file unconditionally. (On non-Unix + * machines, it might `accidentally' not copy it.) + * + * On Unix machines, this means `if the input is a pipe or tty, + * copy it to a temporary file'. On other systems, all stdio files + * might happen to be seekable. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-fopen.h> +#endif + +#include <stdio.h> +#include "types.h" /* for BSD_FILE_SYSTEM */ +#include "seek.h" + +#ifdef HAVE_PROTOTYPES +extern int MakeRWTempFile(char *); +#else +extern int MakeRWTempFile(); +#endif + +#ifdef EASY_BUT_NOT_GOOD + +FILE *CopyFile(f) FILE *f; { return (f); } +FILE *SeekFile(f) FILE *f; { return (f); } + +#else + +#include <errno.h> +#ifdef BSD_FILE_SYSTEM +#include <sys/param.h> /* want MAXBSIZE */ +#else +#include <sys/types.h> +#endif +#include <sys/stat.h> + +#ifndef KPATHSEA +long lseek(); +char *malloc(); + +extern int errno; +#endif + +/* + * Make and return a version of `f' on which fseek works (unconditionally). + * This code is somewhat Unix-specific. + */ +FILE * +CopyFile(f) + FILE *f; +{ + register int tf, n, ifd, w; + register char *p, *buf; + register int blksize; + struct stat st; + int e; +#ifdef MAXBSIZE +#define BSIZE MAXBSIZE +#else +#define BSIZE BUFSIZ +#endif + char stackbuf[BSIZE]; +#if defined(WIN32) || defined(MSDOS) || defined(__CYGWIN32__) + int orig_fdmode; +#endif + char *open_mode; + + /* get a read/write temp file which will vanish when closed */ + if ((tf = MakeRWTempFile(stackbuf)) < 0) { + e = errno; + (void) fclose(f); + errno = e; + return (NULL); + } + + /* compute buffer size and choose buffer */ + ifd = fileno(f); + buf = stackbuf; + blksize = sizeof stackbuf; +#ifdef BSD_FILE_SYSTEM + if (fstat(tf, &st) == 0 && st.st_blksize > blksize) { + /* + * The output block size is the important one, + * but the input block size is not irrelevant. + * + * This should actually compute the lcm, but we + * will rely on block sizes being powers of two + * (so that the larger is the lcm). + */ + blksize = st.st_blksize; + if (fstat(ifd, &st) == 0 && st.st_blksize > blksize) + blksize = st.st_blksize; + if ((buf = malloc((unsigned)blksize)) == NULL) { + buf = stackbuf; + blksize = sizeof stackbuf; + } + } +#endif + +#if defined(WIN32) || defined(MSDOS) || defined(__CYGWIN32__) + /* make sure we open the temp file in the same mode that + the original handle was open. */ + orig_fdmode = setmode(ifd, 0); + setmode(tf, orig_fdmode); +#endif + /* copy from input file to temp file */ + (void) lseek(ifd, 0L, 0); /* paranoia */ + while ((n = read(ifd, p = buf, blksize)) > 0) { + do { + if ((w = write(tf, p, n)) < 0) { + (void) close(tf); + (void) fclose(f); + return (NULL); + } + p += w; + } while ((n -= w) > 0); + } + e = errno; /* in case n < 0 */ + if (buf != stackbuf) + free(buf); + if (n < 0) { + (void) close(tf); + (void) fclose(f); + errno = e; + return (NULL); + } + + /* discard the input file, and rewind and open the temporary */ + (void) fclose(f); + (void) lseek(tf, 0L, 0); + errno = 0; +#if defined(WIN32) || defined(MSDOS) || defined(__CYGWIN32__) + open_mode = orig_fdmode == O_BINARY ? FOPEN_RBIN_MODE : "r"; +#else + open_mode = "r"; +#endif + if ((f = fdopen(tf, open_mode)) == NULL) { + if (errno == 0) + e = EMFILE; + (void) close(tf); + errno = e; + } + return (f); +} + +/* + * Copy an input file, but only if necessary. + */ +FILE *SeekFile(f) + FILE *f; +{ + int fd = fileno(f); + + return (lseek(fd, 0L, 1) >= 0 && !isatty(fd) ? f : CopyFile(f)); +} + +#endif /* EASY_BUT_NOT_GOOD */ diff --git a/Build/source/texk/seetexk/seek.h b/Build/source/texk/seetexk/seek.h new file mode 100644 index 00000000000..a8c898db851 --- /dev/null +++ b/Build/source/texk/seetexk/seek.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Declarations for seek.c: SeekFile(FILE *fp) returns a + * version of `fp' on which `fseek' functions properly; + * CopyFile(FILE *fp) returns a temporary copy of fp. + */ +#ifdef WIN32 +#undef CopyFile +FILE *SeekFile(FILE *fp), *CopyFile(FILE *fp); +#else +FILE *SeekFile(/* FILE *fp */), *CopyFile(/* FILE *fp */); +#endif diff --git a/Build/source/texk/seetexk/skip.c b/Build/source/texk/seetexk/skip.c new file mode 100644 index 00000000000..54366b331ab --- /dev/null +++ b/Build/source/texk/seetexk/skip.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/skip.c,v 3.1 89/08/22 21:45:13 chris Exp $"; +#endif + +#include <stdio.h> +#include "types.h" +#include "fio.h" + +/* + * Skip a font definition. The font number has already been consumed. + */ +SkipFontDef(fp) + register FILE *fp; +{ + register int i; + + (void) GetLong(fp); /* checksum */ + (void) GetLong(fp); /* mag */ + (void) GetLong(fp); /* designsize */ + i = UnSign8(GetByte(fp)) + UnSign8(GetByte(fp)); + while (--i >= 0) + (void) GetByte(fp); +} diff --git a/Build/source/texk/seetexk/split.c b/Build/source/texk/seetexk/split.c new file mode 100644 index 00000000000..21d0d648325 --- /dev/null +++ b/Build/source/texk/seetexk/split.c @@ -0,0 +1,226 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/split.c,v 3.1 89/08/22 21:59:36 chris Exp $"; +#endif + +#include <ctype.h> + +/* + * Split a line into an array of words. This is destructive of + * the original line; the word pointers point to places within + * that line. + * + * The pound-sign character `#', at the beginning of the line or + * after white space, marks the end of the line. + * + * Return the number of words made, or -1 for overflow. + */ + +/* + * The lexical states are much like `sh's, except that we also do + * C-style backslash-escapes. + */ +enum lexstate { + S_BLANK, /* outside a word */ + S_WORD, /* inside a word, no quoting */ + S_SQUOTE, /* inside a single quote */ + S_DQUOTE, /* inside a double quote */ + S_BKSL0, /* last char was \ */ + S_BKSL1, /* last chars were \, [0-7] */ + S_BKSL2 /* last chars were \, [0-7][0-7] */ +}; + +int +split(s, w, nw) + register char *s, **w; + int nw; +{ + register int c; + register char *canon = s; + register int wleft = nw; + enum lexstate state, prebkstate; + + /* + * Start out in the `blank' state (outside a word). Handle + * quotes and things. Backslashes are handled by saving the + * `pre-backslash' state, doing the backslash, and restoring + * that state at the end of the backslash sequence. + */ + state = S_BLANK; + while ((c = *s++) != 0) { +reswitch: + switch (state) { + + /* + * Blanks: spaces stay in blank state; '#' ends the line; + * anything else starts a word. However, quotes may put + * us into quote states, rather than word states. + */ + case S_BLANK: + if (isspace(c)) + continue; + if (c == '#') + goto stopped_by_comment; + if (--wleft < 0) + return (-1); + *w++ = canon; + state = S_WORD; + /* FALLTHROUGH */ + + /* + * In a word. Spaces take us out (and end the + * current word). Quotes, however, put us into + * quote states. + */ + case S_WORD: + if (isspace(c)) { + *canon++ = 0; + state = S_BLANK; + break; + } + if (c == '\'') { + state = S_SQUOTE; + break; + } + if (c == '"') { + state = S_DQUOTE; + break; + } + if (c == '\\') { + prebkstate = S_WORD; + state = S_BKSL0; + break; + } + *canon++ = c; + break; + + /* + * Inside a single quote, the only special character + * is another single quote. This matches the Bourne + * shell quoting convention exactly. + */ + case S_SQUOTE: + if (c == '\'') + state = S_WORD; + else + *canon++ = c; + break; + + /* + * Inside a double quote, double quotes get us out, + * but backslashes must be interpreted. + */ + case S_DQUOTE: + if (c == '\\') { + prebkstate = S_DQUOTE; + state = S_BKSL0; + } else if (c == '"') + state = S_WORD; + else + *canon++ = c; + break; + + /* + * If we are handling a backslash, we will either + * restore the state, or go to BKSL1 state. In + * the latter case, do not advance the canonicalisation + * pointer, since we might have more octal digits + * to insert. + */ + case S_BKSL0: + state = prebkstate; /* probably */ + switch (c) { + + case 'b': + *canon++ = '\b'; + break; + + case 'f': + *canon++ = '\f'; + break; + + case 'n': + *canon++ = '\n'; + break; + + case 'r': + *canon++ = '\r'; + break; + + case 't': + *canon++ = '\t'; + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + *canon = c - '0'; + state = S_BKSL1; + break; + + default: + *canon++ = c; + break; + } + break; + + + /* + * In BKSL1, we have seen backslash and one octal + * digit. There may be more (in which case just + * count them on in), or there might be something + * that requires we restore the state and try again. + */ + case S_BKSL1: + switch (c) { + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + *canon <<= 3; + *canon |= c - '0'; + state = S_BKSL2; + break; + + default: + canon++; + state = prebkstate; + goto reswitch; + } + break; + + /* + * BKSL2 is like BKSL1, except that it cannot + * help but restore the original state, since + * there are no four-character octal sequences. + */ + case S_BKSL2: + state = prebkstate; /* assuredly */ + switch (c) { + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + *canon <<= 3; + *canon++ |= c - '0'; + break; + + default: + canon++; + goto reswitch; + } + break; + } + } +stopped_by_comment: +#ifdef notdef + if (state != S_WORD && state != S_BLANK) + error(0, 0, "warning: unclosed quote"); +#endif + if (state != S_BLANK) + *canon = 0; + return (nw - wleft); +} diff --git a/Build/source/texk/seetexk/stamp-auto.in b/Build/source/texk/seetexk/stamp-auto.in new file mode 100644 index 00000000000..efbce6cfde4 --- /dev/null +++ b/Build/source/texk/seetexk/stamp-auto.in @@ -0,0 +1 @@ +Sun Mar 21 20:44:24 CET 2004 diff --git a/Build/source/texk/seetexk/strsave.c b/Build/source/texk/seetexk/strsave.c new file mode 100644 index 00000000000..a7b53d4af8d --- /dev/null +++ b/Build/source/texk/seetexk/strsave.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * Save a string in managed memory. + */ + +#if !defined( WIN32 ) && !defined( _AMIGA ) +char *malloc(), *realloc(); +extern int errno; +#endif + +#include "types.h" /* for bcopy */ +#include "error.h" + +char * +strsave(s) + register char *s; +{ + register int l = strlen(s) + 1; + register char *p = malloc((unsigned) l); + + if (p == 0) + error(1, errno, "no room for %d bytes of string", l); + bcopy(s, p, l); + return (p); +} diff --git a/Build/source/texk/seetexk/strtol.c b/Build/source/texk/seetexk/strtol.c new file mode 100644 index 00000000000..5cb6662fbb6 --- /dev/null +++ b/Build/source/texk/seetexk/strtol.c @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <ctype.h> + +/* + * This is for people who don't have strtol defined on their systems. + * -- Compliments of Daniel.Stodolsky@cs.cmu.edu + */ + +long strtol(nptr,base,eptr) +char *nptr; +int base; +char **eptr; +{ + long l; + + if (base==10) + { + if (sscanf(nptr,"%ld",&l)!=1) + { + *eptr = nptr; + return 0; + } + else + { + while(!isdigit(*nptr)) + nptr++; + while (isdigit(*nptr)) + nptr++; + *eptr = nptr; + return l; + } + } + else + if (base==16) + { + if (sscanf(nptr,"%lx",&l)!=1) + { + *eptr = nptr; + return 0; + } + else + { + while(!isxdigit(*nptr)) + nptr++; + while (isxdigit(*nptr)) + nptr++; + *eptr = nptr; + return l; + } + } + else + { /* a base we don't understand. Puke */ + *eptr = nptr; + return 0; + } +} diff --git a/Build/source/texk/seetexk/tempfile.c b/Build/source/texk/seetexk/tempfile.c new file mode 100644 index 00000000000..c47fffa519f --- /dev/null +++ b/Build/source/texk/seetexk/tempfile.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/tempfile.c,v 3.1 89/08/22 21:45:20 chris Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <sys/types.h> + +#ifdef _AMIGA +#define getpid() 42 +#endif /* _AMIGA */ + +#if defined( WIN32 ) || defined( _AMIGA ) +#include "types.h" +#else +#include <sys/file.h> + +char *getenv(); + +#endif + +#ifdef KPATHSEA +#include <kpathsea/c-fopen.h> +#else +#ifndef O_BINARY +#define O_BINARY 0 +#endif +#endif + +#if defined(WIN32) || defined(MSDOS) +#define TMP_OPEN_MODE (O_RDWR | O_BINARY) +#else +#define TMP_OPEN_MODE 2 +#endif + +#ifndef WIN32 +#define __cdecl +#endif + +#ifdef DOSISH +static char *TmpFile; +static void __cdecl +RemoveTempFile(void) +{ + if (TmpFile) { + unlink(TmpFile); + TmpFile = (char *)0; + } +} +#endif + +/* + * Create an open but unlinked (i.e., remove-on-exit-or-file-close) + * file. Return the file descriptor, or -1 if unable to create such + * a file. The buffer `name' is used to hold the file name (so that + * if this returns -1, it is useful for error messages). + * + * We use the despicable trick of unlinking an open temporary file. + * The alternatives are too painful. If it becomes necessary to + * do this another way, however, here is a method suggested by Fred + * Blonder: fork, and have the parent wait for the child to exit. + * (The parent must avoid being killed during this phase.) When + * the child exits, the parent should then remove the temporary file, + * then exit with the same status, or send itself the same signal. + */ +int +MakeRWTempFile(name) + register char *name; +{ + register int tf, n; + int mypid, tries; + char *tmpdir; + + if ((tmpdir = getenv("TMP")) == NULL + && (tmpdir = getenv("TEMP")) == NULL + && (tmpdir = getenv("TMPDIR")) == NULL) +#if defined(WIN32) || defined(MSDOS) + tmpdir = "."; +#else + tmpdir = "/tmp"; +#endif + /* compose a suitable temporary file name, and get an r/w descriptor */ + mypid = getpid(); + n = 0; + tries = 0; + do { + (void) sprintf(name, "%s/#%d.%d", tmpdir, mypid, n++); +#ifndef DOSISH + (void) unlink(name); +#endif +#ifdef O_CREAT /* have three-argument open syscall */ + tries++; + tf = open(name, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0666); +#else + if (access(name, 0) == 0) { + /* + * Skip existing files. Note that tf might + * not be set yet. + */ + tf = -1; + continue; + } + tries++; + tf = creat(name, 0666); + if (tf >= 0) { + (void) close(tf); + tf = open(name, TMP_OPEN_MODE); + if (tf < 0) + (void) unlink(name); + } +#endif + } while (tf < 0 && tries < 20); + if (tf < 0) /* probably unrecoverable user error */ + return (-1); + +#ifdef DOSISH + /* Can't use the despicable trick of unlinking an open file, + since the filesystem won't wait for it to be closed. Let's + be somewhat less despicable. */ + TmpFile = (char *)malloc(strlen(name) + 1); + if (TmpFile) { + strcpy(TmpFile, name); + atexit(RemoveTempFile); + } +#else + (void) unlink(name); +#endif + return (tf); +} diff --git a/Build/source/texk/seetexk/tfm.c b/Build/source/texk/seetexk/tfm.c new file mode 100644 index 00000000000..9a9a43aa6ef --- /dev/null +++ b/Build/source/texk/seetexk/tfm.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/tfm.c,v 3.1 89/08/22 22:00:12 chris Exp $"; +#endif + +/* + * TFM file reading routines. + * + * TODO: + * finish + */ + +#include <stdio.h> +#include "types.h" +#include "fio.h" +#include "tfm.h" + +static int trd_header(), trd_ci(), trd_fix(); + +#if !defined( WIN32 ) && !defined( _AMIGA ) +char *malloc(); +#endif + +#define ALLOC(n, type) ((type *)malloc((unsigned)((n) * sizeof(type)))) + +int +readtfmfile(f, t, stopafterwidth) + register FILE *f; + register struct tfmdata *t; + int stopafterwidth; /* ??? */ +{ + i32 nc; + + if (trd_header(f, &t->t_hdr)) + return (-1); + nc = t->t_hdr.th_ec - t->t_hdr.th_bc + 1; + + t->t_ci = NULL; + t->t_width = NULL; + t->t_height = NULL; + t->t_depth = NULL; + + (void) fseek(f, t->t_hdr.th_lh * 4L, 1); /* XXX */ + + if ((t->t_ci = ALLOC(nc, struct char_info_word)) == NULL || + trd_ci(f, nc, t->t_ci) || + (t->t_width = ALLOC(t->t_hdr.th_nw, i32)) == NULL || + trd_fix(f, t->t_hdr.th_nw, t->t_width)) + goto bad; + if (stopafterwidth) + return (0); + if ((t->t_height = ALLOC(t->t_hdr.th_nh, i32)) == NULL || + trd_fix(f, t->t_hdr.th_nh, t->t_height) || + (t->t_depth = ALLOC(t->t_hdr.th_nd, i32)) == NULL || + trd_fix(f, t->t_hdr.th_nd, t->t_depth)) + goto bad; + return (0); + +bad: + if (t->t_ci != NULL) + free((char *) t->t_ci); + if (t->t_width != NULL) + free((char *) t->t_width); + if (t->t_height != NULL) + free((char *) t->t_height); + if (t->t_depth != NULL) + free((char *) t->t_depth); + return (-1); +} + +static int +trd_header(f, th) + register FILE *f; + register struct tfmheader *th; +{ + register i32 *p; + + for (p = &th->th_lf; p <= &th->th_np; p++) + fGetWord(f, *p); + if (feof(f)) + return (-1); + return (0); +} + +static int +trd_ci(f, nc, ci) + register FILE *f; + register int nc; + register struct char_info_word *ci; +{ + + while (--nc >= 0) { + ci->ci_width = fgetbyte(f); + ci->ci_h_d = fgetbyte(f); + ci->ci_i_t = fgetbyte(f); + ci->ci_remainder = fgetbyte(f); + ci++; + } + if (feof(f)) + return (-1); + return (0); +} + +static int +trd_fix(f, nf, p) + register FILE *f; + register int nf; + register i32 *p; +{ + + while (--nf >= 0) { + fGetLong(f, *p); + p++; + } + if (feof(f)) + return (-1); + return (0); +} diff --git a/Build/source/texk/seetexk/tfm.h b/Build/source/texk/seetexk/tfm.h new file mode 100644 index 00000000000..9a50657e873 --- /dev/null +++ b/Build/source/texk/seetexk/tfm.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * TFM file information. + */ + +/* + * TFM files start with a series of unsigned 16 bit integers. We + * read this into the structure `tfm_header'. These are type i32 + * so that they may be used as integer quantities without concern + * as to sign extension. + */ +struct tfmheader { + i32 th_lf; /* length of the file (16 bit words) */ + i32 th_lh; /* length of the header data (words) */ + i32 th_bc; /* beginning character */ + i32 th_ec; /* ending character (inclusive) */ + i32 th_nw; /* number of words in width table */ + i32 th_nh; /* number of words in height table */ + i32 th_nd; /* number of words in depth table */ + i32 th_ni; /* words in italic correction table */ + i32 th_nl; /* words in ligature/kern table */ + i32 th_nk; /* words in kern table */ + i32 th_ne; /* words in extensible character table */ + i32 th_np; /* number of font parameter words */ +}; + +/* + * The remainder of the TFM file comprises the following information, + * all of which are 32 bit quantities: + * + * header: array [0..lh-1] of stuff + * char_info: array [bc..ec] of char_info_word + * width: array [0..nw-1] of fix_word + * height: array [0..nh-1] of fix_word + * depth: array [0..nd-1] of fix_word + * italic: array [0..ni-1] of fix_word + * lig_kern: array [0..nl-1] of lig_kern_command + * kern: array [0..ne-1] of extensible_recipie + * param: array [0..np-1] of fix_word + */ + +/* + * A char_info_word is built of four unsigned eight-bit quantities. The first + * is an index into the width table (this saves 24 bits for every + * character that has the same width as another character). The + * second is a composite height and depth index. The third is a + * composite italic index and tag, and the fourth is a remainder. + * + * XXX needs explaining + */ +struct char_info_word { + char ci_width; /* width index */ + char ci_h_d; /* height and depth index */ + char ci_i_t; /* italic index and tag */ + char ci_remainder; /* ??? */ +}; + +/* + * These macros split up h_and_d and i_and_t values. + */ +#define T_CI_H(ci) (((ci)->ci_h_d >> 4) & 0xf) +#define T_CI_D(ci) ((ci)->ci_h_d & 0xf) +#define T_CI_I(ci) (((ci)->ci_i_t >> 2) & 0x3f) +#define T_CI_T(ci) ((ci)->ci_i_t & 3) + +/* + * This structure contains everything one might need to know about + * a TFM file at run-time. + * + * XXX incomplete, or wrong, as yet + */ +struct tfmdata { + struct tfmheader t_hdr; /* full header */ + struct char_info_word *t_ci; /* char info */ + i32 *t_width; /* widths table */ + i32 *t_height; /* heights */ + i32 *t_depth; /* depths */ +}; diff --git a/Build/source/texk/seetexk/tfmfont.c b/Build/source/texk/seetexk/tfmfont.c new file mode 100644 index 00000000000..e18be7ce1a1 --- /dev/null +++ b/Build/source/texk/seetexk/tfmfont.c @@ -0,0 +1,262 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +#ifndef lint +static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/tfmfont.c,v 3.4 89/11/29 02:29:58 chris Exp $"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "types.h" +#include "conv.h" +#include "font.h" +#include "tfm.h" + +/* + * TFM font operations. This defines three fonts: + * + * box - prints as little square boxes, outlining what TeX + * thinks is the character; carries a warning. + * blank - prints as entirely blank; carries a warning. + * tfm - prints as entirely blank; can be used for built-in fonts. + * invis - an alias for tfm. + * + * The first two also complain that no font is available in the + * requested size; these are intended to be used as a last resort + * so that users can always print DVI files. You should configure + * in exactly one of box or blank. + * + * TODO: + * base box edge widths on Conversion.c_dpi + */ +static int box_read(), blank_read(), tfm_read(); +static int tfm_getgly(), tfm_rasterise(); +static void tfm_freefont(); + + /* magnifications are unused in tfm fonts */ +struct fontops boxops = /* `boxtops'? Is this a cereal driver? */ + { "box", 1, 0.0, box_read, tfm_getgly, tfm_rasterise, tfm_freefont }; +struct fontops blankops = + { "blank", 2, 0.0, blank_read, tfm_getgly, tfm_rasterise, tfm_freefont }; +struct fontops tfmops = + { "tfm", 0, 0.0, tfm_read, tfm_getgly, tfm_rasterise, tfm_freefont }; +struct fontops invisops = + { "invis", 0, 0.0, tfm_read, tfm_getgly, tfm_rasterise, tfm_freefont }; + +/* + * Local info. + */ +struct tfm_details { + int tfm_edge; /* box edge widths, in pixels */ + struct tfmdata tfm_data; /* the TFM file data */ +}; + +/* + * Get the tfm_details from font f. + */ +#define ftotfm(f) ((struct tfm_details *)(f)->f_details) + +static int do_read(); + +#if !defined( WIN32 ) && !defined( _AMIGA ) +extern int errno; +char *malloc(); +#endif + +/* + * Read a Box font. + */ +static int +box_read(f, fd) + struct font *f; + int fd; +{ + + return (do_read(f, fd, 0)); +} + +/* + * Read a Blank font. + */ +static int +blank_read(f, fd) + struct font *f; + int fd; +{ + + return (do_read(f, fd, 1)); +} + +/* + * Read a TFM font. + */ +static int +tfm_read(f, fd) + struct font *f; + int fd; +{ + + return (do_read(f, fd, 1)); +} + +/* + * Read a TFM font. It is blank if `blank'. + */ +static int +do_read(f, fd, blank) + register struct font *f; + int fd, blank; +{ + register struct tfm_details *tfm; + FILE *fp; + + if ((fp = fdopen(fd, "r")) == NULL) { + (void) close(fd); + return (-1); + } + if ((tfm = (struct tfm_details *)malloc(sizeof *tfm)) == NULL) + goto fail; + if (readtfmfile(fp, &tfm->tfm_data, blank)) + goto fail; + if (blank) + tfm->tfm_edge = 0; + else + tfm->tfm_edge = 2; /* XXX should be based on dpi */ + if (FontHasGlyphs(f, tfm->tfm_data.t_hdr.th_bc, + tfm->tfm_data.t_hdr.th_ec + 1)) + goto fail; + f->f_checksum = 0; /* ??? */ + f->f_design_size = 0; /* ??? */ + f->f_hppp = 0; + f->f_vppp = 0; + f->f_details = (char *)tfm; + (void) fclose(fp); + return (0); + +fail: + (void) fclose(fp); + if (tfm != NULL) + free((char *)tfm); + return (-1); +} + +/* + * Obtain the specified range of glyphs. + */ +static int +tfm_getgly(f, l, h) + register struct font *f; + int l; + register int h; +{ + register struct tfm_details *tfm = ftotfm(f); + register struct glyph *g; + register int i; + register struct char_info_word *ci; +#define t (&tfm->tfm_data) + extern i32 ScaleOneWidth(i32, i32); +#define ftop(fix) fromSP(ScaleOneWidth(fix, f->f_dvimag)) + + for (i = l; i < h; i++) { + ci = &t->t_ci[i - t->t_hdr.th_bc]; + /* zero widths mark invalid characters */ + if (ci->ci_width == 0) + continue; + g = f->f_gly[i]; + g->g_flags = GF_VALID; + g->g_rawtfmwidth = t->t_width[UnSign8(ci->ci_width)]; + g->g_xorigin = 0; + if (tfm->tfm_edge != 0) { + g->g_yorigin = ftop(t->t_height[T_CI_H(ci)]); + g->g_width = ftop(g->g_rawtfmwidth); + g->g_height = g->g_yorigin + + ftop(t->t_depth[T_CI_D(ci)]); + } else { + g->g_yorigin = 0; + g->g_width = 0; + g->g_height = 0; + } + } + return (0); +#undef t +} + +/* + * Obtain rasters for the specified glyphs. + * + * IGNORES tfm->tfm_edge: 2 HARDCODED FOR NOW + */ +static int +tfm_rasterise(f, l, h) + struct font *f; + int l, h; +{ + register struct glyph *g; + register char *p; + register int w, j, i; + struct tfm_details *tfm = ftotfm(f); +#define EDGE 2 + + if (tfm->tfm_edge == 0) + return (0); +if (tfm->tfm_edge != 2) panic("tfm_rasterise"); + for (i = l; i < h; i++) { + g = f->f_gly[i]; + if ((g->g_flags & GF_VALID) == 0 || !HASRASTER(g)) + continue; + w = (g->g_width + 7) >> 3; + p = malloc((unsigned) (g->g_height * w)); + if (p == NULL) + return (-1); + g->g_raster = p; + g->g_rotation = ROT_NORM; + if (g->g_width < 2 * EDGE) { + w = 2 * EDGE - g->g_width; + for (j = g->g_height; --j >= 0;) + *p++ = 0xf0 << w; + } else { + bzero(p, g->g_height * w); + for (j = 0; j < g->g_height;) { + if (j < EDGE || j >= g->g_height - EDGE) { + register int k = w; + + while (--k > 0) + *p++ = 0xff; + *p++ = 0xff << ((8 - g->g_width) & 7); + j++; + continue; + } + /* the following depends on EDGE==2 */ + *p = 0xc0; + p += w - ((g->g_width & 7) == 1 ? 2 : 1); + *p++ |= 0xc0 >> ((g->g_width - EDGE) & 7); + if ((g->g_width & 7) == 1) + *p++ = 0x80; + /* end dependencies */ + if (++j == EDGE && g->g_height >= 2 * EDGE) { + register int n = g->g_height - EDGE; + + p += (n - j) * w; + j = n; + } + } + } + } + return (0); +} + +/* + * Discard the font details. + */ +static void +tfm_freefont(f) + struct font *f; +{ + + free(f->f_details); +} diff --git a/Build/source/texk/seetexk/types.h b/Build/source/texk/seetexk/types.h new file mode 100644 index 00000000000..84e2de24196 --- /dev/null +++ b/Build/source/texk/seetexk/types.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1987, 1989 University of Maryland + * Department of Computer Science. All rights reserved. + * Permission to copy for any purpose is hereby granted + * so long as this copyright notice remains intact. + */ + +/* + * MC-TeX types and macros (system dependent). + * Check to make sure they are correct for your system. + */ + +#ifndef _MCTEX_TYPES_ +#define _MCTEX_TYPES_ + +#ifdef WIN32 +#include <win32lib.h> +#undef index +#undef DT_RIGHT +#define EndPage DviEndPage +#endif + +/* + * Define BSD_FILE_SYSTEM if you have the BSD file system `stat' + * structure (with the st_blksize field). Otherwise, MakeSeekable() + * will be slower than necessary. + */ +#undef BSD_FILE_SYSTEM + +/* + * Define this as the name of a routine that handles overlapping block + * copies, if there is such a routine. Usually it will be called memmove() + * but on 4.3BSD it is called bcopy(). Note that the 4.2BSD bcopy() does + * not handle overlap, and must not be used here. If there is no routine, + * or if its overlap handling is uncertain, leave BLOCK_COPY undefined. + * + * (The bcopy provided in lib/bcopy.c does handle overlap.) + */ +/* #define BLOCK_COPY(from, to, len) memmove(to, from, len) */ +#define BLOCK_COPY(from, to, len) bcopy(from, to, len) + +#ifdef KPATHSEA + +#include <kpathsea/config.h> +#include <kpathsea/c-memstr.h> + +#ifdef HAVE_PROTOTYPES +#define NeedFunctionPrototypes 1 +#else +#undef NeedFunctionPrototypes +#endif + +#else + +/* + * Define void as int if your compiler does not support void, + * or if there are bugs in its support (e.g., 4.1BSD). + */ +/* #define void int */ + +/* + * Define the following if and only if vfprintf is in your C library. + * If not, lib/error.c will make assumptions about the implementation + * of stdio. If neither works, you may have to come up with something + * yourself. + */ +#define HAVE_VPRINTF + +/* + * If you have memcpy/memmove, but not bcopy, use the definition below. + * If you have neither, try the bcopy provided in lib/bcopy.c. + */ +#define bcopy(from, to, len) memmove(to, from, len) + +/* + * If you have memcmp, but not bcmp, use the definition below. + * If you have neither, try the bcmp provided in lib/bcmp.c. + */ +#define bcmp(s1, s2, len) memcmp(s1, s2, len) + +#define bzero(s, len) memset(s, '\0', len) + +#define index(s, c) strchr(s, c) + +#endif /* KPATHSEA */ +/* + * Define the following types and macros as required by your system. + */ + +typedef short i16; /* a 16 bit integer (signed) */ + +typedef long i32; /* a 32 bit integer (signed) */ +typedef unsigned long ui32; /* a 32 bit integer (unsigned) */ + +/* macros to sign extend quantities that are less than 32 bits long */ + +/* these compilers mishandle (int)(char)(constant), but a subterfuge works */ +#if defined(sun) || defined(hp300) +#define Sign8(n) ((i32)(char)(int)(n)) +#endif + +/* these have signed characters and (int)(char)(constant) works */ +#if defined(vax) || defined(mips) +#define Sign8(n) ((i32)(char)(n)) +#endif + +/* this works everywhere, but may be slow */ +#ifndef Sign8 +#define Sign8(n) ((n) & 0x80 ? ((n) | ~0xff) : (n)) +#endif + +/* this should work everywhere */ +#ifndef Sign16 +#define Sign16(n) ((i32)(i16)(n)) +#endif + +/* this works where int is 32 bits, and >> sign extents and is fast */ +#if defined(vax) || defined(mips) +#define Sign24(n) (((n) << 8) >> 8) +#endif + +/* this works everywhere, but may be slow */ +#ifndef Sign24 +#define Sign24(n) ((n) & 0x800000 ? ((n) | ~0xffffff) : (n)) +#endif + +/* macros to truncate quantites that may be signed */ +#define UnSign8(n) ((i32)(n) & 0xff) +#define UnSign16(n) ((i32)(n) & 0xffff) +#define UnSign24(n) ((i32)(n) & 0xffffff) + +#endif /* _MCTEX_TYPES_ */ diff --git a/Build/source/texk/seetexk/win32.mak b/Build/source/texk/seetexk/win32.mak new file mode 100644 index 00000000000..917a7abd4ec --- /dev/null +++ b/Build/source/texk/seetexk/win32.mak @@ -0,0 +1,69 @@ +################################################################################ +# +# Makefile : SeeTeXk +# Author : Fabrice Popineau <Fabrice.Popineau@supelec.fr> +# Platform : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources +# Time-stamp: <02/06/02 15:04:09 popineau> +# +################################################################################ +root_srcdir = ..\.. +!ifdef DEVELOPMENT +INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development +!else +INCLUDE=$(INCLUDE);$(root_srcdir)\texk +!endif + +USE_GNUW32 = 1 +USE_KPATHSEA = 1 + +!include <msvc/common.mak> + +libobjects = $(objdir)\error.obj $(objdir)\fio.obj \ + $(objdir)\search.obj $(objdir)\seek.obj \ + $(objdir)\gripes0.obj $(objdir)\gripes1.obj \ + $(objdir)\dviclass.obj $(objdir)\tempfile.obj + +objects = $(objdir)\dviconcat.obj $(objdir)\dviselect.obj \ + $(objdir)\dvibook.obj $(objdir)\dvitodvi.obj + +programs = $(objdir)\dviconcat.exe $(objdir)\dviselect.exe \ + $(objdir)\dvibook.exe $(objdir)\dvitodvi.exe + +manfiles = dviconcat.1 dviselect.1 dvibook.1 dvitodvi.1 + +default all: $(objdir) $(programs) + +$(objdir)\libtex.lib: $(libobjects) + $(archive) $(libobjects) + +$(objdir)\dviconcat.exe: $(objdir)\dviconcat.obj $(objdir)\libtex.lib $(kpathsealib) + $(link) $(**) $(setargvobj) $(conlibs) + +$(objdir)\dviselect.exe: $(objdir)\dviselect.obj $(objdir)\libtex.lib $(kpathsealib) + $(link) $(**) $(conlibs) + +$(objdir)\dvibook.exe: $(objdir)\dvibook.obj $(objdir)\libtex.lib $(kpathsealib) + $(link) $(**) $(conlibs) + +$(objdir)\dvitodvi.exe: $(objdir)\dvitodvi.obj $(objdir)\libtex.lib $(kpathsealib) + $(link) $(**) $(conlibs) + +# makedepend fails to find this one +$(objdir)\error.obj: c-auto.h + +!include <msvc/config.mak> + +!include <msvc/install.mak> + +install:: install-exec + +!include <msvc/clean.mak> + + +!include <msvc/rdepend.mak> +!include "./depend.mak" + +# +# Local Variables: +# mode: makefile +# End: |