summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mpware
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/mpware')
-rw-r--r--Build/source/texk/web2c/mpware/ChangeLog467
-rw-r--r--Build/source/texk/web2c/mpware/Makefile.in62
-rw-r--r--Build/source/texk/web2c/mpware/README6
-rw-r--r--Build/source/texk/web2c/mpware/depend.mak75
-rw-r--r--Build/source/texk/web2c/mpware/depend.mk21
-rw-r--r--Build/source/texk/web2c/mpware/dmp.c1326
-rw-r--r--Build/source/texk/web2c/mpware/dmp.rc34
-rw-r--r--Build/source/texk/web2c/mpware/makempx.in181
-rw-r--r--Build/source/texk/web2c/mpware/mpto.c365
-rw-r--r--Build/source/texk/web2c/mpware/mpto.rc34
-rw-r--r--Build/source/texk/web2c/mpware/newer.c144
-rw-r--r--Build/source/texk/web2c/mpware/win32.mak75
12 files changed, 2790 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/mpware/ChangeLog b/Build/source/texk/web2c/mpware/ChangeLog
new file mode 100644
index 00000000000..ef2bd1c7b8b
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/ChangeLog
@@ -0,0 +1,467 @@
+2005-08-28 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mpto.c: For for the tex_pretex1 text from Taco Hoekwater
+ <taco@elvenkind.com>.
+
+2005-08-23 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mpto.c: Update to 0.902.
+
+2005-06-26 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in: Replace ac_include with kpse_include. From Peter
+ Breitenlohner.
+
+2005-06-22 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mpto.c: Merge code from version 0.9.
+
+ * Makefile.in (mpto): mpto doesn't need to link with libraries any
+ more.
+
+ * makempx.in: Update to version 0.9.
+
+ * dmp.c: Update copyright notice to indicate dmp is in the public
+ domain. Change bug report address.
+
+ * README: Update to version from metapost 0.901.
+
+ * newer.c: Use HAVE_CONFIG_H to check whether we can use web2c's
+ c-auto.h and config.h headers. Use HAVE_ST_MTIM to check whether
+ we have the high-res timers in struct stat.
+
+2005-06-21 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c (main): Include web2c version in version output.
+
+ * Makefile.in (newer): Don't link in any libraries (we shouldn't
+ be needing any).
+
+ * newer.c: Extensive rewrite to make it handle multiple arguments.
+ Suggested by Reinhard Kotucha <reinhard.kotucha@web.de>.
+
+2004-12-19 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * dmp.c [Hprime,MAXCHARS]: Larger values as there can be many more
+ than 256 chars in a font. Suggested by Michail Vidiassov
+ <master@iaas.msu.ru>.
+
+2004-07-23 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Have TROFF use -Tps instead of -Tpost, as the former
+ is what GROFF uses.
+
+ * dmp.c: Changes to support groff (which is the most likely
+ candidate for being actually used these days).
+ (hash): Use unsigned char to calculate hash value.
+ (get_int_map): Variant of get_int() that will accept octal and hex
+ values.
+ (get_float_map): Variant of get_float() that actually just skips over
+ the (comma-separated) list.
+ (scan_desc_line): Use get_int_map() and get_float_map() where
+ relevant.
+ (set_string): Set a word, to implement groff's 't' directive.
+ (do_graphic): Ignore 'Fd'.
+ (do_x_cmd): Account for groff's scaling.
+ (do_page): Account for groff's scaling. Implement (or ignore)
+ additional groff commands 'F', 'm', 'u' (aborts), 't'.
+ (dmp_usage): Modify help text.
+ These changes were suggested by Michail Vidiassov
+ <master@iaas.msu.ru>.
+
+2004-07-14 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mpto.c (main): Second argument to usagehelp.
+
+2004-06-19 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Since the trap statement is already quoted, the
+ quotes around $ERRLOG must be escaped. Found by Werner Lemberg
+ <wl@gnu.org>.
+
+2004-06-15 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Add quotes in various places to support filenames
+ with spaces in them.
+
+2004-05-29 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Forgot the filename in the sed command.
+
+ * makempx.in: If the mpxerr.tex begins with a %&-line, get the
+ name of the program to use from it. The default 'tex' has become
+ a problem now that 'latex' requires the 'etex' engine. Reported
+ by Lars Madsen <daleif@imf.au.dk>.
+
+2004-04-16 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Tell eqn to format for 'post' terminal, just like
+ troff is told to do. The asusmption here is that when troff
+ supports -Tpost, eqn does as well. From Michail Vidiassov
+ <master@iaas.msu.ru>.
+
+ * mpto.c: According to CSTR #54 the ".lf" directive should be ".lf
+ %d %s", not ".lf line %d %s" as used in the original code. Found
+ by Michail Vidiassov <master@iaas.msu.ru>.
+
+2003-02-15 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in: From klibtool to libtool. Based on patches from
+ Albert Chin-A-Young <china@thewrittenword.com>.
+
+ * makempx.in: We might as well be consistent in the use of '
+ versus ".
+
+2003-02-07 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Add --parse-first-line to arguments of "default"
+ TeX.
+
+2002-11-30 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c [WIN32]: Don't include sys/types.h and sys/stat.h.
+
+2002-10-06 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in (install-exec): Simplify. TeXlive merge.
+
+2001-12-11 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in (install-exec): Now that we link mpto with kpathsea,
+ use klibtool to install it. From by Adrian Bunk <bunk@fs.tum.de>.
+
+2001-11-19 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * dmp.c: Changes to keep C++ compilers from choking.
+
+2001-11-18 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c: Changes to keep C++ compilers from choking.
+
+ * mpto.c: Changes to keep C++ compilers from choking. Make calls
+ to usage() conform to the new interface.
+
+ * dmp.c: Changes to keep C++ compilers from choking.
+
+2001-10-26 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in (mpto): Now links with libkpathsea.
+
+ * mpto.c: Make buffer size obey buf_size texmf.cnf specification.
+ Add -tex=program option. Add protoypes.
+
+ * makempx.in: Add -tex=<program> option.
+
+2001-09-26 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c: Correct help text. From Oliver Moeller
+ <omoeller@csd.uu.se>.
+
+1999-03-15 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c [WIN32]: Patchlet from Fabrice.
+
+1999-02-04 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c (main): Remove __cdecl, from Fabrice.
+ [!WIN32]: Remove define of __cdecl, from Fabrice.
+
+ * mpto.c (main): Remove __cdecl, from Fabrice.
+ [!WIN32]: Remove define of __cdecl, from Fabrice.
+
+ * dmp.c (main): Remove __cdecl. From Fabrice.
+
+1999-01-27 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * newer.c (main): Add __cdecl, from Fabrice.
+
+ * mpto.c (main): Add __cdecl, by Fabrice.
+
+ * dmp.c (main): Add __cdecl, by Fabrice.
+ (dmp_usage): Import kpse_bug_address using KPSEDLL. From Fabrice.
+
+1999-01-13 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in: Rename kpathsea.make to kpathsea.mk.
+
+1999-01-10 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * makempx.in: Make makempx independent of compile-time BINDIR.
+ From Thomas.
+
+ * Makefile.in: Change of ../make/*.make to ../make/*.mk.
+
+1998-12-04 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mpto.c (getline): Change to handle all EOL conventions, not just
+ the native one.
+
+Mon Mar 23 19:18:12 1998 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in (dmp, makempx): Correct dependencies. From Eli
+ Zaretskii.
+
+Thu Jan 29 16:11:25 1998 Olaf Weber <infovore@xs4all.nl>
+
+ * dmp.c: Update for 0.64.
+
+Thu Dec 18 20:36:37 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * dmp.c (fsearch): Use binmode field.
+
+ * dmp.c (fsearch): Assume kpse_truetype_format and
+ kpse_type42_format are for binary files.
+
+Mon Dec 1 20:21:13 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * makempx.in: Use --interaction=batchmode instead of '\batchmode'.
+ Now TeX can look at the mpx$$.tex file to see if a %&format line
+ is present.
+
+Wed Nov 19 17:12:32 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * dmp.c (fsearch): Add kpse_tex-ps_header_format and
+ kpse_pict_format to the binary modes.
+
+Mon Oct 20 08:38:01 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * mpto.c, newer.c [WIN32]: Include string.h. From Fabrice Popineau.
+
+Sun Oct 19 11:00:35 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * makempx.in: Removed web2c maintainer's name.
+
+ * newer.c (main): Removed web2c maintainer's name. Use int main,
+ not void main.
+
+ * mpto.c (main): Removed web2c maintainer's name. Main returns
+ and int, not void.
+
+Fri Oct 17 14:07:21 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * dmp.c: Include the GROFF NOTES comments by Ulrik Vieth.
+
+Wed Oct 15 17:47:09 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * dmp.c (search): Select binary mode to open file for some
+ formats, just like kpse_file_open does. After Eli Zaretskii
+ <eliz@is.elta.co.il>.
+
+ * makempx.in: Fix message about `cat' failure. From Eli Zaretskii
+ <eliz@is.elta.co.il>.
+
+Fri Oct 3 11:54:56 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * mpto.c: Correct TROFF line directives (in the troff_pre*
+ variables).
+
+ * newer.c: Include stdlib.h. From Fabrice Popineau.
+ * mpto.c: Include stdlib.h (for exit).
+ * dmp.c: Add prototype for printversionandexit. After Fabrice
+ Popineau.
+
+Tue Sep 30 16:29:17 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * Makefile.in: Insert version string into makempx.
+ * makempx.in (mode): Modified to get version string from Makefile.
+
+ * newer.c, mpto.c: Modified to use version string from c-auto.h.
+
+ * mpto.c: suppress the printing of a comment if the first
+ *tex..etex block encountered is a verbatimtex..etex block.
+
+Thu Feb 13 16:18:39 1997 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in (install-exec): makempx is in the build directory,
+ not srcdir.
+ From: Andreas Schott <ays@rzg.mpg.de>.
+
+Mon Jan 20 17:30:44 1997 Karl Berry <karl@cs.umb.edu>
+
+ * Version 7.0.
+
+Mon Dec 9 01:31:55 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * makempx.in: Use `basename $0` in usage and version messages
+ for consistency with other programs and scripts.
+
+ * makempx.in: Fix a confusion between TROFF_INERR and TROFF_OUTERR.
+
+ * makempx.in: Remove unfinished $MPXFILE if an error occurs rather
+ than leaving behind a broken version that might confuse $NEWER.
+
+ * newer.c, mpto.c, dmp.c: Reformat usage message for consistency.
+
+ * newer.c (main): Back out unnecessary usage() function again.
+ All cases of incorrect input were already caught before.
+
+ * mpto.c (main): Issue "Need exactly one file arg. Try --help"
+ message if called with no arguments.
+
+ * dmp.c (main): Issue "Need one or two file args. Try --help"
+ message if called with no arguments.
+ This makes it impossible to use dmp as a filter reading from
+ stdin, but it's more in line with the behavior of dvitomp.
+
+ * dmp.c (main): Exit after perror() if file opening failed.
+ This might have been the reason for some remaining seg faults.
+
+Tue Dec 3 18:06:46 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * makempx.in: Must use `eval $TROFF' to get the `eqn | troff'
+ pipeline to work as intended.
+
+Tue Dec 3 00:42:20 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * newer.c (main): Don't seg fault if no args.
+ * newer.c (usage): New separate routine.
+
+ * dmp.c (copy_spec_char): Fix call of fsearch().
+ Refer to DIR_SEP_STRING instead of hard-wired "/".
+
+Mon Nov 18 13:26:52 1996 Karl Berry <karl@cs.umb.edu>
+
+ * makempx.in: Missing ` in --version. From Ulrik.
+
+Sun Nov 10 16:00:41 1996 Karl Berry <karl@cs.umb.edu>
+
+ * newer.c (main): Do not refer to dmp in the --version output.
+
+ * mpto.c (main): Don't seg fault if no args.
+ Do not refer to dmp in the --version output.
+ From Ulrik.
+
+Tue Oct 15 17:20:18 1996 Karl Berry <karl@cs.umb.edu>
+
+ * newer.c, mpto.c: Oops, can't use printversionandexit after all
+ without linking with kpathsea. Not worth it.
+ Just write out the notice.
+
+Tue Oct 8 16:46:17 1996 Karl Berry <karl@cs.umb.edu>
+
+ * *.c: Call printversionandexit for --version.
+ * makempx.in: Change --version output.
+
+Sat Sep 7 16:20:17 1996 Karl Berry <karl@cs.umb.edu>
+
+ * makempx.in (PATH): Include MAKEMPX_BINDIR, not compile_bindir.
+
+ * dmp.c (dmp_usage): Include bug reporting address.
+ * mpto.c (usage): Likewise.
+ * newer.c (main): Likewise.
+ * makempx.in (usage): Likewise.
+
+Sat Aug 10 13:27:54 1996 Karl Berry <karl@cs.umb.edu>
+
+ * dmp.c: Oops, forgot to declare kpathsea_version_string.
+
+Sun Aug 4 15:39:42 1996 Karl Berry <karl@cs.umb.edu>
+
+ * dmp.c: Also print kpathsea_version_string if --version.
+ Give perror if open of argument files for reading/writing fail.
+
+ * Makefile.in (newer, mpto): Include $(proglib) for versionstring.
+
+Fri Jul 26 15:47:57 1996 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in: Remove co.make.
+
+Sat Jun 8 13:15:01 1996 K. Berry <kb@cs.umb.edu>
+
+ * Makefile.in (newer, mpto): Use $(LIBS) $(XLOADLIBES) for these
+ standalone programs instead of $(LOADLIBES), a la squeeze
+ (dmp): Use $(kpathsea_link).
+
+Fri Apr 26 17:55:06 1996 Karl Berry <karl@cs.umb.edu>
+
+ * makempx.in: Add mptexpre feature. From John Hobby.
+
+Sat Apr 20 17:44:39 1996 Karl Berry <karl@cs.umb.edu>
+
+ * newer.c (main): Recognize --help and --version.
+
+Tue Mar 26 17:37:13 1996 Karl Berry <karl@cs.umb.edu>
+
+ * dmp.c: Include c-ctype.h.
+
+Fri Dec 29 17:16:09 1995 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in: misc.make is now clean.make.
+
+Tue Dec 12 16:52:00 1995 Karl Berry <karl@cs.umb.edu>
+
+ * dmp.c: Correct --version output. From Ulrik.
+
+Thu Nov 16 16:23:53 1995 Karl Berry <karl@cs.umb.edu>
+
+ * dmp.c: Call kpse_set_progname. From Gregor Hoffleit.
+
+ * makempx.in: Use filename.tex if converting to TeX. From Ulrik.
+
+ * mpto.c (main): Check mpfile for the fopen failing, not mpname.
+ Implement a -E <errfile> option.
+ (usage): Have a -E option on the Amiga.
+ From Andreas Scherer.
+
+Sat Sep 30 15:56:47 1995 Karl Berry <karl@cs.umb.edu>
+
+ * makempx.in: Quote "$1" for unusual filenames.
+
+Tue Aug 22 14:13:52 1995 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in: Include rdepend.make and depend.make.
+
+Mon Jul 31 15:45:12 1995 Karl Berry <karl@cs.umb.edu>
+
+ * mpto.c (usage): Improve help message.
+
+ * dmp.c: Convert to use kpathsea.
+
+Sun Jul 30 11:10:10 1995 Karl Berry <karl@cs.umb.edu>
+
+ * makempx.in (mode): Merge troffmpx into this.
+
+Thu Apr 13 16:40:08 1995 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * makempx, troffmpx: replaced by templates makempx.in, troffmpx.in.
+ The actual shell scripts are produced by sed, replacing @BINDIR@
+ by the actual installation directory $(bindir), which is known to
+ the Makefile when invoked as a sub-make from the top-level Makefile.
+
+ * newer.c: include "c-auto.h" as a replacement for "site.h".
+
+ * mptotex.c, mptotr.c: no changes needed.
+
+ * dvitomp.ch: complete rewrite, incorporating material from
+ ../dviutil/dviutil.ch and the original dvitomp.ch.
+
+ * dmp.c: include "c-auto.h" as a replacement for "site.h".
+ Also include a special header file "dmp.h" containing MetaPost
+ specific stuff that isn't found in "c-auto.h". Use MPSUPPORT
+ instead of MPPOOL as the directory for troff support files.
+
+ * dmp.h.in: added new template file for "dmp.h". The actual header
+ file is produced by sed, repacing @TEXMF@ by the actual library
+ directory $(texmf), which is known to the Makefile when invoked
+ as a sub-make from the top-level Makefile.
+
+ * pathexp.c: include "c-auto.h" as a replacement for "site.h".
+ Use `#ifdef HAVE_DIRENT_H' and `#ifdef HAVE_STRING_H' instead
+ of `#ifdef BSD'. (There still remains one case of `#ifdef SYSV'
+ that needs to be checked.)
+
+Wed Apr 12 18:56:19 1995 Ulrik Vieth <vieth@macbeth>
+
+ * Makefile: discarded, will be regenerated from Makefile.in
+ during configure run.
+
+ * Makefile.in: complete rewrite, based on ../dviutil/Makefile.in.
+
+ * convert: discarded, using ../lib/convert instead.
+
+ * mpware.def: discarded, using ../lib/common.defines instead.
+
+ * mpware.h: discarded, using the web2c header files from ../lib.
+
+ * dvimpext.c: discarded, using routines from ../lib/lib.a instead.
+
diff --git a/Build/source/texk/web2c/mpware/Makefile.in b/Build/source/texk/web2c/mpware/Makefile.in
new file mode 100644
index 00000000000..c110088a1ba
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/Makefile.in
@@ -0,0 +1,62 @@
+# Makefile for the MetaPost support programs.
+
+kpse_include ../make/paths.mk
+kpse_include ../make/common.mk
+kpse_include ../make/programs.mk
+kpse_include kpathsea.mk
+
+proglib = ../lib/lib.a
+programs = dmp mpto newer makempx
+
+default: all
+all: $(programs)
+
+dmp: dmp.o $(kpathsea)
+ $(kpathsea_link) dmp.o $(LOADLIBES)
+mpto: mpto.o
+ $(kpathsea_link) mpto.o
+newer: newer.o
+ $(link_command) newer.o
+makempx: makempx.in Makefile.in
+ sed -e 's,@BINDIR@,$(bindir),g' -e 's,@web2cver@,@WEB2CVERSION@,g' \
+ <$(srcdir)/makempx.in >$@
+ -chmod a+x $@
+
+newer.o dmp.o: ../c-auto.h
+
+checkdir = $(srcdir)/../check
+check: mpto makempx newer dmp
+ makempx $(checkdir)/label.mp ../check/xlabel.mpx
+ ./mpto -tex $(checkdir)/testex.mp | diff $(checkdir)/testex.tex -
+ sed '16s/^%//' <$(checkdir)/testex.mp >testex1
+ -mpto -tex testex1 >/dev/null 2>testex2
+ sed '17s/^%//' <$(checkdir)/testex.mp >testex1
+ -mpto -tex testex1 >/dev/null 2>>testex2
+ sed '18s/^%//' <$(checkdir)/testex.mp >testex1
+ -mpto -tex testex1 >/dev/null 2>>testex2
+ sed '19s/^%//' <$(checkdir)/testex.mp >testex1
+ -mpto -tex testex1 >/dev/null 2>>testex2
+ sed '20s/^%//' <$(checkdir)/testex.mp >testex1
+ -mpto -tex testex1 >/dev/null 2>>testex2
+ diff $(checkdir)/testex.err testex2
+
+Makefile: Makefile.in ../config.status
+ cd .. && $(SHELL) config.status
+
+install: install-exec install-data
+install-exec: $(programs)
+ $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) $(scriptdir)
+ $(INSTALL_PROGRAM) newer $(bindir)/newer
+ $(INSTALL_LIBTOOL_PROG) dmp $(bindir)
+ $(INSTALL_LIBTOOL_PROG) mpto $(bindir)
+ $(INSTALL_SCRIPT) makempx $(scriptdir)/makempx
+install-data:
+
+kpse_include ../make/tkpathsea.mk
+kpse_include ../make/clean.mk
+
+mostlyclean::
+ rm -f testex1 testex2
+
+kpse_include ../make/rdepend.mk
+kpse_include mpware/depend.mk
diff --git a/Build/source/texk/web2c/mpware/README b/Build/source/texk/web2c/mpware/README
new file mode 100644
index 00000000000..a7c792cda81
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/README
@@ -0,0 +1,6 @@
+$Id: README,v 1.2 2005/06/22 17:24:56 olaf Exp $
+
+Public domain, including the test files whose format precludes a
+standard license statement.
+
+This directory contains assorted utility routines for MetaPost.
diff --git a/Build/source/texk/web2c/mpware/depend.mak b/Build/source/texk/web2c/mpware/depend.mak
new file mode 100644
index 00000000000..505ca7646a1
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/depend.mak
@@ -0,0 +1,75 @@
+$(objdir)/dmp.obj: \
+ ../config.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 \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/../web2c/c-auto.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-pathch.h
+
+$(objdir)/newer.obj: \
+ ../c-auto.h \
+ ../config.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 \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/../web2c/c-auto.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/c-fopen.h
+
+$(objdir)/mpto.obj: \
+ ../c-auto.h \
+ ../cpascal.h \
+ ../config.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 \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/../web2c/c-auto.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/tex-file.h \
+ ../help.h \
+ $(kpathseadir)/variable.h
+
diff --git a/Build/source/texk/web2c/mpware/depend.mk b/Build/source/texk/web2c/mpware/depend.mk
new file mode 100644
index 00000000000..9b8032410e3
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/depend.mk
@@ -0,0 +1,21 @@
+dmp.o: dmp.c ../config.h $(kpathsea_srcdir)/config.h $(kpathsea_dir)/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 \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-pathch.h
+mpto.o: mpto.c
+newer.o: newer.c ../c-auto.h ../config.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_dir)/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 \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h
diff --git a/Build/source/texk/web2c/mpware/dmp.c b/Build/source/texk/web2c/mpware/dmp.c
new file mode 100644
index 00000000000..8682fce330c
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/dmp.c
@@ -0,0 +1,1326 @@
+/* $Id: dmp.c,v 1.17 2005/06/22 17:31:43 olaf Exp $
+ *
+ * Public domain.
+ *
+ * Previous versions of this file were copyright 1990 - 1995 by AT&T
+ * Bell Laboratories. It has since been put into the public domain.
+ *
+ * John Hobby wrote the original version, which has since been
+ * modified by several other people.
+ */
+
+/* This program reads device-independent troff output files,
+ and converts them into a symbolic form understood by MetaPost. Some
+ of the code was borrowed from DVItoMP. It understands all the D? graphics
+ functions that dpost does but it ignores `x X' device control functions
+ such as `x X SetColor:...', `x X BeginPath:', and `x X DrawPath:...'.
+
+ The output file is a sequence of MetaPost picture expressions, one for every
+ page in the input file. It makes no difference where the input file comes
+ from, but it is intended to process the result of running eqn and troff on
+ the output of MPtoTR. Such a file contains one page for every btex...etex
+ block in the original input. This program then creates a corresponding
+ sequence of MetaPost picture expressions for use as an auxiliary input file.
+ Since MetPost expects such files to have the extension .mpx, the output
+ is sometimes called an `mpx' file.
+
+ The |banner| string defined here should be changed whenever this program
+ gets modified.
+*/
+char *banner="% Written by DMP, Version 0.64"; /* first line of output */
+char *term_banner="This is DMP, Version 0.64";
+
+#include "config.h"
+#include <kpathsea/c-proto.h>
+#include <kpathsea/tex-file.h>
+#include <kpathsea/c-ctype.h>
+#include <kpathsea/c-pathch.h>
+#include <math.h>
+
+/* From ../cpascal.h */
+extern void printversionandexit P3H(const_string, const_string, const_string);
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+#define POOLMAX 65000 /* total characters in all font and char names */
+#define FCOUNT 100 /* maximum number of fonts */
+#define SHIFTS 100 /* maximum number of characters with special shifts */
+#define line_length 79 /* maximum output line length (must be at least 60) */
+#define Hprime 2459 /* much bigger than max(chars/font,fonts/job) */
+#define MAXCHARS 2048 /* character codes fall in the range 0..MAXCHARS-1 */
+#define LLENGTH 1024 /* one more than maximum line length for troff output */
+
+#define is_specchar(c) (c<=2) /* does charcode c identify a special char? */
+#define LWscale 0.03 /* line width for graphics as a fraction of pointsize */
+#define YCORR 12.0 /* V coordinate of reference point in (big) points */
+
+char strpool[POOLMAX]; /* text for font names and char names */
+int poolsize = 0; /* chars used so far in strpool */
+
+char *texname[FCOUNT]; /* TeX names (null-terminated strings) */
+int font_num[FCOUNT]; /* external font numbers */
+float font_design_size[FCOUNT]; /* design size in TeX points */
+struct hcell *charcodes[FCOUNT];/* hash tables for translating char names */
+int next_specfnt[FCOUNT]; /* used to link special fonts together */
+float charwd[FCOUNT][MAXCHARS]; /* width/ptsize indexed [font num][char code] */
+int nfonts; /* no. of internal font nums (texname indices)*/
+int shiftchar[SHIFTS]; /* charcode of character to shift, else -1 */
+float shifth[SHIFTS],shiftv[SHIFTS]; /* shift vals/fontsize (y is upward) */
+int shiftptr = 0; /* number of entries in shift tables */
+int shiftbase[FCOUNT]; /* initial index into shifth,shiftv,shiftchar */
+int specfnt = FCOUNT; /* int. num. of first special font (or FCOUNT)*/
+int *specf_tail = &specfnt; /* tail of specfnt list (*specf_tail==FCOUNT) */
+FILE *trf; /* the input file (troff output) */
+FILE *mpxf; /* the output file */
+struct hcell *trfonts; /* hash tab for internal nums of troff fonts */
+float unit = 0.0; /* (big) points per troff unit (0 when unset)*/
+int h,v; /* current position in tr. units (v downward)*/
+float cursize; /* current type size in (big) points */
+int curfont; /* internal number for current font */
+float Xslant; /* degrees additional slant for all fonts */
+float Xheight; /* yscale fonts to this height if nonzero */
+char *dbname = "trfonts.map"; /* file for table of troff & TFM font names */
+char *adjname = "trchars.adj"; /* file for character shift amounts */
+#define tfmpath kpse_tfm_format
+#define dbpath kpse_mpsupport_format
+#define trpath kpse_troff_font_format
+int lnno = 0; /* line num. in troff output file (our input) */
+
+
+void quit P3C(char*,msg1,char*,msg2,char*,msg3)
+{
+ fprintf(stderr,"DMP abort at troff output line %d:\n%s%s%s\n",
+ lnno, msg1, msg2, msg3);
+ exit(1);
+}
+
+void warn P3C(char*,msg1,char*,msg2,char*,msg3)
+{
+ fprintf(stderr,"DMP warning at troff output line %d:\n%s%s%s\n",
+ lnno, msg1, msg2, msg3);
+}
+
+void add_to_pool P1C(char,c)
+{
+ if (poolsize==POOLMAX) quit("Need to increase POOLMAX","","");
+ else strpool[poolsize++] = c;
+}
+
+
+
+
+/**************************************************************
+ Hash tables
+***************************************************************/
+
+typedef struct hcell {
+ char* lab;
+ int datum;
+} Hcell;
+
+#define new_htab (Hcell*) calloc((unsigned)Hprime, (unsigned)sizeof(Hcell))
+
+
+int hash P1C(char*,s)
+{
+ register int r;
+ for(r=0; *s!=0; s++) {
+ /* GROFF - in font metrics file the character name may be 8bit
+ groff_font(5): Groff supports eight bit characters;
+ groff_out(5): Note that single characters can have the
+ eighth bit set, as can the names of fonts and special
+ characters.
+ */
+ r = (r<<1) + *(unsigned char*)s;
+ while (r>=Hprime) r-=Hprime;
+ }
+ return r;
+}
+
+
+/* Find or insert the given string in the hash table and return the address
+ of the datum.
+*/
+Hcell *failure; /* null unless last hfind failed (used below) */
+
+int *hfind P2C(char*,s,Hcell*,htab)
+{
+ register Hcell *p;
+ register int cnt = Hprime;
+ failure = (Hcell *) 0;
+ p = &htab[hash(s)];
+ do {
+ if (p->lab==NULL) {
+ failure = p;
+ if (s<&strpool[0] || s>=&strpool[POOLMAX]) {
+ p->lab = &strpool[poolsize];
+ do add_to_pool(*s); while (*s++!='\0');
+ } else p->lab = s;
+ return &p->datum;
+ }
+ if (strcmp(s, p->lab)==0) return &p->datum;
+ if (p==htab) p= &htab[Hprime-1];
+ else p--;
+ } while (--cnt >= 0);
+ quit("Need to increase Hprime","","");
+ return (int*)0; /* keep lint happy */
+}
+
+
+/* If the last hfind() failed, undo the insertion and return zero (FALSE).
+*/
+int hfound()
+{
+ if (failure==(Hcell *)0) return 1;
+ failure->lab = NULL;
+ return 0;
+}
+
+
+
+/**************************************************************
+ Search Paths
+***************************************************************/
+
+FILE *fsearch P3C(char*,nam, char*,ext, kpse_file_format_type,format)
+{
+ FILE *f = NULL;
+
+ string fname = kpse_find_file (nam, format, true);
+ const_string mode = kpse_format_info[format].binmode
+ ? FOPEN_RBIN_MODE
+ : FOPEN_R_MODE;
+ if (fname) {
+ f = xfopen (fname, mode);
+ }
+ if (f==NULL) quit("Cannot find ",nam,ext);
+ return f;
+}
+
+
+
+/**************************************************************
+ Scanning Numbers
+***************************************************************/
+
+/* The standard functions atoi(), atof(), and sscanf() provide ways of reading
+ numbers from strings but they give no indication of how much of the string
+ is consumed. These homemade versions don't parse scientific notation.
+*/
+char *arg_tail; /* char after the number just gotten; NULL on failure */
+
+
+int get_int P1C(char *,s)
+{
+ register int i, d, neg;
+ if (s==NULL) goto bad;
+ for (neg=0;; s++)
+ if (*s=='-') neg=!neg;
+ else if (*s!=' ' && *s!='\t') break;
+ if (i= *s-'0', 0>i||i>9) goto bad;
+ while (d= *++s-'0', 0<=d&&d<=9)
+ i = 10*i + d;
+ arg_tail = s;
+ return neg ? -i : i;
+bad:arg_tail = NULL;
+ return 0;
+}
+
+/* GROFF font description files use octal character codes
+ groff_font(5): The code can be any integer. If it starts with
+ a 0 it will be interpreted as octal; if it starts with 0x
+ or 0X it will be intepreted as hexadecimal.
+*/
+int get_int_map P1C(char *,s)
+{
+ register int i;
+ if (s==NULL) goto bad;
+ i=strtol(s,&arg_tail,0);
+ if (s==arg_tail) goto bad;
+ return i;
+bad:arg_tail = NULL;
+ return 0;
+}
+
+/* Troff output files contain few if any non-integers, but this program is
+ prepared to read floats whenever they seem reasonable; i.e., when the
+ number is not being used for character positioning. (For non-PostScript
+ applications h and v are usually in pixels and should be integers.)
+*/
+float get_float P1C(char *,s)
+{
+ register int d, neg, digits;
+ register float x, y;
+
+ digits = 0;
+ if (s!=NULL) {
+ for (neg=0;; s++)
+ if (*s=='-') neg=!neg;
+ else if (*s!=' ' && *s!='\t') break;
+ x = 0.0;
+ while (d= *s-'0', 0<=d&&d<=9) {
+ x = 10.0*x + d;
+ digits++; s++;
+ }
+ if (*s=='.') {
+ y = 1.0;
+ while (d= *++s-'0', 0<=d&&d<=9) {
+ y /= 10.0;
+ x += y*d;
+ digits++;
+ }
+ }
+ }
+ if (digits==0) {
+ arg_tail = NULL;
+ return 0.0;
+ }
+ arg_tail = s;
+ return neg ? -x : x;
+}
+
+/* GROFF font description files have metrics field
+ of comma-separated integers. Traditional troff
+ have a float in this position. The value is not
+ used anyway - thus just skip the value,
+ eat all non-space chars.
+*/
+float get_float_map P1C(char *,s)
+{
+ if (s!=NULL) {
+ while (isspace(*s))
+ s++;
+ while (!isspace(*s) && *s)
+ s++;
+ }
+ arg_tail = s;
+ return 0;
+}
+
+/**************************************************************
+ Reading Initialization Files
+***************************************************************/
+
+/* Read the database file, reserve internal font numbers and set
+ the texname[] entries. Each line in the database file contains
+ <troff-name>\t,PostScript-name>\t<TeX-name>
+ or just <troff-name>\t,PostScript-name> if the TeX name matches the
+ PostScript name. ("\t" means one or more tabs.)
+*/
+
+void read_fmap P1C(char*,dbase)
+{
+ FILE *fin;
+ int c; /* last character read */
+ char *nam; /* a font name being read */
+
+ nfonts = 0;
+ fin = fsearch(dbase,"",dbpath);
+ trfonts = new_htab;
+ while ((c=getc(fin))!=EOF) {
+ if (nfonts==FCOUNT) quit("Need to increase FCOUNT","","");
+ nam = &strpool[poolsize];
+ for (;c!='\t'; c=getc(fin)) add_to_pool(c);
+ add_to_pool(0);
+ *hfind(nam, trfonts) = nfonts;
+ texname[nfonts] = &strpool[poolsize];
+ do {
+ poolsize = texname[nfonts] - strpool;
+ do c=getc(fin); while (c=='\t');
+ for (;c!='\t' && c!='\n'; c=getc(fin))
+ add_to_pool(c);
+ add_to_pool(0);
+ } while (c=='\t');
+ font_num[nfonts] = -1; /* indicate font is not mounted */
+ nfonts++;
+ }
+ fclose(fin);
+}
+
+
+/* Some characters need their coordinates shifted in order to agree with
+ troff's view of the world. Logically, this information belongs in the
+ font description files but it actually resides in a PostScript prolog
+ that the troff output processor dpost reads. Since that file is in
+ PostScript and subject to change, we read the same information from
+ a small auxiliary file that gives shift amounts relative to the font
+ size with y upward.
+*/
+/* GROFF NOTE:
+ The PostScript prologue in GNU groff's font directory does not
+ contain any character shift information, so the following function
+ becomes redundant. Simply keeping an empty "trchars.adj" file
+ around will do fine without requiring any changes to this program.
+*/
+void read_char_adj P1C(char*,adjfile)
+{
+ FILE* fin;
+ char buf[200];
+ int i;
+
+ fin = fsearch(adjfile, "", dbpath);
+ for (i=0; i<nfonts; i++)
+ shiftbase[i] = 0;
+ while (fgets(buf,200,fin)!=NULL) {
+ if (shiftptr==SHIFTS-1) quit("Need to increase SHIFTS","","");
+ if (buf[0]!=' ' && buf[0]!='\t') {
+ for (i=0; buf[i]!='\0'; i++)
+ if (buf[i]=='\n') buf[i]='\0';
+ shiftchar[shiftptr++] = -1;
+ shiftbase[*hfind(buf,trfonts)] = shiftptr;
+ if (!hfound()) quit(adjfile," refers to unknown font ",buf);
+ } else {
+ shiftchar[shiftptr] = get_int(buf);
+ shifth[shiftptr] = get_float(arg_tail);
+ shiftv[shiftptr] = -get_float(arg_tail);
+ if (arg_tail==NULL) quit("Bad shift entry : \"",buf,"\"");
+ shiftptr++;
+ }
+ }
+ shiftchar[shiftptr++] = -1;
+ fclose(fin);
+}
+
+
+/**************************************************************
+ Reading Font Files
+***************************************************************/
+
+
+/* Read the TFM file for the font with internal number f, updating the
+ data structures appropriately. We get the character widths out of the
+ tfm file instead of the troff font description file because they don't
+ because the latter source reflects alterations made only by dpost (the
+ troff output driver that is bypassed when using MetaPost).
+*/
+void read_tfm P1C(int, f)
+{
+ FILE* tf;
+ long a = 0;
+ int sizes[5]; /* file & header lengths, bc, ec, words in wd table */
+ long wd[256]; /* the width table (font size relative, scaled 2^20) */
+ int i, j;
+ long wtmp; /* needed to a floating exception on certain machines */
+
+ tf = fsearch(texname[f], ".tfm", tfmpath);
+ for (i=0; i<5; i++) {
+ sizes[i] = getc(tf);
+ sizes[i] = (sizes[i]<<8) | (getc(tf) & 0377);
+ }
+ if (sizes[1]<2 || sizes[2]<0 || sizes[3]<sizes[2]-1 || sizes[3]>255
+ || sizes[0]<sizes[1]+sizes[3]-sizes[2]+sizes[4]+7)
+ quit("Bad tfm file: ",texname[f],".tfm");
+ for (i=2*5; i<28; i++)
+ (void) getc(tf);
+ for (i=0; i<4; i++)
+ a = (a<<8) | (long) (getc(tf) & 0377);
+ font_design_size[f] = ((float) a)/1048576.0;
+ fseek(tf, (long)(28+4*(sizes[1]+sizes[3]-sizes[2])), 0);
+ for (i=0; i<sizes[4]; i++) {
+ wd[i] = 0L;
+ for (j=0; j<4; j++)
+ wd[i] = (wd[i]<<8) | (long) (getc(tf) & 0377);
+ }
+ fseek(tf, (long)(24+4*sizes[1]), 0);
+ for (i=sizes[2]; i<=sizes[3]; i++) {
+ wtmp = wd[getc(tf) & 0377];
+ charwd[f][i] = ((double) wtmp)/1048576.0/unit;
+ for (j=3; --j>=0;) (void) getc(tf);
+ }
+ fclose(tf);
+}
+
+
+/* Given one line from the character description file for the font with
+ internal number f, save the appropriate data in the charcodes[f] table.
+ A return value of zero indicates a syntax error.
+*/
+/* GROFF NOTE:
+ GNU groff uses an extended font description file format documented
+ in groff_font(5). In order to allow parsing of groff's font files,
+ this function needs to be rewritten as follows:
+
+ 1. The `metrics' field parsed by "get_float(lin);" may include
+ a comma-separated list of up to six decimal integers rather
+ than just a single floating-point number.
+
+ 2. The `charcode' field parsed by "lastcode = get_int(arg_tail);"
+ may be given either in decimal, octal, or hexadecimal format.
+*/
+int scan_desc_line P2C(int,f, char*,lin)
+{
+ static int lastcode;
+ char *s;
+
+ s = &strpool[poolsize];
+ while (*lin!=' ' && *lin!='\t' && *lin!='\0')
+ add_to_pool(*lin++);
+ add_to_pool('\0');
+ while (*lin==' ' || *lin=='\t') lin++;
+ if (*lin=='"')
+ *hfind(s,charcodes[f]) = lastcode;
+ else {
+ (void) get_float_map(lin);
+ (void) get_int(arg_tail);
+ lastcode = get_int_map(arg_tail);
+ if (arg_tail==NULL) return 0;
+ *hfind(s,charcodes[f]) = lastcode;
+ if (lastcode<0 || lastcode>=MAXCHARS) return 0;
+ }
+ return 1;
+}
+
+/* Read the font description file for the font with the given troff name
+ and update the data structures. The result is the internal font number.
+*/
+int read_fontdesc P1C(char*,nam)
+{
+ char buf[200];
+ FILE* fin; /* input file */
+ int f; /* internal font number */
+
+ if (unit==0.0) quit("Resolution is not set soon enough","","");
+ f = *hfind(nam, trfonts);
+ if (!hfound())
+ quit("Font was not in map file","","");
+ fin = fsearch(nam, "", trpath);
+ for (;;) {
+ if (fgets(buf,200,fin)==NULL)
+ quit("Description file for ",nam," ends unexpectedly");
+ if (strncmp(buf,"special",7)==0) {
+ *specf_tail = f;
+ next_specfnt[f] = FCOUNT;
+ specf_tail = &next_specfnt[f];
+ } else if (strncmp(buf,"charset",7)==0)
+ break;
+ }
+ charcodes[f] = new_htab;
+ while (fgets(buf,200,fin)!=NULL)
+ if (scan_desc_line(f, buf) == 0)
+ quit(nam," has a bad line in its description file: ",buf);
+ fclose(fin);
+ return f;
+}
+
+
+
+/**************************************************************
+ Low Level Output Routines
+***************************************************************/
+
+/* One of the basic output operations is to write a \MP\ string expression for
+ a sequence of characters to be typeset. The main difficulties are that such
+ strings can contain arbitrary eight-bit bytes and there is no fixed limit on
+ the length of the string that needs to be produced. In extreme cases this
+ can lead to expressions such as
+ char7&char15\&char31&"?FWayzz"
+ &"zzaF"&char15&char3&char31
+ &"Nxzzzzzzzwvtsqo"
+
+ A global variable state keeps track of the output process.
+ When state=normal we have begun a quoted string and the next character
+ should be a printable character or a closing quote. When state=special
+ the last thing printed was a `char' construction or a closing quote
+ and an ampersand should come next. The starting condition state=initial
+ is a lot like state=special, except no ampersand is required.
+*/
+#define special 0 /* the state after printing a `char' expression */
+#define normal 1 /* the state value in a quoted string */
+#define initial 2 /* initial state */
+
+int state = initial;
+int print_col = 0; /* there are at most this many characters on the current line */
+
+
+/* To print a string on the MPX file, initialize print_col, ensure that
+ state=initial, and pass the characters one-at-a-time to print_char.
+*/
+void print_char P1C(char,cc)
+{
+ int printable; /* nonzero if it is safe to print c */
+ int l; /* number of chars in c or the `char' expression */
+ int c; /* equal to cc mod 256, but always positive */
+
+ c = cc&0377;
+ printable = isprint(c) && c<128; /* avoid high-bit-on Latin-1 chars */
+ if (printable) l=1;
+ else if (c<10) l=5;
+ else if (c<100) l=6;
+ else l=7;
+ if (print_col+l>line_length-2) {
+ if (state==normal) {
+ putc('"',mpxf);
+ state = special;
+ }
+ putc('\n',mpxf);
+ print_col = 0;
+ }
+ if (state==normal)
+ if (printable) putc(c,mpxf);
+ else {
+ fprintf(mpxf,"\"&char%d",c);
+ print_col += 2;
+ }
+ else {
+ if (state==special) {
+ putc('&',mpxf);
+ print_col++;
+ }
+ if (printable) {
+ fprintf(mpxf,"\"%c",c);
+ print_col++;
+ } else
+ fprintf(mpxf,"char%d",c);
+ }
+ print_col += l;
+ state = printable ? normal : special;
+}
+
+
+/* The end_char_string procedure gets the string ended properly and ensures
+ that there is room for |l| more characters on the output line.
+*/
+void end_char_string P1C(int, l)
+{
+ while (state>special) {
+ putc('"',mpxf);
+ print_col++;
+ state--;
+ }
+ if (print_col+l>line_length) {
+ putc('\n',mpxf);
+ print_col = 0;
+ }
+ state = initial; /* get ready to print the next string */
+}
+
+
+
+/**************************************************************
+ Page and Character Output
+***************************************************************/
+
+char font_used[FCOUNT]; /* nonzero for fonts used on this page */
+int fonts_used; /* nonzero if any font been used on this page */
+int graphics_used; /* nonzero if any graphics seen on this page */
+float str_h1,str_v; /* corrected start pos for current out string */
+float str_h2; /* where the current output string ends */
+int str_f; /* internal font num for cur. output string */
+float str_size; /* point size for this text string */
+
+
+/* Before using any fonts we need to define a MetaPost macro for typesetting
+ character strings.
+*/
+void prepare_font_use()
+{
+ int k;
+
+ for (k=0;k<nfonts;k++) font_used[k]=0;
+ fonts_used = 1;
+ fprintf(mpxf,"string n[];\n");
+ fprintf(mpxf,"vardef s(expr t,m,x,y) =\n");
+ fprintf(mpxf," addto p also t scaled(m*1.00375) shifted(x,y); enddef;\n");
+}
+
+
+/* Do what is necessary when the font with internal number f is used for the
+ first time on a page.
+*/
+void first_use P1C(int,f)
+{
+ font_used[f] = 1;
+ fprintf(mpxf, "n%d=\"%s\";\n", font_num[f], texname[f]);
+}
+
+
+/* Print any transformations required by the current Xslant and Xheight
+ settings.
+*/
+void slant_and_ht()
+{
+ int i = 0;
+
+ if (Xslant!=0.0) {
+ fprintf(mpxf," slanted%.5f",Xslant);
+ i++;
+ }
+ if (Xheight!=cursize && Xheight!=0.0 && cursize!=0.0) {
+ fprintf(mpxf," yscaled%.4f", Xheight/cursize);
+ i++;
+ }
+ if (i>0) fprintf(mpxf, "\n ");
+}
+
+
+/* We maintain the invariant that str_f is -1 when there is no output string
+ under construction.
+*/
+void finish_last_char()
+{
+ float m,x,y; /* font scale, MetaPost coords of reference point */
+
+ if (str_f>=0) {
+ m = str_size/font_design_size[str_f];
+ x = str_h1*unit;
+ y = YCORR-str_v*unit;
+ if (fabs(x)>=4096.0 || fabs(y)>=4096.0 || m>=4096.0 || m<0) {
+ warn("text out of range ignored","","");
+ end_char_string(67);
+ }
+ else end_char_string(47);
+ fprintf(mpxf,")infont n%d", font_num[str_f]);
+ slant_and_ht();
+ fprintf(mpxf,",%.5f,%.4f,%.4f);\n", m, x,y);
+ str_f = -1;
+ }
+}
+
+
+/* Output character number c in the font with internal number f.
+*/
+void set_num_char P2C(int,f,int,c)
+{
+ float hh, vv; /* corrected versions of h, v */
+ int i;
+
+ hh = h;
+ vv = v;
+ for (i=shiftbase[f]; shiftchar[i]>=0; i++)
+ if (shiftchar[i]==c) {
+ hh += (cursize/unit)*shifth[i];
+ vv += (cursize/unit)*shiftv[i];
+ break;
+ }
+ if (c==0) quit("attempt to typeset an invalid character","","");
+ if (hh-str_h2>=1.0 || str_h2-hh>=1.0 || vv-str_v>=1.0 || str_v-vv>=1.0
+ || f!=str_f || cursize!=str_size) {
+ if (str_f>=0) finish_last_char();
+ else if (!fonts_used)
+ prepare_font_use(); /* first font usage on this page */
+ if (!font_used[f])
+ first_use(f); /* first use of font f on this page */
+ fprintf(mpxf,"s((");
+ print_col = 3;
+ str_f=f; str_v=vv; str_h1=hh;
+ str_size = cursize;
+ }
+ print_char(c);
+ str_h2 = hh + cursize*charwd[f][c];
+}
+
+/* Output a string. */
+void set_string P1C(char*,cname)
+{
+ float hh; /* corrected version of h, current horisontal position */
+
+ if (!*cname) return;
+ hh = h;
+ set_num_char(curfont,*cname);
+ hh+= cursize*charwd[curfont][*cname];
+ while (*++cname){
+ print_char(*cname);
+ hh += cursize*charwd[curfont][*cname];
+ }
+ h = rint(hh);
+ finish_last_char();
+}
+
+/* The following initialization and clean-up is required.
+*/
+void start_picture()
+{
+ fonts_used = graphics_used = 0;
+ str_f = -1;
+ str_v = 0.0;
+ str_h2 = 0.0;
+ str_size = 0.0;
+ fprintf(mpxf,"begingroup save C,D,p,s,n; picture p; p=nullpicture;\n");
+}
+
+void stop_picture()
+{
+ if (str_f>=0) finish_last_char();
+ fprintf(mpxf,"p endgroup\n");
+}
+
+
+
+/**************************************************************
+ Special Characters
+***************************************************************/
+
+/* Given the troff name of a special character, this routine finds its
+ definition and copies it to the MPX file. It also finds the name of
+ the vardef macro, puts it in the string pool, and index where the
+ string starts. The name should be C.<something>.
+*/
+char specintro[] = "vardef "; /* MetaPost name follows this */
+#define speci 7 /* length of the above string */
+
+int copy_spec_char P1C(char*,cname)
+{
+ int k = 0; /* how much of specintro so far */
+ FILE *deff;
+ int c, s;
+
+ deff = fsearch(concat3("charlib",DIR_SEP_STRING,cname), "", dbpath);
+ while (k<speci) {
+ if ((c=getc(deff))==EOF)
+ quit("No vardef in ",concat3("charlib",DIR_SEP_STRING,cname),"");
+ putc(c, mpxf);
+ if (c==specintro[k]) k++; else k=0;
+ }
+ s = poolsize;
+ while ((c=getc(deff))!='(') {
+ if (c==EOF) quit("vardef in ",concat3("charlib",DIR_SEP_STRING,cname),
+ " has no arguments");
+ putc(c, mpxf);
+ add_to_pool(c);
+ }
+ putc(c, mpxf);
+ add_to_pool('\0');
+ while ((c=getc(deff))!=EOF)
+ putc(c, mpxf);
+ return s;
+}
+
+
+/* When given a character name instead of a number, we need to check if
+ it is a special character and download the definition if necessary.
+ If the character is not in the current font we have to search the special
+ fonts.
+*/
+Hcell *spec_tab = (Hcell*)0;
+
+void set_char P1C(char*,cname)
+{
+ int f, c, *flagp;
+
+ if (*cname==' '||*cname=='\t') return;
+ f = curfont;
+ c = *hfind(cname, charcodes[f]);
+ if (!hfound()) {
+ for (f=specfnt; f!=FCOUNT; f=next_specfnt[f]) {
+ c = *hfind(cname, charcodes[f]);
+ if (hfound()) goto out;
+ }
+ quit("There is no character ",cname,"");
+ }
+out:if (!is_specchar(c)) set_num_char(f,c);
+ else {
+ if (str_f>=0) finish_last_char();
+ if (!fonts_used) prepare_font_use();
+ if (!font_used[f]) first_use(f);
+ if (spec_tab==(Hcell*)0)
+ spec_tab = new_htab;
+ flagp = hfind(cname, spec_tab);
+ if (*flagp==0)
+ *flagp = copy_spec_char(cname); /* this won't be zero */
+ fprintf(mpxf, "s(%s(n%d)", &strpool[*flagp], font_num[f]);
+ slant_and_ht();
+ fprintf(mpxf, ",%.5f,%.4f,%.4f);\n",
+ cursize/font_design_size[f], h*unit, YCORR-v*unit);
+ }
+}
+
+
+
+/**************************************************************
+ Font Definitions
+***************************************************************/
+
+/* Mount the font with troff name nam at external font number n and read any
+ necessary font files.
+*/
+void do_font_def P2C(int,n, char*,nam)
+{
+ int f, k;
+
+ f = *hfind(nam, trfonts);
+ if (!hfound())
+ quit("Font ",nam," was not in map file");
+ if (font_design_size[f]==0) {
+ read_fontdesc(nam);
+ read_tfm(f);
+ }
+ for (k=0; k<nfonts; k++)
+ if (font_num[k]==n) font_num[k]= -1;
+ font_num[f] = n;
+}
+
+
+
+/**************************************************************
+ Time on `makepath pencircle'
+***************************************************************/
+
+#define Speed ((float) (PI/4.0))
+
+/* Given the control points of a cubic Bernstein polynomial, evaluate
+ it at t.
+*/
+float Beval P2C(float*,xx, float, t)
+{
+ float zz[4];
+ register int i, j;
+ for (i=0; i<=3; i++) zz[i]=xx[i];
+ for (i=3; i>0; i--)
+ for (j=0; j<i; j++)
+ zz[j] += t*(zz[j+1]-zz[j]);
+ return zz[0];
+}
+
+
+/* Find the direction angle at time t on the path `makepath pencircle'.
+ The tables below give the Bezier control points for MetaPost's cubic
+ approximation to the first octant of a unit circle.
+*/
+float xx[4] = {1.0, 1.0, 0.8946431597, 0.7071067812};
+float yy[4] = {0.0, 0.2652164899, 0.5195704026, 0.7071067812};
+
+float circangle P1C(float,t)
+{
+ float ti;
+
+ ti = floor(t);
+ t -= ti;
+ return (float) atan(Beval(yy,t)/Beval(xx,t)) + ti*Speed;
+}
+
+
+/* Find the spline parameter where `makepath pencircle' comes closest to
+ (cos(a)/2,sin(a)/2).
+*/
+float circtime P1C(float,a)
+{
+ int i;
+ float t;
+ t = a/Speed;
+ for (i=2; --i>=0;)
+ t += (a - circangle(t))/Speed;
+ return t;
+}
+
+
+
+/**************************************************************
+ Troff Graphics
+***************************************************************/
+
+float gx, gy; /* current point for graphics (init. (h,YCORR/unit-v) */
+
+void prepare_graphics()
+{
+ fprintf(mpxf,"vardef D(expr d)expr q =\n");
+ fprintf(mpxf," addto p doublepath q withpen pencircle scaled d; enddef;\n");
+ graphics_used = 1;
+}
+
+
+/* This function prints the current position (gx,gy). Then if it can read dh dv
+ from string s, it increments (gx,gy) and prints "--". By returning the rest
+ of the string s or NULL if nothing could be read from s, it provides the
+ argument for the next iteration.
+*/
+char *do_line P1C(char*,s)
+{
+ float dh, dv;
+
+ fprintf(mpxf, "(%.3f,%.3f)", gx*unit, gy*unit);
+ dh = get_float(s);
+ dv = get_float(arg_tail);
+ if (arg_tail==NULL) return NULL;
+ gx += dh;
+ gy -= dv;
+ fprintf(mpxf,"--\n");
+ return arg_tail;
+}
+
+
+/* Function spline_seg() reads two pairs of (dh,dv) increments and prints the
+ corresponding quadratic B-spline segment, leaving the ending point to be
+ printed next time. The return value is the string with the first (dh,dv)
+ pair lopped off. If only one pair of increments is found, we prepare to
+ terminate the iteration by printing last time's ending point and returning
+ NULL.
+*/
+char * spline_seg P1C(char*,s)
+{
+ float dh1, dv1, dh2, dv2;
+
+ dh1 = get_float(s);
+ dv1 = get_float(arg_tail);
+ if (arg_tail==NULL) quit("Missing spline increments","","");
+ s = arg_tail;
+ fprintf(mpxf, "(%.3f,%.3f)", (gx+.5*dh1)*unit, (gy-.5*dv1)*unit);
+ gx += dh1;
+ gy -= dv1;
+ dh2 = get_float(s);
+ dv2 = get_float(arg_tail);
+ if (arg_tail==NULL) return NULL;
+ fprintf(mpxf, "..\ncontrols (%.3f,%.3f) and (%.3f,%.3f)..\n",
+ (gx-dh1/6.0)*unit, (gy+dv1/6.0)*unit, (gx+dh2/6.0)*unit,
+ (gy-dv2/6.0)*unit);
+ return s;
+}
+
+
+/* Draw an ellipse with the given major and minor axes.
+*/
+void do_ellipse P2C(float,a, float,b)
+{
+ fprintf(mpxf, "makepath(pencircle xscaled %.3f\n yscaled %.3f",
+ a*unit, b*unit);
+ fprintf(mpxf, " shifted (%.3f,%.3f));\n", (gx+.5*a)*unit, gy*unit);
+ gx += a;
+}
+
+
+/* Draw a counter-clockwise arc centered at (cx,cy) with initial and final radii
+ (ax,ay) and (bx,by) respectively.
+*/
+void do_arc P6C(float,cx, float,cy, float,ax, float,ay, float,bx, float,by)
+{
+ float t1, t2;
+
+ t1 = circtime(atan2(ay, ax));
+ t2 = circtime(atan2(by, bx));
+ if (t2 < t1) t2 += 8.0;
+ fprintf(mpxf, "subpath (%.5f,%.5f) of\n", t1, t2);
+ fprintf(mpxf, " makepath(pencircle scaled %.3f shifted (%.3f,%.3f));\n",
+ 2.0*sqrt(ax*ax+ay*ay)*unit, cx*unit, cy*unit);
+ gx = cx + bx;
+ gy = cy + by;
+}
+
+
+
+/* string s is everything following the initial `D' in a troff graphics command.
+*/
+void do_graphic P1C(char*,s)
+{
+ float h1, v1, h2, v2;
+ finish_last_char();
+ /* GROFF uses Fd to set fill color for solid drawing objects to the
+ default, so just ignore that.
+ */
+ if (s[0] == 'F' && s[1] == 'd') return;
+ gx = (float) h;
+ gy = YCORR/unit - ((float) v);
+ if (!graphics_used) prepare_graphics();
+ fprintf(mpxf,"D(%.4f) ", LWscale*cursize);
+ switch (*s++) {
+ case 'c':
+ h1 = get_float(s);
+ if (arg_tail==NULL) quit("Bad argument in ",s-2,"");
+ do_ellipse(h1,h1);
+ break;
+ case 'e':
+ h1 = get_float(s);
+ v1 = get_float(arg_tail);
+ if (arg_tail==NULL) quit("Bad argument in ",s-2,"");
+ do_ellipse(h1,v1);
+ break;
+ case 'A':
+ fprintf(mpxf, "reverse ");
+ /* fall through */
+ case 'a':
+ h1 = get_float(s);
+ v1 = get_float(arg_tail);
+ h2 = get_float(arg_tail);
+ v2 = get_float(arg_tail);
+ if (arg_tail==NULL) quit("Bad argument in ",s-2,"");
+ do_arc(gx+h1, gy-v1, -h1, v1, h2, -v2);
+ break;
+ case 'l': case 'p':
+ while (s!=NULL)
+ s = do_line(s);
+ fprintf(mpxf, ";\n");
+ break;
+ case 'q':
+ do s = spline_seg(s); while (s!=NULL);
+ fprintf(mpxf, ";\n");
+ break;
+ case '~':
+ fprintf(mpxf, "(%.3f,%.3f)--", gx*unit, gy*unit);
+ do s = spline_seg(s); while (s!=NULL);
+ fprintf(mpxf, "--(%.3f,%.3f);\n", gx*unit, gy*unit);
+ break;
+ default:
+ quit("Unknown drawing function",s-2,"");
+ }
+ h = (int) floor(gx+.5);
+ v = (int) floor(YCORR/unit+.5-gy);
+}
+
+
+
+/**************************************************************
+ Interpreting Troff Output
+***************************************************************/
+
+void change_font P1C(int,f)
+{
+ for (curfont=0; curfont<nfonts; curfont++)
+ if (font_num[curfont]==f) return;
+ quit("Bad font setting","","");
+}
+
+
+/* String s0 is everything following the initial `x' in a troff device control
+ command. A zero result indicates a stop command.
+*/
+int do_x_cmd P1C(char *,s0)
+{
+ float x;
+ int n;
+ char *s;
+
+ s = s0;
+ while (*s==' ' || *s=='\t') s++;
+ switch (*s++) {
+ case 'r':
+ if (unit!=0.0) quit("Attempt to reset resolution","","");
+ while (*s!=' ' && *s!='\t') s++;
+ unit = get_float(s);
+ if (unit<=0.0) quit("Bad resolution: x",s0,"");
+ unit = 72.0/unit;
+ break;
+ case 'f':
+ while (*s!=' ' && *s!='\t') s++;
+ n = get_int(s);
+ if (arg_tail==NULL) quit("Bad font def: x",s0,"");
+ s = arg_tail;
+ while (*s==' ' || *s=='\t') s++;
+ do_font_def(n, s);
+ break;
+ case 's':
+ return 0;
+ case 'H':
+ while (*s!=' ' && *s!='\t') s++;
+ Xheight = get_float(s);
+ /* GROFF troff output is scaled
+ groff_out(5): The argument to the s command is in scaled
+ points (units of points/n, where n is the argument
+ to the sizescale command in the DESC file.) The
+ argument to the x Height command is also in scaled points.
+ sizescale for groff devps is 1000
+ */
+ if(unit != 0.0) Xheight *= unit;
+ else Xheight /= 1000.0;
+ if (Xheight==cursize) Xheight=0.0;
+ break;
+ case 'S':
+ while (*s!=' ' && *s!='\t') s++;
+ Xslant = get_float(s)*(PI/180.0);
+ x = cos(Xslant);
+ if (-1e-4<x && x<1e-4) quit("Excessive slant","","");
+ Xslant = sin(Xslant)/x;
+ break;
+ default:
+ /* do nothing */;
+ }
+ return 1;
+}
+
+
+/* This routine reads commands from the troff output file up to and including
+ the next `p' or `x s' command. It also calls set_num_char() and set_char()
+ to generate output when appropriate. A zero result indicates that there
+ are no more pages to do.
+*/
+/* GROFF NOTE:
+ GNU groff uses an extended device-independent output file format
+ documented in groff_out(5). In order to allow parsing of groff's
+ output files, this function either needs to be extended to support
+ the new command codes, or else the use of the "t" and "u" commands
+ must be disabled by removing the line "tcommand" from the DESC file
+ in the $(prefix)/lib/groff/devps directory.
+*/
+int do_page()
+{
+ char buf[LLENGTH];
+ char a, *c, *cc;
+
+ h = v = 0;
+ while (fgets(buf,LLENGTH,trf)!=NULL) {
+ for (c=buf; *c!='\n'; c++)
+ if (*c=='\0') quit("Need to increase LLENGTH","","");
+ *c = '\0';
+ lnno++;
+ c = buf;
+ while (*c!='\0') {
+ switch(*c) {
+ case ' ': case '\t': case 'w':
+ c++;
+ break;
+ case 's':
+ cursize = get_float(c+1);
+ /* GROFF troff output is scaled
+ groff_out(5): The argument to the s command is in scaled
+ points (units of points/n, where n is the argument
+ to the sizescale command in the DESC file.) The
+ argument to the x Height command is also in scaled
+ points.
+ sizescale for groff devps is 1000
+ */
+ if (unit != 0.0) cursize *= unit;
+ else cursize /= 1000.0;
+ goto iarg;
+ case 'f':
+ change_font(get_int(c+1));
+ goto iarg;
+ case 'c':
+ if (c[1]=='\0') quit("Bad c command in troff output","","");
+ cc = c+2;
+ goto set;
+ case 'C':
+ cc=c; do cc++; while (*cc!=' ' && *cc!='\t' && *cc!='\0');
+ goto set;
+ case 'N':
+ set_num_char(curfont, get_int(c+1));
+ goto iarg;
+ case 'H':
+ h = get_int(c+1);
+ goto iarg;
+ case 'V':
+ v = get_int(c+1);
+ goto iarg;
+ case 'h':
+ h += get_int(c+1);
+ goto iarg;
+ case 'v':
+ v += get_int(c+1);
+ goto iarg;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (c[1]<'0' || c[1]>'9' || c[2]=='\0')
+ quit("Bad nnc command in troff output","","");
+ h += 10*(c[0]-'0') + c[1]-'0';
+ c++;
+ cc = c+2;
+ goto set;
+ case 'p':
+ return 1;
+ case 'n':
+ (void) get_int(c+1);
+ (void) get_int(arg_tail);
+ goto iarg;
+ case 'D':
+ do_graphic(c+1);
+ goto eoln;
+ case 'x':
+ if (!do_x_cmd(c+1)) return 0;
+ goto eoln;
+ case '#':
+ goto eoln;
+ case 'F':
+ /* GROFF uses this command to report filename */
+ goto eoln;
+ case 'm':
+ /* GROFF uses this command to control color */
+ goto eoln;
+ case 'u':
+ /* GROFF uses this command to output a word with additional
+ white space between characters, not implemented
+ */
+ quit("Bad command in troff output\n",
+ "change the DESC file for your GROFF PostScript device, ",
+ "remove tcommand");
+ case 't':
+ /* GROFF uses this command to output a word */
+ cc=c; do cc++; while (*cc!=' ' && *cc!='\t' && *cc!='\0');
+ a= *cc; *cc='\0';
+ set_string(++c);
+ c = cc;
+ *c = a;
+ continue;
+ default:
+ quit("Bad command in troff output","","");
+ }
+ continue;
+ set:a= *cc; *cc='\0';
+ set_char(++c);
+ c = cc;
+ *c = a;
+ continue;
+ iarg:c = arg_tail;
+ }
+ eoln:/* do nothing */;
+ }
+ return 0;
+}
+
+
+/**************************************************************
+ Main Program
+***************************************************************/
+
+void dmp_usage P2C(char*,name, int,status)
+{
+ extern KPSEDLL char *kpse_bug_address;
+ FILE *f = status == 0 ? stdout : stderr;
+ fputs ("Usage: dmp [OPTION]... DITROFFFILE [MPXFILE]\n\
+ Translate DITROFFFILE to the MetaPost MPXFILE or standard output.\n\
+\n\
+--help display this help and exit\n\
+--version output version information and exit\n", f);
+ putc ('\n', f);
+ fputs ("Email bug reports to metapost@tug.org.\n", f);
+ exit(status);
+}
+
+int main P2C(int, argc, char**, argv)
+{
+ int more;
+
+ trf = stdin;
+ mpxf = stdout;
+
+ kpse_set_progname (argv[0]);
+
+ if (argc == 1) {
+ fputs ("dmp: Need one or two file arguments.\n", stderr);
+ fputs ("Try `dmp --help' for more information.\n", stderr);
+ exit(1);
+ } else if (argc > 1 && strcmp (argv[1], "--help") == 0) {
+ dmp_usage (argv[0], 0);
+ } else if (argc > 1 && strcmp (argv[1], "--version") == 0) {
+ printversionandexit (term_banner,
+ "AT&T Bell Laboratories", "John Hobby");
+ }
+ if (argc>3) dmp_usage(argv[0], 1);
+ if (argc>1) {
+ trf = fopen(argv[1], "r");
+ if (trf==(FILE*)0) {
+ fprintf (stderr, "%s: ", argv[0]);
+ perror (argv[1]);
+ exit(1);
+ }
+ if (argc>2) {
+ mpxf = fopen(argv[2], "w");
+ if (mpxf==(FILE*)0) {
+ fprintf (stderr, "%s: ", argv[0]);
+ perror (argv[2]);
+ exit(1);
+ }
+ }
+ }
+ fprintf(mpxf, "%s\n", banner);
+ read_fmap(dbname);
+ read_char_adj(adjname);
+ if (do_page()) {
+ do {
+ h=0; v=0;
+ Xslant = Xheight = 0.0;
+ start_picture();
+ more = do_page();
+ stop_picture();
+ fprintf(mpxf,"mpxbreak\n");
+ } while (more);
+ }
+ return 0;
+}
diff --git a/Build/source/texk/web2c/mpware/dmp.rc b/Build/source/texk/web2c/mpware/dmp.rc
new file mode 100644
index 00000000000..d658e8905d3
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/dmp.rc
@@ -0,0 +1,34 @@
+/* dmp.rc: dmp resources -*- C++ -*-
+
+ Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ This file 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 file; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <texlive-version.h>
+
+#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " dmp 0.64"
+
+#define VER_INTERNALNAME_STR "dmp"
+#define VER_ORIGINALFILENAME_STR "dmp.exe"
+
+#define VER_LEGALCOPYRIGHT_STR " Copyright 1990 - 1995 by AT&T Bell Laboratories"
+
+#define VER_FILEDESCRIPTION_STR "Converts Troff device independent files Into METAPOST readable Files"
+
+#include <texlive.version>
+
+/* dmp.rc ends here */
diff --git a/Build/source/texk/web2c/mpware/makempx.in b/Build/source/texk/web2c/mpware/makempx.in
new file mode 100644
index 00000000000..8aaa9bac1dc
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/makempx.in
@@ -0,0 +1,181 @@
+#!/bin/sh
+# $Id: makempx.in,v 1.18 2005/06/22 17:33:26 olaf Exp $
+# Make an MPX file from the labels in a MetaPost source file,
+# using mpto and either dvitomp (TeX) or dmp (troff).
+# From John Hobby's original (though there's not much of it left by now).
+# Public domain.
+#
+#
+version=0.9
+
+: ${DMP=dmp}
+: ${DVITOMP=dvitomp}
+: ${MAKEMPX_BINDIR=`echo $0 | sed 's%/[^/]*$%%'`}
+: ${MPTEXPRE=mptexpre.tex}
+: ${MPTOTEX='mpto -tex'}
+: ${MPTOTR='mpto -troff'}
+: ${NEWER=newer}
+# This is oriented towards GNU roff: old value was
+# 'eqn -Tpost -d\$\$ | troff -Tpost'
+: ${TROFF='eqn -Tps -d\$\$ | troff -Tps'}
+
+# convert relative path to absolute in $MAKEMPX_BINDIR:
+case "$MAKEMPX_BINDIR" in
+ /*) ;;
+ *) MAKEMPX_BINDIR=`pwd`/$MAKEMPX_BINDIR;;
+esac
+
+PATH=$MAKEMPX_BINDIR:/bin:/usr/bin:$PATH
+
+# These names are documented in the MetaPost manual, so it's
+# unwise to change them.
+ERRLOG=mpxerr.log # file for an error log if necessary
+TEXERR=mpxerr.tex # file for erroneous TeX if any
+DVIERR=mpxerr.dvi # troublesome dvi file if any
+TROFF_INERR=mpxerr # file for erroneous troff input, if any
+TROFF_OUTERR=mpxerr.t # file for troublesome troff output, if any
+
+
+usage="Usage: $0 [-tex|-tex=<program>|-troff] MPFILE MPXFILE.
+ If MPXFILE is older than MPFILE, translate the labels from the MetaPost
+ input file MPFIle to low-level commands in MPXFILE, by running
+ $MPTOTEX, $TEX, and $DVITOMP
+ by default; or, if -troff is specified,
+ $MPTOTR, $TROFF, and $DMP.
+
+ The current directory is used for writing temporary files. Errors are
+ left in mpxerr.{tex,log,dvi}.
+
+ If the file named in \$MPTEXPRE (mptexpre.tex by default) exists, it is
+ prepended to the output in tex mode.
+
+Email bug reports to metapost@tug.org."
+
+
+mode=tex
+
+while test $# -gt 0; do
+ case "$1" in
+ -help|--help)
+ echo "$usage"; exit 0;;
+ -version|--version)
+ echo "`basename $0` $version"
+ echo "There is NO warranty. This script is public domain.
+Primary author: John Hobby."
+ exit 0;;
+ -troff|--troff) mode=troff;;
+ -tex|--tex) mode=tex;;
+ -tex=*|--tex=*) mode=tex; TEX=`echo "$1" | sed 's/^-*tex=//'`;;
+ -*)
+ echo "$0: Invalid option: $1." >&2
+ echo "Try \``basename $0` --help' for more information." >&2
+ exit 1;;
+ *)
+ if test -z "$MPFILE"; then
+ MPFILE=$1 # input file
+ elif test -z "$MPXFILE"; then
+ MPXFILE=$1 # output file
+ else
+ echo "$0: Extra argument $1." >&2
+ echo "Try \``basename $0` --help' for more information." >&2
+ exit 1
+ fi;;
+ esac
+ shift
+done
+
+if test -z "$MPFILE" || test -z "$MPXFILE"; then
+ echo "$0: Need exactly two file arguments." >&2
+ echo "Try \``basename $0` --help' for more information." >&2
+ exit 1
+fi
+
+trap "rm -f mpx$$.* \"$ERRLOG\"; exit 4" 1 2 3 15
+
+# If MPX file is up-to-date, do nothing.
+if $NEWER "$MPFILE" "$MPXFILE"; then
+
+ # Have to remake.
+ # Step 0: Check typesetter mode for consistency.
+ case "$mode" in
+ tex) MPTO="$MPTOTEX";;
+ troff) MPTO="$MPTOTR";;
+ *) echo "$0: Unknown typesetter mode: $mode" >&2
+ exit 1;;
+ esac
+
+ # Step 1: Extract typesetter source from MetaPost source.
+ if $MPTO "$MPFILE" >mpx$$.tex 2>"$ERRLOG"; then :;
+ # success
+ else
+ # failure
+ echo "$0: Command failed: $MPTO $MPFILE" >&2
+ cat "$ERRLOG" >&2
+ rm -f mpx$$.tex
+ exit 1
+ fi
+ if test "$mode" = troff; then
+ mv -f mpx$$.tex mpx$$.i
+ fi
+
+ # Step 2: Run typesetter.
+ if test "$mode" = tex; then
+ if test -r "$MPTEXPRE"; then
+ # Prepend user file.
+ cat "$MPTEXPRE" mpx$$.tex >mpx$$.tmp
+ mv mpx$$.tmp mpx$$.tex
+ fi
+
+ test -z "$TEX" && \
+ TEX=`sed -n '1s/%\&[ ]*\([^ ]*\).*$/\1 --parse-first-line/p;q' mpx$$.tex`
+ test -z "$TEX" && TEX='tex --parse-first-line'
+
+ if $TEX --interaction=batchmode mpx$$.tex </dev/null >/dev/null; then
+ WHATEVER_TO_MPX="$DVITOMP"
+ INFILE=mpx$$.dvi
+ INERROR=$DVIERR
+ else
+ # failure
+ mv -f mpx$$.tex "$TEXERR"
+ mv -f mpx$$.log "$ERRLOG"
+ echo "$0: Command failed: $TEX $TEXERR; see $ERRLOG" >&2
+ exit 2
+ fi
+ elif test "$mode" = troff; then
+ if cat mpx$$.i | eval $TROFF >mpx$$.t; then
+ # success, prepare for step 3.
+ WHATEVER_TO_MPX="$DMP"
+ INFILE=mpx$$.t
+ INERROR=$TROFF_OUTERR
+ else
+ # failure
+ mv -f mpx$$.i "$TROFF_INERR"
+ echo "$0: Command failed: cat $TROFF_INERR | $TROFF" >&2
+ rm -f mpx$$.t
+ exit 2
+ fi
+ else
+ echo "$0: Unknown typesetter mode: $mode; how did this happen?" >&2
+ exit 2
+ fi
+
+ # Step 3: Translate typesetter output to a MetaPost MPX.
+ if $WHATEVER_TO_MPX "$INFILE" "$MPXFILE" >"$ERRLOG"; then
+ : # success
+ else
+ # failure
+ mv -f "$INFILE" "$INERROR"
+ test $mode = troff && mv -f mpx$$.i "$TROFF_INERR"
+ echo "$0: Command failed: $WHATEVER_TO_MPX $INERROR $MPXFILE" >&2
+ # Better to remove $MPXFILE if something went wrong rather than
+ # leaving behind an unfinished or unusable version since $NEWER
+ # might think that all is fine if $MPXFILE exists.
+ rm -f "$MPXFILE"
+ cat "$ERRLOG" >&2
+ exit 3
+ fi
+
+ rm -f "$ERRLOG" mpx$$.*
+fi
+
+exit 0
diff --git a/Build/source/texk/web2c/mpware/mpto.c b/Build/source/texk/web2c/mpware/mpto.c
new file mode 100644
index 00000000000..0bc29fc259b
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/mpto.c
@@ -0,0 +1,365 @@
+/* $Id: mpto.c,v 1.21 2005/08/28 09:17:25 olaf Exp $
+ * Public domain.
+ *
+ * Previous versions of mpto were copyright 1990 - 1995 by AT&T Bell
+ * Laboratories. It has since been put into the public domain.
+ *
+ * John Hobby wrote the original version, which has since been
+ * extensively altered.
+ */
+
+/* mpto [-tex|-troff] MPFILE
+ *
+ * This program transforms a MetaPost input file into a TeX or troff input
+ * file by stripping out btex...etex and verbatimtex...etex sections.
+ * Leading and trailing spaces and tabs are removed from the extracted
+ * material and it is surrounded by the preceding and following strings
+ * defined immediately below. The input file should be given as argument 1
+ * and the resulting TeX or troff file is written on standard output.
+ *
+ * Changes incorporated from Web2c:
+ * - merged TeX and troff mode
+ * - support -E<errlog>, for AMIGA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef WIN32
+#include <string.h>
+#endif
+
+
+/* MetaPost itself has a configurable max line length, but we can afford to
+ use smaller values than that */
+#define bufsize 1000
+
+char* tex_predoc = "";
+char* tex_postdoc = "\\end{document}\n";
+char* tex_pretex1 = "\\gdef\\mpxshipout{\\shipout\\hbox\\bgroup%\n"
+ " \\setbox0=\\hbox\\bgroup}%\n"
+ "\\gdef\\stopmpxshipout{\\egroup"
+ " \\dimen0=\\ht0 \\advance\\dimen0\\dp0\n"
+ " \\dimen1=\\ht0 \\dimen2=\\dp0\n"
+ " \\setbox0=\\hbox\\bgroup\n"
+ " \\box0\n"
+ " \\ifnum\\dimen0>0 \\vrule width1sp height\\dimen1 depth\\dimen2 \n"
+ " \\else \\vrule width1sp height1sp depth0sp\\relax\n"
+ " \\fi\\egroup\n"
+ " \\ht0=0pt \\dp0=0pt \\box0 \\egroup}\n"
+ "\\mpxshipout%% line %d %s\n";
+char* tex_pretex = "\\mpxshipout%% line %d %s\n";
+char* tex_posttex = "\\stopmpxshipout\n";
+char* tex_preverb1 = ""; /* if very first instance */
+char* tex_preverb = "%% line %d %s\n"; /* all other instances */
+char* tex_postverb = "%\n";
+
+/* According to CSTR #54 the ".lf" directive should be ".lf %d %s",
+ * not ".lf line %d %s" as used in the original code. This affects
+ * troff_pretex1, troff_pretex, troff_preverb1, troff_preverb.
+ */
+char* troff_predoc = ".po 0\n";
+char* troff_postdoc = "";
+char* troff_pretex1 = ".lf %d %s\n"; /* first instance */
+char* troff_pretex = ".bp\n.lf %d %s\n"; /* subsequent instances */
+char* troff_posttex = "\n";
+char* troff_preverb1 = ".lf %d %s\n";
+char* troff_preverb = ".lf %d %s\n";
+char* troff_postverb = "\n";
+
+char* predoc;
+char* postdoc;
+char* pretex1;
+char* pretex;
+char* posttex;
+char* preverb1;
+char* preverb;
+char* postverb;
+
+char *mpname;
+FILE *mpfile;
+int lnno = 0; /* current line number */
+int texcnt = 0; /* btex..etex blocks so far */
+int verbcnt = 0; /* verbatimtex..etex blocks so far */
+char *bb, *tt, *aa; /* start of before, token, and after strings */
+char buf[bufsize]; /* the input line */
+
+void
+err (char * msg)
+{
+ fprintf(stderr, "mpto: %s:%d: %s\n",mpname, lnno, msg);
+ exit(1);
+}
+
+void
+usage (char *progn)
+{
+ fprintf(stderr, "Try `%s --help' for more information\n", progn);
+ exit(1);
+}
+
+char *
+getline(void) /* returns NULL on EOF or error, otherwise buf */
+{
+ int c;
+ unsigned loc = 0;
+ while ((c = getc (mpfile)) != EOF && c != '\n' && c != '\r') {
+ buf[loc++] = c;
+ if (loc == bufsize)
+ err("Line is too long");
+ }
+ if (c == EOF) return NULL;
+ buf[loc] = 0;
+ if (c == '\r') {
+ c = getc(mpfile);
+ if (c != '\n') ungetc(c, mpfile);
+ }
+ lnno++;
+ return buf;
+}
+
+
+/* Return nonzero if a prefix of string s matches the null-terminated string t
+ * and the next character is not a letter of an underscore.
+ */
+int
+match_str (char *s, char *t)
+{
+ while (*t!=0) {
+ if (*s!=*t) return 0;
+ s++; t++;
+ }
+ switch (*s) {
+ case 'a': case 'c': case 'd': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
+ case 'o': case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'w': case 'x': case 'y': case 'z': case '_':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z': case 'b': case 'e': case 'v':
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+
+/* This function tries to express s as the concatenation of three strings
+ * b, t, a, with the global pointers bb, tt, and aa set to the start of the
+ * corresponding strings. String t is either a quote mark, a percent sign,
+ * or an alphabetic token "btex", "etex", or "verbatimtex". (An alphabetic
+ * token is a maximal sequence of letters and underscores.) If there are
+ * several possible substrings t, we choose the leftmost one. If there is
+ * no such t, we set b=s and return 0.
+ */
+int
+getbta (char *s)
+{
+ int ok=1; /* zero if last character was a-z, A-Z, or _ */
+
+ bb = s;
+ for (tt=bb; *tt!=0; tt++)
+ switch (*tt) {
+ case '"': case '%':
+ aa = tt+1;
+ return 1;
+ case 'b':
+ if (ok && match_str(tt,"btex")) {
+ aa = tt+4;
+ return 1;
+ } else ok=0;
+ break;
+ case 'e':
+ if (ok && match_str(tt,"etex")) {
+ aa = tt+4;
+ return 1;
+ } else ok=0;
+ break;
+ case 'v':
+ if (ok && match_str(tt,"verbatimtex")) {
+ aa = tt+11;
+ return 1;
+ } else ok=0;
+ break;
+ case 'a': case 'c': case 'd': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
+ case 'o': case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'w': case 'x': case 'y': case 'z': case '_':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ ok = 0;
+ break;
+ default:
+ ok = 1;
+ }
+ aa = tt;
+ return 0;
+}
+
+
+void
+copytex(void)
+{
+ char *s; /* where a string to print stops */
+ char c;
+
+ while (*aa==' ' || *aa=='\t') aa++;
+ if (*aa==0)
+ if ((aa=getline())==NULL)
+ err("btex section does not end");
+ do { if (*aa==0)
+ if ((aa=getline())==NULL)
+ err("btex section does not end");
+ else printf("\n");
+ if (getbta(aa) && *tt=='e') {
+ s = tt-1;
+ while (s>=bb && (*s==' ' || *s=='\t'))
+ s--;
+ s++;
+ } else {
+ if (*tt=='b') err("btex in TeX mode");
+ if (*tt=='v') err("verbatimtex in TeX mode");
+ s = aa;
+ }
+ c = *s;
+ *s = 0;
+ printf("%s", bb);
+ *s = c;
+ } while (*tt!='e');
+}
+
+
+void
+do_line(void)
+{
+ aa = buf;
+ while (getbta(aa))
+ if (*tt=='%') break;
+ else if (*tt=='"') {
+ do if (!getbta(aa)) err("string does not end");
+ while (*tt!='"');
+ } else if (*tt=='b') {
+ if (texcnt++ ==0) printf(pretex1,lnno,mpname);
+ else printf(pretex,lnno,mpname);
+ copytex();
+ printf("%s",posttex);
+ } else if (*tt=='v') {
+ if (verbcnt++ ==0 && texcnt==0)
+ printf(preverb1,lnno,mpname);
+ else printf(preverb,lnno,mpname);
+ copytex();
+ printf("%s",postverb);
+ } else err("unmatched etex");
+}
+
+int
+main(int argc, char **argv)
+{
+ int mode;
+ if (argc == 1) {
+ fputs ("mpto: Need exactly one file argument.\n", stderr);
+ fputs ("Try `mpto --help' for more information.\n", stderr);
+ exit(1);
+ } else if (argc > 1 && (strcmp (argv[1], "--help") == 0
+ || strcmp (argv[1], "-help") == 0)) {
+ fputs ("Usage: mpto [-tex|-troff] MPFILE",stdout);
+#ifdef AMIGA
+ fputs (" [-E<errlog-file>]",stdout);
+#endif
+ fputs ("\n Strip btex..etex and verbatimtex...etex parts from MetaPost input\n\
+ file MPFILE, converting to either TeX or troff (TeX by default).\n\
+\n\
+--help display this help and exit\n\
+--version output version information and exit\n",stdout);
+ fputs ("\nEmail bug reports to metapost@tug.org.\n", stdout);
+ exit (0);
+ } else if (argc > 1 && (strcmp (argv[1], "--version") == 0
+ || strcmp (argv[1], "-version") == 0)) {
+ printf ("mpto 0.902\n\
+This program is in the public domain.\n\
+Primary author of mpto: John Hobby.\n");
+ exit (0);
+ } else if (argc == 2) {
+ mpname = argv[1];
+ mode = 0;
+#ifdef AMIGA
+ } else if (argc == 3) {
+ if (strcmp (argv[1], "-tex") == 0) {
+ mpname = argv[2];
+ mode = 0;
+ } else if (strcmp (argv[1], "-troff") == 0) {
+ mpname = argv[2];
+ mode = 1;
+ } else if (strncmp(argv[2], "-E", 2) || (argv[2]+2 == NULL)) {
+ usage(argv[0]);
+ } else {
+ mpname = argv[1];
+ freopen(argv[2]+2, "w", stderr);
+ }
+ } else if (argc == 4) {
+ if (strcmp (argv[1], "-tex") == 0) {
+ mode = 0;
+ } else if (strcmp (argv[1], "-troff") == 0) {
+ mode = 1;
+ } else {
+ usage(argv[0]);
+ }
+ if (strncmp(argv[3], "-E", 2) || (argv[3]+2 == NULL)) {
+ usage(argv[0]);
+ } else {
+ mpname = argv[2];
+ freopen(argv[3]+2, "w", stderr);
+ }
+#else /* not AMIGA */
+ } else if (argc == 3) {
+ if (strcmp (argv[1], "-tex") == 0) {
+ mode = 0;
+ } else if (strcmp (argv[1], "-troff") == 0) {
+ mode = 1;
+ } else {
+ usage (argv[0]);
+ }
+ mpname = argv[2];
+#endif /* not AMIGA */
+ } else {
+ usage(argv[0]);
+ }
+
+ mpfile = fopen(mpname, "r");
+ if (mpfile==NULL) {
+ fprintf (stderr, "%s: ", argv[0]);
+ perror (mpname);
+ exit (1);
+ }
+
+ /* This is far from elegant, but life is short. */
+ if (mode == 0) {
+ predoc = tex_predoc;
+ postdoc = tex_postdoc;
+ pretex1 = tex_pretex1;
+ pretex = tex_pretex;
+ posttex = tex_posttex;
+ preverb1 = tex_preverb1;
+ preverb = tex_preverb;
+ postverb = tex_postverb;
+ } else {
+ predoc = troff_predoc;
+ postdoc = troff_postdoc;
+ pretex1 = troff_pretex1;
+ pretex = troff_pretex;
+ posttex = troff_posttex;
+ preverb1 = troff_preverb1;
+ preverb = troff_preverb;
+ postverb = troff_postverb;
+ }
+ printf("%s",predoc);
+ while (getline()!=NULL)
+ do_line();
+ printf("%s",postdoc);
+ exit(0);
+}
diff --git a/Build/source/texk/web2c/mpware/mpto.rc b/Build/source/texk/web2c/mpware/mpto.rc
new file mode 100644
index 00000000000..831b2d588f4
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/mpto.rc
@@ -0,0 +1,34 @@
+/* mpto.rc: mpto resources -*- C++ -*-
+
+ Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ This file 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 file; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <texlive-version.h>
+
+#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " mpto 0.63"
+
+#define VER_INTERNALNAME_STR "mpto"
+#define VER_ORIGINALFILENAME_STR "mpto.exe"
+
+#define VER_FILEDESCRIPTION_STR "Converts MetaPost Files Into TeX Files\0"
+#define VER_LEGALCOPYRIGHT_STR " Copyright 1990 - 1995 by AT&T Bell Laboratories"
+#define VER_COMPANYNAME_STR "AT&T Bell Laboratories"
+
+#include <texlive.version>
+
+/* mpto.rc ends here */
diff --git a/Build/source/texk/web2c/mpware/newer.c b/Build/source/texk/web2c/mpware/newer.c
new file mode 100644
index 00000000000..69ab23aeb67
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/newer.c
@@ -0,0 +1,144 @@
+/* newer - true if any source file is newer than the target file.
+ *
+ * Public domain.
+ *
+ * This program used to be Copyright 1990 - 1995 by AT&T Bell Laboratories,
+ * and the original version was written by John Hobby. It has since been
+ * placed in the public domain.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "c-auto.h" /* In case we need, e.g., _POSIX_SOURCE */
+#include "config.h"
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifndef WIN32
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+/* Exit codes are 0 for success ("true") and 1 for failure ("false"). */
+#define exit_false 1
+#define exit_true 0
+
+/* We may have high-res timers in struct stat. If we do, use them. */
+#if HAVE_ST_MTIM
+#define NEWER(S,T) (S.st_mtim.tv_sec > T.st_mtim.tv_sec || \
+ (S.st_mtim.tv_sec == T.st_mtim.tv_sec && \
+ S.st_mtim.tv_nsec >= T.st_mtim.tv_nsec))
+#else
+#define NEWER(S,T) (S.st_mtime >= T.st_mtime)
+#endif
+
+int i;
+int verbose = 1;
+int missing_source = 0;
+int missing_target = 0;
+int result = exit_false;
+
+/*
+ * newer src1 [ src2 ... srcN ] target
+ *
+ * returns 0 if files `src1' ... `srcN' exist and
+ * at least one of them is not older than `target'
+ * or if `target' doesn't exist.
+ */
+
+int
+main(int argc, char **argv)
+{
+ struct stat source_stat, target_stat;
+
+ while ((argc > 1) && (argv[1][0] == '-')) {
+ if (strcmp(argv[1], "-v") == 0 ||
+ strcmp(argv[1], "-verbose") == 0 ||
+ strcmp(argv[1], "--verbose") == 0) {
+
+ verbose = 1;
+ argv++;
+ argc--;
+
+ } else if (strcmp(argv[1], "-q") == 0 ||
+ strcmp(argv[1], "-quiet") == 0 ||
+ strcmp(argv[1], "--quiet") == 0) {
+
+ verbose = 0;
+ argv++;
+ argc--;
+
+ } else if (strcmp(argv[1], "-help") == 0 ||
+ strcmp(argv[1], "--help") == 0) {
+
+ fputs("Usage: newer [OPTION] src1 [ src2 ... srcN ] target\n\
+ Exit successfully if `src1' ... `srcN' exist and at least\n\
+ one of them is not older than `target'.\n\
+ Also exit successfully if `target' doesn't exist.\n\
+\n\
+--help display this help and exit\n\
+--quiet do not print anything\n\
+--verbose list missing input files (default)\n\
+--version output version information and exit\n\n", stdout);
+ fputs ("Email bug reports to metapost@tug.org.\n", stdout);
+ exit(0);
+
+ } else if (strcmp(argv[1], "-version") == 0 ||
+ strcmp(argv[1], "--version") == 0) {
+
+ fputs("newer 0.901\n\
+This program is in the public domain.\n\
+Primary author of newer: John Hobby.\n", stdout);
+ exit(0);
+
+ } else {
+
+ fprintf(stderr, "newer: Unknown option \"%s\"\n", argv[1]);
+ fputs("Try `newer --help' for more information.\n", stderr);
+ exit(1);
+
+ }
+ }
+
+ /* do we have at least two arguments? */
+ if (argc < 3) {
+ fputs ("newer: Too few arguments.\n\
+Try `newer --help' for more information.\n", stderr);
+ exit(1);
+ }
+
+ /* check the target file */
+ if (stat(argv[argc-1], &target_stat) < 0) {
+ if (verbose) {
+ fprintf(stderr, "newer: target file `%s' doesn't exist.\n",
+ argv[argc-1]);
+ }
+ missing_target = 1;
+ }
+
+ /* check the source files */
+ for (i = 1; i < (argc-1); i++) {
+ if (stat(argv[i], &source_stat) < 0) {
+ if (verbose) {
+ fprintf (stderr, "newer: source file `%s' doesn't exist.\n",
+ argv[i]);
+ }
+ missing_source = 1;
+ } else if (!missing_target) {
+ if (NEWER(source_stat, target_stat)) {
+ result = exit_true;
+ }
+ }
+ }
+
+ /* Adjust result for cases when source or target is missing:
+ * missing source => exit_false
+ * missing target => exit_true
+ */
+ if (missing_source) {
+ result = exit_false;
+ } else if (missing_target) {
+ result = exit_true;
+ }
+
+ return result;
+}
diff --git a/Build/source/texk/web2c/mpware/win32.mak b/Build/source/texk/web2c/mpware/win32.mak
new file mode 100644
index 00000000000..64a6109575e
--- /dev/null
+++ b/Build/source/texk/web2c/mpware/win32.mak
@@ -0,0 +1,75 @@
+################################################################################
+#
+# Makefile : Web2C / mpware
+# Author : Fabrice Popineau <Fabrice.Popineau@supelec.fr>
+# Platform : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources
+# Time-stamp: <03/02/21 11:53:59 popineau>
+#
+################################################################################
+root_srcdir = ..\..\..
+!ifdef DEVELOPMENT
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development
+!else
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk
+!endif
+
+USE_KPATHSEA = 1
+USE_GNUW32 = 1
+
+!include <msvc/common.mak>
+
+DEFS = -I.. $(DEFS) -DHAVE_CONFIG_H
+proglib = ../lib/$(objdir)/lib.lib
+programs = $(objdir)\dmp.exe $(objdir)\mpto.exe $(objdir)\newer.exe
+
+default: all
+all: $(objdir) $(programs)
+
+$(objdir)\dmp.exe: $(objdir)\dmp.obj $(objdir)\dmp.res $(proglib) $(kpathsealib)
+ $(link) $(**) $(conlibs)
+$(objdir)\mpto.exe: $(objdir)\mpto.obj $(objdir)\mpto.res $(proglib) $(kpathsealib)
+ $(link) $(**) $(conlibs)
+$(objdir)\newer.exe: $(objdir)\newer.obj $(proglib) $(gnuw32lib)
+ $(link) $(**) $(conlibs)
+
+$(objdir)\newer.obj: newer.c
+ $(compile) -UKPSE_DLL newer.c
+
+checkdir = $(srcdir)\..\tests
+check: $(objdir)\mpto.exe $(objdir)\newer.exe $(objdir)\dmp.exe
+ pushd $(root_srcdir)\texk\contrib & $(make) $(objdir)\makempx.exe & popd
+ $(top_srcdir)\contrib\$(objdir)\makempx $(checkdir)/label.mp $(checkdir)/xlabel.mpx
+ .\$(objdir)\mpto -tex $(checkdir)/testex.mp | diff $(checkdir)/testex.tex -
+ $(sed) '16s/^%//' <$(checkdir)/testex.mp >testex1
+ -.\$(objdir)\mpto -tex testex1 >nul 2>testex2
+ $(sed) '17s/^%//' <$(checkdir)/testex.mp >testex1
+ -.\$(objdir)\mpto -tex testex1 >nul 2>>testex2
+ $(sed) '18s/^%//' <$(checkdir)/testex.mp >testex1
+ -.\$(objdir)\mpto -tex testex1 >nul 2>>testex2
+ $(sed) '19s/^%//' <$(checkdir)/testex.mp >testex1
+ -.\$(objdir)\mpto -tex testex1 >nul 2>>testex2
+ $(sed) '20s/^%//' <$(checkdir)/testex.mp >testex1
+ -.\$(objdir)\mpto -tex testex1 >nul 2>>testex2
+ $(diff) $(checkdir)/testex.err testex2
+
+#Makefile: Makefile.in ../config.status
+# (cd ..; sh config.status)
+
+!include <msvc/config.mak>
+!include <msvc/install.mak>
+
+install:: install-exec
+
+install-programs: install-exec
+
+!include <msvc/clean.mak>
+
+clean::
+ -@$(del) testex1 testex2
+
+!include <msvc/rdepend.mak>
+!include "./depend.mak"
+
+# Local Variables:
+# mode: Makefile
+# End: