diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-06-08 13:19:40 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-06-08 13:19:40 +0000 |
commit | bf36456c4da174e063dd0b02cd0e0c0d263197aa (patch) | |
tree | 07381cb0445b171fc20ec4c06b97086683b069ab | |
parent | 15ddae32da5dc602755b01990048e9392c25aef5 (diff) |
prepare detex 2.8
git-svn-id: svn://tug.org/texlive/trunk@18815 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/detex/Makefile.am | 12 | ||||
-rw-r--r-- | Build/source/texk/detex/Makefile.in | 42 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.7/states.sed (renamed from Build/source/texk/detex/states.sed) | 0 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8-PATCHES/TL-Changes | 9 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/COPYRIGHT | 35 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/Makefile | 139 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/README | 195 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/detex.h | 81 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/detex.l | 839 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/detex.man | 126 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/os2/README | 7 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/os2/detex-32.def | 3 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/os2/detex.def | 2 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/os2/makefile.os2 | 96 | ||||
-rw-r--r-- | Build/source/texk/detex/detex-2.8/states.sed | 57 |
15 files changed, 1621 insertions, 22 deletions
diff --git a/Build/source/texk/detex/Makefile.am b/Build/source/texk/detex/Makefile.am index d542a9ffc8e..000ec857d59 100644 --- a/Build/source/texk/detex/Makefile.am +++ b/Build/source/texk/detex/Makefile.am @@ -5,6 +5,12 @@ ## ACLOCAL_AMFLAGS = -I ../../m4 +EXTRA_DIST = detex-2.7 detex-2.8 detex-2.8-PATCHES + +# in case of an SVN repository +dist-hook: + rm -rf `find $(distdir) -name .svn` + INCLUDES = $(KPATHSEA_INCLUDES) AM_CPPFLAGS = -DKPATHSEA -Dlint AM_CFLAGS = $(WARNING_CFLAGS) @@ -31,11 +37,7 @@ dist_check_SCRIPTS = detex.test TESTS = detex.test -EXTRA_DIST = test.lout test.tex test.tout +EXTRA_DIST += test.lout test.tex test.tout CLEANFILES = test.out texmf.cnf -## Not used -## -EXTRA_DIST += states.sed - diff --git a/Build/source/texk/detex/Makefile.in b/Build/source/texk/detex/Makefile.in index 2fda1d95cd4..81c98d649e2 100644 --- a/Build/source/texk/detex/Makefile.in +++ b/Build/source/texk/detex/Makefile.in @@ -256,6 +256,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I ../../m4 +EXTRA_DIST = detex-2.7 detex-2.8 detex-2.8-PATCHES test.lout test.tex \ + test.tout INCLUDES = $(KPATHSEA_INCLUDES) AM_CPPFLAGS = -DKPATHSEA -Dlint AM_CFLAGS = $(WARNING_CFLAGS) @@ -264,7 +266,6 @@ LDADD = $(KPATHSEA_LIBS) dist_man1_MANS = detex.man dist_check_SCRIPTS = detex.test TESTS = detex.test -EXTRA_DIST = test.lout test.tex test.tout states.sed CLEANFILES = test.out texmf.cnf all: c-auto.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -633,6 +634,9 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ @@ -863,22 +867,26 @@ uninstall-man: uninstall-man1 .PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ clean clean-binPROGRAMS clean-generic clean-libtool ctags dist \ - dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-compile \ - distclean-generic distclean-hdr distclean-libtool \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-man1 install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-man \ - uninstall-man1 - + dist-all dist-bzip2 dist-gzip dist-hook dist-lzma dist-shar \ + dist-tarZ dist-xz dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man1 install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-man uninstall-man1 + + +# in case of an SVN repository +dist-hook: + rm -rf `find $(distdir) -name .svn` $(detex_OBJECTS): $(KPATHSEA_DEPEND) diff --git a/Build/source/texk/detex/states.sed b/Build/source/texk/detex/detex-2.7/states.sed index 1c99ebabe9e..1c99ebabe9e 100644 --- a/Build/source/texk/detex/states.sed +++ b/Build/source/texk/detex/detex-2.7/states.sed diff --git a/Build/source/texk/detex/detex-2.8-PATCHES/TL-Changes b/Build/source/texk/detex/detex-2.8-PATCHES/TL-Changes new file mode 100644 index 00000000000..dbc5fd124b5 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8-PATCHES/TL-Changes @@ -0,0 +1,9 @@ +Changes applied to the detex-2.8 tree as obtained from: + http://www.cs.purdue.edu/homes/trinkle/detex/ + +Removed: + lexout.c + +Renamed: + detex.1l -> detex.man + diff --git a/Build/source/texk/detex/detex-2.8/COPYRIGHT b/Build/source/texk/detex/detex-2.8/COPYRIGHT new file mode 100644 index 00000000000..33c5e6c5399 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/COPYRIGHT @@ -0,0 +1,35 @@ + +Copyright (c) 1986-2007 Purdue University +All rights reserved. + +Developed by: Daniel Trinkle + Department of Computer Science, Purdue University + http://www.cs.purdue.edu/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal with the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +o Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimers. + +o Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + +o Neither the names of Daniel Trinkle, Purdue University, nor the + names of its contributors may be used to endorse or promote products + derived from this Software without specific prior written + permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. diff --git a/Build/source/texk/detex/detex-2.8/Makefile b/Build/source/texk/detex/detex-2.8/Makefile new file mode 100644 index 00000000000..e6a75b763a7 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/Makefile @@ -0,0 +1,139 @@ +# Copyright (c) 1986-2007 Purdue University +# All rights reserved. +# +# Developed by: Daniel Trinkle +# Department of Computer Science, Purdue University +# http://www.cs.purdue.edu/ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal with the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# o Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimers. +# +# o Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimers in the +# documentation and/or other materials provided with the distribution. +# +# o Neither the names of Daniel Trinkle, Purdue University, nor the +# names of its contributors may be used to endorse or promote products +# derived from this Software without specific prior written +# permission. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +# +# +# Makefile for detex and delatex +# +# Detex is a program to remove TeX and LaTeX constructs from text source. + +# Installation directory +# +DESTDIR = /usr/local/bin + +# Specify you favorite compiler +# +#CC = gcc + +# Compile time flags, just uncomment the necessary lines +# Some say GNU make does not correctly handle += -- you may have to use := +# +DEFS = +# +# Add -traditional for GNU cc on ISC 386/ix system and possibly others +# (reported by pinard@iro.umontreal.ca) +# +#DEFS += ${DEFS} -traditional +# +# Add -DHAVE_STRING_H for the SysV string manipulation routines +# +#DEFS += ${DEFS} -DHAVE_STRING_H +# +# Add -DMAXPATHLEN=<length> if it is not defined in /usr/include/sys/param.h +# +#DEFS += ${DEFS} -DMAXPATHLEN=1024 +# +# Add -DNO_MALLOC_DECL if your system does not like the malloc() declaration +# in detex.l (reported by pinard@iro.umontreal.ca) +# +#DEFS += ${DEFS} -DNO_MALLOC_DECL +# +CFLAGS = -O ${DEFS} + +# Use your favorite lexical scanner +# +LEX = lex +#LEX = flex + +#LFLAGS = -8 -C + +# scanner library +# +LEXLIB = -ll +#LEXLIB = -lfl + +LPR = lpr -p + +# Program names +# +PROGS = detex + +# Header files +# +HDR = detex.h + +# Sources +# +SRC = detex.l + +# Objects for various programs +# +D_OBJ = detex.o + +all: ${PROGS} + +detex: ${D_OBJ} + ${CC} ${CFLAGS} -o $@ ${D_OBJ} ${LEXLIB} + +detex.c: + sed -f states.sed detex.l > xxx.l + ${LEX} ${LFLAGS} xxx.l + rm -f xxx.l + mv lex.yy.c detex.c + +lexout.c: detex.c + mv detex.c lexout.c + +man-page: + troff -man detex.1l + +# If you want detex available as delatex, uncomment the last two lines of +# this target +install: detex + rm -f ${DESTDIR}/detex + install -c -m 775 -o binary -g staff -s detex ${DESTDIR} +# rm -f ${DESTDIR}/delatex +# ln ${DESTDIR}/detex ${DESTDIR}/delatex + +clean: + -rm -f a.out core *.s *.o ERRS errs .,* .emacs_[0-9]* + -rm -f ${PROGS} xxx.l lex.yy.c + +print: ${HDR} ${SRC} + ${LPR} Makefile ${HDR} ${SRC} + +# Dependencies +# +detex.c: detex.h +detex.c: detex.l diff --git a/Build/source/texk/detex/detex-2.8/README b/Build/source/texk/detex/detex-2.8/README new file mode 100644 index 00000000000..a310a7f3fd0 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/README @@ -0,0 +1,195 @@ +Detex - Version 2.8 + +Detex is a program to remove TeX constructs from a text file. It recognizes +the \input command. + +This program assumes it is dealing with LaTeX input if it sees the string +"\begin{document}" in the text. It recognizes the \include and \includeonly +commands. + +This directory contains the following files: + +README - you're looking at it. + +COPYRIGHT - NCSA/University of Illinois Open Source License + +Makefile - makefile for generating detex on a 4.2BSD Unix system. + +detex.1l - troff source for the detex manual page. + Assuming you have the -man macros, use "make man-page" to + generate it. + +detex.h - Various global definitions. These should be modified to suit + the local installation. + +detex.l - Lex and C source for the detex program. + +lexout.c - C code generated from detex.l using lex on a Sun (SunOS 4.1.1) + This can be useful for DOS, OS/2 or systems that don't have + lex. + +states.sed - sed(1) script to munge the state names in detex.l so that + reasonable names can be used in the source without causing + lex(1) to overflow. + +os2 - subdirectory containing support for compilation on + OS/2 and DOS systems + + +This software package is distributed under the NCSA/University of +Illinois Open Source License. The latest version is available at +http://www.cs.purdue.edu/homes/trinkle/detex/ Send comments and fixes +to me via email. + +Daniel Trinkle <trinkle@cs.purdue.edu> +Department of Computer Sciences +Purdue University +West Lafayette, IN 47907-1398 + +April 26, 1986 + +Modified -- June 4, 1986 +Changed so that it automatically recognizes LaTeX source and ignores several +environment modes such as array. + + +Modified (Version 2.0) -- June 30, 1984 +Now handles white space in sequences like "\begin { document }". Detex is not +as easily confused by such things as display mode ends and begins that don't +match up. + + +Modified -- September 19, 1986 +Added the "-e <environment-list>" option to ignore specified LaTeX +environments. + + +Modified -- June 30, 1987 +Added the "-n" no-follow option, to allow detex to ignore \input and \include +commands. Also changed the algorithm for locating the input files. It now +interprets the "." more reasonably (i.e. it is not always the beginning of an +extension). + + +Modified -- December 15, 1988 +Added handling of verbatim environment in LaTeX mode and added it to the list +of modes ignored by default. Because of limitations with lex, it was +necessary to shorten the names of some of the existing start states before +adding a new one (ugh). + + +Modified -- January 3, 1988 +Added ignore of \$ inside $$ (math) pair. + + +Modified (Version 2.2) -- June 25, 1990 +Control sequences are no longer replaced by space, but just removed. This +means accents no longer cause output words to be broken. The "-c" option was +added to show the arguments of \cite, \ref, and \pageref macros. This is +useful when using something like style on the output. + + +Modified (Version 2.3) -- September 7, 1990 +Fixed the handling of Ctl mode a little better and added an exception +for \index on suggestions from kcb@hss.caltech.edu (KC Border). Also +changed the value for DEFAULTINPUTS to coincide with a local change. + + +Modified -- February 10, 1991 +Added -t option to force TeX mode even when seeing the "\begin{document}" +string in the input. + + +Modified -- February 23, 1991 +Based on suggestions from pinard@iro.umontreal.ca (Francois Pinard), I +added support for the SysV string routines (-DUSG), added defines for +the flex lexical scanner (-DFLEX_SCANNER), changed NULL to '\0' when +using it as a character (his sys defined NULL as (void *)0), changed +the Makefile to use ${CC} instead of cc, and added comments about the +new compile time options. + + +Modified (Version 2.4) -- September 2, 1992 +Corrected the way CITEBEGIN worked. Due to serious braindeath I had +the condition wrong in the if test. It should be (fLatex && !fCite). +This solves the problem a couple people reported with amstex style +\ref entries. + +Added a preprocessing sed(1) command to replace all the long, easy to +read state names with short two letter state names (SA-S?) so that lex +won't overflow and I don't have to keep shortening the state names +every time I add one. If a state is added, it must also be added to +states.sed (order is important) along with its unique S? replacement. + +Added \pagestyle, \setcounter, and \verb handling from +K.Sattar@cs.exeter.ac.uk (Khalid Sattar). Also allows invocation as +"delatex" to force LaTeX mode. + +Applied patches from queinnec@cenatls.cena.dgac.fr (Philippe Queinnec) +to handle nested {}s in state <LaMacro2> (\bibitem, \cite, \index). + +Added special ligature handling (\aa, \ae, \oe, \l, \o, \i, \j, \ss) +at the suggestion of gwp@dido.caltech.edu (G. W. Pigman II). + +Cleaned up the comments on detex.h, added mathmatica to DEFAULTENV. + + +Modified (Version 2.5) -- January 28, 1993 +Leading spaces in macros are no longer stripped. This means +"foo\footnote{ bar}" comes out as "foo bar" instead of "foobar". + +Fixed special ligature handling so it works in cases line {\ss} instead of +just when followed by a space. + + +Modified (Version 2.6) -- July 30, 1993 +Added OS/2 port from hankedr@mail.auburn.edu (Darrel R Hankerson). + +Added handling of leading and trailing ':' in TEXINPUTS per the latest +TeX as suggested by jnp@tfl.dk (J|rgen N|rgaard). + +Changed the way the input path is constructed in SetInputPaths() so we +never try to modify a constant string. + +Changed the way the the ignore environment list is contructed in +SetEnvIgnore() so we never try to modify a constant string. + +Changed the USG define to HAVE_STRING_H. + +Fixed the states.sed script so it only replaces "Input" in the correct +places. I would like to use the \< \> word separator patterns but +they are not supported by all versions of sed. This as least works. + +Changed the detex.c target in the Makefile to use a temporary file +because I experienced problems (segmentation fault) with lex on +Solaris 2.1 when input was from stdin. + + +Modified (Version 2.7) -- September 10, 1997 +Removed line breaks in detex.l between a few patterns and actions. It +appears that flex is no longer able to handle this. Thanks to Anthony +Harris <harris@hebb.neurology.pitt.edu> and Marty Leisner +<leisner@sdsp.mc.xerox.com> for reporting this. + + +Porting notes -- March 30, 1992 +When using gcc, or compiling on a NeXT, you should compile with +-fwritable-strings. With the change to SetInputPaths() in 2.6 this +should no longer be necessary. + +On a NeXT, it has been reported that lex replaces the '\0' with NULL, +and then the compiler complains about it. I think this is an old bug +that is no longer applicable. + +July 30, 1993 +The flex scanner generator does not work because it does not handle +input buffering the same way as lex. I don't know of any reasonable +way to rewrite detex to get around this problem. + +May 25, 1995 +According to alain@ia1.u-strasbg.fr (Alain Ketterlin), using flex +allows 8-bit characters to be handled correctly. + +Modified (Version 2.8) -- January 1, 2008 +Added NCSA/University of Illinois Open Source License to facilitate +free redistribution. diff --git a/Build/source/texk/detex/detex-2.8/detex.h b/Build/source/texk/detex/detex-2.8/detex.h new file mode 100644 index 00000000000..68aa9b1d064 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/detex.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1986-2007 Purdue University + * All rights reserved. + * + * Developed by: Daniel Trinkle + * Department of Computer Science, Purdue University + * http://www.cs.purdue.edu/ + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal with the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimers in the + * documentation and/or other materials provided with the distribution. + * + * o Neither the names of Daniel Trinkle, Purdue University, nor the + * names of its contributors may be used to endorse or promote products + * derived from this Software without specific prior written + * permission. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. + */ + +/****** +** The following parameters should be modified as necessary +** MAXINCLIST - maximum number of files allowed in an \includeonly list +** +** DEFAULTINPUTS - this should be the same as the default TEXINPUTS +** CHPATHSEP - the path separator character in TEXINPUTS +** MAXINPUTPATHS - (arbitrary) number of separate paths in TEXINPUTS +** +** DEFAULTENV - list of LaTeX environments ignored +** CHENVSEP - the list separator character in the ignore envronment list +** MAXENVS - maximum number of environments listed in the ignore list +** CCHMAXENV - maximum count of characters in an environment name (LaTex) +******/ + +#define MAXINCLIST 40 + +#ifdef OS2 +#define DEFAULTINPUTS ".;/emtex/texinput" +#define CHPATHSEP ';' +#else +#define DEFAULTINPUTS ".:/usr/local/tex/inputs" +#define CHPATHSEP ':' +#endif +#define MAXINPUTPATHS 10 + +#define DEFAULTENV "array,eqnarray,equation,figure,mathmatica,picture,table,verbatim" +#define CHENVSEP ',' +#define MAXENVS 10 +#define CCHMAXENV 100 + +/****** +** These probably should not be changed +******/ + +#define CHOPT '-' +#define CHCITEOPT 'c' +#define CHENVOPT 'e' +#define CHLATEXOPT 'l' +#define CHNOFOLLOWOPT 'n' +#define CHSPACEOPT 's' +#define CHTEXOPT 't' +#define CHWORDOPT 'w' + +#define ERROR -1 diff --git a/Build/source/texk/detex/detex-2.8/detex.l b/Build/source/texk/detex/detex-2.8/detex.l new file mode 100644 index 00000000000..72a8397d029 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/detex.l @@ -0,0 +1,839 @@ +%{ +#ifndef lint +static char rcsid[] = "$Header: /p/src/local/bin/detex/RCS/detex.l,v 2.22 2007/03/01 20:22:01 trinkle Exp trinkle $"; +#endif + +/* + * Copyright (c) 1986-2007 Purdue University + * All rights reserved. + * + * Developed by: Daniel Trinkle + * Department of Computer Science, Purdue University + * http://www.cs.purdue.edu/ + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal with the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimers in the + * documentation and/or other materials provided with the distribution. + * + * o Neither the names of Daniel Trinkle, Purdue University, nor the + * names of its contributors may be used to endorse or promote products + * derived from this Software without specific prior written + * permission. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. + */ + + +/* + * detex [-e environment-list] [-c] [-l] [-n] [-s] [-t] [-w] [file[.tex] ] + * + * This program is used to remove TeX or LaTeX constructs from a text + * file. + */ + +#include "detex.h" +#ifdef HAVE_STRING_H +#include <string.h> +#define index strchr +#define rindex strrchr +#else +#include <strings.h> +#endif +#ifndef MAXPATHLEN +#include <sys/param.h> +#endif +#ifdef OS2 +#include <stdlib.h> +#endif + +#define LaBEGIN if (fLatex) BEGIN +#define IGNORE if (fSpace && !fWord) putchar(' ') +#define SPACE if (!fWord) putchar(' ') +#define NEWLINE if (!fWord) putchar('\n') +#define LATEX fLatex=!fForcetex +#define KILLARGS(x) cArgs=x; LaBEGIN LaMacro +#define STRIPARGS(x) cArgs=x; LaBEGIN LaMacro2 +#define CITE(x) if (fLatex && !fCite) KILLARGS(x) + +char *SafeMalloc(); +#ifndef NO_MALLOC_DECL +char *malloc(); +#endif +#ifdef OS2 +void yyless(int); +#endif + +char *rgsbEnvIgnore[MAXENVS]; /* list of environments ignored */ +char *rgsbIncList[MAXINCLIST]; /* list of includeonly files */ +char *rgsbInputPaths[MAXINPUTPATHS]; /* list of input paths in order */ +char sbCurrentEnv[CCHMAXENV]; /* current environment being ignored */ +char *sbProgName; /* name we were invoked with */ +FILE *rgfp[NOFILE+1]; /* stack of input/include files */ +int cfp = 0; /* count of files in stack */ +int cOpenBrace = 0; /* count of `{' in <LaMacro> and <LaMacro2> */ +int cArgs = 0; /* argument connt in <LaArgs> */ +int csbEnvIgnore; /* count of environments ignored */ +int csbIncList = 0; /* count of includeonly files */ +int csbInputPaths; /* count of input paths */ +int fLatex = 0; /* flag to indicated delatex */ +int fWord = 0; /* flag for -w option */ +int fFollow = 1; /* flag to follow input/include */ +int fCite = 0; /* flag to echo \cite and \ref args */ +int fSpace = 0; /* flag to replace \cs with space */ +int fForcetex = 0; /* flag to inhibit latex mode */ + +#ifdef FLEX_SCANNER +/* flex has contexts for buffers that need to be switched when file changes + * otherwise output contains imported files in reverse order. Weird, but + * true. + */ +YY_BUFFER_STATE rgsb[NOFILE + 1]; /* flex context stack */ +int csb = 0; /* depth of flex context stack */ +#endif /* FLEX_SCANNER */ + +%} + +S [ \t\n]* +W [a-zA-Z]+ +N [+-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+)) +U pt|pc|in|bp|cm|mm|dd|cc|sp +D {S}(({N}{S}{U})|(\\{W})){S} +Z \*? + +%Start Define Display IncludeOnly Input Math Normal Control +%Start LaBegin LaDisplay LaEnd LaEnv LaFormula LaInclude +%Start LaMacro LaOptArg LaMacro2 LaOptArg2 LaVerbatim +%start LaBreak LaPicture + +%% +<Normal>"%".* /* ignore comments */ ; + +<Normal>"\\begin"{S}"{"{S}"document"{S}"}" {LATEX; IGNORE;} + +<Normal>"\\begin" /* environment start */ {LaBEGIN LaBegin; IGNORE;} + +<LaBegin>{S}"{"{S}"verbatim"{S}"}" { if (BeginEnv("verbatim")) + BEGIN LaEnv; + else + BEGIN LaVerbatim; + IGNORE; + } + +<LaVerbatim>"\\end"{S}"{"{S}"verbatim"{S}"}" /* verbatim mode */ {BEGIN Normal; IGNORE;} +<LaVerbatim>[^\\]+ ECHO; +<LaVerbatim>. ECHO; + +<LaBegin>{S}"{"{S}"minipage"{S}"}" { KILLARGS(1); + if (BeginEnv("minpage")) + BEGIN LaEnv; + else + BEGIN Normal; + IGNORE; + } + +<LaBegin>{W} { if (BeginEnv(yytext)) + BEGIN LaEnv; + else + BEGIN Normal; + IGNORE; + } +<LaBegin>"\n" NEWLINE; +<LaBegin>. ; + +<LaEnv>"\\end" /* absorb some environments */ {LaBEGIN LaEnd; IGNORE;} +<LaEnv>"\n" NEWLINE; +<LaEnv>. ; + +<LaEnd>{W} /* end environment */ { if (EndEnv(yytext)) + BEGIN Normal; + IGNORE; + } +<LaEnd>"}" {BEGIN LaEnv; IGNORE;} +<LaEnd>"\n" NEWLINE; +<LaEnd>. ; + +<Normal>"\\vskip"{D} ; +<Normal>"\\vspace"{Z}{S}"{"{D}"}" ; +<Normal>"\\hskip"{D} ; +<Normal>"\\hspace"{Z}{S}"{"{D}"}" ; +<Normal>"\\addvspace"{S}"{"{D}"}" ; + +<Normal>"\\newlength" { KILLARGS(1); } +<Normal>"\\setlength" { KILLARGS(2); } +<Normal>"\\addtolength" { KILLARGS(2); } +<Normal>"\\settowidth" { KILLARGS(2); } +<Normal>"\\settoheight" { KILLARGS(2); } +<Normal>"\\settodepth" { KILLARGS(2); } +<Normal>"\\newsavebox" { KILLARGS(1); } +<Normal>"\\sbox" { KILLARGS(1); } +<Normal>"\\savebox" { KILLARGS(2); } +<Normal>"\\usebox" { KILLARGS(1); } +<Normal>"\\raisebox" { STRIPARGS(2); } +<Normal>"\\parbox" { KILLARGS(1); } +<Normal>"\\scalebox" { STRIPARGS(2); } +<Normal>"\\resizebox"{Z} { KILLARGS(2); } +<Normal>"\\reflectbox" ; +<Normal>"\\rotatebox" { KILLARGS(1); } +<Normal>"\\includegraphics"[^{]* { LaBEGIN LaPicture; } + +<LaPicture>"{" ; +<LaPicture>[^{}]+ { printf("<Picture %s>", yytext); } +<LaPicture>"\}" BEGIN Normal; + +<Normal>"\\definecolor" { KILLARGS(3); } +<Normal>"\\color" { KILLARGS(1); } +<Normal>"\\textcolor" { KILLARGS(2); } +<Normal>"\\colorbox" { KILLARGS(2); } +<Normal>"\\fcolorbox" { KILLARGS(3); } +<Normal>"\\pagecolor" { KILLARGS(1); } +<Normal>"\\foilhead" { STRIPARGS(1); } + +<Normal>"\\part"{Z} ; +<Normal>"\\section"{Z} ; +<Normal>"\\subsection"{Z} ; +<Normal>"\\subsubsection"{Z} ; +<Normal>"\\paragraph"{Z} ; +<Normal>"\\sunparagraph"{Z} ; + +<Normal>"\\bibitem" /* ignore args */ {KILLARGS(1); IGNORE;} +<Normal>"\\bibliography" /* of these \cs */ {KILLARGS(1); IGNORE;} +<Normal>"\\bibstyle" {KILLARGS(1); IGNORE;} +<Normal>"\\cite" {CITE(1); IGNORE;} +<Normal>"\\documentstyle" {LATEX; KILLARGS(1); IGNORE;} +<Normal>"\\documentclass" {LATEX; KILLARGS(1); IGNORE;} +<Normal>"\\usepackage" {KILLARGS(1); IGNORE;} +<Normal>"\\end" {KILLARGS(1); IGNORE;} +<Normal>"\\index" {KILLARGS(1); SPACE;} +<Normal>"\\footnote" {KILLARGS(1); SPACE;} +<Normal>"\\label" {KILLARGS(1); IGNORE;} +<Normal>"\\pageref" {CITE(1); IGNORE;} +<Normal>"\\pagestyle" {KILLARGS(1); IGNORE;} +<Normal>"\\ref" {CITE(1); IGNORE;} +<Normal>"\\setcounter" {KILLARGS(1); IGNORE;} +<Normal>"\\verb" /* ignore \verb<ch>...<ch> */ { if (fLatex) { + char verbchar, c; + verbchar = input(); + while ((c = input()) != verbchar) + if (c == '\n') + NEWLINE; + } + IGNORE; + } + +<Normal>"\\newcommand" { LATEX; KILLARGS(2); } +<Normal>"\\renewcommand" { LATEX; KILLARGS(2); } +<Normal>"\\newenvironment" { LATEX; KILLARGS(3); } + +<Normal>"\\def" /* ignore def begin */ {BEGIN Define; IGNORE;} +<Define>"{" BEGIN Normal; +<Define>"\n" NEWLINE; +<Define>. ; + +<Normal>"\\(" /* formula mode */ {LaBEGIN LaFormula; IGNORE;} +<LaFormula>"\\)" BEGIN Normal; +<LaFormula>"\n" NEWLINE; +<LaFormula>. ; + +<Normal>"\\[" /* display mode */ {LaBEGIN LaDisplay; IGNORE;} +<LaDisplay>"\\]" BEGIN Normal; +<LaDisplay>"\n" NEWLINE; +<LaDisplay>. ; + +<Normal>"$$" /* display mode */ {BEGIN Display; IGNORE;} +<Display>"$$" BEGIN Normal; +<Display>"\n" NEWLINE; +<Display>. ; + +<Normal>"$" /* math mode */ {BEGIN Math; IGNORE;} +<Math>"$" BEGIN Normal; +<Math>"\n" NEWLINE; +<Math>"\\$" ; +<Math>. ; + +<Normal>"\\include" /* process files */ {LaBEGIN LaInclude; IGNORE;} +<LaInclude>[^{ \t\n}]+ { IncludeFile(yytext); + BEGIN Normal; + } +<LaInclude>"\n" NEWLINE; +<LaInclude>. ; + +<Normal>"\\includeonly" {BEGIN IncludeOnly; IGNORE;} +<IncludeOnly>[^{ \t,\n}]+ AddInclude(yytext); +<IncludeOnly>"}" { if (csbIncList == 0) + rgsbIncList[csbIncList++] = '\0'; + BEGIN Normal; + } +<IncludeOnly>"\n" NEWLINE; +<IncludeOnly>. ; + +<Normal>"\\input" {BEGIN Input; IGNORE;} +<Input>[^{ \t\n}]+ { InputFile(yytext); + BEGIN Normal; + } +<Input>"\n" NEWLINE; +<Input>. ; + +<Normal>\\(aa|AA|ae|AE|oe|OE|ss)[ \t]*[ \t\n}] /* handle ligatures */ {(void)printf("%.2s", yytext+1);} +<Normal>\\[OoijLl][ \t]*[ \t\n}] {(void)printf("%.1s", yytext+1);} +<Normal>"\\linebreak" BEGIN LaBreak; + +<Normal>\\[a-zA-Z@]+ /* ignore other \cs */ {BEGIN Control; IGNORE;} +<Normal>"\\ " SPACE; +<Normal>"\\\\"{Z}(\[[^\]]*\])? NEWLINE; +<Normal>\\. IGNORE; +<LaBreak>[0-4]? { if (yytext==NULL || strlen(yytext)==0 + || atoi(yytext)==4) + NEWLINE; + BEGIN Normal; + } + +<Control>\\[a-zA-Z@]+ IGNORE; +<Control>[a-zA-Z@0-9]*[-'=`][^ \t\n{]* IGNORE; +<Control>"\n" {BEGIN Normal; NEWLINE;} +<Control>[ \t]*[{]* {BEGIN Normal; IGNORE;} +<Control>. {yyless(0);BEGIN Normal;} + +<Normal>[{}\\|] /* special characters */ IGNORE; +<Normal>[!?]"`" IGNORE; +<Normal>~ SPACE; + +<Normal>{W}[']*{W} { if (fWord) + (void)printf("%s\n", yytext); + else + ECHO; + } +<Normal>[0-9]+ if (!fWord) ECHO; +<Normal>(.|\n) if (!fWord) ECHO; + +<LaMacro>"\[" { BEGIN LaOptArg; } +<LaMacro>"{" { cOpenBrace++; } +<LaMacro>"}" { cOpenBrace--; + if (cOpenBrace == 0) + { + if (--cArgs==0) + BEGIN Normal; + } + } +<LaMacro>. ; +<LaOptArg>"\]" BEGIN LaMacro; +<LaOptArg>[^\]]* ; + +<LaMacro2>"\[" { BEGIN LaOptArg2; } +<LaMacro2>"{" { if (cOpenBrace == 0) + { + if (--cArgs==0) + { + BEGIN Normal; + cOpenBrace--; + } + } + cOpenBrace++; + } +<LaMacro2>"}" { cOpenBrace--; } +<LaMacro2>. ; +<LaOptArg2>"\]" BEGIN LaMacro2; +<LaOptArg2>. ; +%% +/****** +** main -- +** Set sbProgName to the base of arg 0. +** Set the input paths. +** Check for options +** -c echo LaTeX \cite, \ref, and \pageref values +** -e <env-list> list of LaTeX environments to ignore +** -l force latex mode +** -n do not follow \input and \include +** -s replace control sequences with space +** -t force tex mode +** -w word only output +** Set the list of LaTeX environments to ignore. +** Process each input file. +** If no input files are specified on the command line, process stdin. +******/ + +main(cArgs,rgsbArgs) +int cArgs; +char *rgsbArgs[]; +{ + char *pch, *sbEnvList = DEFAULTENV, sbBadOpt[2]; + FILE *TexOpen(); + int fSawFile = 0, iArgs = 1; + + /* get base name and decide what we are doing, detex or delatex */ +#ifdef OS2 + char drive[_MAX_DRIVE], dir[_MAX_DIR]; + char fname[_MAX_FNAME], ext[_MAX_EXT]; +#ifdef __EMX__ + _wildcard(&cArgs, &rgsbArgs); + _response(&cArgs, &rgsbArgs); +#endif + _splitpath (rgsbArgs[0], drive, dir, fname, ext); + sbProgName = strlwr(fname); +#else + if ((sbProgName = rindex(rgsbArgs[0], '/')) != NULL) + sbProgName++; + else + sbProgName = rgsbArgs[0]; +#endif + if (strcmp("delatex",sbProgName) == 0) + fLatex = 1; + + /* set rgsbInputPaths for use with TexOpen() */ + SetInputPaths(); + + /* process command line options */ + while (iArgs < cArgs && *(pch = rgsbArgs[iArgs]) == CHOPT) { + while (*++pch) + switch (*pch) { + case CHCITEOPT: + fCite = 1; + break; + case CHENVOPT: + if (++iArgs >= cArgs) { + ErrorExit("-e option requires and argument"); + } + sbEnvList = rgsbArgs[iArgs]; + break; + case CHLATEXOPT: + fLatex = 1; + break; + case CHNOFOLLOWOPT: + fFollow = 0; + break; + case CHSPACEOPT: + fSpace = 1; + break; + case CHTEXOPT: + fForcetex = 1; + break; + case CHWORDOPT: + fWord = 1; + break; + default: +#ifdef OS2 + OS2UsageExit(); +#else + sbBadOpt[0] = *pch; + sbBadOpt[1] = '\0'; + Warning("unknown option ignored -", sbBadOpt); +#endif + } + iArgs++; + } + SetEnvIgnore(sbEnvList); + + /* process input files */ + for (; iArgs < cArgs; iArgs++) { + fSawFile++; + if ((yyin = TexOpen(rgsbArgs[iArgs])) == NULL) { + Warning("can't open file", rgsbArgs[iArgs]); + continue;; + } + BEGIN Normal; + (void)yylex(); + } + + /* if there were no input files, assume stdin */ + if (!fSawFile) { + yyin = stdin; +#ifdef OS2 + if (isatty(fileno(stdin))) + OS2UsageExit(); +#endif + BEGIN Normal; + (void)yylex(); + } +#ifndef FLEX_SCANNER + if (YYSTATE != Normal) + ErrorExit("input contains an unterminated mode or environment"); +#endif + return(0); +} + +#ifdef FLEX_SCANNER +#undef yywrap +#endif + +/****** +** yywrap -- handles EOF for lex. Check to see if the stack of open files +** has anything on it. If it does, set yyin to the to value. If not +** return the termination signal for lex. +******/ + +yywrap() +{ + (void)fclose(yyin); +#ifdef FLEX_SCANNER + /* Pop context state */ + if (csb > 0) { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( rgsb[--csb] ); + } +#endif /* FLEX_SCANNER */ + if (cfp > 0) { + yyin = rgfp[--cfp]; + return(0); + } + return(1); +} + +#ifdef OS2 + +/****** +** yyless -- return characters to the input stream. Some systems don't have +** a yyless routine +******/ + +void yyless(n) +int n; +{ + int i = strlen(yytext); + + while (i > n) unput(yytext[--i]); + yytext[yyleng = n] = '\0'; +} +#endif + +/****** +** SetEnvIgnore -- sets rgsbEnvIgnore to the values indicated by the +** sbEnvList. +******/ + +SetEnvIgnore(sbEnvList) +char *sbEnvList; +{ + char *sb; + + sb = SafeMalloc(strlen(sbEnvList) + 1, "malloc for SetEnvIgnore failed"); + (void) strcpy(sb, sbEnvList); + csbEnvIgnore = SeparateList(sb, rgsbEnvIgnore, CHENVSEP, MAXENVS); + if (csbEnvIgnore == ERROR) + ErrorExit("The environtment list contains too many environments"); +} + +/****** +** BeginEnv -- checks to see if sbEnv is in the list rgsbEnvIgnore. If it +** is, sbCurrentEnv is set to sbEnv. +******/ + +BeginEnv(sbEnv) +char *sbEnv; +{ + int i; + + if (!fLatex) return(0); + for (i = 0; i < csbEnvIgnore; i++) + if (strcmp(sbEnv, rgsbEnvIgnore[i]) == 0) { + (void)strcpy(sbCurrentEnv, sbEnv); + return(1); + } + return(0); +} + +/****** +** EndEnv -- checks to see if sbEnv is the current environment being ignored. +******/ + +EndEnv(sbEnv) +char *sbEnv; +{ + if (!fLatex) return(0); + if (strcmp(sbEnv, sbCurrentEnv) == 0) + return(1); + return(0); +} + +/****** +** InputFile -- push the current yyin and open sbFile. If the open fails, +** the sbFile is ignored. +******/ + +InputFile(sbFile) +char *sbFile; +{ + FILE *TexOpen(); + + if (!fFollow) + return; + rgfp[cfp++] = yyin; + if ((yyin = TexOpen(sbFile)) == NULL) { + Warning("can't open \\input file", sbFile); + yyin = rgfp[--cfp]; + return; + } +#ifdef FLEX_SCANNER + rgsb[csb++] = YY_CURRENT_BUFFER; + yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) ); +#endif /* FLEX_SCANNER */ +} + +/****** +** IncludeFile -- if sbFile is not in the rgsbIncList, push current yyin +** and open sbFile. If the open fails, the sbFile is ignored. +******/ + +IncludeFile(sbFile) +char *sbFile; +{ + FILE *TexOpen(); + + if (!fFollow) + return; + if (!InList(sbFile)) + return; + rgfp[cfp++] = yyin; + if ((yyin = TexOpen(sbFile)) == NULL) { + Warning("can't open \\include file", sbFile); + yyin = rgfp[--cfp]; + return; + } +#ifdef FLEX_SCANNER + rgsb[csb++] = YY_CURRENT_BUFFER; + yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) ); +#endif /* FLEX_SCANNER */ +} + +/****** +** AddInclude -- adds sbFile to the rgsbIncList and increments csbIncList. +** If the include list is too long, sbFile is ignored. +******/ + +AddInclude(sbFile) +char *sbFile; +{ + if (!fFollow) + return; + if (csbIncList >= MAXINCLIST) + Warning("\\includeonly list is too long, ignoring", sbFile); + rgsbIncList[csbIncList] = SafeMalloc(strlen(sbFile) + 1, "malloc for AddInclude failed"); + (void)strcpy(rgsbIncList[csbIncList++], sbFile); +} + +/****** +** InList -- checks to see if sbFile is in the rgsbIncList. If there is +** no list, all files are assumed to be "in the list". +******/ + +InList(sbFile) +char *sbFile; +{ + char *pch, sbBase[MAXPATHLEN]; + int i; + + if (csbIncList == 0) /* no list */ + return(1); + (void)strcpy(sbBase, sbFile); + if ((pch = rindex(sbBase, '.')) != NULL) + *pch = '\0'; + i = 0; + while ((i < csbIncList) && rgsbIncList[i]) + if (strcmp(rgsbIncList[i++], sbBase) == 0) + return(1); + return(0); +} + +/****** +** SetInputPaths -- sets rgsbInputPaths to the values indicated by the +** TEXINPUTS environment variable if set or else DEFAULTINPUTS. If +** the user's TEXINPUTS has a leading ':' prepend the DEFAULTINPUTS +** to the path, if there is a trailing ':' append the DEFAULTINPUTS. +** This is consistent with the most recent TeX. However, this +** routine does not honor the '//' construct (expand subdirs). +******/ + +SetInputPaths() +{ + char *sb, *sbPaths, *getenv(); + int cchDefaults, cchPaths; + + cchDefaults = strlen(DEFAULTINPUTS); +#ifdef OS2 + if ((sb = getenv("TEXINPUT")) == NULL) +#endif + if ((sb = getenv("TEXINPUTS")) == NULL) + sb = DEFAULTINPUTS; + cchPaths = strlen(sb); + if (sb[0] == CHPATHSEP) + cchPaths += cchDefaults; + if (sb[strlen(sb) - 1] == CHPATHSEP) + cchPaths += cchDefaults; + sbPaths = SafeMalloc(cchPaths + 1, "malloc for SetInputPaths failed"); + sbPaths[0] = '\0'; + if (sb[0] == CHPATHSEP) + (void)strcat(sbPaths, DEFAULTINPUTS); + (void)strcat(sbPaths, sb); + if (sb[strlen(sb) - 1] == CHPATHSEP) + (void)strcat(sbPaths, DEFAULTINPUTS); + + csbInputPaths = SeparateList(sbPaths, rgsbInputPaths, CHPATHSEP, MAXINPUTPATHS); + if (csbInputPaths == ERROR) +#ifdef OS2 + ErrorExit("TEXINPUT(S) environment variable has too many paths"); +#else + ErrorExit("TEXINPUTS environment variable has too many paths"); +#endif +} + +/****** +** SeparateList -- takes a chSep separated list sbList, replaces the +** chSep's with NULLs and sets rgsbList[i] to the beginning of +** the ith word in sbList. The number of words is returned. A +** ERROR is returned if there are more than csbMax words. +******/ + +SeparateList(sbList, rgsbList, chSep, csbMax) +char *sbList, *rgsbList[], chSep; +int csbMax; +{ + int csbList = 0; + + while (sbList && *sbList && csbList < csbMax) { + rgsbList[csbList++] = sbList; + if (sbList = index(sbList, chSep)) + *sbList++ = '\0'; + } + return(sbList && *sbList ? ERROR : csbList); +} + +/****** +** TexOpen -- tries to open sbFile in each of the rgsbInputPaths in turn. +** For each input path the following order is used: +** file.tex - must be as named, if not there go to the next path +** file.ext - random extension, try it +** file - base name, add .tex and try it +** file - try it as is +** Notice that if file exists in the first path and file.tex exists in +** one of the other paths, file in the first path is what is opened. +** If the sbFile begins with a '/', no paths are searched. +******/ + +FILE * +TexOpen(sbFile) +char *sbFile; +{ + char *pch, *sbNew; + FILE *fp; + int iPath; + static char sbFullPath[MAXPATHLEN]; + + for (iPath = 0; iPath < csbInputPaths; iPath++) { +#ifdef OS2 + if (*sbFile == '/' || *sbFile == '\\' || strchr(sbFile, ':')) { /* absolute path */ +#else + if (*sbFile == '/') { /* absolute path */ +#endif + (void)sprintf(sbFullPath, "%s", sbFile); + iPath = csbInputPaths; /* only check once */ + } else + (void)sprintf(sbFullPath, "%s/%s", rgsbInputPaths[iPath], sbFile); +#ifdef OS2 + pch = sbFullPath; + while (pch = strchr(pch, '\\')) + *pch = '/'; +#endif + + /* If sbFile ends in .tex then it must be there */ + if ((pch = rindex(sbFullPath, '.')) != NULL + && (strcmp(pch, ".tex") == 0)) + if ((fp = fopen(sbFullPath, "r")) != NULL) + return(fp); + else + continue; + + /* if .<ext> then try to open it. the '.' represents */ + /* the beginning of an extension if it is not the first */ + /* character and it does not follow a '.' or a '/' */ + if (pch != NULL && pch > &(sbFullPath[0]) + && *(pch - 1) != '.' && *(pch - 1) != '/' + && (fp = fopen(sbFullPath, "r")) != NULL) + return(fp); + + /* just base name, add .tex to the name */ + sbNew = SafeMalloc(strlen(sbFullPath) + 5, "malloc for TexOpen failed"); + (void)strcpy(sbNew, sbFullPath); + (void)strcat(sbNew, ".tex"); + if ((fp = fopen(sbNew, "r")) != NULL) + return(fp); + + /* try sbFile regardless */ + if ((fp = fopen(sbFullPath, "r")) != NULL) + return(fp); + } + return((FILE *)NULL); +} + +/****** +** SafeMalloc -- wrapper around malloc() to check for failure. +******/ + +char * +SafeMalloc(cch, sbMessage) +int cch; +char *sbMessage; +{ + char *sb; + + if ((sb = (char *)malloc((unsigned)cch)) == NULL) + ErrorExit(sbMessage); + return(sb); +} + +/****** +** Warning -- print a warning message preceded by the program name. +******/ + +Warning(sb1, sb2) +char *sb1, *sb2; +{ + (void)fprintf(stderr, "%s: warning: %s %s\n", sbProgName, sb1, sb2); +} + +/****** +** ErrorExit -- print an error message preceded by the program name. +** Stdout is flushed and detex exits. +******/ + +ErrorExit(sb1) +char *sb1; +{ + (void)fflush(stdout); + (void)fprintf(stderr, "%s: error: %s\n", sbProgName, sb1); + exit(1); +} +#ifdef OS2 + +/****** +** OS2UsageExit -- print OS/2 usage message and exit. +******/ + +OS2UsageExit() +{ + (void)printf("\n%s [ -clnstw ] [ -e environment-list ] [ filename[.tex] ... ]\n", + sbProgName); + puts(" -c echo LaTeX \\cite, \\ref, and \\pageref values\n \ +-e <env-list> list of LaTeX environments to ignore\n \ +-l force latex mode\n \ +-n do not follow \\input and \\include\n \ +-s replace control sequences with space\n \ +-t force tex mode\n \ +-w word only output"); + exit(0); +} +#endif diff --git a/Build/source/texk/detex/detex-2.8/detex.man b/Build/source/texk/detex/detex-2.8/detex.man new file mode 100644 index 00000000000..93e71005746 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/detex.man @@ -0,0 +1,126 @@ +.TH DETEX 1L "12 August 1993" "Purdue University" +.SH NAME +detex \- a filter to strip \fITeX\fP commands from a .tex file. +.SH SYNOPSIS +.B detex +[ \fB\-clnstw\fR ] [ \fB\-e\fI environment-list\fR ] [ \fIfilename\fR[.tex] ... ] +.SH DESCRIPTION +.I Detex +(Version 2.6) +reads each file in sequence, removes all comments and +.I TeX +control sequences +and writes the remainder on the standard output. +All text in math mode and display mode is removed. +By default, +.I detex +follows \\input commands. +If a file cannot be opened, a warning message is +printed and the command is ignored. +If the +.B \-n +option is used, no \\input or \\include commands will be processed. +This allows single file processing. +If no input file is given on the command line, +.I detex +reads from standard input. +.PP +If the magic sequence ``\\begin{document}'' appears in the text, +.I detex +assumes it is dealing with +.I LaTeX +source and +.I detex +recognizes additional constructs used in +.IR LaTeX . +These include the \\include and \\includeonly commands. +The +.B \-l +option can be used to force +.I LaTeX +mode and the +.B \-t +option can be used to force +.I TeX +mode regardless of input content. +.PP +Text in various environment modes of +.I LaTeX +is ignored. The default modes are array, eqnarray, equation, figure, +mathmatica, picture, table and verbatim. The +.B \-e +option can be used to specify a comma separated +.I environment-list +of environments to ignore. The list replaces the defaults so specifying an +empty list effectively causes no environments to be ignored. +.PP +The +.B \-c +option can be used in +.I LaTeX +mode to have detex echo the arguments to \\cite, +\\ref, and \\pageref macros. This can be useful when sending the output to +a style checker. +.PP +.I Detex +assumes the standard character classes are being used for +.IR TeX . +.I Detex +allows white space between control sequences +and magic characters like `{' when recognizing things like +.I LaTeX +environments. +.PP +If the +.B \-w +flag is given, the output is a word list, one `word' (string of two or more +letters and apostrophes beginning with a letter) +per line, and all other characters ignored. +Without \fB\-w\fR the output follows the original, +with the deletions mentioned above. Newline characters are +preserved where possible +so that the lines of output match the input as closely as possible. +.PP +The TEXINPUTS environment variable is used to find \\input and \\include +files. Like \fITeX\fP, it interprets a leading or trailing `:' as the default +TEXINPUTS. It does \fInot\fP support the `//' directory expansion magic sequence. +.PP +Detex now handles the basic \fITeX\fP ligatures as a special case, replacing the +ligatures with acceptable charater substitutes. This eliminates +spelling errors introduced by merely removing them. The ligatures are +\\aa, \\ae, \\oe, \\ss, \\o, \\l (and their upper-case +equivalents). The special "dotless" characters \\i and \\j are also +replaced with i and j respectively. +.PP +Note that previous versions of +.I detex +would replace control sequences with a space character to prevent words +from running together. +However, this caused accents in the middle of words to break words, generating +"spelling errors" that were not desirable. +Therefore, the new version merely removes these accents. +The old functionality can be essentially duplicated by using the +.B \-s +option. +.SH SEE ALSO +tex(1L) +.SH DIAGNOSTICS +Nesting of \\input is allowed but the number of opened files must not +exceed the system's limit on the number of simultaneously opened files. +.I Detex +ignores unrecognized option characters after printing a warning message. +.SH AUTHOR +Daniel Trinkle, Computer Science Department, Purdue University +.SH BUGS +.I Detex +is not a complete +.I TeX +interpreter, so it can be confused by some constructs. +Most errors result in too much rather than too little output. +.PP +Running \fILaTeX\fR +source without a ``\\begin{document}'' +through \fIdetex\fR may produce +errors. +.PP +Suggestions for improvements are (mildly) encouraged. diff --git a/Build/source/texk/detex/detex-2.8/os2/README b/Build/source/texk/detex/detex-2.8/os2/README new file mode 100644 index 00000000000..7b0c562dd10 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/os2/README @@ -0,0 +1,7 @@ +This directory contains file contributed by hankedr@mail.auburn.edu +(Darrel R Hankerson) to facilitate compilation on OS/2 and DOS +systems. Use the lexout.c provided in the top level directory. + + detex.def linker definition file (16-bit versions) + detex-32.def linker definition file + Makefile.os2 makefile for MSC 6.00A or EMX/gcc (tested with dmake 3.8) diff --git a/Build/source/texk/detex/detex-2.8/os2/detex-32.def b/Build/source/texk/detex/detex-2.8/os2/detex-32.def new file mode 100644 index 00000000000..88cc9457ef3 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/os2/detex-32.def @@ -0,0 +1,3 @@ +NAME detex WINDOWCOMPAT NEWFILES +DESCRIPTION 'detex for OS/2 and MSDOS' +STACKSIZE 0x8000 diff --git a/Build/source/texk/detex/detex-2.8/os2/detex.def b/Build/source/texk/detex/detex-2.8/os2/detex.def new file mode 100644 index 00000000000..616c3156923 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/os2/detex.def @@ -0,0 +1,2 @@ +NAME detex WINDOWCOMPAT NEWFILES +DESCRIPTION 'detex for OS/2 and MSDOS' diff --git a/Build/source/texk/detex/detex-2.8/os2/makefile.os2 b/Build/source/texk/detex/detex-2.8/os2/makefile.os2 new file mode 100644 index 00000000000..daf50a0b7b5 --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/os2/makefile.os2 @@ -0,0 +1,96 @@ +# Makefile for "detex" (tested with dmake 3.8) 22 July 1993 +# +# - for GNU gcc (emx 0.8g kit) under OS/2 (32-bit) +# - for Microsoft C 6.00 under OS/2 or MSDOS (16-bit) + +# To use, enter "{d,n}make -f makefile.os2" (this makefile depends on its +# name being "makefile.os2"). + +default: + @echo Enter "$(MAKE) -f makefile.os2 emx" + @echo Enter "$(MAKE) -f makefile.os2 emxbnd" + @echo or "$(MAKE) -f makefile.os2 msc" + @echo or "$(MAKE) -f makefile.os2 mscbnd" + +# See the original Makefile for a complete list of options. +# +# Add -DMAXPATHLEN=<length> if it is not defined in /usr/include/sys/param.h +# +#MAXPATHLEN = -DMAXPATHLEN=1024 +# +# Add -DNO_MALLOC_DECL if your system does not like the malloc() declaration +# in detex.l (reported by pinard@iro.umontreal.ca) +# +NO_MALLOC_DECL = -DNO_MALLOC_DECL +# + +emx: + $(MAKE) -f makefile.os2 all \ + CC="gcc -Zomf -Zmtd" O=".obj" \ + CF="" \ + LDFLAGS="" \ + LDFLAGS2="" \ + DEF="detex-32.def" + +emxbnd: + $(MAKE) -f makefile.os2 all \ + CC="gcc" O=".o" \ + CF="" \ + LDFLAGS="" \ + LDFLAGS2="" \ + DEF="detex-32.def" + +msc: + $(MAKE) -f makefile.os2 all \ + CC="cl -AS " O=".obj" \ + CF="-D__STDC__ -DMAXPATHLEN=1024" \ + LDFLAGS="-Lp" \ + LDFLAGS2="setargv.obj -link /NOE" \ + DEF="detex.def" + +mscbnd: + $(MAKE) -f makefile.os2 all \ + CC="cl -AS " O=".obj" \ + CF="-D__STDC__ -DMAXPATHLEN=1024" \ + LDFLAGS="-Lp -Fb" \ + LDFLAGS2="setargv.obj -link /NOE" \ + DEF="detex.def" + + +CFLAGS = $(CF) -DOS2 -DHAVE_STRING_H $(NO_MALLOC_DECL) -DNOFILE=99 + +.c$O : + $(CC) $(CFLAGS) -c $< + +all : detex.exe + +detex.exe : detex$O $(DEF) + $(CC) $(LDFLAGS) -o $@ $< $(LDFLAGS2) + + +# Use your favorite lexical scanner +# +# flex buffered input causes problems--see flexdoc.man. +LEX = lex +LEX_YY = lex.yy +#LEX = flex +#LEX_YY = lexyy + +#LFLAGS = -8 -C + +CP = cp +FMT_CMD = groff -man + +# lexout.c obtained from lex output on sparc. + +#detex.c: +# sed -f states.sed detex.l | ${LEX} ${LFLAGS} +# mv $(LEX_YY).c detex.c + +detex.c : lexout.c + $(CP) $< $@ + +man-page: + $(FMT_CMD) detex.1l + +detex$O : detex.h diff --git a/Build/source/texk/detex/detex-2.8/states.sed b/Build/source/texk/detex/detex-2.8/states.sed new file mode 100644 index 00000000000..110f5fa6f7c --- /dev/null +++ b/Build/source/texk/detex/detex-2.8/states.sed @@ -0,0 +1,57 @@ +# Copyright (c) 1986-2007 Purdue University +# All rights reserved. +# +# Developed by: Daniel Trinkle +# Department of Computer Science, Purdue University +# http://www.cs.purdue.edu/ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal with the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# o Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimers. +# +# o Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimers in the +# documentation and/or other materials provided with the distribution. +# +# o Neither the names of Daniel Trinkle, Purdue University, nor the +# names of its contributors may be used to endorse or promote products +# derived from this Software without specific prior written +# permission. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +# +# +# convert long labels to a shorter form so lex(1) won't overflow +s/LaBegin/SA/g +s/LaDisplay/SB/g +s/LaEnd/SC/g +s/LaEnv/SD/g +s/LaFormula/SE/g +s/LaInclude/SF/g +s/LaMacro2/SG/g +s/LaMacro/SH/g +s/LaVerbatim/SI/g +s/Define/SJ/g +s/Display/SK/g +s/IncludeOnly/SL/g +s/\([ <]\)Input\([ >;]\)/\1SM\2/g +s/Math/SN/g +s/Normal/SO/g +s/Control/SP/g +s/LaPicture/SQ/g +s/LaBreak/SR/g +s/LaOptArg2/SS/g +s/LaOptArg/ST/g |