From 62ad2c7662f9293b35f3c92c65e4c007c5efe335 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 25 May 2009 13:58:15 +0000 Subject: remove mpware/ and old (Pascal Web) mpost and dvitomp git-svn-id: svn://tug.org/texlive/trunk@13459 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/mpdir/ChangeLog | 4 - Build/source/texk/web2c/mpdir/Makefile.in.orig | 41 - Build/source/texk/web2c/mpdir/am/mp.am | 63 - Build/source/texk/web2c/mpdir/avl.c | 792 ----------- Build/source/texk/web2c/mpdir/avl.h | 118 -- Build/source/texk/web2c/mpdir/avlstuff.c | 50 - Build/source/texk/web2c/mpdir/avlstuff.h | 29 - Build/source/texk/web2c/mpdir/mapfile.c | 848 ----------- Build/source/texk/web2c/mpdir/mp.defines | 53 - Build/source/texk/web2c/mpdir/mplib.h | 176 --- Build/source/texk/web2c/mpdir/mpmac.h | 218 --- Build/source/texk/web2c/mpdir/mpostlib.mk | 21 - Build/source/texk/web2c/mpdir/turningnumber.c | 113 -- Build/source/texk/web2c/mpdir/utils.c | 689 --------- Build/source/texk/web2c/mpdir/writeenc.c | 141 -- Build/source/texk/web2c/mpdir/writefont.c | 232 --- Build/source/texk/web2c/mpdir/writet1.c | 1732 ----------------------- Build/source/texk/web2c/mpware/ChangeLog | 573 -------- Build/source/texk/web2c/mpware/Makefile.am | 40 - Build/source/texk/web2c/mpware/Makefile.in | 631 --------- Build/source/texk/web2c/mpware/Makefile.in.orig | 63 - Build/source/texk/web2c/mpware/README | 6 - Build/source/texk/web2c/mpware/dmp.c | 1561 -------------------- Build/source/texk/web2c/mpware/dmp.h | 21 - Build/source/texk/web2c/mpware/dmp_ffile.c | 356 ----- Build/source/texk/web2c/mpware/makempx.c | 786 ---------- Build/source/texk/web2c/mpware/makempx.in | 182 --- Build/source/texk/web2c/mpware/mpto.c | 490 ------- Build/source/texk/web2c/mpware/newer.c | 147 -- 29 files changed, 10176 deletions(-) delete mode 100644 Build/source/texk/web2c/mpdir/ChangeLog delete mode 100644 Build/source/texk/web2c/mpdir/Makefile.in.orig delete mode 100644 Build/source/texk/web2c/mpdir/am/mp.am delete mode 100644 Build/source/texk/web2c/mpdir/avl.c delete mode 100644 Build/source/texk/web2c/mpdir/avl.h delete mode 100644 Build/source/texk/web2c/mpdir/avlstuff.c delete mode 100644 Build/source/texk/web2c/mpdir/avlstuff.h delete mode 100644 Build/source/texk/web2c/mpdir/mapfile.c delete mode 100644 Build/source/texk/web2c/mpdir/mp.defines delete mode 100644 Build/source/texk/web2c/mpdir/mplib.h delete mode 100644 Build/source/texk/web2c/mpdir/mpmac.h delete mode 100644 Build/source/texk/web2c/mpdir/mpostlib.mk delete mode 100644 Build/source/texk/web2c/mpdir/turningnumber.c delete mode 100644 Build/source/texk/web2c/mpdir/utils.c delete mode 100644 Build/source/texk/web2c/mpdir/writeenc.c delete mode 100644 Build/source/texk/web2c/mpdir/writefont.c delete mode 100644 Build/source/texk/web2c/mpdir/writet1.c delete mode 100644 Build/source/texk/web2c/mpware/ChangeLog delete mode 100644 Build/source/texk/web2c/mpware/Makefile.am delete mode 100644 Build/source/texk/web2c/mpware/Makefile.in delete mode 100644 Build/source/texk/web2c/mpware/Makefile.in.orig delete mode 100644 Build/source/texk/web2c/mpware/README delete mode 100644 Build/source/texk/web2c/mpware/dmp.c delete mode 100644 Build/source/texk/web2c/mpware/dmp.h delete mode 100644 Build/source/texk/web2c/mpware/dmp_ffile.c delete mode 100644 Build/source/texk/web2c/mpware/makempx.c delete mode 100644 Build/source/texk/web2c/mpware/makempx.in delete mode 100644 Build/source/texk/web2c/mpware/mpto.c delete mode 100644 Build/source/texk/web2c/mpware/newer.c (limited to 'Build/source') diff --git a/Build/source/texk/web2c/mpdir/ChangeLog b/Build/source/texk/web2c/mpdir/ChangeLog deleted file mode 100644 index e2150acef94..00000000000 --- a/Build/source/texk/web2c/mpdir/ChangeLog +++ /dev/null @@ -1,4 +0,0 @@ -2009-05-25 Karl Berry - - * am/mp.am (install-exec-hook): new target to install dvitomp - symlink. diff --git a/Build/source/texk/web2c/mpdir/Makefile.in.orig b/Build/source/texk/web2c/mpdir/Makefile.in.orig deleted file mode 100644 index 8b51105e713..00000000000 --- a/Build/source/texk/web2c/mpdir/Makefile.in.orig +++ /dev/null @@ -1,41 +0,0 @@ -# @configure_input@ -# Makefile for libmpost - taco@elvenkind.com, but -# mostly ripped off from Makefile.in from pdftex -# $Id $ - -kpse_include ../make/common.mk -kpse_include ../make/programs.mk -kpse_include ../make/library.mk - -kpathsea_srcdir_parent = $(srcdir)/../.. -kpathsea_dir_parent = ../.. - -ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) -CXX = @CXX@ - -XCPPFLAGS=-I.. -I$(srcdir)/.. -I../.. -I$(srcdir)/../.. - -OBJS = mapfile.o avl.o avlstuff.o utils.o writeenc.o writet1.o writefont.o turningnumber.o - -all: libmpost.a makecpool - -libmpost.a: $(OBJS) - rm -f $@ - $(AR) $(ARFLAGS) $@ $(OBJS) - $(RANLIB) $@ - -makecpool: makecpool.o - $(link_command) makecpool.o - -kpse_include ../make/clean.mk - -clean:: - rm -f libmpost.a makecpool - -depend: - rm -f $(OBJS) - XXCFLAGS=-MM XCFLAGS=-MM $(MAKE) -k $(OBJS) | \ - grep -v "^$(CC)\|$(CXX)\|$(AR)\|make" | \ - sed 's: [^ ]*/\.\./libs/[^ ]*::g' > $(srcdir)/depend.mk - -kpse_include mpdir/depend.mk diff --git a/Build/source/texk/web2c/mpdir/am/mp.am b/Build/source/texk/web2c/mpdir/am/mp.am deleted file mode 100644 index b7074ef3250..00000000000 --- a/Build/source/texk/web2c/mpdir/am/mp.am +++ /dev/null @@ -1,63 +0,0 @@ -## texk/web2c/mpdir/am/mp.am: Makefile fragment for MetaPost. -## -## Copyright (C) 2009 Peter Breitenlohner -## You may freely use, modify and/or distribute this file. - -## MetaPost -## -if MP -bin_PROGRAMS += oldmpost -endif MP -EXTRA_PROGRAMS += oldmpost - -oldmpost_CPPFLAGS = -I$(srcdir)/mpdir -oldmpost_LDADD = liboldmpost.a $(LDADD) -oldmpost_c_h = mpini.c mp0.c mp1.c mp2.c mpcoerce.h mpd.h -nodist_oldmpost_SOURCES = $(oldmpost_c_h) mp-pool.c mpextra.c -$(oldmpost_c_h): mp-web2c -mp-web2c: mp.p $(web2c_texmf) mpdir/mp.defines web2c/cvtmf1.sed web2c/cvtmf2.sed - $(web2c) mp - echo timestamp >$@ - touch $(oldmpost_c_h) -EXTRA_DIST += mp.web mp.ch lib/texmfmp.c mpdir/mp.defines mpdir/mplib.h -mpextra.c: lib/texmfmp.c mpd.h - sed s/TEX-OR-MF-OR-MP/mp/ $(srcdir)/lib/texmfmp.c >$@ -mp.p mp.pool: mp-tangle -mp-tangle: tangle$(EXEEXT) mp.web mp.ch - $(tangle) mp mp - echo timestamp >$@ - touch mp.p mp.pool -mp-pool.c: mp.pool $(makecpool_stamp) mpdir/mplib.h - $(makecpool) mp.pool $(srcdir)/mpdir/mplib.h >$@ || rm -f $@ -DISTCLEANFILES += $(nodist_oldmpost_SOURCES) mp-web2c \ - mp.p mp.pool mp-tangle - -## liboldmpost -## -EXTRA_LIBRARIES += liboldmpost.a - -liboldmpost_a_CPPFLAGS = -I$(srcdir)/mpdir - -liboldmpost_a_SOURCES = \ - mpdir/avl.c \ - mpdir/avl.h \ - mpdir/avlstuff.c \ - mpdir/avlstuff.h \ - mpdir/mapfile.c \ - mpdir/mpmac.h \ - mpdir/turningnumber.c \ - mpdir/utils.c \ - mpdir/writeenc.c \ - mpdir/writefont.c \ - mpdir/writet1.c - -# We must create mpd.h before building the liboldmpost_a_OBJECTS. -$(liboldmpost_a_OBJECTS): mpd.h - -## Eventually delete these files -## -EXTRA_DIST += \ - metapost.mk \ - mpdir/Makefile.in.orig \ - mpdir/mpostlib.mk - diff --git a/Build/source/texk/web2c/mpdir/avl.c b/Build/source/texk/web2c/mpdir/avl.c deleted file mode 100644 index 703c4b2e72d..00000000000 --- a/Build/source/texk/web2c/mpdir/avl.c +++ /dev/null @@ -1,792 +0,0 @@ -/* Produced by texiweb from libavl.w on 2003/01/06 at 18:07. */ - -/* libavl - library for manipulation of binary trees. - Copyright (C) 1998-2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - - The author may be contacted at on the Internet, or - write to Ben Pfaff, Stanford University, Computer Science Dept., 353 - Serra Mall, Stanford CA 94305, USA. -*/ - -#include -#include -#include -#include -#include "avl.h" - -/* Creates and returns a new table - with comparison function |compare| using parameter |param| - and memory allocator |allocator|. - Returns |NULL| if memory allocation failed. */ -struct avl_table *avl_create (avl_comparison_func * compare, void *param, - struct libavl_allocator *allocator) -{ - struct avl_table *tree; - - assert (compare != NULL); - - if (allocator == NULL) - allocator = &avl_allocator_default; - - tree = allocator->libavl_malloc (allocator, sizeof *tree); - if (tree == NULL) - return NULL; - - tree->avl_root = NULL; - tree->avl_compare = compare; - tree->avl_param = param; - tree->avl_alloc = allocator; - tree->avl_count = 0; - tree->avl_generation = 0; - - return tree; -} - -/* Search |tree| for an item matching |item|, and return it if found. - Otherwise return |NULL|. */ -void *avl_find (const struct avl_table *tree, const void *item) -{ - const struct avl_node *p; - - assert (tree != NULL && item != NULL); - for (p = tree->avl_root; p != NULL;) { - int cmp = tree->avl_compare (item, p->avl_data, tree->avl_param); - - if (cmp < 0) - p = p->avl_link[0]; - else if (cmp > 0) - p = p->avl_link[1]; - else /* |cmp == 0| */ - return p->avl_data; - } - - return NULL; -} - -/* Inserts |item| into |tree| and returns a pointer to |item|'s address. - If a duplicate item is found in the tree, - returns a pointer to the duplicate without inserting |item|. - Returns |NULL| in case of memory allocation failure. */ -void **avl_probe (struct avl_table *tree, void *item) -{ - struct avl_node *y, *z; /* Top node to update balance factor, and parent. */ - struct avl_node *p, *q; /* Iterator, and parent. */ - struct avl_node *n; /* Newly inserted node. */ - struct avl_node *w; /* New root of rebalanced subtree. */ - int dir; /* Direction to descend. */ - - unsigned char da[AVL_MAX_HEIGHT]; /* Cached comparison results. */ - int k = 0; /* Number of cached results. */ - - assert (tree != NULL && item != NULL); - - z = (struct avl_node *) &tree->avl_root; - y = tree->avl_root; - dir = 0; - for (q = z, p = y; p != NULL; q = p, p = p->avl_link[dir]) { - int cmp = tree->avl_compare (item, p->avl_data, tree->avl_param); - if (cmp == 0) - return &p->avl_data; - - if (p->avl_balance != 0) - z = q, y = p, k = 0; - da[k++] = dir = cmp > 0; - } - - n = q->avl_link[dir] = - tree->avl_alloc->libavl_malloc (tree->avl_alloc, sizeof *n); - if (n == NULL) - return NULL; - - tree->avl_count++; - n->avl_data = item; - n->avl_link[0] = n->avl_link[1] = NULL; - n->avl_balance = 0; - if (y == NULL) - return &n->avl_data; - - for (p = y, k = 0; p != n; p = p->avl_link[da[k]], k++) - if (da[k] == 0) - p->avl_balance--; - else - p->avl_balance++; - - if (y->avl_balance == -2) { - struct avl_node *x = y->avl_link[0]; - if (x->avl_balance == -1) { - w = x; - y->avl_link[0] = x->avl_link[1]; - x->avl_link[1] = y; - x->avl_balance = y->avl_balance = 0; - } else { - assert (x->avl_balance == +1); - w = x->avl_link[1]; - x->avl_link[1] = w->avl_link[0]; - w->avl_link[0] = x; - y->avl_link[0] = w->avl_link[1]; - w->avl_link[1] = y; - if (w->avl_balance == -1) - x->avl_balance = 0, y->avl_balance = +1; - else if (w->avl_balance == 0) - x->avl_balance = y->avl_balance = 0; - else /* |w->avl_balance == +1| */ - x->avl_balance = -1, y->avl_balance = 0; - w->avl_balance = 0; - } - } else if (y->avl_balance == +2) { - struct avl_node *x = y->avl_link[1]; - if (x->avl_balance == +1) { - w = x; - y->avl_link[1] = x->avl_link[0]; - x->avl_link[0] = y; - x->avl_balance = y->avl_balance = 0; - } else { - assert (x->avl_balance == -1); - w = x->avl_link[0]; - x->avl_link[0] = w->avl_link[1]; - w->avl_link[1] = x; - y->avl_link[1] = w->avl_link[0]; - w->avl_link[0] = y; - if (w->avl_balance == +1) - x->avl_balance = 0, y->avl_balance = -1; - else if (w->avl_balance == 0) - x->avl_balance = y->avl_balance = 0; - else /* |w->avl_balance == -1| */ - x->avl_balance = +1, y->avl_balance = 0; - w->avl_balance = 0; - } - } else - return &n->avl_data; - z->avl_link[y != z->avl_link[0]] = w; - - tree->avl_generation++; - return &n->avl_data; -} - -/* Inserts |item| into |table|. - Returns |NULL| if |item| was successfully inserted - or if a memory allocation error occurred. - Otherwise, returns the duplicate item. */ -void *avl_insert (struct avl_table *table, void *item) -{ - void **p = avl_probe (table, item); - return p == NULL || *p == item ? NULL : *p; -} - -/* Inserts |item| into |table|, replacing any duplicate item. - Returns |NULL| if |item| was inserted without replacing a duplicate, - or if a memory allocation error occurred. - Otherwise, returns the item that was replaced. */ -void *avl_replace (struct avl_table *table, void *item) -{ - void **p = avl_probe (table, item); - if (p == NULL || *p == item) - return NULL; - else { - void *r = *p; - *p = item; - return r; - } -} - -/* Deletes from |tree| and returns an item matching |item|. - Returns a null pointer if no matching item found. */ -void *avl_delete (struct avl_table *tree, const void *item) -{ - /* Stack of nodes. */ - struct avl_node *pa[AVL_MAX_HEIGHT]; /* Nodes. */ - unsigned char da[AVL_MAX_HEIGHT]; /* |avl_link[]| indexes. */ - int k; /* Stack pointer. */ - - struct avl_node *p; /* Traverses tree to find node to delete. */ - int cmp; /* Result of comparison between |item| and |p|. */ - - assert (tree != NULL && item != NULL); - - k = 0; - p = (struct avl_node *) &tree->avl_root; - for (cmp = -1; cmp != 0; - cmp = tree->avl_compare (item, p->avl_data, tree->avl_param)) { - int dir = cmp > 0; - - pa[k] = p; - da[k++] = dir; - - p = p->avl_link[dir]; - if (p == NULL) - return NULL; - } - item = p->avl_data; - - if (p->avl_link[1] == NULL) - pa[k - 1]->avl_link[da[k - 1]] = p->avl_link[0]; - else { - struct avl_node *r = p->avl_link[1]; - if (r->avl_link[0] == NULL) { - r->avl_link[0] = p->avl_link[0]; - r->avl_balance = p->avl_balance; - pa[k - 1]->avl_link[da[k - 1]] = r; - da[k] = 1; - pa[k++] = r; - } else { - struct avl_node *s; - int j = k++; - - for (;;) { - da[k] = 0; - pa[k++] = r; - s = r->avl_link[0]; - if (s->avl_link[0] == NULL) - break; - - r = s; - } - - s->avl_link[0] = p->avl_link[0]; - r->avl_link[0] = s->avl_link[1]; - s->avl_link[1] = p->avl_link[1]; - s->avl_balance = p->avl_balance; - - pa[j - 1]->avl_link[da[j - 1]] = s; - da[j] = 1; - pa[j] = s; - } - } - - tree->avl_alloc->libavl_free (tree->avl_alloc, p); - - assert (k > 0); - while (--k > 0) { - struct avl_node *y = pa[k]; - - if (da[k] == 0) { - y->avl_balance++; - if (y->avl_balance == +1) - break; - else if (y->avl_balance == +2) { - struct avl_node *x = y->avl_link[1]; - if (x->avl_balance == -1) { - struct avl_node *w; - assert (x->avl_balance == -1); - w = x->avl_link[0]; - x->avl_link[0] = w->avl_link[1]; - w->avl_link[1] = x; - y->avl_link[1] = w->avl_link[0]; - w->avl_link[0] = y; - if (w->avl_balance == +1) - x->avl_balance = 0, y->avl_balance = -1; - else if (w->avl_balance == 0) - x->avl_balance = y->avl_balance = 0; - else /* |w->avl_balance == -1| */ - x->avl_balance = +1, y->avl_balance = 0; - w->avl_balance = 0; - pa[k - 1]->avl_link[da[k - 1]] = w; - } else { - y->avl_link[1] = x->avl_link[0]; - x->avl_link[0] = y; - pa[k - 1]->avl_link[da[k - 1]] = x; - if (x->avl_balance == 0) { - x->avl_balance = -1; - y->avl_balance = +1; - break; - } else - x->avl_balance = y->avl_balance = 0; - } - } - } else { - y->avl_balance--; - if (y->avl_balance == -1) - break; - else if (y->avl_balance == -2) { - struct avl_node *x = y->avl_link[0]; - if (x->avl_balance == +1) { - struct avl_node *w; - assert (x->avl_balance == +1); - w = x->avl_link[1]; - x->avl_link[1] = w->avl_link[0]; - w->avl_link[0] = x; - y->avl_link[0] = w->avl_link[1]; - w->avl_link[1] = y; - if (w->avl_balance == -1) - x->avl_balance = 0, y->avl_balance = +1; - else if (w->avl_balance == 0) - x->avl_balance = y->avl_balance = 0; - else /* |w->avl_balance == +1| */ - x->avl_balance = -1, y->avl_balance = 0; - w->avl_balance = 0; - pa[k - 1]->avl_link[da[k - 1]] = w; - } else { - y->avl_link[0] = x->avl_link[1]; - x->avl_link[1] = y; - pa[k - 1]->avl_link[da[k - 1]] = x; - if (x->avl_balance == 0) { - x->avl_balance = +1; - y->avl_balance = -1; - break; - } else - x->avl_balance = y->avl_balance = 0; - } - } - } - } - - tree->avl_count--; - tree->avl_generation++; - return (void *) item; -} - -/* Refreshes the stack of parent pointers in |trav| - and updates its generation number. */ -static void trav_refresh (struct avl_traverser *trav) -{ - assert (trav != NULL); - - trav->avl_generation = trav->avl_table->avl_generation; - - if (trav->avl_node != NULL) { - avl_comparison_func *cmp = trav->avl_table->avl_compare; - void *param = trav->avl_table->avl_param; - struct avl_node *node = trav->avl_node; - struct avl_node *i; - - trav->avl_height = 0; - for (i = trav->avl_table->avl_root; i != node;) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - assert (i != NULL); - - trav->avl_stack[trav->avl_height++] = i; - i = i->avl_link[cmp (node->avl_data, i->avl_data, param) > 0]; - } - } -} - -/* Initializes |trav| for use with |tree| - and selects the null node. */ -void avl_t_init (struct avl_traverser *trav, struct avl_table *tree) -{ - trav->avl_table = tree; - trav->avl_node = NULL; - trav->avl_height = 0; - trav->avl_generation = tree->avl_generation; -} - -/* Initializes |trav| for |tree| - and selects and returns a pointer to its least-valued item. - Returns |NULL| if |tree| contains no nodes. */ -void *avl_t_first (struct avl_traverser *trav, struct avl_table *tree) -{ - struct avl_node *x; - - assert (tree != NULL && trav != NULL); - - trav->avl_table = tree; - trav->avl_height = 0; - trav->avl_generation = tree->avl_generation; - - x = tree->avl_root; - if (x != NULL) - while (x->avl_link[0] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[0]; - } - trav->avl_node = x; - - return x != NULL ? x->avl_data : NULL; -} - -/* Initializes |trav| for |tree| - and selects and returns a pointer to its greatest-valued item. - Returns |NULL| if |tree| contains no nodes. */ -void *avl_t_last (struct avl_traverser *trav, struct avl_table *tree) -{ - struct avl_node *x; - - assert (tree != NULL && trav != NULL); - - trav->avl_table = tree; - trav->avl_height = 0; - trav->avl_generation = tree->avl_generation; - - x = tree->avl_root; - if (x != NULL) - while (x->avl_link[1] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[1]; - } - trav->avl_node = x; - - return x != NULL ? x->avl_data : NULL; -} - -/* Searches for |item| in |tree|. - If found, initializes |trav| to the item found and returns the item - as well. - If there is no matching item, initializes |trav| to the null item - and returns |NULL|. */ -void *avl_t_find (struct avl_traverser *trav, struct avl_table *tree, - void *item) -{ - struct avl_node *p, *q; - - assert (trav != NULL && tree != NULL && item != NULL); - trav->avl_table = tree; - trav->avl_height = 0; - trav->avl_generation = tree->avl_generation; - for (p = tree->avl_root; p != NULL; p = q) { - int cmp = tree->avl_compare (item, p->avl_data, tree->avl_param); - - if (cmp < 0) - q = p->avl_link[0]; - else if (cmp > 0) - q = p->avl_link[1]; - else { /* |cmp == 0| */ - - trav->avl_node = p; - return p->avl_data; - } - - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = p; - } - - trav->avl_height = 0; - trav->avl_node = NULL; - return NULL; -} - -/* Attempts to insert |item| into |tree|. - If |item| is inserted successfully, it is returned and |trav| is - initialized to its location. - If a duplicate is found, it is returned and |trav| is initialized to - its location. No replacement of the item occurs. - If a memory allocation failure occurs, |NULL| is returned and |trav| - is initialized to the null item. */ -void *avl_t_insert (struct avl_traverser *trav, struct avl_table *tree, - void *item) -{ - void **p; - - assert (trav != NULL && tree != NULL && item != NULL); - - p = avl_probe (tree, item); - if (p != NULL) { - trav->avl_table = tree; - trav->avl_node = ((struct avl_node *) - ((char *) p - offsetof (struct avl_node, avl_data))); - trav->avl_generation = tree->avl_generation - 1; - return *p; - } else { - avl_t_init (trav, tree); - return NULL; - } -} - -/* Initializes |trav| to have the same current node as |src|. */ -void *avl_t_copy (struct avl_traverser *trav, const struct avl_traverser *src) -{ - assert (trav != NULL && src != NULL); - - if (trav != src) { - trav->avl_table = src->avl_table; - trav->avl_node = src->avl_node; - trav->avl_generation = src->avl_generation; - if (trav->avl_generation == trav->avl_table->avl_generation) { - trav->avl_height = src->avl_height; - memcpy (trav->avl_stack, (const void *) src->avl_stack, - sizeof *trav->avl_stack * trav->avl_height); - } - } - - return trav->avl_node != NULL ? trav->avl_node->avl_data : NULL; -} - -/* Returns the next data item in inorder - within the tree being traversed with |trav|, - or if there are no more data items returns |NULL|. */ -void *avl_t_next (struct avl_traverser *trav) -{ - struct avl_node *x; - - assert (trav != NULL); - - if (trav->avl_generation != trav->avl_table->avl_generation) - trav_refresh (trav); - - x = trav->avl_node; - if (x == NULL) { - return avl_t_first (trav, trav->avl_table); - } else if (x->avl_link[1] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[1]; - - while (x->avl_link[0] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[0]; - } - } else { - struct avl_node *y; - - do { - if (trav->avl_height == 0) { - trav->avl_node = NULL; - return NULL; - } - - y = x; - x = trav->avl_stack[--trav->avl_height]; - } - while (y == x->avl_link[1]); - } - trav->avl_node = x; - - return x->avl_data; -} - -/* Returns the previous data item in inorder - within the tree being traversed with |trav|, - or if there are no more data items returns |NULL|. */ -void *avl_t_prev (struct avl_traverser *trav) -{ - struct avl_node *x; - - assert (trav != NULL); - - if (trav->avl_generation != trav->avl_table->avl_generation) - trav_refresh (trav); - - x = trav->avl_node; - if (x == NULL) { - return avl_t_last (trav, trav->avl_table); - } else if (x->avl_link[0] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[0]; - - while (x->avl_link[1] != NULL) { - assert (trav->avl_height < AVL_MAX_HEIGHT); - trav->avl_stack[trav->avl_height++] = x; - x = x->avl_link[1]; - } - } else { - struct avl_node *y; - - do { - if (trav->avl_height == 0) { - trav->avl_node = NULL; - return NULL; - } - - y = x; - x = trav->avl_stack[--trav->avl_height]; - } - while (y == x->avl_link[0]); - } - trav->avl_node = x; - - return x->avl_data; -} - -/* Returns |trav|'s current item. */ -void *avl_t_cur (struct avl_traverser *trav) -{ - assert (trav != NULL); - - return trav->avl_node != NULL ? trav->avl_node->avl_data : NULL; -} - -/* Replaces the current item in |trav| by |new| and returns the item replaced. - |trav| must not have the null item selected. - The new item must not upset the ordering of the tree. */ -void *avl_t_replace (struct avl_traverser *trav, void *new) -{ - void *old; - - assert (trav != NULL && trav->avl_node != NULL && new != NULL); - old = trav->avl_node->avl_data; - trav->avl_node->avl_data = new; - return old; -} - -static void -copy_error_recovery (struct avl_node **stack, int height, - struct avl_table *new, avl_item_func * destroy) -{ - assert (stack != NULL && height >= 0 && new != NULL); - - for (; height > 2; height -= 2) - stack[height - 1]->avl_link[1] = NULL; - avl_destroy (new, destroy); -} - -/* Copies |org| to a newly created tree, which is returned. - If |copy != NULL|, each data item in |org| is first passed to |copy|, - and the return values are inserted into the tree, - with |NULL| return values taken as indications of failure. - On failure, destroys the partially created new tree, - applying |destroy|, if non-null, to each item in the new tree so far, - and returns |NULL|. - If |allocator != NULL|, it is used for allocation in the new tree. - Otherwise, the same allocator used for |org| is used. */ -struct avl_table *avl_copy (const struct avl_table *org, avl_copy_func * copy, - avl_item_func * destroy, - struct libavl_allocator *allocator) -{ - struct avl_node *stack[2 * (AVL_MAX_HEIGHT + 1)]; - int height = 0; - - struct avl_table *new; - const struct avl_node *x; - struct avl_node *y; - - assert (org != NULL); - new = avl_create (org->avl_compare, org->avl_param, - allocator != NULL ? allocator : org->avl_alloc); - if (new == NULL) - return NULL; - new->avl_count = org->avl_count; - if (new->avl_count == 0) - return new; - - x = (const struct avl_node *) &org->avl_root; - y = (struct avl_node *) &new->avl_root; - for (;;) { - while (x->avl_link[0] != NULL) { - assert (height < 2 * (AVL_MAX_HEIGHT + 1)); - - y->avl_link[0] = - new->avl_alloc->libavl_malloc (new->avl_alloc, - sizeof *y->avl_link[0]); - if (y->avl_link[0] == NULL) { - if (y != (struct avl_node *) &new->avl_root) { - y->avl_data = NULL; - y->avl_link[1] = NULL; - } - - copy_error_recovery (stack, height, new, destroy); - return NULL; - } - - stack[height++] = (struct avl_node *) x; - stack[height++] = y; - x = x->avl_link[0]; - y = y->avl_link[0]; - } - y->avl_link[0] = NULL; - - for (;;) { - y->avl_balance = x->avl_balance; - if (copy == NULL) - y->avl_data = x->avl_data; - else { - y->avl_data = copy (x->avl_data, org->avl_param); - if (y->avl_data == NULL) { - y->avl_link[1] = NULL; - copy_error_recovery (stack, height, new, destroy); - return NULL; - } - } - - if (x->avl_link[1] != NULL) { - y->avl_link[1] = - new->avl_alloc->libavl_malloc (new->avl_alloc, - sizeof *y->avl_link[1]); - if (y->avl_link[1] == NULL) { - copy_error_recovery (stack, height, new, destroy); - return NULL; - } - - x = x->avl_link[1]; - y = y->avl_link[1]; - break; - } else - y->avl_link[1] = NULL; - - if (height <= 2) - return new; - - y = stack[--height]; - x = stack[--height]; - } - } -} - -/* Frees storage allocated for |tree|. - If |destroy != NULL|, applies it to each data item in inorder. */ -void avl_destroy (struct avl_table *tree, avl_item_func * destroy) -{ - struct avl_node *p, *q; - - assert (tree != NULL); - - for (p = tree->avl_root; p != NULL; p = q) - if (p->avl_link[0] == NULL) { - q = p->avl_link[1]; - if (destroy != NULL && p->avl_data != NULL) - destroy (p->avl_data, tree->avl_param); - tree->avl_alloc->libavl_free (tree->avl_alloc, p); - } else { - q = p->avl_link[0]; - p->avl_link[0] = q->avl_link[1]; - q->avl_link[1] = p; - } - - tree->avl_alloc->libavl_free (tree->avl_alloc, tree); -} - -/* Allocates |size| bytes of space using |malloc()|. - Returns a null pointer if allocation fails. */ -void *avl_malloc (struct libavl_allocator *allocator, size_t size) -{ - assert (allocator != NULL && size > 0); - return malloc (size); -} - -/* Frees |block|. */ -void avl_free (struct libavl_allocator *allocator, void *block) -{ - assert (allocator != NULL && block != NULL); - free (block); -} - -/* Default memory allocator that uses |malloc()| and |free()|. */ -struct libavl_allocator avl_allocator_default = { - avl_malloc, - avl_free -}; - -#undef NDEBUG -#include - -/* Asserts that |avl_insert()| succeeds at inserting |item| into |table|. */ -void - (avl_assert_insert) (struct avl_table * table, void *item) { - void **p = avl_probe (table, item); - assert (p != NULL && *p == item); -} - -/* Asserts that |avl_delete()| really removes |item| from |table|, - and returns the removed item. */ -void *(avl_assert_delete) (struct avl_table * table, void *item) { - void *p = avl_delete (table, item); - assert (p != NULL); - return p; -} diff --git a/Build/source/texk/web2c/mpdir/avl.h b/Build/source/texk/web2c/mpdir/avl.h deleted file mode 100644 index acdf8bacc53..00000000000 --- a/Build/source/texk/web2c/mpdir/avl.h +++ /dev/null @@ -1,118 +0,0 @@ -/* Produced by texiweb from libavl.w on 2003/01/06 at 18:07. */ - -/* libavl - library for manipulation of binary trees. - Copyright (C) 1998-2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - - The author may be contacted at on the Internet, or - write to Ben Pfaff, Stanford University, Computer Science Dept., 353 - Serra Mall, Stanford CA 94305, USA. -*/ - -#ifndef AVL_H -# define AVL_H 1 - -# include -# if defined(__cplusplus) -extern "C" { -# endif - - -/* Function types. */ - typedef int avl_comparison_func (const void *avl_a, const void *avl_b, - void *avl_param); - typedef void avl_item_func (void *avl_item, void *avl_param); - typedef void *avl_copy_func (void *avl_item, void *avl_param); - -# ifndef LIBAVL_ALLOCATOR -# define LIBAVL_ALLOCATOR -/* Memory allocator. */ - struct libavl_allocator { - void *(*libavl_malloc) (struct libavl_allocator *, size_t libavl_size); - void (*libavl_free) (struct libavl_allocator *, void *libavl_block); - }; -# endif - -/* Default memory allocator. */ - extern struct libavl_allocator avl_allocator_default; - void *avl_malloc (struct libavl_allocator *, size_t); - void avl_free (struct libavl_allocator *, void *); - -/* Maximum AVL height. */ -# ifndef AVL_MAX_HEIGHT -# define AVL_MAX_HEIGHT 32 -# endif - -/* Tree data structure. */ - struct avl_table { - struct avl_node *avl_root; /* Tree's root. */ - avl_comparison_func *avl_compare; /* Comparison function. */ - void *avl_param; /* Extra argument to |avl_compare|. */ - struct libavl_allocator *avl_alloc; /* Memory allocator. */ - size_t avl_count; /* Number of items in tree. */ - unsigned long avl_generation; /* Generation number. */ - }; - -/* An AVL tree node. */ - struct avl_node { - struct avl_node *avl_link[2]; /* Subtrees. */ - void *avl_data; /* Pointer to data. */ - signed char avl_balance; /* Balance factor. */ - }; - -/* AVL traverser structure. */ - struct avl_traverser { - struct avl_table *avl_table; /* Tree being traversed. */ - struct avl_node *avl_node; /* Current node in tree. */ - struct avl_node *avl_stack[AVL_MAX_HEIGHT]; - /* All the nodes above |avl_node|. */ - size_t avl_height; /* Number of nodes in |avl_parent|. */ - unsigned long avl_generation; /* Generation number. */ - }; - -/* Table functions. */ - struct avl_table *avl_create (avl_comparison_func *, void *, - struct libavl_allocator *); - struct avl_table *avl_copy (const struct avl_table *, avl_copy_func *, - avl_item_func *, struct libavl_allocator *); - void avl_destroy (struct avl_table *, avl_item_func *); - void **avl_probe (struct avl_table *, void *); - void *avl_insert (struct avl_table *, void *); - void *avl_replace (struct avl_table *, void *); - void *avl_delete (struct avl_table *, const void *); - void *avl_find (const struct avl_table *, const void *); - void avl_assert_insert (struct avl_table *, void *); - void *avl_assert_delete (struct avl_table *, void *); - -# define avl_count(table) ((size_t) (table)->avl_count) - -/* Table traverser functions. */ - void avl_t_init (struct avl_traverser *, struct avl_table *); - void *avl_t_first (struct avl_traverser *, struct avl_table *); - void *avl_t_last (struct avl_traverser *, struct avl_table *); - void *avl_t_find (struct avl_traverser *, struct avl_table *, void *); - void *avl_t_insert (struct avl_traverser *, struct avl_table *, void *); - void *avl_t_copy (struct avl_traverser *, const struct avl_traverser *); - void *avl_t_next (struct avl_traverser *); - void *avl_t_prev (struct avl_traverser *); - void *avl_t_cur (struct avl_traverser *); - void *avl_t_replace (struct avl_traverser *, void *); - -# if defined(__cplusplus) -} -# endif -#endif /* avl.h */ diff --git a/Build/source/texk/web2c/mpdir/avlstuff.c b/Build/source/texk/web2c/mpdir/avlstuff.c deleted file mode 100644 index 300cd2c5218..00000000000 --- a/Build/source/texk/web2c/mpdir/avlstuff.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright (c) 2004-2005 Han The Thanh, - -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 Free -Software Foundation; either version 2 of the License, 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, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id: avlstuff.c,v 1.12 2005/07/11 20:27:39 hahe Exp hahe $ - -*/ - -#include "mplib.h" -#include -#include -#include "avl.h" - -static const char perforce_id[] = - "$Id: avlstuff.c,v 1.12 2005/07/11 20:27:39 hahe Exp hahe $"; - -/* memory management functions for avl */ - -void *avl_xmalloc (struct libavl_allocator *allocator, size_t size) -{ - assert (allocator != NULL && size > 0); - return xmalloc (size); -} - -void avl_xfree (struct libavl_allocator *allocator, void *block) -{ - assert (allocator != NULL && block != NULL); - xfree (block); -} - -struct libavl_allocator avl_xallocator = { - avl_xmalloc, - avl_xfree -}; - - -/**********************************************************************/ diff --git a/Build/source/texk/web2c/mpdir/avlstuff.h b/Build/source/texk/web2c/mpdir/avlstuff.h deleted file mode 100644 index 2ffa57b627d..00000000000 --- a/Build/source/texk/web2c/mpdir/avlstuff.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2004 Han The Thanh, - -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 Free -Software Foundation; either version 2 of the License, 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, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/avlstuff.h#5 $ - -formatted by indent -kr -*/ - -#include "avl.h" - -/* memory management functions for avl */ - -extern struct libavl_allocator avl_xallocator; - -/* end of file avlstuff.h */ diff --git a/Build/source/texk/web2c/mpdir/mapfile.c b/Build/source/texk/web2c/mpdir/mapfile.c deleted file mode 100644 index 4887c19ad5e..00000000000 --- a/Build/source/texk/web2c/mpdir/mapfile.c +++ /dev/null @@ -1,848 +0,0 @@ -/* Copyright (c) 2006 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id: mapfile.c,v 1.20 2005/10/16 17:41:51 hahe Exp hahe $ - -*/ - -#include -#include "mplib.h" -#include -#include -#include - -static const char perforce_id[] = - "$Id: mapfile.c,v 1.20 2005/10/16 17:41:51 hahe Exp hahe $"; - -#define FM_BUF_SIZE 1024 - -static FILE *fm_file; - -#define fm_open() \ - open_input (&fm_file, kpse_fontmap_format, FOPEN_RBIN_MODE) -#define fm_close() xfclose(fm_file, cur_file_name) -#define fm_getchar() xgetc(fm_file) -#define fm_eof() feof(fm_file) - -enum _mode { FM_DUPIGNORE, FM_REPLACE, FM_DELETE }; -enum _ltype { MAPFILE, MAPLINE }; -enum _tfmavail { TFM_UNCHECKED, TFM_FOUND, TFM_NOTFOUND }; - -typedef struct mitem { - int mode; /* FM_DUPIGNORE or FM_REPLACE or FM_DELETE */ - int type; /* map file or map line */ - char *line; /* pointer to map file name or map line */ - int lineno; /* line number in map file */ -} mapitem; -mapitem *mitem = NULL; - -fm_entry *fm_cur; -static const char nontfm[] = ""; - -#define read_field(r, q, buf) do { \ - q = buf; \ - while (*r != ' ' && *r != '\0') \ - *q++ = *r++; \ - *q = '\0'; \ - skip (r, ' '); \ -} while (0) - -#define set_field(F) do { \ - if (q > buf) \ - fm->F = xstrdup(buf); \ - if (*r == '\0') \ - goto done; \ -} while (0) - -#define cmp_return(a, b) \ - if (a > b) \ - return 1; \ - if (a < b) \ - return -1 - -fm_entry *new_fm_entry (void) -{ - fm_entry *fm; - fm = xtalloc (1, fm_entry); - fm->tfm_name = NULL; - fm->ps_name = NULL; - fm->flags = 4; - fm->ff_name = NULL; - fm->subset_tag = NULL; - fm->encoding = NULL; - fm->tfm_num = getnullfont (); - fm->tfm_avail = TFM_UNCHECKED; - fm->type = 0; - fm->slant = 0; - fm->extend = 0; - fm->ff_objnum = 0; - fm->fn_objnum = 0; - fm->fd_objnum = 0; - fm->charset = NULL; - fm->all_glyphs = false; - fm->links = 0; - fm->pid = -1; - fm->eid = -1; - fm->subfont = NULL; - return fm; -} - -void delete_fm_entry (fm_entry * fm) -{ - xfree (fm->tfm_name); - xfree (fm->ps_name); - xfree (fm->ff_name); - xfree (fm->subset_tag); - xfree (fm->charset); - xfree (fm); -} - -static ff_entry *new_ff_entry (void) -{ - ff_entry *ff; - ff = xtalloc (1, ff_entry); - ff->ff_name = NULL; - ff->ff_path = NULL; - return ff; -} - -static void delete_ff_entry (ff_entry * ff) -{ - xfree (ff->ff_name); - xfree (ff->ff_path); - xfree (ff); -} - -static fm_entry *dummy_fm_entry () -{ - static const fm_entry const_fm_entry; - return (fm_entry *) & const_fm_entry; -} - -char *mk_base_tfm (char *tfmname, int *i) -{ - static char buf[SMALL_BUF_SIZE]; - char *p = tfmname, *r = strend (p) - 1, *q = r; - while (q > p && isdigit (*q)) - --q; - if (!(q > p) || q == r || (*q != '+' && *q != '-')) - return NULL; - check_buf (q - p + 1, SMALL_BUF_SIZE); - strncpy (buf, p, (size_t) (q - p)); - buf[q - p] = '\0'; - *i = atoi (q); - return buf; -} - -static fmentryptr fmlookup (fontnumber); - -boolean hasfmentry (fontnumber f) -{ - if (mpfontmap[f] == NULL) - mpfontmap[f] = fmlookup (f); - assert (mpfontmap[f] != NULL); - return mpfontmap[f] != (fmentryptr) dummy_fm_entry (); -} - -/**********************************************************************/ - -struct avl_table *tfm_tree = NULL; -struct avl_table *ps_tree = NULL; -struct avl_table *ff_tree = NULL; - -/* AVL sort fm_entry into tfm_tree by tfm_name */ - -static int comp_fm_entry_tfm (const void *pa, const void *pb, void *p) -{ - return strcmp (((const fm_entry *) pa)->tfm_name, - ((const fm_entry *) pb)->tfm_name); -} - -/* AVL sort fm_entry into ps_tree by ps_name, slant, and extend */ - -static int comp_fm_entry_ps (const void *pa, const void *pb, void *p) -{ - const fm_entry *p1 = (const fm_entry *) pa, *p2 = (const fm_entry *) pb; - int i; - assert (p1->ps_name != NULL && p2->ps_name != NULL); - if ((i = strcmp (p1->ps_name, p2->ps_name))) - return i; - cmp_return (p1->slant, p2->slant); - cmp_return (p1->extend, p2->extend); - if (p1->tfm_name != NULL && p2->tfm_name != NULL && - (i = strcmp (p1->tfm_name, p2->tfm_name))) - return i; - return 0; -} - -/* AVL sort ff_entry into ff_tree by ff_name */ - -static int comp_ff_entry (const void *pa, const void *pb, void *p) -{ - return strcmp (((const ff_entry *) pa)->ff_name, - ((const ff_entry *) pb)->ff_name); -} - -static void create_avl_trees () -{ - if (tfm_tree == NULL) { - tfm_tree = avl_create (comp_fm_entry_tfm, NULL, &avl_xallocator); - assert (tfm_tree != NULL); - } - if (ps_tree == NULL) { - ps_tree = avl_create (comp_fm_entry_ps, NULL, &avl_xallocator); - assert (ps_tree != NULL); - } - if (ff_tree == NULL) { - ff_tree = avl_create (comp_ff_entry, NULL, &avl_xallocator); - assert (ff_tree != NULL); - } -} - -/* -The function avl_do_entry() is not completely symmetrical with regards -to tfm_name and ps_name handling, e. g. a duplicate tfm_name gives a -"goto exit", and no ps_name link is tried. This is to keep it compatible -with the original version. -*/ - -int avl_do_entry (fm_entry * fp, int mode) -{ - fm_entry *p; - void *a; - void **aa; - - /* handle tfm_name link */ - - if (strcmp (fp->tfm_name, nontfm)) { - p = (fm_entry *) avl_find (tfm_tree, fp); - if (p != NULL) { - if (mode == FM_DUPIGNORE) { - pdftex_warn - ("fontmap entry for `%s' already exists, duplicates ignored", - fp->tfm_name); - goto exit; - } else { /* mode == FM_REPLACE / FM_DELETE */ - if (fontsizes[p->tfm_num]!=0) { - pdftex_warn - ("fontmap entry for `%s' has been used, replace/delete not allowed", - fp->tfm_name); - goto exit; - } - a = avl_delete (tfm_tree, p); - assert (a != NULL); - unset_tfmlink (p); - if (!has_pslink (p)) - delete_fm_entry (p); - } - } - if (mode != FM_DELETE) { - aa = avl_probe (tfm_tree, fp); - assert (aa != NULL); - set_tfmlink (fp); - } - } - - /* handle ps_name link */ - - if (fp->ps_name != NULL) { - assert (fp->tfm_name != NULL); - p = (fm_entry *) avl_find (ps_tree, fp); - if (p != NULL) { - if (mode == FM_DUPIGNORE) { - pdftex_warn - ("ps_name entry for `%s' already exists, duplicates ignored", - fp->ps_name); - goto exit; - } else { /* mode == FM_REPLACE / FM_DELETE */ - if (fontsizes[p->tfm_num]!=0) { - /* REPLACE/DELETE not allowed */ - pdftex_warn - ("fontmap entry for `%s' has been used, replace/delete not allowed", - p->tfm_name); - goto exit; - } - a = avl_delete (ps_tree, p); - assert (a != NULL); - unset_pslink (p); - if (!has_tfmlink (p)) - delete_fm_entry (p); - } - } - if (mode != FM_DELETE) { - aa = avl_probe (ps_tree, fp); - assert (aa != NULL); - set_pslink (fp); - } - } - exit: - if (!has_tfmlink (fp) && !has_pslink (fp)) /* e. g. after FM_DELETE */ - return 1; /* deallocation of fm_entry structure required */ - else - return 0; -} - -/**********************************************************************/ -/* consistency check for map entry, with warn flag */ - -int check_fm_entry (fm_entry * fm, boolean warn) -{ - int a = 0; - assert (fm != NULL); - if (fm->ps_name != NULL) { - if (is_basefont (fm)) { - if (is_fontfile (fm) && !is_included (fm)) { - if (warn) - pdftex_warn - ("invalid entry for `%s': font file must be included or omitted for base fonts", - fm->tfm_name); - a += 1; - } - } else { /* not a base font */ - /* if no font file given, drop this entry */ - /* if (!is_fontfile (fm)) { - if (warn) - pdftex_warn - ("invalid entry for `%s': font file missing", - fm->tfm_name); - a += 2; - } - */ - } - } - if (is_truetype (fm) && is_reencoded (fm) && !is_subsetted (fm)) { - if (warn) - pdftex_warn - ("invalid entry for `%s': only subsetted TrueType font can be reencoded", - fm->tfm_name); - a += 4; - } - if ((fm->slant != 0 || fm->extend != 0) && - (is_truetype (fm))) { - if (warn) - pdftex_warn - ("invalid entry for `%s': SlantFont/ExtendFont can be used only with embedded T1 fonts", - fm->tfm_name); - a += 8; - } - if (abs (fm->slant) > 1000) { - if (warn) - pdftex_warn - ("invalid entry for `%s': too big value of SlantFont (%g)", - fm->tfm_name, fm->slant / 1000.0); - a += 16; - } - if (abs (fm->extend) > 2000) { - if (warn) - pdftex_warn - ("invalid entry for `%s': too big value of ExtendFont (%g)", - fm->tfm_name, fm->extend / 1000.0); - a += 32; - } - if (fm->pid != -1 && - !(is_truetype (fm) && is_included (fm) && - is_subsetted (fm) && !is_reencoded (fm))) { - if (warn) - pdftex_warn - ("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts", - fm->tfm_name); - a += 64; - } - return a; -} - -/**********************************************************************/ -/* returns true if s is one of the 14 std. font names; speed-trimmed. */ - -boolean check_basefont (char *s) -{ - static const char *basefont_names[] = { - "Courier", /* 0:7 */ - "Courier-Bold", /* 1:12 */ - "Courier-Oblique", /* 2:15 */ - "Courier-BoldOblique", /* 3:19 */ - "Helvetica", /* 4:9 */ - "Helvetica-Bold", /* 5:14 */ - "Helvetica-Oblique", /* 6:17 */ - "Helvetica-BoldOblique", /* 7:21 */ - "Symbol", /* 8:6 */ - "Times-Roman", /* 9:11 */ - "Times-Bold", /* 10:10 */ - "Times-Italic", /* 11:12 */ - "Times-BoldItalic", /* 12:16 */ - "ZapfDingbats" /* 13:12 */ - }; - static const int index[] = - { -1, -1, -1, -1, -1, -1, 8, 0, -1, 4, 10, 9, -1, -1, 5, 2, 12, 6, - -1, 3, -1, 7 - }; - const size_t n = strlen (s); - int k = -1; - if (n > 21) - return false; - if (n == 12) { /* three names have length 12 */ - switch (*s) { - case 'C': - k = 1; /* Courier-Bold */ - break; - case 'T': - k = 11; /* Times-Italic */ - break; - case 'Z': - k = 13; /* ZapfDingbats */ - break; - default: - return false; - } - } else - k = index[n]; - if (k > -1 && !strcmp (basefont_names[k], s)) - return true; - return false; -}; - -/**********************************************************************/ - -static void fm_scan_line () -{ - int a, b, c, j, u = 0, v = 0; - float d; - fm_entry *fm; - char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE]; - char *p, *q, *r, *s; - switch (mitem->type) { - case MAPFILE: - p = fm_line; - do { - c = fm_getchar (); - append_char_to_buf (c, p, fm_line, FM_BUF_SIZE); - } - while (c != 10); - *(--p) = '\0'; - r = fm_line; - break; - case MAPLINE: - r = mitem->line; /* work on string from makecstring() */ - break; - default: - assert (0); - } - if (*r == '\0' || is_cfg_comment (*r)) - return; - fm = new_fm_entry (); - read_field (r, q, buf); - set_field (tfm_name); - p = r; - read_field (r, q, buf); - if (*buf != '<' && *buf != '"') - set_field (ps_name); - else - r = p; /* unget the field */ - if (isdigit (*r)) { /* font flags given */ - fm->flags = atoi (r); - while (isdigit (*r)) - r++; - } - while (1) { /* loop through "specials", encoding, font file */ - skip (r, ' '); - switch (*r) { - case '\0': - goto done; - case '"': /* opening quote */ - r++; - u = v = 0; - do { - skip (r, ' '); - if (sscanf (r, "%f %n", &d, &j) > 0) { - s = r + j; /* jump behind number, eat also blanks, if any */ - if (*(s - 1) == 'E' || *(s - 1) == 'e') - s--; /* e. g. 0.5ExtendFont: %f = 0.5E */ - if (str_prefix (s, "SlantFont")) { - d *= 1000.0; /* correct rounding also for neg. numbers */ - fm->slant = (integer) (d > 0 ? d + 0.5 : d - 0.5); - r = s + strlen ("SlantFont"); - } else if (str_prefix (s, "ExtendFont")) { - d *= 1000.0; - fm->extend = (integer) (d > 0 ? d + 0.5 : d - 0.5); - if (fm->extend == 1000) - fm->extend = 0; - r = s + strlen ("ExtendFont"); - } else { /* unknown name */ - for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */ - c = *r; /* remember char for temporary end of string */ - *r = '\0'; - pdftex_warn - ("invalid entry for `%s': unknown name `%s' ignored", - fm->tfm_name, s); - *r = c; - } - } else - for (; *r != ' ' && *r != '"' && *r != '\0'; r++); - } - while (*r == ' '); - if (*r == '"') /* closing quote */ - r++; - else { - pdftex_warn - ("invalid entry for `%s': closing quote missing", - fm->tfm_name); - goto bad_line; - } - break; - case 'P': /* handle cases for subfonts like 'PidEid=3,1' */ - if (sscanf (r, "PidEid=%i, %i %n", &a, &b, &c) >= 2) { - fm->pid = a; - fm->eid = b; - r += c; - break; - } - default: /* encoding or font file specification */ - a = b = 0; - if (*r == '<') { - a = *r++; - if (*r == '<' || *r == '[') - b = *r++; - } - read_field (r, q, buf); - /* encoding, formats: '8r.enc' or '<8r.enc' or '<[8r.enc' */ - if (strlen (buf) > 4 && strcasecmp (strend (buf) - 4, ".enc") == 0) { - fm->encoding = add_enc (buf); - u = v = 0; /* u, v used if intervening blank: "<< foo" */ - } else if (strlen (buf) > 0) { /* file name given */ - /* font file, formats: - * subsetting: ' no subsetting */ - } - set_field (ff_name); - u = v = 0; - } else { - u = a; - v = b; - } - } - } - done: - if (fm->ps_name != NULL && check_basefont (fm->ps_name)) - set_basefont (fm); - if (is_fontfile (fm) - && strcasecmp (strend (fm_fontfile (fm)) - 4, ".ttf") == 0) - set_truetype (fm); - if (check_fm_entry (fm, true) != 0) - goto bad_line; - /* - Until here the map line has been completely scanned without errors; - fm points to a valid, freshly filled-out fm_entry structure. - Now follows the actual work of registering/deleting. - */ - // if (handle_subfont_fm (fm, mitem->mode)) /* is this a subfont? */ - // return; - if (avl_do_entry (fm, mitem->mode) == 0) /* if success */ - return; - bad_line: - delete_fm_entry (fm); -} - -/**********************************************************************/ - -void fm_read_info () -{ - if (tfm_tree == NULL) - create_avl_trees (); - if (mitem->line == NULL) /* nothing to do */ - return; - mitem->lineno = 1; - switch (mitem->type) { - case MAPFILE: - set_cur_file_name (mitem->line); - if (!fm_open ()) { - pdftex_warn ("cannot open font map file"); - } else { - cur_file_name = (char *) nameoffile + 1; - mp_printf ("{%s", cur_file_name); - while (!fm_eof ()) { - fm_scan_line (); - mitem->lineno++; - } - fm_close (); - mp_printf ("}"); - fm_file = NULL; - } - break; - case MAPLINE: - cur_file_name = NULL; /* makes pdftex_warn() shorter */ - fm_scan_line (); - break; - default: - assert (0); - } - mitem->line = NULL; /* done with this line */ - cur_file_name = NULL; - return; -} - -/**********************************************************************/ - -fontnumber tfmoffm (fmentryptr fm_pt) -{ - return ((fm_entry *) fm_pt)->tfm_num; -} - -static fm_entry *mk_ex_fm (fontnumber f, fm_entry * basefm, int ex) -{ - fm_entry *fm; - integer e = basefm->extend; - if (e == 0) - e = 1000; - fm = new_fm_entry (); - fm->flags = basefm->flags; - fm->encoding = basefm->encoding; - fm->type = basefm->type; - fm->slant = basefm->slant; - fm->extend = roundxnoverd (e, 1000 + ex, 1000); /* modify ExtentFont to simulate expansion */ - if (fm->extend == 1000) - fm->extend = 0; - fm->tfm_name = xstrdup (makecstring (fontname[f])); - if (basefm->ps_name != NULL) - fm->ps_name = xstrdup (basefm->ps_name); - fm->ff_name = xstrdup (basefm->ff_name); - fm->ff_objnum = 0; - fm->tfm_num = f; - fm->tfm_avail = TFM_FOUND; - assert (strcmp (fm->tfm_name, nontfm)); - return fm; -} - -static void init_fm (fm_entry * fm, fontnumber f) -{ - // if (fm->fd_objnum == 0 && !no_font_desc (fm)) - // fm->fd_objnum = pdfnewobjnum (); - // if (fm->ff_objnum == 0 && is_included (fm)) - // fm->ff_objnum = pdfnewobjnum (); - if (fm->tfm_num == getnullfont ()) { - fm->tfm_num = f; - fm->tfm_avail = TFM_FOUND; - } -} - -static fmentryptr fmlookup (fontnumber f) -{ - char *tfm; - fm_entry *fm, *exfm; - fm_entry tmp; - int ai, e; - if (tfm_tree == NULL) - fm_read_info (); /* only to read default map file */ - tfm = makecstring (fontname[f]); - assert (strcmp (tfm, nontfm)); - - /* Look up for full [+-] */ - tmp.tfm_name = tfm; - fm = (fm_entry *) avl_find (tfm_tree, &tmp); - if (fm != NULL) { - init_fm (fm, f); - return (fmentryptr) fm; - } - tfm = mk_base_tfm (makecstring (fontname[f]), &e); - if (tfm == NULL) /* not an expanded font, nothing to do */ - return (fmentryptr) dummy_fm_entry (); - - tmp.tfm_name = tfm; - fm = (fm_entry *) avl_find (tfm_tree, &tmp); - if (fm != NULL) { /* found an entry with the base tfm name, e.g. cmr10 */ - return (fmentryptr) fm; /* font expansion uses the base font */ - /* the following code would be obsolete, as would be mk_ex_fm() */ - if (!is_t1fontfile (fm) || !is_included (fm)) { - pdftex_warn - ("font %s cannot be expanded (not an included Type1 font)", - tfm); - return (fmentryptr) dummy_fm_entry (); - } - exfm = mk_ex_fm (f, fm, e); /* copies all fields from fm except tfm name */ - init_fm (exfm, f); - ai = avl_do_entry (exfm, FM_DUPIGNORE); - assert (ai == 0); - return (fmentryptr) exfm; - } - return (fmentryptr) dummy_fm_entry (); -} - -/* - Early check whether a font file exists. Used e. g. for replacing fonts - of embedded PDF files: Without font file, the font within the embedded - PDF-file is used. Search tree ff_tree is used in 1st instance, as it - may be faster than the kpse_find_file(), and kpse_find_file() is called - only once per font file name + expansion parameter. This might help - keeping speed, if many PDF pages with same fonts are to be embedded. - - The ff_tree contains only font files, which are actually needed, - so this tree typically is much smaller than the tfm_tree or ps_tree. -*/ - -ff_entry *check_ff_exist (fm_entry * fm) -{ - ff_entry *ff; - ff_entry tmp; - void **aa; - - assert (fm->ff_name != NULL); - tmp.ff_name = fm->ff_name; - ff = (ff_entry *) avl_find (ff_tree, &tmp); - if (ff == NULL) { /* not yet in database */ - ff = new_ff_entry (); - ff->ff_name = xstrdup (fm->ff_name); - if (is_truetype (fm)) - ff->ff_path = kpse_find_file (fm->ff_name, kpse_truetype_format, 0); - else - ff->ff_path = kpse_find_file (fm->ff_name, kpse_type1_format, 0); - aa = avl_probe (ff_tree, ff); - assert (aa != NULL); - } - return ff; -} - - -/**********************************************************************/ -/* -Process map file given by its name or map line contents. Items not -beginning with [+-=] flush default map file, if it has not yet been -read. Leading blanks and blanks immediately following [+-=] are ignored. -*/ - -void process_map_item (char *s, int type) -{ - char *p; - int mode; - if (*s == ' ') - s++; /* ignore leading blank */ - switch (*s) { - case '+': /* +mapfile.map, +mapline */ - mode = FM_DUPIGNORE; /* insert entry, if it is not duplicate */ - s++; - break; - case '=': /* =mapfile.map, =mapline */ - mode = FM_REPLACE; /* try to replace earlier entry */ - s++; - break; - case '-': /* -mapfile.map, -mapline */ - mode = FM_DELETE; /* try to delete entry */ - s++; - break; - default: - mode = FM_DUPIGNORE; /* like +, but also: */ - mitem->line = NULL; /* flush default map file name */ - } - if (*s == ' ') - s++; /* ignore blank after [+-=] */ - p = s; /* map item starts here */ - switch (type) { - case MAPFILE: /* remove blank at end */ - while (*p != '\0' && *p != ' ') - p++; - *p = '\0'; - break; - case MAPLINE: /* blank at end allowed */ - break; - default: - assert (0); - } - if (mitem->line != NULL) /* read default map file first */ - fm_read_info (); - if (*s != '\0') { /* only if real item to process */ - mitem->mode = mode; - mitem->type = type; - mitem->line = s; - fm_read_info (); - } -} - -void mpmapfile (strnumber t) -{ - char *s = xstrdup(makecstring (t)); - process_map_item (s, MAPFILE); - xfree (s); -} - -void mpmapline (strnumber t) -{ - char *s = xstrdup(makecstring (t)); - process_map_item (s, MAPLINE); - xfree (s); -} - -void mpinitmapfile (int is_troff) -{ - assert (mitem == NULL); - mitem = xtalloc (1, mapitem); - mitem->mode = FM_DUPIGNORE; - mitem->type = MAPFILE; - if (kpse_find_file("mpost.map", kpse_fontmap_format,0)) - mitem->line = xstrdup ("mpost.map"); - else { - if (is_troff) { - mitem->line = xstrdup ("troff.map"); - } else { - mitem->line = xstrdup ("pdftex.map"); - } - } -} - -/**********************************************************************/ -/* cleaning up... */ - -static void destroy_fm_entry_tfm (void *pa, void *pb) -{ - fm_entry *fm; - fm = (fm_entry *) pa; - if (!has_pslink (fm)) - delete_fm_entry (fm); - else - unset_tfmlink (fm); -} -static void destroy_fm_entry_ps (void *pa, void *pb) -{ - fm_entry *fm; - fm = (fm_entry *) pa; - if (!has_tfmlink (fm)) - delete_fm_entry (fm); - else - unset_pslink (fm); -} -static void destroy_ff_entry (void *pa, void *pb) -{ - ff_entry *ff; - ff = (ff_entry *) pa; - delete_ff_entry (ff); -} void fm_free (void) -{ - if (tfm_tree != NULL) - avl_destroy (tfm_tree, destroy_fm_entry_tfm); - if (ps_tree != NULL) - avl_destroy (ps_tree, destroy_fm_entry_ps); - if (ff_tree != NULL) - avl_destroy (ff_tree, destroy_ff_entry); -} - -/**********************************************************************/ -/* end of mapfile.c */ diff --git a/Build/source/texk/web2c/mpdir/mp.defines b/Build/source/texk/web2c/mpdir/mp.defines deleted file mode 100644 index 4c8c35f6f11..00000000000 --- a/Build/source/texk/web2c/mpdir/mp.defines +++ /dev/null @@ -1,53 +0,0 @@ -{ -Copyright (c) 2006, 2008 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id$ -} - -{ functions from mapfile.c } - -@define function hasfmentry(); -@define function tfmoffm(); -@define procedure mpmapfile(); -@define procedure mpmapline(); -@define procedure mpinitmapfile(); - -{ functions from writefont.c } - -@define procedure mploadencodings(); -@define procedure mpfontencodings(); -@define function fontisreencoded(); -@define function fontisincluded(); -@define function fontissubsetted(); - -@define function fmencodingname(); -@define function fmfontname(); -@define function fmfontsubsetname(); -@define function fmfontslant(); -@define function fmfontextend(); - -@define function dopsfont(); - -{ functions from utils.c } - -@define procedure setjobid(); - -{ function from turningnumber.c } - -@define function bezierslope(); diff --git a/Build/source/texk/web2c/mpdir/mplib.h b/Build/source/texk/web2c/mpdir/mplib.h deleted file mode 100644 index bc015275e06..00000000000 --- a/Build/source/texk/web2c/mpdir/mplib.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -Copyright (c) 2006 Taco Hoekwater - -This file is part of pdfTeX. - -pdfTeX is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -pdfTeX 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 pdfTeX; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id$ -*/ - -#ifndef MPOSTLIB -# define MPOSTLIB - -/* WEB2C macros and prototypes */ -# if !defined(MPCOERCE) -# define EXTERN extern -# include "mpd.h" -# endif - -/* pdftexlib macros */ -# include "mpmac.h" - -# include "avlstuff.h" - - -/* pdftexlib type declarations */ -typedef struct { - const char *pdfname; - const char *t1name; - float value; - boolean valid; -} key_entry; - -typedef struct { - boolean loaded; /* the encoding has been loaded? */ - char *name; /* encoding file name */ - char *encname; /* encoding true name */ - integer objnum; /* object number */ - char **glyph_names; - integer tounicode; /* object number of associated ToUnicode entry */ -} enc_entry; - -typedef struct { - char *tfm_name; /* TFM file name */ - char *ps_name; /* PostScript name */ - integer flags; /* font flags */ - char *ff_name; /* font file name */ - char *subset_tag; /* pseudoUniqueTag for subsetted font */ - enc_entry *encoding; /* pointer to corresponding encoding */ - fontnumber tfm_num; /* number of the TFM refering this entry */ - unsigned short type; /* font type (T1/TTF/...) */ - short slant; /* SlantFont */ - short extend; /* ExtendFont */ - integer ff_objnum; /* FontFile object number */ - integer fn_objnum; /* FontName/BaseName object number */ - integer fd_objnum; /* FontDescriptor object number */ - char *charset; /* string containing used glyphs */ - boolean all_glyphs; /* embed all glyphs? */ - unsigned short links; /* link flags from tfm_tree and ps_tree */ - short tfm_avail; /* flags whether a tfm is available */ - short pid; /* Pid for truetype fonts */ - short eid; /* Eid for truetype fonts */ - void *subfont; /* subfont mapping, not used */ -} fm_entry; - -typedef struct { - char *ff_name; /* base name of font file */ - char *ff_path; /* full path to font file */ -} ff_entry; - -/* variable declarations */ - -extern boolean fontfile_found; -extern char **t1_glyph_names, *t1_builtin_glyph_names[]; -extern char *cur_file_name; -extern const char notdef[]; -extern integer t1_length1, t1_length2, t1_length3; -extern key_entry font_keys[]; -extern strnumber last_tex_string; -extern size_t last_ptr_index; -extern char fontname_buf[]; - -/* function prototypes */ - -/* mapfile.c */ -extern int avl_do_entry (fm_entry *, int); -extern ff_entry *check_ff_exist (fm_entry *); -extern void delete_fm_entry (fm_entry *); -extern void fm_free (void); -extern void fm_read_info (void); -extern boolean hasfmentry (fontnumber); -extern fm_entry *lookup_fontmap (char *); -extern void mpmapfile (integer); -extern void mpmapline (integer); -extern void mpinitmapfile (int); -extern fm_entry *new_fm_entry (void); -extern fontnumber tfmoffm (fmentryptr); - -/* utils.c */ -extern char *convertStringToPDFString (const char *in, int len); -extern void escapehex (poolpointer in); -extern void escapename (poolpointer in); -extern void escapestring (poolpointer in); -extern scaled extxnoverd (scaled, scaled, scaled); -extern void initversionstring (char **versions); -extern void make_subset_tag (fm_entry *, char **, int); -extern char *makecfilename (strnumber s); -extern char *makecstring (integer); -extern strnumber maketexstring (const char *); -extern void mp_printf (const char *, ...); -extern void pdf_printf (const char *, ...); -extern void pdf_puts (const char *); -extern void pdftex_fail (const char *, ...); -extern void pdftex_warn (const char *, ...); -extern void setjobid (int, int, int, int); -extern void stripspaces (char *p); -extern char *stripzeros (char *a); -extern void unescapehex (poolpointer in); -extern int xfflush (FILE *); -extern size_t xfwrite (void *, size_t size, size_t nmemb, FILE *); -extern int xgetc (FILE *); -extern int xputc (int, FILE *); - -/* writeenc.c */ -extern enc_entry *add_enc (char *); -extern void enc_free (void); -extern void read_enc (enc_entry *); -extern void write_enc (char **, enc_entry *, integer); - -/* writefont.c */ -extern boolean dopsfont (fontnumber); -extern strnumber fmencodingname (fontnumber); -extern integer fmfontextend (fontnumber); -extern strnumber fmfontname (fontnumber); -extern integer fmfontslant (fontnumber); -extern strnumber fmfontsubsetname (fontnumber); -extern boolean fontisincluded (fontnumber); -extern boolean fontissubsetted (fontnumber); -extern boolean fontisreencoded (fontnumber); -extern void mpfontencodings (int, int); -extern void mploadencodings (int); - -/* writet1.c */ -extern void load_enc (char *, char **, char **); -extern void t1_free (void); -extern boolean t1_subset (char *, char *, unsigned char *); -extern int t1_updatefm (int, fm_entry *); -extern void writet1 (int, fm_entry *); - -#define bitfile psfile - -/* avlstuff.c */ -extern void avlputobj (integer, integer); -extern integer avlfindobj (integer, integer, integer); - -/* turningnumber.c */ - -extern angle bezierslope(integer,integer,integer,integer,integer,integer,integer,integer,int); - -/* loadpool.c */ - -extern int loadpoolstrings (integer); - -#endif /* MPOSTLIB */ diff --git a/Build/source/texk/web2c/mpdir/mpmac.h b/Build/source/texk/web2c/mpdir/mpmac.h deleted file mode 100644 index bc9e6a79640..00000000000 --- a/Build/source/texk/web2c/mpdir/mpmac.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -Copyright (c) 2006 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id $ -*/ - -#ifndef MPOSTMAC -# define MPOSTMAC - -/* Not all systems define it. */ -# ifndef M_PI -# define M_PI 3.14159265358979323846 - /* pi */ -# define M_PI_2 1.5707963267948966192E0 - /*Hex 2^ 0 * 1.921FB54442D18 */ -# define M_PI_4 7.8539816339744830962E-1 - /*Hex 2^-1 * 1.921FB54442D18 */ -# endif - -# ifdef WIN32 -// Why relying on gmalloc() ??? -# define gmalloc(n) xmalloc(n) -# define gfree(p) free(p) -# define inline __inline -# define srandom(n) srand(n) -# define random() rand() -# endif - -/* Pascal WEB macros */ -# define maxinteger 0x7FFFFFFF -# define maxdimen 0x3FFFFFFF - -# define objinfo(n) objtab[n].int0 - -# define pdfroom(n) do { \ - if ((unsigned)(n + pdfptr) > (unsigned)pdfbufsize) { \ - if (pdfosmode) \ - zpdfosgetosbuf(n); \ - else { \ - if ((unsigned)(n) > (unsigned)pdfbufsize) \ - pdftex_fail("PDF output buffer overflowed"); \ - else \ - pdfflush(); \ - } \ - } \ -} while (0) - -# define pdfout(c) do { \ - pdfroom(1); \ - pdfbuf[pdfptr++] = c; \ -} while (0) - -# define pdfoffset() (pdfgone + pdfptr) -# define pdfinitfont(f) {tmpf = f; pdfcreatefontobj();} - -# define MAX_CHAR_CODE 255 -# define PRINTF_BUF_SIZE 1024 -# define MAX_CSTRING_LEN 1024 * 1024 -# define MAX_PSTRING_LEN 1024 -# define SMALL_BUF_SIZE 256 -# define SMALL_ARRAY_SIZE 256 -# define FONTNAME_BUF_SIZE 128 - /* a PDF name can be maximum 127 chars long */ - -# define pdftex_debug tex_printf - -# define check_buf(size, buf_size) \ - if ((unsigned)(size) > (unsigned)(buf_size)) \ - pdftex_fail("buffer overflow: (%d,%d) at file %s, line %d",size,buf_size, __FILE__, __LINE__ ) - -# define append_char_to_buf(c, p, buf, buf_size) do { \ - if (c == 9) \ - c = 32; \ - if (c == 13 || c == EOF) \ - c = 10; \ - if (c != ' ' || (p > buf && p[-1] != 32)) { \ - check_buf(p - buf + 1, (buf_size)); \ - *p++ = c; \ - } \ -} while (0) - -# define append_eol(p, buf, buf_size) do { \ - check_buf(p - buf + 2, (buf_size)); \ - if (p - buf > 1 && p[-1] != 10) \ - *p++ = 10; \ - if (p - buf > 2 && p[-2] == 32) { \ - p[-2] = 10; \ - p--; \ - } \ - *p = 0; \ -} while (0) - -# define remove_eol(p, buf) do { \ - p = strend(buf) - 1; \ - if (*p == 10) \ - *p = 0; \ -} while (0) - -# define skip(p, c) if (*p == c) p++ - -# define alloc_array(T, n, s) do { \ - if (T##_array == NULL) { \ - T##_limit = (s); \ - if ((unsigned)(n) > T##_limit) \ - T##_limit = (n); \ - T##_array = xtalloc(T##_limit, T##_entry); \ - T##_ptr = T##_array; \ - } \ - else if ((unsigned)(T##_ptr - T##_array + (n)) > T##_limit) { \ - last_ptr_index = T##_ptr - T##_array; \ - T##_limit *= 2; \ - if ((unsigned)(T##_ptr - T##_array + (n)) > T##_limit) \ - T##_limit = T##_ptr - T##_array + (n); \ - xretalloc(T##_array, T##_limit, T##_entry); \ - T##_ptr = T##_array + last_ptr_index; \ - } \ -} while (0) - -# define is_cfg_comment(c) \ - (c == 10 || c == '*' || c == '#' || c == ';' || c == '%') - -# define define_array(T) \ -T##_entry *T##_ptr, *T##_array = NULL; \ -size_t T##_limit - -# define xfree(p) do { if (p != NULL) free(p); p = NULL; } while (0) -# define strend(s) strchr(s, 0) -# define xtalloc XTALLOC -# define xretalloc XRETALLOC - -# define ASCENT_CODE 0 -# define CAPHEIGHT_CODE 1 -# define DESCENT_CODE 2 -# define FONTNAME_CODE 3 -# define ITALIC_ANGLE_CODE 4 -# define STEMV_CODE 5 -# define XHEIGHT_CODE 6 -# define FONTBBOX1_CODE 7 -# define FONTBBOX2_CODE 8 -# define FONTBBOX3_CODE 9 -# define FONTBBOX4_CODE 10 -# define MAX_KEY_CODE (FONTBBOX1_CODE + 1) -# define FONT_KEYS_NUM (FONTBBOX4_CODE + 1) - -# define F_INCLUDED 0x01 -# define F_SUBSETTED 0x02 -# define F_TRUETYPE 0x04 -# define F_BASEFONT 0x08 -# define F_SUBFONT 0x10 - -# define set_included(fm) ((fm)->type |= F_INCLUDED) -# define set_subsetted(fm) ((fm)->type |= F_SUBSETTED) -# define set_truetype(fm) ((fm)->type |= F_TRUETYPE) -# define set_basefont(fm) ((fm)->type |= F_BASEFONT) -# define set_subfont(fm) ((fm)->type |= F_SUBFONT) - -# define unset_included(fm) ((fm)->type &= ~F_INCLUDED) -# define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED) -# define unset_truetype(fm) ((fm)->type &= ~F_TRUETYPE) -# define unset_basefont(fm) ((fm)->type &= ~F_BASEFONT) -# define unset_subfont(fm) ((fm)->type &= ~F_SUBFONT) - -# define unset_fontfile(fm) xfree((fm)->ff_name) - -# define is_included(fm) ((fm)->type & F_INCLUDED) -# define is_subsetted(fm) ((fm)->type & F_SUBSETTED) -# define is_truetype(fm) ((fm)->type & F_TRUETYPE) -# define is_basefont(fm) ((fm)->type & F_BASEFONT) -# define is_subfont(fm) ((fm)->type & F_SUBFONT) -# define no_font_desc(fm) (is_basefont(fm) && !is_included(fm)) - -# define fm_slant(fm) (fm)->slant -# define fm_extend(fm) (fm)->extend -# define fm_fontfile(fm) (fm)->ff_name - -# define is_reencoded(fm) ((fm)->encoding != NULL) -# define is_fontfile(fm) (fm_fontfile(fm) != NULL) -# define is_t1fontfile(fm) (is_fontfile(fm) && !is_truetype(fm)) - -# define LINK_TFM 0x01 -# define LINK_PS 0x02 -# define set_tfmlink(fm) ((fm)->links |= LINK_TFM) -# define set_pslink(fm) ((fm)->links |= LINK_PS) -# define unset_tfmlink(fm) ((fm)->links &= ~LINK_TFM) -# define unset_pslink(fm) ((fm)->links &= ~LINK_PS) -# define has_tfmlink(fm) ((fm)->links & LINK_TFM) -# define has_pslink(fm) ((fm)->links & LINK_PS) - - -# define set_cur_file_name(s) \ - cur_file_name = s; \ - packfilename(maketexstring(cur_file_name), getnullstr(), getnullstr()) - -# define cmp_return(a, b) \ - if (a > b) \ - return 1; \ - if (a < b) \ - return -1 - -# define str_prefix(s1, s2) (strncmp((s1), (s2), strlen(s2)) == 0) - -#endif /* MPOSTMAC */ diff --git a/Build/source/texk/web2c/mpdir/mpostlib.mk b/Build/source/texk/web2c/mpdir/mpostlib.mk deleted file mode 100644 index e4297341864..00000000000 --- a/Build/source/texk/web2c/mpdir/mpostlib.mk +++ /dev/null @@ -1,21 +0,0 @@ -## mpostlib.mk - Makefile fragment for libraries used by mpost -# Public domain. - -# Include dependencies to get the built if we don't do make -# from the top-level directory. - -Makefile: mpdir/mpostlib.mk - -# libmpost -mpostlib = mpdir/libmpost.a -mpostlib_sources = $(srcdir)/mpdir/*.c $(srcdir)/mpdir/*.h - -mpdir/libmpost.a: $(mpostlib_sources) - cd mpdir && $(MAKE) $(common_makeargs) libmpost.a - -# Convenience variables. -mpostlibs = $(mpostlib) -mpostlibsdep = $(mpostlib) $(makecpool) - -## end of mpostlib.mk - Makefile fragment for libraries used by mpost - diff --git a/Build/source/texk/web2c/mpdir/turningnumber.c b/Build/source/texk/web2c/mpdir/turningnumber.c deleted file mode 100644 index bfb7d9133d2..00000000000 --- a/Build/source/texk/web2c/mpdir/turningnumber.c +++ /dev/null @@ -1,113 +0,0 @@ -/* $Id$ */ - -#include "mplib.h" - -#define bezier_error (720<<20)+1 - -#define sign(v) ((v)>0 ? 1 : ((v)<0 ? -1 : 0 )) - -#define print_roots(a) { if (debuglevel>(65536*2)) \ - fprintf(stdout,"bezierslope(): %s, i=%f, o=%f, angle=%f\n", \ - (a),in,out,res); } - -#define out ((double)(xo>>20)) -#define mid ((double)(xm>>20)) -#define in ((double)(xi>>20)) - -#define divisor (256*256) - -#define double2angle(a) (int)floor(a*256.0*256.0*16.0) - -angle -bezierslope(integer AX,integer AY,integer BX,integer BY, - integer CX,integer CY,integer DX,integer DY, int debuglevel) { - double a, b, c; - integer deltax,deltay; - double ax,ay,bx,by,cx,cy,dx,dy; - - angle xi = 0, xo = 0, xm = 0; - double res = 0; - - ax=AX/divisor; ay=AY/divisor; - bx=BX/divisor; by=BY/divisor; - cx=CX/divisor; cy=CY/divisor; - dx=DX/divisor; dy=DY/divisor; - - deltax = (BX-AX); deltay = (BY-AY); - if (deltax==0 && deltay == 0) { deltax=(CX-AX); deltay=(CY-AY); } - if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); } - xi = anangle(deltax,deltay); - - deltax = (CX-BX); deltay = (CY-BY); - xm = anangle(deltax,deltay); - - deltax = (DX-CX); deltay = (DY-CY); - if (deltax==0 && deltay == 0) { deltax=(DX-BX); deltay=(DY-BY); } - if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); } - xo = anangle(deltax,deltay); - - a = (bx-ax)*(cy-by) - (cx-bx)*(by-ay); /* a = (bp-ap)x(cp-bp); */ - b = (bx-ax)*(dy-cy) - (by-ay)*(dx-cx);; /* b = (bp-ap)x(dp-cp);*/ - c = (cx-bx)*(dy-cy) - (dx-cx)*(cy-by); /* c = (cp-bp)x(dp-cp);*/ - - if (debuglevel>(65536*2)) { - fprintf(stdout, - "bezierslope(): (%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f)\n", - ax,ay,bx,by,cx,cy,dx,dy); - fprintf(stdout,"bezierslope(): a,b,c,b^2,4ac: (%.2f,%.2f,%.2f,%.2f,%.2f)\n",a,b,c,b*b,4*a*c); - } - - if ((a==0)&&(c==0)) { - res = (b==0 ? 0 : (out-in)); - print_roots("no roots (a)"); - } else if ((a==0)||(c==0)) { - if ((sign(b) == sign(a)) || (sign(b) == sign(c))) { - res = out-in; /* ? */ - if (res<-180.0) - res += 360.0; - else if (res>180.0) - res -= 360.0; - print_roots("no roots (b)"); - } else { - res = out-in; /* ? */ - print_roots("one root (a)"); - } - } else if ((sign(a)*sign(c))<0) { - res = out-in; /* ? */ - if (res<-180.0) - res += 360.0; - else if (res>180.0) - res -= 360.0; - print_roots("one root (b)"); - } else { - if (sign(a) == sign(b)) { - res = out-in; /* ? */ - if (res<-180.0) - res += 360.0; - else if (res>180.0) - res -= 360.0; - print_roots("no roots (d)"); - } else { - if ((b*b) == (4*a*c)) { - res = bezier_error; - /* print_roots("double root"); *//* cusp */ - } else if ((b*b) < (4*a*c)) { - res = out-in; /* ? */ - if (res<=0.0 &&res>-180.0) - res += 360.0; - else if (res>=0.0 && res<180.0) - res -= 360.0; - print_roots("no roots (e)"); - } else { - res = out-in; - if (res<-180.0) - res += 360.0; - else if (res>180.0) - res -= 360.0; - print_roots("two roots"); /* two inflections */ - } - } - } - return double2angle(res); -} - diff --git a/Build/source/texk/web2c/mpdir/utils.c b/Build/source/texk/web2c/mpdir/utils.c deleted file mode 100644 index 00e51cc5edc..00000000000 --- a/Build/source/texk/web2c/mpdir/utils.c +++ /dev/null @@ -1,689 +0,0 @@ -/* Copyright (c) 2006 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id $ -*/ - -#ifdef HAVE_ASPRINTF /* asprintf is not defined in openbsd-compat.h, but in stdio.h */ -# include -#endif -#include - -#include -#include -#include -#include -#include -#include /* for DBL_EPSILON */ -#include "mplib.h" - -/* define char_ptr, char_array & char_limit */ -typedef char char_entry; -define_array (char); - -#define Z_NULL 0 - -typedef unsigned char Byte; -typedef Byte Bytef; - -#define check_nprintf(size_get, size_want) \ - if ((unsigned)(size_get) >= (unsigned)(size_want)) \ - pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__); - -/*@unused@*/ -static const char perforce_id[] = - "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/utils.c#24 $"; - -char *cur_file_name = NULL; -strnumber last_tex_string; -static char print_buf[PRINTF_BUF_SIZE]; -static char *job_id_string = NULL; -extern string ptexbanner; /* from web2c/lib/texmfmp.c */ -extern string versionstring; /* from web2c/lib/version.c */ -extern KPSEDLL string kpathsea_version_string; /* from kpathsea/version.c */ - -size_t last_ptr_index; /* for use with alloc_array */ - - - -void pdf_puts (const char *s) -{ - while (*s) - fputc(*s++,psfile); -} - -void pdf_printf (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - vsnprintf (print_buf, PRINTF_BUF_SIZE, fmt, args); - pdf_puts (print_buf); - va_end (args); -} - -strnumber maketexstring (const char *s) -{ - size_t l; - if (s == NULL || *s == 0) - return getnullstr (); - l = strlen (s); - check_buf (poolptr + l, poolsize); - while (l-- > 0) - strpool[poolptr++] = *s++; - last_tex_string = makestring (); - return last_tex_string; -} - -void mp_printf (const char *fmt, ...) -{ - va_list args; - int saved_selector; - saved_selector = selector; - va_start (args, fmt); - vsnprintf (print_buf, PRINTF_BUF_SIZE, fmt, args); - selector = gettermandlogid(); - print (maketexstring (print_buf)); - flushstr (last_tex_string); - xfflush (stdout); - va_end (args); - selector = saved_selector; /* ps_file_only, probably */ -} - -/* pdftex_fail may be called when a buffer overflow has happened/is - happening, therefore may not call mktexstring. However, with the - current implementation it appears that error messages are misleading, - possibly because pool overflows are detected too late. - - The output format of this fuction must be the same as pdf_error in - pdftex.web! */ - -void pdftex_fail (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - fputs ("\nError: module writet1", stderr); - if (cur_file_name) - fprintf (stderr, " (file %s)", cur_file_name); - fputs (": ", stderr); - vsprintf (print_buf, fmt, args); - fputs (print_buf, stderr); - fputs - ("\n ==> Fatal error occurred, the output PS file is not finished!\n", - stderr); - va_end (args); - exit (1); -} - -/* The output format of this fuction must be the same as pdf_warn in - pdftex.web! */ -void pdftex_warn (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - fputs ("\nWarning: module writet1", stderr); - if (cur_file_name) - fprintf (stderr, " (file %s)", cur_file_name); - fputs (": ", stderr); - vsprintf (print_buf, fmt, args); - fputs (print_buf, stderr); - fputs ("\n", stderr); - va_end (args); -} - - -static char *cstrbuf = NULL; - -char *makecstring (integer s) -{ - char *p; - static int allocsize; - int allocgrow, i, l ; - if (s==0) - return ""; - l = strstart[nextstr[s]] - strstart[s]; - if (l==0) - return ""; - check_buf (l + 1, MAX_CSTRING_LEN); - if (cstrbuf == NULL) { - allocsize = l + 1; - cstrbuf = xmallocarray (char, allocsize); - } else if (l + 1 > allocsize) { - allocgrow = allocsize * 0.2; - if (l + 1 - allocgrow > allocsize) - allocsize = l + 1; - else if (allocsize < MAX_CSTRING_LEN - allocgrow) - allocsize += allocgrow; - else - allocsize = MAX_CSTRING_LEN; - cstrbuf = xrealloc (cstrbuf, sizeof (char) * allocsize); - } - p = cstrbuf; - for (i = 0; i < l; i++) - *p++ = strpool[i + strstart[s]]; - *p = 0; - return cstrbuf; -} - -size_t xfwrite (void *ptr, size_t size, size_t nmemb, FILE * stream) -{ - if (fwrite (ptr, size, nmemb, stream) != nmemb) - pdftex_fail ("fwrite() failed"); - return nmemb; -} - -int xfflush (FILE * stream) -{ - if (fflush (stream) != 0) - pdftex_fail ("fflush() failed"); - return 0; -} - -int xgetc (FILE * stream) -{ - int c = getc (stream); - if (c < 0 && c != EOF) - pdftex_fail ("getc() failed"); - return c; -} - -int xputc (int c, FILE * stream) -{ - int i = putc (c, stream); - if (i < 0) - pdftex_fail ("putc() failed"); - return i; -} - - -scaled extxnoverd (scaled x, scaled n, scaled d) -{ - double r = (((double) x) * ((double) n)) / ((double) d); - if (r > DBL_EPSILON) - r += 0.5; - else - r -= 0.5; - if (r >= (double) maxinteger || r <= -(double) maxinteger) - pdftex_warn ("arithmetic: number too big"); - return (scaled) r; -} - -/* Converts any string given in in in an allowed PDF string which can be - * handled by printf et.al.: \ is escaped to \\, parenthesis are escaped and - * control characters are octal encoded. - * This assumes that the string does not contain any already escaped - * characters! - */ -char *convertStringToPDFString (const char *in, int len) -{ - static char pstrbuf[MAX_PSTRING_LEN]; - char *out = pstrbuf; - int i, j = 0, k; - char buf[5]; - for (i = 0; i < len; i++) { - check_buf (j + sizeof (buf), MAX_PSTRING_LEN); - if (((unsigned char) in[i] < '!') || ((unsigned char) in[i] > '~')) { - /* convert control characters into oct */ - k = snprintf (buf, sizeof (buf), - "\\%03o", (unsigned int) (unsigned char) in[i]); - check_nprintf (k, sizeof (buf)); - out[j++] = buf[0]; - out[j++] = buf[1]; - out[j++] = buf[2]; - out[j++] = buf[3]; - } else if ((in[i] == '(') || (in[i] == ')')) { - /* escape paranthesis */ - out[j++] = '\\'; - out[j++] = in[i]; - } else if (in[i] == '\\') { - /* escape backslash */ - out[j++] = '\\'; - out[j++] = '\\'; - } else { - /* copy char :-) */ - out[j++] = in[i]; - } - } - out[j] = '\0'; - return pstrbuf; -} - - -/* Converts any string given in in in an allowed PDF string which can be - * handled by printf et.al.: \ is escaped to \\, parenthesis are escaped and - * control characters are octal encoded. - * This assumes that the string does not contain any already escaped - * characters! - * - * See escapename for parameter description. - */ -void escapestring (poolpointer in) -{ - const poolpointer out = poolptr; - unsigned char ch; - while (in < out) { - if (poolptr + 4 >= poolsize) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - return; - } - - ch = (unsigned char) strpool[in++]; - - if ((ch < '!') || (ch > '~')) { - /* convert control characters into oct */ - int i = snprintf ((char *) &strpool[poolptr], 5, - "\\%.3o", (unsigned int) ch); - check_nprintf (i, 5); - poolptr += i; - continue; - } - if ((ch == '(') || (ch == ')') || (ch == '\\')) { - /* escape parenthesis and backslash */ - strpool[poolptr++] = '\\'; - } - /* copy char :-) */ - strpool[poolptr++] = ch; - } -} - -/* Convert any given string in a PDF name using escaping mechanism - of PDF 1.2. The result does not include the leading slash. - - PDF specification 1.6, section 3.2.6 "Name Objects" explains: -
- Beginning with PDF 1.2, any character except null (character code 0) may - be included in a name by writing its 2-digit hexadecimal code, preceded - by the number sign character (#); see implementation notes 3 and 4 in - Appendix H. This syntax is required to represent any of the delimiter or - white-space characters or the number sign character itself; it is - recommended but not required for characters whose codes are outside the - range 33 (!) to 126 (~). -
- The following table shows the conversion that are done by this - function: - code result reason - ----------------------------------- - 0 ignored not allowed - 1..32 escaped must for white-space: - 9 (tab), 10 (lf), 12 (ff), 13 (cr), 32 (space) - recommended for the other control characters - 35 escaped escape char "#" - 37 escaped delimiter "%" - 40..41 escaped delimiters "(" and ")" - 47 escaped delimiter "/" - 60 escaped delimiter "<" - 62 escaped delimiter ">" - 91 escaped delimiter "[" - 93 escaped delimiter "]" - 123 escaped delimiter "{" - 125 escaped delimiter "}" - 127..255 escaped recommended - else copy regular characters - - Parameter "in" is a pointer into the string pool where - the input string is located. The output string is written - as temporary string right after the input string. - Thus at the begin of the procedure the global variable - "poolptr" points to the start of the output string and - after the end when the procedure returns. -*/ -void escapename (poolpointer in) -{ - const poolpointer out = poolptr; - unsigned char ch; - int i; - - while (in < out) { - if (poolptr + 3 >= poolsize) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - return; - } - - ch = (unsigned char) strpool[in++]; - - if ((ch >= 1 && ch <= 32) || ch >= 127) { - /* escape */ - i = snprintf ((char *) &strpool[poolptr], 4, - "#%.2X", (unsigned int) ch); - check_nprintf (i, 4); - poolptr += i; - continue; - } - switch (ch) { - case 0: - /* ignore */ - break; - case 35: - case 37: - case 40: - case 41: - case 47: - case 60: - case 62: - case 91: - case 93: - case 123: - case 125: - /* escape */ - i = snprintf ((char *) &strpool[poolptr], 4, - "#%.2X", (unsigned int) ch); - check_nprintf (i, 4); - poolptr += i; - break; - default: - /* copy */ - strpool[poolptr++] = ch; - } - } -} - -/* Convert any given string in a PDF hexadecimal string. The - result does not include the angle brackets. - - This procedure uses uppercase hexadecimal letters. - - See escapename for description of parameters. -*/ -void escapehex (poolpointer in) -{ - const poolpointer out = poolptr; - unsigned char ch; - int i; - - while (in < out) { - if (poolptr + 2 >= poolsize) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - return; - } - - ch = (unsigned char) strpool[in++]; - - i = snprintf ((char *) &strpool[poolptr], 3, "%.2X", (unsigned int) ch); - check_nprintf (i, 3); - poolptr += 2; - } -} - -/* Unescape any given hexadecimal string. - - Last hex digit can be omitted, it is replaced by zero, see - PDF specification. - - Invalid digits are silently ignored. - - See escapename for description of parameters. -*/ -void unescapehex (poolpointer in) -{ - const poolpointer out = poolptr; - unsigned char ch; - unsigned char a = 0; /* to avoid warning about uninitialized use of a */ - boolean first = true; - - while (in < out) { - if (poolptr + 1 >= poolsize) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - return; - } - - ch = (unsigned char) strpool[in++]; - - if ((ch >= '0') && (ch <= '9')) { - ch -= '0'; - } else if ((ch >= 'A') && (ch <= 'F')) { - ch -= 'A' - 10; - } else if ((ch >= 'a') && (ch <= 'f')) { - ch -= 'a' - 10; - } else { - continue; /* ignore wrong character */ - } - - if (first) { - a = ch << 4; - first = false; - continue; - } - - strpool[poolptr++] = a + ch; - first = true; - } - if (!first) { /* last hex digit is omitted */ - strpool[poolptr++] = ch << 4; - } -} - - -/* makecfilename - input/ouput same as makecstring: - input: string number - output: C string with quotes removed. - That means, file names that are legal on some operation systems - cannot any more be used since pdfTeX version 1.30.4. -*/ -char *makecfilename (strnumber s) -{ - char *name = makecstring (s); - char *p = name; - char *q = name; - - while (*p) { - if (*p != '"') - *q++ = *p; - p++; - } - *q = '\0'; - return name; -} - -/* function strips trailing zeros in string with numbers; */ -/* leading zeros are not stripped (as in real life) */ -char *stripzeros (char *a) -{ - enum { NONUM, DOTNONUM, INT, DOT, LEADDOT, FRAC } s = NONUM, t = NONUM; - char *p, *q, *r; - for (p = q = r = a; *p != '\0';) { - switch (s) { - case NONUM: - if (*p >= '0' && *p <= '9') - s = INT; - else if (*p == '.') - s = LEADDOT; - break; - case DOTNONUM: - if (*p != '.' && (*p < '0' || *p > '9')) - s = NONUM; - break; - case INT: - if (*p == '.') - s = DOT; - else if (*p < '0' || *p > '9') - s = NONUM; - break; - case DOT: - case LEADDOT: - if (*p >= '0' && *p <= '9') - s = FRAC; - else if (*p == '.') - s = DOTNONUM; - else - s = NONUM; - break; - case FRAC: - if (*p == '.') - s = DOTNONUM; - else if (*p < '0' || *p > '9') - s = NONUM; - break; - default:; - } - switch (s) { - case DOT: - r = q; - break; - case LEADDOT: - r = q + 1; - break; - case FRAC: - if (*p > '0') - r = q + 1; - break; - case NONUM: - if ((t == FRAC || t == DOT) && r != a) { - q = r--; - if (*r == '.') /* was a LEADDOT */ - *r = '0'; - r = a; - } - break; - default:; - } - *q++ = *p++; - t = s; - } - *q = '\0'; - return a; -} - -void stripspaces (char *p) -{ - char *q; - for (q = p; *p != '\0'; p++) { - if (*p != ' ') - *q++ = *p; - } - *q = '\0'; -} - -void initversionstring (char **versions) -{ -} - -void setjobid (int year, int month, int day, int time) -{ - char *name_string, *format_string, *s; - size_t slen; - int i; - - if (job_id_string != NULL) - return; - - name_string = xstrdup (makecstring (jobname)); - format_string = xstrdup (makecstring (memident)); - - slen = SMALL_BUF_SIZE + - strlen (name_string) + - strlen (format_string) + - //strlen (banner) + - strlen (versionstring) + strlen (kpathsea_version_string); - s = xtalloc (slen, char); - /* The Web2c version string starts with a space. */ - i = snprintf (s, slen, - "%.4d/%.2d/%.2d %.2d:%.2d %s %s%s %s", - (year>>16), (month>>16), (day>>16), (time>>16) / 60, (time>>16) % 60, - name_string, format_string, //ptexbanner, - versionstring, kpathsea_version_string); - check_nprintf (i, slen); - job_id_string = xstrdup (s); - xfree (s); - xfree (name_string); - xfree (format_string); -} - - - -static void fnstr_append (const char *s) -{ - size_t l = strlen (s) + 1; - alloc_array (char, l, SMALL_ARRAY_SIZE); - strcat (char_ptr, s); - char_ptr = strend (char_ptr); -} - -/* this is not really a true crc32, but it should be just enough to keep - subsets prefixes somewhat disjunct */ -unsigned long crc32 (int oldcrc, const Byte *buf, int len) { - unsigned long ret = 0; - int i; - if (oldcrc==0) - ret = (23<<24)+(45<<16)+(67<<8)+89; - else - for (i=0;itfm_name != NULL) { - fnstr_append (" TFM name: "); - fnstr_append (fm_cur->tfm_name); - } - fnstr_append (" PS name: "); - //if (font_keys[FONTNAME_CODE].valid) - // fnstr_append (fontname_buf); - //else - if (fm_cur->ps_name != NULL) - fnstr_append (fm_cur->ps_name); - fnstr_append (" Encoding: "); - if (fm_cur->encoding != NULL && (fm_cur->encoding)->name != NULL) - fnstr_append ((fm_cur->encoding)->name); - else - fnstr_append ("built-in"); - fnstr_append (" CharSet: "); - assert (glyph_names != NULL); - for (i = 0; i < 256; i++) - if (mpcharmarked (tex_font, i) && glyph_names[i] != notdef) { - if (glyph_names[i]!=NULL) { - fnstr_append ("/"); - fnstr_append (glyph_names[i]); - } - } - if (fm_cur->charset != NULL) { - fnstr_append (" Extra CharSet: "); - fnstr_append (fm_cur->charset); - } - crc = crc32 (0L, Z_NULL, 0); - crc = crc32 (crc, (Bytef *) char_array, strlen (char_array)); - /* we need to fit a 32-bit number into a string of 6 uppercase chars long; - * there are 26 uppercase chars ==> each char represents a number in range - * 0..25. The maximal number that can be represented by the tag is - * 26^6 - 1, which is a number between 2^28 and 2^29. Thus the bits 29..31 - * of the CRC must be dropped out. - */ - for (i = 0; i < 6; i++) { - tag[i] = 'A' + crc % 26; - crc /= 26; - } - tag[6] = 0; - fm_cur->subset_tag = xstrdup (tag); -} - diff --git a/Build/source/texk/web2c/mpdir/writeenc.c b/Build/source/texk/web2c/mpdir/writeenc.c deleted file mode 100644 index ac4dc5cba7b..00000000000 --- a/Build/source/texk/web2c/mpdir/writeenc.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2006 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id $ -*/ - -#include "mplib.h" - -/*@unused@*/ -static const char perforce_id[] = - "$Id: writeenc.c,v 1.3 2005/12/26 14:20:13 hahe Exp hahe $"; - -void read_enc (enc_entry * e) -{ - assert (e != NULL); - if (e->loaded) - return; - e->encname = NULL; - load_enc (e->name, &e->encname, e->glyph_names); - e->loaded = true; -} - -/* write_enc is used to write either external encoding (given in map file) or - * internal encoding (read from the font file); when glyph_names is NULL - * the 2nd argument is a pointer to the encoding entry; otherwise the 3rd is - * the object number of the Encoding object - */ -void write_enc (char **glyph_names, enc_entry * e, integer eobjnum) -{ - int i; - int s; - int foffset; - char **g; - if (glyph_names == NULL) { - assert (e != NULL); - if (e->objnum != 0) /* the encoding has been written already */ - return; - e->objnum = 1; - g = e->glyph_names; - } else { - g = glyph_names; - } - pdf_printf("\n%%%%BeginResource: encoding %s",e->encname); - pdf_printf ("\n/%s [ ", e->encname); - foffset = strlen(e->name)+3; - for (i = 0; i < 256; i++) { - s = strlen(g[i]); - if (s+1+foffset>=80) { - pdf_printf ("\n"); - foffset = 0; - } - foffset += s+2; - pdf_printf ("/%s ", g[i]); - } - if (foffset>75) - pdf_printf ("\n"); - pdf_puts ("] def\n"); - pdf_printf("%%%%EndResource"); -} - -/**********************************************************************/ -/* All encoding entries go into AVL tree for fast search by name. */ - -struct avl_table *enc_tree = NULL; - -/* AVL sort enc_entry into enc_tree by name */ - -static int comp_enc_entry (const void *pa, const void *pb, void *p) -{ - return strcmp (((const enc_entry *) pa)->name, - ((const enc_entry *) pb)->name); -} - -enc_entry *add_enc (char *s) -{ - int i; - enc_entry tmp, *p; - void **aa; - - assert (s != NULL); - if (enc_tree == NULL) { - enc_tree = avl_create (comp_enc_entry, NULL, &avl_xallocator); - assert (enc_tree != NULL); - } - tmp.name = s; - p = (enc_entry *) avl_find (enc_tree, &tmp); - if (p != NULL) /* encoding already registered */ - return p; - p = xtalloc (1, enc_entry); - p->loaded = false; - p->name = xstrdup (s); - p->objnum = 0; - p->tounicode = 0; - p->glyph_names = xtalloc (256, char *); - for (i = 0; i < 256; i++) - p->glyph_names[i] = (char *) notdef; - aa = avl_probe (enc_tree, p); - assert (aa != NULL); - return p; -} - -/**********************************************************************/ -/* cleaning up... */ - -static void destroy_enc_entry (void *pa, void *pb) -{ - enc_entry *p; - int i; - - p = (enc_entry *) pa; - xfree (p->name); - if (p->glyph_names != NULL) - for (i = 0; i < 256; i++) - if (p->glyph_names[i] != notdef) - xfree (p->glyph_names[i]); - xfree (p->glyph_names); - xfree (p); -} - -void enc_free () -{ - if (enc_tree != NULL) - avl_destroy (enc_tree, destroy_enc_entry); -} - -/**********************************************************************/ diff --git a/Build/source/texk/web2c/mpdir/writefont.c b/Build/source/texk/web2c/mpdir/writefont.c deleted file mode 100644 index 528e1577bd1..00000000000 --- a/Build/source/texk/web2c/mpdir/writefont.c +++ /dev/null @@ -1,232 +0,0 @@ -/* -Copyright (c) 1996-2006 Han The Thanh, - -This file is part of pdfTeX. - -pdfTeX is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -pdfTeX 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 pdfTeX; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id: writefont.c,v 1.3 2005/12/27 19:04:42 hahe Exp $ -*/ - -#include "mplib.h" - -static const char perforce_id[] = - "$Id: writefont.c,v 1.3 2005/12/27 19:04:42 hahe Exp $"; - -boolean fontfile_found; -boolean is_otf_font; -char fontname_buf[FONTNAME_BUF_SIZE]; - -boolean fontisreencoded (fontnumber f) { - fm_entry *fm; - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL - && (fm->ps_name != NULL) - && is_reencoded (fm)) - return 1; - } - return 0; -} - -boolean fontisincluded (fontnumber f) { - fm_entry *fm; - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL - && (fm->ps_name != NULL && fm->ff_name != NULL) - && is_included (fm)) - return 1; - } - return 0; -} - -boolean fontissubsetted (fontnumber f) { - fm_entry *fm; - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL - && (fm->ps_name != NULL && fm->ff_name != NULL) - && is_included (fm) && is_subsetted (fm)) - return 1; - } - return 0; -} - - -strnumber fmencodingname (fontnumber f) { - enc_entry *e; - fm_entry *fm; - if (hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - if (is_reencoded (fm)) { - e = fm->encoding; - if (e->encname!=NULL) { - return maketexstring(e->encname); - } - } else { - return 0; - } - } - } - pdftex_fail ("fontmap encoding problems for font %s",makecstring (fontname[f])); - return 0; -} - -strnumber fmfontname (fontnumber f) { - fm_entry *fm; - if (hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - if (fontisincluded(f) && !fontpsnamefixed[f]) { - /* find the real fontname, and update ps_name and subset_tag if needed */ - if(t1_updatefm(f,fm)) { - fontpsnamefixed[f] = true; - } else { - pdftex_fail ("font loading problems for font %s",makecstring (fontname[f])); - } - } - return maketexstring(fm->ps_name); - } - } - pdftex_fail ("fontmap name problems for font %s",makecstring (fontname[f])); - return 0; -} - -strnumber fmfontsubsetname (fontnumber f) { - fm_entry *fm; - char *s; - if (hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - if (is_subsetted(fm)) { - s = xmalloc(strlen(fm->ps_name)+8); - snprintf(s,strlen(fm->ps_name)+8,"%s-%s",fm->subset_tag,fm->ps_name); - return maketexstring(s); - } else { - return maketexstring(fm->ps_name); - } - } - } - pdftex_fail ("fontmap name problems for font %s",makecstring (fontname[f])); - return 0; -} - - - -integer fmfontslant (fontnumber f) { - fm_entry *fm; - if (hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - return fm->slant; - } - } - return 0; -} - -integer fmfontextend (fontnumber f) { - fm_entry *fm; - if (hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - return fm->extend; - } - } - return 0; -} - - - -void mploadencodings (int lastfnum) { - int nullfont; - int f; - enc_entry *e; - fm_entry *fm_cur; - nullfont = getnullfont(); - for (f=nullfont+1;f<=lastfnum;f++) { - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm_cur = (fm_entry *) mpfontmap[f]; - if (fm_cur != NULL && - fm_cur->ps_name != NULL && - is_reencoded (fm_cur)) { - e = fm_cur->encoding; - read_enc (e); - } - } - } -} - -void mpfontencodings (int lastfnum, int encodings_only) { - int nullfont; - int f; - enc_entry *e; - fm_entry *fm; - nullfont = getnullfont(); - for (f=nullfont+1;f<=lastfnum;f++) { - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - if (is_reencoded (fm)) { - if (encodings_only || (!is_subsetted (fm))) { - e = fm->encoding; - write_enc (NULL, e, 0); - /* clear for next run */ - e->objnum = 0; - } - } - } - } - } -} - -boolean dopsfont (fontnumber f) -{ - fm_entry *fm_cur; - if (mpfontmap[f] == NULL) - pdftex_fail ("pdffontmap not initialized for font %s", - makecstring (fontname[f])); - if (hasfmentry (f)) - fm_cur = (fm_entry *) mpfontmap[f]; - else - fm_cur = NULL; - if (fm_cur == NULL) - return 1; - if (is_truetype(fm_cur) || - (fm_cur->ps_name == NULL && fm_cur->ff_name == NULL)) { - return 0; - } - - if (is_included(fm_cur)) { - printnl(maketexstring("%%BeginResource: font ")); - flushstr (last_tex_string); - if (is_subsetted(fm_cur)) { - print(maketexstring(fm_cur->subset_tag)); - flushstr (last_tex_string); - print(maketexstring("-")); - flushstr (last_tex_string); - } - print(maketexstring(fm_cur->ps_name)); - flushstr (last_tex_string); - println(); - writet1 (f,fm_cur); - printnl(maketexstring("%%EndResource")); - flushstr (last_tex_string); - println(); - } - return 1; -} - diff --git a/Build/source/texk/web2c/mpdir/writet1.c b/Build/source/texk/web2c/mpdir/writet1.c deleted file mode 100644 index 3823a7650da..00000000000 --- a/Build/source/texk/web2c/mpdir/writet1.c +++ /dev/null @@ -1,1732 +0,0 @@ -/* Copyright (c) 2006 Taco Hoekwater - -This file is part of MetaPost. - -MetaPost is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -MetaPost 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 MetaPost; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -$Id$ - -*/ - -static const char perforce_id[] = - "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writet1.c#25 $"; - -# include "mplib.h" -# define t1_open() \ - open_input(&t1_file, kpse_type1_format, FOPEN_RBIN_MODE) -# define enc_open() \ - open_input(&enc_file, kpse_enc_format, FOPEN_RBIN_MODE) -# define external_enc() (fm_cur->encoding)->glyph_names - -# define full_file_name() cur_file_name -# define get_length1() -# define get_length2() -# define get_length3() -# define is_used_char(c) mpcharmarked(tex_font, c) -# define out_eexec_char t1_outhex -# define save_offset() -# define end_last_eexec_line() \ - hexline_length = HEXLINE_WIDTH; \ - end_hexline(); \ - t1_eexec_encrypt = false -# define t1_log(s) mp_printf(s) -# define t1_putchar(c) fputc(c, bitfile) -# define embed_all_glyphs(tex_font) false -# undef pdfmovechars -# ifdef SHIFTLOWCHARS -extern char errbuf[]; -extern Boolean shiftlowchars; -# define pdfmovechars shiftlowchars -# define t1_char(c) T1Char(c) -# else /* SHIFTLOWCHARS */ -# define t1_char(c) c -# define pdfmovechars 0 -# endif /* SHIFTLOWCHARS */ -# define extra_charset() dvips_extra_charset -# define update_subset_tag() - -# define fixedcontent true - -static char *dvips_extra_charset; -static int hexline_length; -const char notdef[] = ".notdef"; -/* static size_t last_ptr_index; */ - -#include -#include -#include - -#define t1_getchar() getc(t1_file) -#define t1_ungetchar(c) ungetc(c, t1_file) -#define t1_eof() feof(t1_file) -#define t1_close() xfclose(t1_file, cur_file_name) - -#define enc_getchar() getc(enc_file) -#define enc_eof() feof(enc_file) -#define enc_close() xfclose(enc_file, cur_file_name) - -#define valid_code(c) (c >= 0 && c < 256) - -static const char *standard_glyph_names[256] = - { notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - "space", "exclam", "quotedbl", "numbersign", - "dollar", "percent", "ampersand", "quoteright", "parenleft", - "parenright", "asterisk", "plus", "comma", "hyphen", "period", - "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", - "eight", "nine", "colon", "semicolon", "less", - "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", - "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", - "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", - "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", - "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", - "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", - notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, "exclamdown", "cent", - "sterling", "fraction", "yen", "florin", "section", "currency", - "quotesingle", "quotedblleft", "guillemotleft", - "guilsinglleft", "guilsinglright", "fi", "fl", notdef, "endash", - "dagger", "daggerdbl", "periodcentered", notdef, - "paragraph", "bullet", "quotesinglbase", "quotedblbase", - "quotedblright", "guillemotright", "ellipsis", "perthousand", - notdef, "questiondown", notdef, "grave", "acute", "circumflex", - "tilde", "macron", "breve", "dotaccent", "dieresis", notdef, - "ring", "cedilla", notdef, "hungarumlaut", "ogonek", "caron", "emdash", - notdef, notdef, notdef, notdef, notdef, notdef, - notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, - notdef, "AE", notdef, "ordfeminine", notdef, notdef, - notdef, notdef, "Lslash", "Oslash", "OE", "ordmasculine", notdef, - notdef, notdef, notdef, notdef, "ae", notdef, notdef, - notdef, "dotlessi", notdef, notdef, "lslash", "oslash", "oe", - "germandbls", notdef, notdef, notdef, notdef -}; - -static char charstringname[] = "/CharStrings"; - -char **t1_glyph_names; -char *t1_builtin_glyph_names[256]; -char charsetstr[0x4000]; -static boolean read_encoding_only; -static int t1_encoding; - -#define T1_BUF_SIZE 0x10 -#define ENC_BUF_SIZE 0x1000 - -#define ENC_STANDARD 0 -#define ENC_BUILTIN 1 - -#define CS_HSTEM 1 -#define CS_VSTEM 3 -#define CS_VMOVETO 4 -#define CS_RLINETO 5 -#define CS_HLINETO 6 -#define CS_VLINETO 7 -#define CS_RRCURVETO 8 -#define CS_CLOSEPATH 9 -#define CS_CALLSUBR 10 -#define CS_RETURN 11 -#define CS_ESCAPE 12 -#define CS_HSBW 13 -#define CS_ENDCHAR 14 -#define CS_RMOVETO 21 -#define CS_HMOVETO 22 -#define CS_VHCURVETO 30 -#define CS_HVCURVETO 31 -#define CS_1BYTE_MAX (CS_HVCURVETO + 1) - -#define CS_DOTSECTION CS_1BYTE_MAX + 0 -#define CS_VSTEM3 CS_1BYTE_MAX + 1 -#define CS_HSTEM3 CS_1BYTE_MAX + 2 -#define CS_SEAC CS_1BYTE_MAX + 6 -#define CS_SBW CS_1BYTE_MAX + 7 -#define CS_DIV CS_1BYTE_MAX + 12 -#define CS_CALLOTHERSUBR CS_1BYTE_MAX + 16 -#define CS_POP CS_1BYTE_MAX + 17 -#define CS_SETCURRENTPOINT CS_1BYTE_MAX + 33 -#define CS_2BYTE_MAX (CS_SETCURRENTPOINT + 1) -#define CS_MAX CS_2BYTE_MAX - -typedef unsigned char byte; - -typedef struct { - byte nargs; /* number of arguments */ - boolean bottom; /* take arguments from bottom of stack? */ - boolean clear; /* clear stack? */ - boolean valid; -} cc_entry; /* CharString Command */ - -typedef struct { - char *name; /* glyph name (or notdef for Subrs entry) */ - byte *data; - unsigned short len; /* length of the whole string */ - unsigned short cslen; /* length of the encoded part of the string */ - boolean used; - boolean valid; -} cs_entry; - -static unsigned short t1_dr, t1_er; -static const unsigned short t1_c1 = 52845, t1_c2 = 22719; -static unsigned short t1_cslen; -static short t1_lenIV; -static char enc_line[ENC_BUF_SIZE]; - -/* define t1_line_ptr, t1_line_array & t1_line_limit */ -typedef char t1_line_entry; -define_array (t1_line); - -/* define t1_buf_ptr, t1_buf_array & t1_buf_limit */ -typedef char t1_buf_entry; -define_array (t1_buf); - -static int cs_start; - -static cs_entry *cs_tab, *cs_ptr, *cs_notdef; -static char *cs_dict_start, *cs_dict_end; -static int cs_count, cs_size, cs_size_pos; - -static cs_entry *subr_tab; -static char *subr_array_start, *subr_array_end; -static int subr_max, subr_size, subr_size_pos; - -/* This list contains the begin/end tokens commonly used in the */ -/* /Subrs array of a Type 1 font. */ -static const char *cs_token_pairs_list[][2] = { - {" RD", "NP"}, - {" -|", "|"}, - {" RD", "noaccess put"}, - {" -|", "noaccess put"}, - {NULL, NULL} -}; -static const char **cs_token_pair; - -static boolean t1_pfa, t1_cs, t1_scan, t1_eexec_encrypt, t1_synthetic; -static int t1_in_eexec; /* 0 before eexec-encrypted, 1 during, 2 after */ -static long t1_block_length; -static int last_hexbyte; -static FILE *t1_file; -static FILE *enc_file; - -#define t1_prefix(s) str_prefix(t1_line_array, s) -#define t1_buf_prefix(s) str_prefix(t1_buf_array, s) -#define t1_suffix(s) str_suffix(t1_line_array, t1_line_ptr, s) -#define t1_buf_suffix(s) str_suffix(t1_buf_array, t1_buf_ptr, s) -#define t1_charstrings() strstr(t1_line_array, charstringname) -#define t1_subrs() t1_prefix("/Subrs") -#define t1_end_eexec() t1_suffix("mark currentfile closefile") -#define t1_cleartomark() t1_prefix("cleartomark") - - -#ifndef pdfTeX -# define HEXLINE_WIDTH 64 - -static void end_hexline () -{ - if (hexline_length == HEXLINE_WIDTH) { - fputs ("\n", bitfile); - hexline_length = 0; - } -} - -static void t1_outhex (byte b) -{ - static char *hexdigits = "0123456789ABCDEF"; - t1_putchar (hexdigits[b / 16]); - t1_putchar (hexdigits[b % 16]); - hexline_length += 2; - end_hexline (); -} -#endif /* pdfTeX */ - - -static void enc_getline (void) -{ - char *p; - int c; - restart: - if (enc_eof ()) - pdftex_fail ("unexpected end of file"); - p = enc_line; - do { - c = enc_getchar (); - append_char_to_buf (c, p, enc_line, ENC_BUF_SIZE); - } - while (c != 10); - append_eol (p, enc_line, ENC_BUF_SIZE); - if (p - enc_line < 2 || *enc_line == '%') - goto restart; -} - -void load_enc (char *enc_name, char **enc_encname, char **glyph_names) -{ - char buf[ENC_BUF_SIZE], *p, *r; - int names_count; - char *myname; - set_cur_file_name (enc_name); - if (!enc_open ()) { - pdftex_warn ("cannot open encoding file for reading"); - cur_file_name = NULL; - return; - } - t1_log ("{"); - t1_log (cur_file_name = full_file_name ()); - enc_getline (); - if (*enc_line != '/' || (r = strchr (enc_line, '[')) == NULL) { - remove_eol (r, enc_line); - pdftex_fail - ("invalid encoding vector (a name or `[' missing): `%s'", enc_line); - } - while (*(r-1)==' ') r--; /* strip trailing spaces from encoding name */ - myname = xmalloc(r-enc_line); - memcpy(myname,enc_line+1,(r-enc_line)-1); - *(myname+(r-enc_line-1))=0; - *enc_encname = myname; - while (*r!='[') r++; - r++; /* skip '[' */ - names_count = 0; - skip (r, ' '); - for (;;) { - while (*r == '/') { - for (p = buf, r++; - *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); - *p = 0; - skip (r, ' '); - if (names_count > 256) - pdftex_fail ("encoding vector contains more than 256 names"); - if (strcmp (buf, notdef) != 0) - glyph_names[names_count] = xstrdup (buf); - names_count++; - } - if (*r != 10 && *r != '%') { - if (str_prefix (r, "] def")) - goto done; - else { - remove_eol (r, enc_line); - pdftex_fail - ("invalid encoding vector: a name or `] def' expected: `%s'", - enc_line); - } - } - enc_getline (); - r = enc_line; - } - done: - enc_close (); - t1_log ("}"); - cur_file_name = NULL; -} - -static void t1_check_pfa (void) -{ - const int c = t1_getchar (); - t1_pfa = (c != 128) ? true : false; - t1_ungetchar (c); -} - -static int t1_getbyte (void) -{ - int c = t1_getchar (); - if (t1_pfa) - return c; - if (t1_block_length == 0) { - if (c != 128) - pdftex_fail ("invalid marker"); - c = t1_getchar (); - if (c == 3) { - while (!t1_eof ()) - t1_getchar (); - return EOF; - } - t1_block_length = t1_getchar () & 0xff; - t1_block_length |= (t1_getchar () & 0xff) << 8; - t1_block_length |= (t1_getchar () & 0xff) << 16; - t1_block_length |= (t1_getchar () & 0xff) << 24; - c = t1_getchar (); - } - t1_block_length--; - return c; -} - -static int hexval (int c) -{ - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - else if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - else if (c >= '0' && c <= '9') - return c - '0'; - else - return -1; -} - -static byte edecrypt (byte cipher) -{ - byte plain; - if (t1_pfa) { - while (cipher == 10 || cipher == 13) - cipher = t1_getbyte (); - last_hexbyte = cipher = (hexval (cipher) << 4) + hexval (t1_getbyte ()); - } - plain = (cipher ^ (t1_dr >> 8)); - t1_dr = (cipher + t1_dr) * t1_c1 + t1_c2; - return plain; -} - -static byte cdecrypt (byte cipher, unsigned short *cr) -{ - const byte plain = (cipher ^ (*cr >> 8)); - *cr = (cipher + *cr) * t1_c1 + t1_c2; - return plain; -} - -static byte eencrypt (byte plain) -{ - const byte cipher = (plain ^ (t1_er >> 8)); - t1_er = (cipher + t1_er) * t1_c1 + t1_c2; - return cipher; -} - -static byte cencrypt (byte plain, unsigned short *cr) -{ - const byte cipher = (plain ^ (*cr >> 8)); - *cr = (cipher + *cr) * t1_c1 + t1_c2; - return cipher; -} - -static char *eol (char *s) -{ - char *p = strend (s); - if (p - s > 1 && p[-1] != 10) { - *p++ = 10; - *p = 0; - } - return p; -} - -static float t1_scan_num (char *p, char **r) -{ - float f; - skip (p, ' '); - if (sscanf (p, "%g", &f) != 1) { - remove_eol (p, t1_line_array); - pdftex_fail ("a number expected: `%s'", t1_line_array); - } - if (r != NULL) { - for (; isdigit (*p) || *p == '.' || - *p == 'e' || *p == 'E' || *p == '+' || *p == '-'; p++); - *r = p; - } - return f; -} - -static boolean str_suffix (const char *begin_buf, const char *end_buf, - const char *s) -{ - const char *s1 = end_buf - 1, *s2 = strend (s) - 1; - if (*s1 == 10) - s1--; - while (s1 >= begin_buf && s2 >= s) { - if (*s1-- != *s2--) - return false; - } - return s2 < s; -} - -static void t1_getline (void) -{ - int c, l, eexec_scan; - char *p; - static const char eexec_str[] = "currentfile eexec"; - static int eexec_len = 17; /* strlen(eexec_str) */ - restart: - if (t1_eof ()) - pdftex_fail ("unexpected end of file"); - t1_line_ptr = t1_line_array; - alloc_array (t1_line, 1, T1_BUF_SIZE); - t1_cslen = 0; - eexec_scan = 0; - c = t1_getbyte (); - if (c == EOF) - goto exit; - while (!t1_eof ()) { - if (t1_in_eexec == 1) - c = edecrypt (c); - alloc_array (t1_line, 1, T1_BUF_SIZE); - append_char_to_buf (c, t1_line_ptr, t1_line_array, t1_line_limit); - if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) { - if (t1_line_array[eexec_scan] == eexec_str[eexec_scan]) - eexec_scan++; - else - eexec_scan = -1; - } - if (c == 10 || (t1_pfa && eexec_scan == eexec_len && c == 32)) - break; - if (t1_cs && t1_cslen == 0 && (t1_line_ptr - t1_line_array > 4) && - (t1_suffix (" RD ") || t1_suffix (" -| "))) { - p = t1_line_ptr - 5; - while (*p != ' ') - p--; - t1_cslen = l = t1_scan_num (p + 1, 0); - cs_start = t1_line_ptr - t1_line_array; /* cs_start is an index now */ - alloc_array (t1_line, l, T1_BUF_SIZE); - while (l-- > 0) - *t1_line_ptr++ = edecrypt (t1_getbyte ()); - } - c = t1_getbyte (); - } - alloc_array (t1_line, 2, T1_BUF_SIZE); /* append_eol can append 2 chars */ - append_eol (t1_line_ptr, t1_line_array, t1_line_limit); - if (t1_line_ptr - t1_line_array < 2) - goto restart; - if (eexec_scan == eexec_len) - t1_in_eexec = 1; - exit: - /* ensure that t1_buf_array has as much room as t1_line_array */ - t1_buf_ptr = t1_buf_array; - alloc_array (t1_buf, t1_line_limit, t1_line_limit); -} - -static void t1_putline (void) -{ - char *p = t1_line_array; - if (t1_line_ptr - t1_line_array <= 1) - return; - if (t1_eexec_encrypt) { - while (p < t1_line_ptr) - out_eexec_char (eencrypt (*p++)); - } else { - while (p < t1_line_ptr) - t1_putchar (*p++); - } -} - -static void t1_puts (const char *s) -{ - if (s != t1_line_array) - strcpy (t1_line_array, s); - t1_line_ptr = strend (t1_line_array); - t1_putline (); -} - -static void t1_printf (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - vsprintf (t1_line_array, fmt, args); - t1_puts (t1_line_array); - va_end (args); -} - -static void t1_init_params (const char *open_name_prefix) -{ - if ((open_name_prefix != NULL) && strlen(open_name_prefix)) { - t1_log (open_name_prefix); - t1_log (cur_file_name); - } - t1_lenIV = 4; - t1_dr = 55665; - t1_er = 55665; - t1_in_eexec = 0; - t1_cs = false; - t1_scan = true; - t1_synthetic = false; - t1_eexec_encrypt = false; - t1_block_length = 0; - t1_check_pfa (); -} - -static void t1_close_font_file (const char *close_name_suffix) -{ - if ((close_name_suffix != NULL) && strlen(close_name_suffix)) { - t1_log (close_name_suffix); - } - t1_close (); - cur_file_name = NULL; -} - -static void t1_check_block_len (boolean decrypt) -{ - int l, c; - if (t1_block_length == 0) - return; - c = t1_getbyte (); - if (decrypt) - c = edecrypt (c); - l = t1_block_length; - if (!(l == 0 && (c == 10 || c == 13))) { - pdftex_warn ("%i bytes more than expected were ignored", l + 1); - while (l-- > 0) - t1_getbyte (); - } -} - -static void t1_start_eexec (fm_entry *fm_cur) -{ - int i; - if (is_included (fm_cur)) { - get_length1 (); - save_offset (); - } - if (!t1_pfa) - t1_check_block_len (false); - for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { - edecrypt (t1_getbyte ()); - *t1_line_ptr++ = 0; - } - t1_eexec_encrypt = true; - if (!read_encoding_only) - if (is_included (fm_cur)) - t1_putline (); /* to put the first four bytes */ -} - -static void t1_stop_eexec (fm_entry *fm_cur) -{ - int c; - if (is_included (fm_cur)) { - get_length2 (); - save_offset (); - } - end_last_eexec_line (); - if (!t1_pfa) - t1_check_block_len (true); - else { - c = edecrypt (t1_getbyte ()); - if (!(c == 10 || c == 13)) { - if (last_hexbyte == 0) - t1_puts ("00"); - else - pdftex_warn ("unexpected data after eexec"); - } - } - t1_cs = false; - t1_in_eexec = 2; -} - -#ifdef pdfTeX -/* macros for various transforms; currently only slant and extend are used */ -# define do_xshift(x,a) {x[4]+=a;} -# define do_yshift(x,a) {x[5]+=a;} -# define do_xscale(x,a) {x[0]*=a; x[2]*=a; x[4]*=a;} -# define do_yscale(x,a) {x[1]*=a; x[3]*=a; x[5]*=a;} -# define do_extend(x,a) {do_xscale(x,a);} -# define do_scale(x,a) {do_xscale(x,a); do_yscale(x,a);} -# define do_slant(x,a) {x[0]+=x[1]*(a); x[2]+=x[3]*(a); x[4]+=x[5]*(a);} -# define do_shear(x,a) {x[1]+=x[0]*(a); x[3]+=x[2]*(a); x[5]+=x[4]*(a);} -# define do_rotate(x,a) \ - {float t, u=cos(a), v=sin(a); \ - t =x[0]*u+x[1]*-v; \ - x[1] =x[0]*v+x[1]* u; x[0]=t; \ - t =x[2]*u+x[3]*-v; \ - x[3] =x[2]*v+x[3]* u; x[2]=t; \ - t =x[4]*u+x[5]*-v; \ - x[5] =x[4]*v+x[5]* u; x[4]=t;} - -static void t1_modify_fm (void) -{ - /* - * font matrix is given as six numbers a0..a5, which stands for the matrix - * - * a0 a1 0 - * M = a2 a3 0 - * a4 a5 1 - * - * ExtendFont is given as - * - * e 0 0 - * E = 0 1 0 - * 0 0 1 - * - * SlantFont is given as - * - * 1 0 0 - * S = s 1 0 - * 0 0 1 - * - * The slant transform must be done _before_ the extend transform - * for compatibility! - */ - float a[6]; - int i, c; - char *p, *q, *r; - if ((p = strchr (t1_line_array, '[')) == 0) - if ((p = strchr (t1_line_array, '{')) == 0) { - remove_eol (p, t1_line_array); - pdftex_fail ("FontMatrix: an array expected: `%s'", t1_line_array); - } - c = *p++; /* save the character '[' resp. '{' */ - strncpy (t1_buf_array, t1_line_array, (size_t) (p - t1_line_array)); - r = t1_buf_array + (p - t1_line_array); - for (i = 0; i < 6; i++) { - a[i] = t1_scan_num (p, &q); - p = q; - } - if (fm_slant (fm_cur) != 0) - do_slant (a, fm_slant (fm_cur) * 1E-3); - if (fm_extend (fm_cur) != 0) - do_extend (a, fm_extend (fm_cur) * 1E-3); - for (i = 0; i < 6; i++) { - sprintf (r, "%g ", a[i]); - r = strend (r); - } - if (c == '[') { - while (*p != ']' && *p != 0) - p++; - } else { - while (*p != '}' && *p != 0) - p++; - } - if (*p == 0) { - remove_eol (p, t1_line_array); - pdftex_fail - ("FontMatrix: cannot find the corresponding character to '%c': `%s'", - c, t1_line_array); - } - strcpy (r, p); - strcpy (t1_line_array, t1_buf_array); - t1_line_ptr = eol (t1_line_array); -} - -static void t1_modify_italic (void) -{ - float a; - char *p, *r; - if (fm_slant (fm_cur) == 0) - return; - p = strchr (t1_line_array, ' '); - strncpy (t1_buf_array, t1_line_array, (size_t) (p - t1_line_array + 1)); - a = t1_scan_num (p + 1, &r); - a -= atan (fm_slant (fm_cur) * 1E-3) * (180 / M_PI); - sprintf (t1_buf_array + (p - t1_line_array + 1), "%g", a); - strcpy (strend (t1_buf_array), r); - strcpy (t1_line_array, t1_buf_array); - t1_line_ptr = eol (t1_line_array); - font_keys[ITALIC_ANGLE_CODE].value = round (a); - font_keys[ITALIC_ANGLE_CODE].valid = true; -} - -#else - -static void t1_modify_fm (void) -{ - // t1_line_ptr = eol (t1_line_array); -} - -static void t1_modify_italic (void) -{ - // t1_line_ptr = eol (t1_line_array); -} - -#endif /* pdfTeX */ - -key_entry font_keys[FONT_KEYS_NUM] = { - {"Ascent", "Ascender", 0, false}, - {"CapHeight", "CapHeight", 0, false}, - {"Descent", "Descender", 0, false}, - {"FontName", "FontName", 0, false}, - {"ItalicAngle", "ItalicAngle", 0, false}, - {"StemV", "StdVW", 0, false}, - {"XHeight", "XHeight", 0, false}, - {"FontBBox", "FontBBox", 0, false}, - {"", "", 0, false}, - {"", "", 0, false}, - {"", "", 0, false} -}; - - -static void t1_scan_keys (int tex_font,fm_entry *fm_cur) -{ - int i, k; - char *p, *r; - key_entry *key; - if (fm_extend (fm_cur) != 0 || fm_slant (fm_cur) != 0) { - if (t1_prefix ("/FontMatrix")) { - t1_modify_fm (); - return; - } - if (t1_prefix ("/ItalicAngle")) { - t1_modify_italic (); - return; - } - } - if (t1_prefix ("/FontType")) { - p = t1_line_array + strlen ("FontType") + 1; - if ((i = t1_scan_num (p, 0)) != 1) - pdftex_fail ("Type%d fonts unsupported by metapost", i); - return; - } - for (key = font_keys; key - font_keys < MAX_KEY_CODE; key++) - if (str_prefix (t1_line_array + 1, key->t1name)) - break; - if (key - font_keys == MAX_KEY_CODE) - return; - key->valid = true; - p = t1_line_array + strlen (key->t1name) + 1; - skip (p, ' '); - if ((k = key - font_keys) == FONTNAME_CODE) { - if (*p != '/') { - remove_eol (p, t1_line_array); - pdftex_fail ("a name expected: `%s'", t1_line_array); - } - r = ++p; /* skip the slash */ - if (is_included (fm_cur)) { - /* save the fontname */ - strncpy (fontname_buf, p, FONTNAME_BUF_SIZE); - for (i=0; fontname_buf[i] != 10; i++); - fontname_buf[i]=0; - - if(is_subsetted (fm_cur)) { - if (fm_cur->encoding!=NULL && fm_cur->encoding->glyph_names!=NULL) - make_subset_tag (fm_cur, fm_cur->encoding->glyph_names, tex_font); - else - make_subset_tag (fm_cur, t1_builtin_glyph_names, tex_font); - - alloc_array (t1_line, (r-t1_line_array+6+1+strlen(fontname_buf)+1), T1_BUF_SIZE); - strncpy (r, fm_cur->subset_tag , 6); - *(r+6) = '-'; - strncpy (r+7, fontname_buf, strlen(fontname_buf)+1); - t1_line_ptr = eol (r); - } else { - /* for (q = p; *q != ' ' && *q != 10; *q++);*/ - /**q = 0;*/ - t1_line_ptr = eol (r); - } - } - return; - } - if ((k == STEMV_CODE || k == FONTBBOX1_CODE) - && (*p == '[' || *p == '{')) - p++; - if (k == FONTBBOX1_CODE) { - for (i = 0; i < 4; i++) { - key[i].value = t1_scan_num (p, &r); - p = r; - } - return; - } - key->value = t1_scan_num (p, 0); -} - -static void t1_scan_param (int tex_font,fm_entry *fm_cur) -{ - static const char *lenIV = "/lenIV"; - if (!t1_scan || *t1_line_array != '/') - return; - if (t1_prefix (lenIV)) { - t1_lenIV = t1_scan_num (t1_line_array + strlen (lenIV), 0); - return; - } - t1_scan_keys (tex_font,fm_cur); -} - -static void copy_glyph_names (char **glyph_names, int a, int b) -{ - if (glyph_names[b] != notdef) { - free (glyph_names[b]); - glyph_names[b] = (char *) notdef; - } - if (glyph_names[a] != notdef) { - glyph_names[b] = xstrdup (glyph_names[a]); - } -} - -static void t1_builtin_enc (void) -{ - int i, a, b, c, counter = 0; - char *r, *p; - /* - * At this moment "/Encoding" is the prefix of t1_line_array - */ - if (t1_suffix ("def")) { /* predefined encoding */ - sscanf (t1_line_array + strlen ("/Encoding"), "%256s", t1_buf_array); - if (strcmp (t1_buf_array, "StandardEncoding") == 0) { - for (i = 0; i < 256; i++) - if (standard_glyph_names[i] == notdef) - t1_builtin_glyph_names[i] = (char *) notdef; - else - t1_builtin_glyph_names[i] = - xstrdup (standard_glyph_names[i]); - t1_encoding = ENC_STANDARD; - } else - pdftex_fail - ("cannot subset font (unknown predefined encoding `%s')", - t1_buf_array); - return; - } else - t1_encoding = ENC_BUILTIN; - /* - * At this moment "/Encoding" is the prefix of t1_line_array, and the encoding is - * not a predefined encoding - * - * We have two possible forms of Encoding vector. The first case is - * - * /Encoding [/a /b /c...] readonly def - * - * and the second case can look like - * - * /Encoding 256 array 0 1 255 {1 index exch /.notdef put} for - * dup 0 /x put - * dup 1 /y put - * ... - * readonly def - */ - for (i = 0; i < 256; i++) - t1_builtin_glyph_names[i] = (char *) notdef; - if (t1_prefix ("/Encoding [") || t1_prefix ("/Encoding[")) { /* the first case */ - r = strchr (t1_line_array, '[') + 1; - skip (r, ' '); - for (;;) { - while (*r == '/') { - for (p = t1_buf_array, r++; - *r != 32 && *r != 10 && *r != ']' && *r != '/'; - *p++ = *r++); - *p = 0; - skip (r, ' '); - if (counter > 255) - pdftex_fail - ("encoding vector contains more than 256 names"); - if (strcmp (t1_buf_array, notdef) != 0) - t1_builtin_glyph_names[counter] = xstrdup (t1_buf_array); - counter++; - } - if (*r != 10 && *r != '%') { - if (str_prefix (r, "] def") - || str_prefix (r, "] readonly def")) - break; - else { - remove_eol (r, t1_line_array); - pdftex_fail - ("a name or `] def' or `] readonly def' expected: `%s'", - t1_line_array); - } - } - t1_getline (); - r = t1_line_array; - } - } else { /* the second case */ - p = strchr (t1_line_array, 10); - for (;;) { - if (*p == 10) { - t1_getline (); - p = t1_line_array; - } - /* - check for `dup put' - */ - if (sscanf (p, "dup %i%256s put", &i, t1_buf_array) == 2 && - *t1_buf_array == '/' && valid_code (i)) { - if (strcmp (t1_buf_array + 1, notdef) != 0) - t1_builtin_glyph_names[i] = xstrdup (t1_buf_array + 1); - p = strstr (p, " put") + strlen (" put"); - skip (p, ' '); - } - /* - check for `dup dup exch get put' - */ - else if (sscanf (p, "dup dup %i exch %i get put", &b, &a) == 2 - && valid_code (a) && valid_code (b)) { - copy_glyph_names (t1_builtin_glyph_names, a, b); - p = strstr (p, " get put") + strlen (" get put"); - skip (p, ' '); - } - /* - check for `dup dup getinterval exch putinterval' - */ - else if (sscanf - (p, "dup dup %i %i getinterval %i exch putinterval", - &a, &c, &b) == 3 && valid_code (a) && valid_code (b) - && valid_code (c)) { - for (i = 0; i < c; i++) - copy_glyph_names (t1_builtin_glyph_names, a + i, b + i); - p = strstr (p, " putinterval") + strlen (" putinterval"); - skip (p, ' '); - } - /* - check for `def' or `readonly def' - */ - else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) - && strcmp (p, "def\n") == 0) - return; - /* - skip an unrecognizable word - */ - else { - while (*p != ' ' && *p != 10) - p++; - skip (p, ' '); - } - } - } -} - -static void t1_check_end (void) -{ - if (t1_eof ()) - return; - t1_getline (); - if (t1_prefix ("{restore}")) - t1_putline (); -} - -static boolean t1_open_fontfile (fm_entry *fm_cur,const char *open_name_prefix) -{ - ff_entry *ff; - ff = check_ff_exist (fm_cur); - if (ff->ff_path != NULL) - t1_file = xfopen (cur_file_name = ff->ff_path, FOPEN_RBIN_MODE); - else { - set_cur_file_name (fm_cur->ff_name); - pdftex_warn ("cannot open Type 1 font file for reading"); - return false; - } - t1_init_params (open_name_prefix); - fontfile_found = true; - return true; -} - -static void t1_scan_only (int tex_font, fm_entry *fm_cur) -{ - do { - t1_getline (); - t1_scan_param (tex_font, fm_cur); - } - while (t1_in_eexec == 0); - t1_start_eexec (fm_cur); - do { - t1_getline (); - t1_scan_param (tex_font, fm_cur); - } - while (!(t1_charstrings () || t1_subrs ())); -} - -static void t1_include (int tex_font, fm_entry *fm_cur) -{ - do { - t1_getline (); - t1_scan_param (tex_font, fm_cur); - t1_putline (); - } - while (t1_in_eexec == 0); - t1_start_eexec (fm_cur); - do { - t1_getline (); - t1_scan_param (tex_font, fm_cur); - t1_putline (); - } - while (!(t1_charstrings () || t1_subrs ())); - t1_cs = true; - do { - t1_getline (); - t1_putline (); - } - while (!t1_end_eexec ()); - t1_stop_eexec (fm_cur); - if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ - do { - t1_getline (); - t1_putline (); - } - while (!t1_cleartomark ()); - t1_check_end (); /* write "{restore}if" if found */ - } - get_length3 (); -} - -#define check_subr(subr) \ - if (subr >= subr_size || subr < 0) \ - pdftex_fail("Subrs array: entry index out of range (%i)", subr); - -static const char **check_cs_token_pair () -{ - const char **p = (const char **) cs_token_pairs_list; - for (; p[0] != NULL; ++p) - if (t1_buf_prefix (p[0]) && t1_buf_suffix (p[1])) - return p; - return NULL; -} - -static void cs_store (boolean is_subr) -{ - char *p; - cs_entry *ptr; - int subr; - for (p = t1_line_array, t1_buf_ptr = t1_buf_array; *p != ' '; - *t1_buf_ptr++ = *p++); - *t1_buf_ptr = 0; - if (is_subr) { - subr = t1_scan_num (p + 1, 0); - check_subr (subr); - ptr = subr_tab + subr; - } else { - ptr = cs_ptr++; - if (cs_ptr - cs_tab > cs_size) - pdftex_fail - ("CharStrings dict: more entries than dict size (%i)", cs_size); - if (strcmp (t1_buf_array + 1, notdef) == 0) /* skip the slash */ - ptr->name = (char *) notdef; - else - ptr->name = xstrdup (t1_buf_array + 1); - } - /* copy " RD " + cs data to t1_buf_array */ - memcpy (t1_buf_array, t1_line_array + cs_start - 4, - (unsigned) (t1_cslen + 4)); - /* copy the end of cs data to t1_buf_array */ - for (p = t1_line_array + cs_start + t1_cslen, t1_buf_ptr = - t1_buf_array + t1_cslen + 4; *p != 10; *t1_buf_ptr++ = *p++); - *t1_buf_ptr++ = 10; - if (is_subr && cs_token_pair == NULL) - cs_token_pair = check_cs_token_pair (); - ptr->len = t1_buf_ptr - t1_buf_array; - ptr->cslen = t1_cslen; - ptr->data = xtalloc (ptr->len, byte); - memcpy (ptr->data, t1_buf_array, ptr->len); - ptr->valid = true; -} - -#define store_subr() cs_store(true) -#define store_cs() cs_store(false) - -#define CC_STACK_SIZE 24 - -static integer cc_stack[CC_STACK_SIZE], *stack_ptr = cc_stack; -static cc_entry cc_tab[CS_MAX]; -static boolean is_cc_init = false; - - -#define cc_pop(N) \ - if (stack_ptr - cc_stack < (N)) \ - stack_error(N); \ - stack_ptr -= N - -#define stack_error(N) { \ - pdftex_warn("CharString: invalid access (%i) to stack (%i entries)", \ - (int) N, (int)(stack_ptr - cc_stack)); \ - goto cs_error; \ -} - -/* -static integer cc_get(integer index) -{ - if (index < 0) { - if (stack_ptr + index < cc_stack ) - stack_error(stack_ptr - cc_stack + index); - return *(stack_ptr + index); - } - else { - if (cc_stack + index >= stack_ptr) - stack_error(index); - return cc_stack[index]; - } -} -*/ - -#define cc_get(N) ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N))) - -#define cc_push(V) *stack_ptr++ = V -#define cc_clear() stack_ptr = cc_stack - -#define set_cc(N, B, A, C) \ - cc_tab[N].nargs = A; \ - cc_tab[N].bottom = B; \ - cc_tab[N].clear = C; \ - cc_tab[N].valid = true - -static void cc_init (void) -{ - int i; - if (is_cc_init) - return; - for (i = 0; i < CS_MAX; i++) - cc_tab[i].valid = false; - set_cc (CS_HSTEM, true, 2, true); - set_cc (CS_VSTEM, true, 2, true); - set_cc (CS_VMOVETO, true, 1, true); - set_cc (CS_RLINETO, true, 2, true); - set_cc (CS_HLINETO, true, 1, true); - set_cc (CS_VLINETO, true, 1, true); - set_cc (CS_RRCURVETO, true, 6, true); - set_cc (CS_CLOSEPATH, false, 0, true); - set_cc (CS_CALLSUBR, false, 1, false); - set_cc (CS_RETURN, false, 0, false); - /* - set_cc(CS_ESCAPE, false, 0, false); - */ - set_cc (CS_HSBW, true, 2, true); - set_cc (CS_ENDCHAR, false, 0, true); - set_cc (CS_RMOVETO, true, 2, true); - set_cc (CS_HMOVETO, true, 1, true); - set_cc (CS_VHCURVETO, true, 4, true); - set_cc (CS_HVCURVETO, true, 4, true); - set_cc (CS_DOTSECTION, false, 0, true); - set_cc (CS_VSTEM3, true, 6, true); - set_cc (CS_HSTEM3, true, 6, true); - set_cc (CS_SEAC, true, 5, true); - set_cc (CS_SBW, true, 4, true); - set_cc (CS_DIV, false, 2, false); - set_cc (CS_CALLOTHERSUBR, false, 0, false); - set_cc (CS_POP, false, 0, false); - set_cc (CS_SETCURRENTPOINT, true, 2, true); - is_cc_init = true; -} - -#define cs_getchar() cdecrypt(*data++, &cr) - -#define mark_subr(n) cs_mark(0, n) -#define mark_cs(s) cs_mark(s, 0) - -static void cs_warn (const char *cs_name, int subr, const char *fmt, ...) -{ - char buf[SMALL_BUF_SIZE]; - va_list args; - va_start (args, fmt); - vsprintf (buf, fmt, args); - va_end (args); - if (cs_name == NULL) - pdftex_warn ("Subr (%i): %s", (int) subr, buf); - else - pdftex_warn ("CharString (/%s): %s", cs_name, buf); -} - -static void cs_mark (const char *cs_name, int subr) -{ - byte *data; - int i, b, cs_len; - integer a, a1, a2; - unsigned short cr; - static integer lastargOtherSubr3 = 3; /* the argument of last call to - OtherSubrs[3] */ - cs_entry *ptr; - cc_entry *cc; - if (cs_name == NULL) { - check_subr (subr); - ptr = subr_tab + subr; - if (!ptr->valid) - return; - } else { - if (cs_notdef != NULL && - (cs_name == notdef || strcmp (cs_name, notdef) == 0)) - ptr = cs_notdef; - else { - for (ptr = cs_tab; ptr < cs_ptr; ptr++) - if (strcmp (ptr->name, cs_name) == 0) - break; - if (ptr == cs_ptr) { - pdftex_warn ("glyph `%s' undefined", cs_name); - return; - } - if (ptr->name == notdef) - cs_notdef = ptr; - } - } - /* only marked CharString entries and invalid entries can be skipped; - valid marked subrs must be parsed to keep the stack in sync */ - if (!ptr->valid || (ptr->used && cs_name != NULL)) - return; - ptr->used = true; - cr = 4330; - cs_len = ptr->cslen; - data = ptr->data + 4; - for (i = 0; i < t1_lenIV; i++, cs_len--) - cs_getchar (); - while (cs_len > 0) { - --cs_len; - b = cs_getchar (); - if (b >= 32) { - if (b <= 246) - a = b - 139; - else if (b <= 250) { - --cs_len; - a = ((b - 247) << 8) + 108 + cs_getchar (); - } else if (b <= 254) { - --cs_len; - a = -((b - 251) << 8) - 108 - cs_getchar (); - } else { - cs_len -= 4; - a = (cs_getchar () & 0xff) << 24; - a |= (cs_getchar () & 0xff) << 16; - a |= (cs_getchar () & 0xff) << 8; - a |= (cs_getchar () & 0xff) << 0; - if (sizeof (integer) > 4 && (a & 0x80000000)) - a |= ~0x7FFFFFFF; - } - cc_push (a); - } else { - if (b == CS_ESCAPE) { - b = cs_getchar () + CS_1BYTE_MAX; - cs_len--; - } - if (b >= CS_MAX) { - cs_warn (cs_name, subr, "command value out of range: %i", - (int) b); - goto cs_error; - } - cc = cc_tab + b; - if (!cc->valid) { - cs_warn (cs_name, subr, "command not valid: %i", (int) b); - goto cs_error; - } - if (cc->bottom) { - if (stack_ptr - cc_stack < cc->nargs) - cs_warn (cs_name, subr, - "less arguments on stack (%i) than required (%i)", - (int) (stack_ptr - cc_stack), (int) cc->nargs); - else if (stack_ptr - cc_stack > cc->nargs) - cs_warn (cs_name, subr, - "more arguments on stack (%i) than required (%i)", - (int) (stack_ptr - cc_stack), (int) cc->nargs); - } - switch (cc - cc_tab) { - case CS_CALLSUBR: - a1 = cc_get (-1); - cc_pop (1); - mark_subr (a1); - if (!subr_tab[a1].valid) { - cs_warn (cs_name, subr, "cannot call subr (%i)", (int) a1); - goto cs_error; - } - break; - case CS_DIV: - cc_pop (2); - cc_push (0); - break; - case CS_CALLOTHERSUBR: - if (cc_get (-1) == 3) - lastargOtherSubr3 = cc_get (-3); - a1 = cc_get (-2) + 2; - cc_pop (a1); - break; - case CS_POP: - cc_push (lastargOtherSubr3); - /* the only case when we care about the value being pushed onto - stack is when POP follows CALLOTHERSUBR (changing hints by - OtherSubrs[3]) - */ - break; - case CS_SEAC: - a1 = cc_get (3); - a2 = cc_get (4); - cc_clear (); - mark_cs (standard_glyph_names[a1]); - mark_cs (standard_glyph_names[a2]); - break; - default: - if (cc->clear) - cc_clear (); - } - } - } - return; - cs_error: /* an error occured during parsing */ - cc_clear (); - ptr->valid = false; - ptr->used = false; -} - -static void t1_subset_ascii_part (int tex_font, fm_entry *fm_cur) -{ - int i, j; - t1_getline (); - while (!t1_prefix ("/Encoding")) { - t1_scan_param (tex_font, fm_cur); - t1_putline (); - t1_getline (); - } - t1_builtin_enc (); - if (is_reencoded (fm_cur)) - t1_glyph_names = external_enc (); - else - t1_glyph_names = t1_builtin_glyph_names; - /* - if (is_included (fm_cur) && is_subsetted (fm_cur)) { - make_subset_tag (fm_cur, t1_glyph_names, tex_font); - update_subset_tag (); - } - */ - if ((!is_subsetted (fm_cur)) && t1_encoding == ENC_STANDARD) - t1_puts ("/Encoding StandardEncoding def\n"); - else { - t1_puts - ("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); - for (i = 0, j = 0; i < 256; i++) { - if (is_used_char (i) && t1_glyph_names[i] != notdef) { - j++; - t1_printf ("dup %i /%s put\n", (int) t1_char (i), - t1_glyph_names[i]); - } - } - /* We didn't mark anything for the Encoding array. */ - /* We add "dup 0 /.notdef put" for compatibility */ - /* with Acrobat 5.0. */ - if (j == 0) - t1_puts ("dup 0 /.notdef put\n"); - t1_puts ("readonly def\n"); - } - do { - t1_getline (); - t1_scan_param (tex_font, fm_cur); - if (!t1_prefix ("/UniqueID")) /* ignore UniqueID for subsetted fonts */ - t1_putline (); - } - while (t1_in_eexec == 0); -} - -#define t1_subr_flush() t1_flush_cs(true) -#define t1_cs_flush() t1_flush_cs(false) - -static void t1_flush_cs (boolean); - -static void cs_init (void) -{ - cs_ptr = cs_tab = NULL; - cs_dict_start = cs_dict_end = NULL; - cs_count = cs_size = cs_size_pos = 0; - cs_token_pair = NULL; - subr_tab = NULL; - subr_array_start = subr_array_end = NULL; - subr_max = subr_size = subr_size_pos = 0; -} - -static void init_cs_entry (cs_entry * cs) -{ - cs->data = NULL; - cs->name = NULL; - cs->len = 0; - cs->cslen = 0; - cs->used = false; - cs->valid = false; -} - -static void t1_mark_glyphs (int tex_font); - -static void t1_read_subrs (int tex_font, fm_entry *fm_cur) -{ - int i, s; - cs_entry *ptr; - t1_getline (); - while (!(t1_charstrings () || t1_subrs ())) { - t1_scan_param (tex_font, fm_cur); - t1_putline (); - t1_getline (); - } - found: - t1_cs = true; - t1_scan = false; - if (!t1_subrs ()) - return; - subr_size_pos = strlen ("/Subrs") + 1; - /* subr_size_pos points to the number indicating dict size after "/Subrs" */ - subr_size = t1_scan_num (t1_line_array + subr_size_pos, 0); - if (subr_size == 0) { - while (!t1_charstrings ()) - t1_getline (); - return; - } - // subr_tab = xtalloc (subr_size, cs_entry); - subr_tab = (cs_entry *)malloc (subr_size*sizeof (cs_entry)); - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - init_cs_entry (ptr); - subr_array_start = xstrdup (t1_line_array); - t1_getline (); - while (t1_cslen) { - store_subr (); - t1_getline (); - } - /* mark the first four entries without parsing */ - for (i = 0; i < subr_size && i < 4; i++) - subr_tab[i].used = true; - /* the end of the Subrs array might have more than one line so we need to - concatnate them to subr_array_end. Unfortunately some fonts don't have - the Subrs array followed by the CharStrings dict immediately (synthetic - fonts). If we cannot find CharStrings in next POST_SUBRS_SCAN lines then - we will treat the font as synthetic and ignore everything until next - Subrs is found - */ -#define POST_SUBRS_SCAN 5 - s = 0; - *t1_buf_array = 0; - for (i = 0; i < POST_SUBRS_SCAN; i++) { - if (t1_charstrings ()) - break; - s += t1_line_ptr - t1_line_array; - alloc_array (t1_buf, s, T1_BUF_SIZE); - strcat (t1_buf_array, t1_line_array); - t1_getline (); - } - subr_array_end = xstrdup (t1_buf_array); - if (i == POST_SUBRS_SCAN) { /* CharStrings not found; - suppose synthetic font */ - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->valid) - xfree (ptr->data); - xfree (subr_tab); - xfree (subr_array_start); - xfree (subr_array_end); - cs_init (); - t1_cs = false; - t1_synthetic = true; - while (!(t1_charstrings () || t1_subrs ())) - t1_getline (); - goto found; - } -} - -static void t1_flush_cs (boolean is_subr) -{ - char *p; - byte *r, *return_cs = NULL; - cs_entry *tab, *end_tab, *ptr; - char *start_line, *line_end; - int count, size_pos; - unsigned short cr, cs_len = 0; /* to avoid warning about uninitialized use of cs_len */ - if (is_subr) { - start_line = subr_array_start; - line_end = subr_array_end; - size_pos = subr_size_pos; - tab = subr_tab; - count = subr_max + 1; - end_tab = subr_tab + count; - } else { - start_line = cs_dict_start; - line_end = cs_dict_end; - size_pos = cs_size_pos; - tab = cs_tab; - end_tab = cs_ptr; - count = cs_count; - } - t1_line_ptr = t1_line_array; - for (p = start_line; p - start_line < size_pos;) - *t1_line_ptr++ = *p++; - while (isdigit (*p)) - p++; - sprintf (t1_line_ptr, "%u", count); - strcat (t1_line_ptr, p); - t1_line_ptr = eol (t1_line_array); - t1_putline (); - - /* create return_cs to replace unsused subr's */ - if (is_subr) { - cr = 4330; - cs_len = 0; - return_cs = xtalloc (t1_lenIV + 1, byte); - if (t1_lenIV > 0) { - for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) - *r = cencrypt (0x00, &cr); - *r = cencrypt (CS_RETURN, &cr); - } else { - *return_cs = CS_RETURN; - } - cs_len++; - } - - for (ptr = tab; ptr < end_tab; ptr++) { - if (ptr->used) { - if (is_subr) - sprintf (t1_line_array, "dup %i %u", (int) (ptr - tab), - ptr->cslen); - else - sprintf (t1_line_array, "/%s %u", ptr->name, ptr->cslen); - p = strend (t1_line_array); - memcpy (p, ptr->data, ptr->len); - t1_line_ptr = p + ptr->len; - t1_putline (); - } else { - /* replace unsused subr's by return_cs */ - if (is_subr) { - sprintf (t1_line_array, "dup %i %u%s ", (int) (ptr - tab), - cs_len, cs_token_pair[0]); - p = strend (t1_line_array); - memcpy (p, return_cs, cs_len); - t1_line_ptr = p + cs_len; - t1_putline (); - sprintf (t1_line_array, " %s", cs_token_pair[1]); - t1_line_ptr = eol (t1_line_array); - t1_putline (); - } - } - xfree (ptr->data); - if (ptr->name != notdef) - xfree (ptr->name); - } - sprintf (t1_line_array, "%s", line_end); - t1_line_ptr = eol (t1_line_array); - t1_putline (); - if (is_subr) - xfree (return_cs); - xfree (tab); - xfree (start_line); - xfree (line_end); -} - -static void t1_mark_glyphs (int tex_font) -{ - int i; - char *charset = extra_charset (); - char *g, *s, *r; - cs_entry *ptr; - if (t1_synthetic || embed_all_glyphs (tex_font)) { /* mark everything */ - if (cs_tab != NULL) - for (ptr = cs_tab; ptr < cs_ptr; ptr++) - if (ptr->valid) - ptr->used = true; - if (subr_tab != NULL) { - for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->valid) - ptr->used = true; - subr_max = subr_size - 1; - } - return; - } - mark_cs (notdef); - for (i = 0; i < 256; i++) - if (is_used_char (i)) { - if (t1_glyph_names[i] == notdef) - pdftex_warn ("character %i is mapped to %s", i, notdef); - else - mark_cs (t1_glyph_names[i]); - } - if (charset == NULL) - goto set_subr_max; - g = s = charset + 1; /* skip the first '/' */ - r = strend (g); - while (g < r) { - while (*s != '/' && s < r) - s++; - *s = 0; /* terminate g by rewriting '/' to 0 */ - mark_cs (g); - g = s + 1; - } - set_subr_max: - if (subr_tab != NULL) - for (subr_max = -1, ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) - if (ptr->used && ptr - subr_tab > subr_max) - subr_max = ptr - subr_tab; -} - -static void t1_subset_charstrings (int tex_font) -{ - cs_entry *ptr; - cs_size_pos = - strstr (t1_line_array, charstringname) + strlen (charstringname) - - t1_line_array + 1; - /* cs_size_pos points to the number indicating - dict size after "/CharStrings" */ - cs_size = t1_scan_num (t1_line_array + cs_size_pos, 0); - cs_ptr = cs_tab = xtalloc (cs_size, cs_entry); - for (ptr = cs_tab; ptr - cs_tab < cs_size; ptr++) - init_cs_entry (ptr); - cs_notdef = NULL; - cs_dict_start = xstrdup (t1_line_array); - t1_getline (); - while (t1_cslen) { - store_cs (); - t1_getline (); - } - cs_dict_end = xstrdup (t1_line_array); - t1_mark_glyphs (tex_font); - if (subr_tab != NULL) { - if (cs_token_pair == NULL) - pdftex_fail - ("This Type 1 font uses mismatched subroutine begin/end token pairs."); - t1_subr_flush (); - } - for (cs_count = 0, ptr = cs_tab; ptr < cs_ptr; ptr++) - if (ptr->used) - cs_count++; - t1_cs_flush (); -} - -static void t1_subset_end (fm_entry *fm_cur) -{ - if (t1_synthetic) { /* copy to "dup /FontName get exch definefont pop" */ - while (!strstr (t1_line_array, "definefont")) { - t1_getline (); - t1_putline (); - } - while (!t1_end_eexec ()) - t1_getline (); /* ignore the rest */ - t1_putline (); /* write "mark currentfile closefile" */ - } else - while (!t1_end_eexec ()) { /* copy to "mark currentfile closefile" */ - t1_getline (); - t1_putline (); - } - t1_stop_eexec (fm_cur); - if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ - while (!t1_cleartomark ()) { - t1_getline (); - t1_putline (); - } - if (!t1_synthetic) /* don't check "{restore}if" for synthetic fonts */ - t1_check_end (); /* write "{restore}if" if found */ - } - get_length3 (); -} - -int t1_updatefm (int f, fm_entry *fm) -{ - char *s, *p; - read_encoding_only = true; - if (!t1_open_fontfile (fm,NULL)) { - return 0; - } - t1_scan_only (f, fm); - s = xstrdup(fontname_buf); - for (p=s;*p != ' ' && *p != 0; p++); - *p=0; - fm->ps_name = s; - t1_close_font_file (""); - return 1; -} - - -void writet1 (int tex_font, fm_entry *fm_cur) -{ - read_encoding_only = false; - if (!is_included (fm_cur)) { /* scan parameters from font file */ - if (!t1_open_fontfile (fm_cur,"{")) - return; - t1_scan_only (tex_font, fm_cur); - t1_close_font_file ("}"); - return; - } - if (!is_subsetted (fm_cur)) { /* include entire font */ - if (!t1_open_fontfile (fm_cur,"<<")) - return; - t1_include (tex_font,fm_cur); - t1_close_font_file (">>"); - return; - } - /* partial downloading */ - if (!t1_open_fontfile (fm_cur,"<")) - return; - t1_subset_ascii_part (tex_font,fm_cur); - t1_start_eexec (fm_cur); - cc_init (); - cs_init (); - t1_read_subrs (tex_font, fm_cur); - t1_subset_charstrings (tex_font); - t1_subset_end (fm_cur); - t1_close_font_file (">"); -} - -void t1_free () -{ - xfree (t1_line_array); - xfree (t1_buf_array); -} diff --git a/Build/source/texk/web2c/mpware/ChangeLog b/Build/source/texk/web2c/mpware/ChangeLog deleted file mode 100644 index cc5eeb2ccaf..00000000000 --- a/Build/source/texk/web2c/mpware/ChangeLog +++ /dev/null @@ -1,573 +0,0 @@ -2008-02-29 Peter Breitenlohner - - * newer.c, makempx.c: replace `#if HAVE_ST_MTIM' by - `#ifdef HAVE_STRUCT_STAT_ST_MTIM' (from AC_CHECK_MEMBERS). - -2008-01-29 Peter Breitenlohner - - * Makefile.in: Add @configure_input@ line. - -2007-05-19 Karl Berry - - * Makefile.in (install-exec): install makempx, as a binary, a la - mpto and dmp, using INSTALL_LIBTOOL_PROG and $(bindir). From - Sanjoy Mahajan, 19 May 2007 13:38:15. - -2006-12-15 [r125] taco - - * makempx.c: file globbing for temporary file deletion - added, to prevent stray files from LaTeX packages. - Version bumped to 0.993 - -2006-12-09 [r122] taco - - * dmp_ffile.c: fix a compile problem on AIX reported by - Vladimir Volowich - -2006-11-28 [r118] taco - - * dmp.c, newer.c, makempx.c, makempx.in, mpto.c: Bump - the version numbers to 0.992 - -2006-11-28 [r117] taco - - * makempx.c: adds a guard against malfunctioning mktemp() - -2006-11-27 [r114-115] taco - - * dmp.c, newer.c, makempx.exe (removed), makempx.c, dmp.h, - dmp_ffile.c, mpto.c: indent -kr -psl - - * dmp_ffile.c: fix fsearch_init() in standalone mode - -2006-11-27 [r113] taco - - * makempx.c: GNU troff commandline adjusted again: use 'troff', - not 'groff' as executable name - -2006-11-26 [r108] taco - - * makempx.c: GNU troff commandline adjusted - -2006-11-26 [r105] taco - - * dmp.c, Makefile.in, dmp.h, dmp_ffile.c: dmp with kpathsea - searching - -2006-11-26 [r103-104] taco - - * makempx.c: small fixes from Akira Kakuto - -2006-11-26 [r102] taco - - * makempx.c: Akira Kakuto says we can have stat() on windows as well - -2006-11-26 [r101] taco - - * makempx.c: mpx%6d changed to mp%06d - -2006-11-26 [r100] taco - - * Makefile.in: new compiled makempx build commands - -2006-11-24 [r99] taco - - * makempx.c: much improved version, but not finished yet - -2006-11-23 [r94] taco - - * makempx.c (added): test version of C makempx. Based on a - source file sent by Akira Kakuto - -2006-11-22 [r92] taco - - * dmp.c, newer.c, makempx.exe (added), makempx.in, mpto.c: insert - maintainer info - -2006-11-20 [r88] taco - - * dmp.c, newer.c, Makefile.in: changes from TeXLive backported, - especially a fix for aliased CHARLIB filenames (). - -2006-11-19 [r78] taco - - * makempx.in, mpto.c: Version numbers changed for commit of - 0.99 to TeXLive - -2006-11-02 [r64] taco - - * dmp.c: Ignore large groff character indices because these can - not be used within MetaPost - -2006-11-02 [r59] taco - - * Makefile.in: Cross-compilation support added - -2006-11-01 [r55] taco - - * dmp.c, dmp.h, dmp_ffile.c: restore CHARLIB type - -2006-11-01 [r54] taco - - * dmp.c: allow characters with index 0 - -2006-11-01 [r53] taco - - * dmp.c: dont call read_char_adj() if gflag is on, this removes - the need to have a dummy trchars.adj for troff - -2006-10-31 [r51] taco - - * dmp.c: new patch from fixes use of 'sizescale'. From Gunnar - Ritter - -2006-09-23 [r31] taco - - * dmp.c, dmp.h, dmp_ffile.c: groff patches from Michail Vidiassov - and Werner Lemberg - -2005-08-24 Taco Hoekwater - - * mpto.c: Fix a bug in mpto resulting in correctly placed labels, - with thanks to Dan Luecking - - * dmp.c: Fix a bug blocking compilation of dmp on MacOSX - - * mpost.c,dmp.c,mpto.c: The executables are now version 0.902 - -2005-08-24 Taco Hoekwater - - * newer.c: The 'newer' command now accepts more than 2 arguments, - testing each of the files in turn. - - * mpto.c: mpto uses a new TeX macro for the generation of labels, - making it more robust wrt. strange user code within the actual - label text. - - * Check-in of version 0.900. - -2004-12-19 Olaf Weber - - * dmp.c [Hprime,MAXCHARS]: Larger values as there can be many more - than 256 chars in a font. Suggested by Michail Vidiassov - . - -2004-07-23 Olaf Weber - - * 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 - . - -2004-07-14 Olaf Weber - - * mpto.c (main): Second argument to usagehelp. - -2004-06-19 Olaf Weber - - * makempx.in: Since the trap statement is already quoted, the - quotes around $ERRLOG must be escaped. Found by Werner Lemberg - . - -2004-06-15 Olaf Weber - - * makempx.in: Add quotes in various places to support filenames - with spaces in them. - -2004-05-29 Olaf Weber - - * 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 . - -2004-04-16 Olaf Weber - - * 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 - . - - * 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 . - -2003-02-15 Olaf Weber - - * Makefile.in: From klibtool to libtool. Based on patches from - Albert Chin-A-Young . - - * makempx.in: We might as well be consistent in the use of ' - versus ". - -2003-02-07 Olaf Weber - - * makempx.in: Add --parse-first-line to arguments of "default" - TeX. - -2002-11-30 Olaf Weber - - * newer.c [WIN32]: Don't include sys/types.h and sys/stat.h. - -2002-10-06 Olaf Weber - - * Makefile.in (install-exec): Simplify. TeXlive merge. - -2001-12-11 Olaf Weber - - * Makefile.in (install-exec): Now that we link mpto with kpathsea, - use klibtool to install it. From by Adrian Bunk . - -2001-11-19 Olaf Weber - - * dmp.c: Changes to keep C++ compilers from choking. - -2001-11-18 Olaf Weber - - * 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 - - * 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= option. - -2001-09-26 Olaf Weber - - * newer.c: Correct help text. From Oliver Moeller - . - -1999-03-15 Olaf Weber - - * newer.c [WIN32]: Patchlet from Fabrice. - -1999-02-04 Olaf Weber - - * 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 - - * 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 - - * Makefile.in: Rename kpathsea.make to kpathsea.mk. - -1999-01-10 Olaf Weber - - * 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 - - * mpto.c (getline): Change to handle all EOL conventions, not just - the native one. - -Mon Mar 23 19:18:12 1998 Olaf Weber - - * Makefile.in (dmp, makempx): Correct dependencies. From Eli - Zaretskii. - -Thu Jan 29 16:11:25 1998 Olaf Weber - - * dmp.c: Update for 0.64. - -Thu Dec 18 20:36:37 1997 Olaf Weber - - * 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 - - * 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 - - * 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 - - * mpto.c, newer.c [WIN32]: Include string.h. From Fabrice Popineau. - -Sun Oct 19 11:00:35 1997 Olaf Weber - - * 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 - - * dmp.c: Include the GROFF NOTES comments by Ulrik Vieth. - -Wed Oct 15 17:47:09 1997 Olaf Weber - - * dmp.c (search): Select binary mode to open file for some - formats, just like kpse_file_open does. After Eli Zaretskii - . - - * makempx.in: Fix message about `cat' failure. From Eli Zaretskii - . - -Fri Oct 3 11:54:56 1997 Olaf Weber - - * 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 - - * 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 - - * Makefile.in (install-exec): makempx is in the build directory, - not srcdir. - From: Andreas Schott . - -Mon Jan 20 17:30:44 1997 Karl Berry - - * Version 7.0. - -Mon Dec 9 01:31:55 1996 Ulrik Vieth - - * 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 - - * 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 - - * 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 - - * makempx.in: Missing ` in --version. From Ulrik. - -Sun Nov 10 16:00:41 1996 Karl Berry - - * 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 - - * 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 - - * *.c: Call printversionandexit for --version. - * makempx.in: Change --version output. - -Sat Sep 7 16:20:17 1996 Karl Berry - - * 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 - - * dmp.c: Oops, forgot to declare kpathsea_version_string. - -Sun Aug 4 15:39:42 1996 Karl Berry - - * 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 - - * Makefile.in: Remove co.make. - -Sat Jun 8 13:15:01 1996 K. Berry - - * 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 - - * makempx.in: Add mptexpre feature. From John Hobby. - -Sat Apr 20 17:44:39 1996 Karl Berry - - * newer.c (main): Recognize --help and --version. - -Tue Mar 26 17:37:13 1996 Karl Berry - - * dmp.c: Include c-ctype.h. - -Fri Dec 29 17:16:09 1995 Karl Berry - - * Makefile.in: misc.make is now clean.make. - -Tue Dec 12 16:52:00 1995 Karl Berry - - * dmp.c: Correct --version output. From Ulrik. - -Thu Nov 16 16:23:53 1995 Karl Berry - - * 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 option. - (usage): Have a -E option on the Amiga. - From Andreas Scherer. - -Sat Sep 30 15:56:47 1995 Karl Berry - - * makempx.in: Quote "$1" for unusual filenames. - -Tue Aug 22 14:13:52 1995 Karl Berry - - * Makefile.in: Include rdepend.make and depend.make. - -Mon Jul 31 15:45:12 1995 Karl Berry - - * mpto.c (usage): Improve help message. - - * dmp.c: Convert to use kpathsea. - -Sun Jul 30 11:10:10 1995 Karl Berry - - * makempx.in (mode): Merge troffmpx into this. - -Thu Apr 13 16:40:08 1995 Ulrik Vieth - - * 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 - - * 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.am b/Build/source/texk/web2c/mpware/Makefile.am deleted file mode 100644 index 80f8c338b47..00000000000 --- a/Build/source/texk/web2c/mpware/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -## Makefile.am for the TeX Live subdirectory texk/web2c/mpware/ -## -## Copyright (C) 2009 Peter Breitenlohner -## You may freely use, modify and/or distribute this file. -## -INCLUDES = -I$(top_builddir)/.. -I$(top_srcdir) $(KPATHSEA_INCLUDES) - -proglib = ../lib/lib.a - -## Automake automatically uses $(proglib)=../lib/lib.a as dependency. -## This does not work for the configure substitution $(KPATHSEA_LIBS), -## thus we let $(proglib) artificially depend on $(KPATHSEA_LIBS). - -## Rebuild $(proglib) -$(proglib): $(KPATHSEA_DEPEND) ${top_srcdir}/lib/*.c - cd ../lib && $(MAKE) $(AM_MAKEFLAGS) - -## Rebuild libkpathsea -@KPATHSEA_RULE@ - -bin_PROGRAMS = dmp makempx mpto newer - -dmp_SOURCES = dmp.c dmp.h dmp_ffile.c -dmp_LDADD = $(proglib) $(KPATHSEA_LIBS) - -makempx_SOURCES = makempx.c -makempx_LDADD = $(proglib) $(KPATHSEA_LIBS) - -mpto_SOURCES = mpto.c - -newer_SOURCES = newer.c - -## Obsolete ? -## -EXTRA_DIST = makempx.in - -## Evetually delete these files -## -EXTRA_DIST += Makefile.in.orig - diff --git a/Build/source/texk/web2c/mpware/Makefile.in b/Build/source/texk/web2c/mpware/Makefile.in deleted file mode 100644 index 77ee3bd9d7c..00000000000 --- a/Build/source/texk/web2c/mpware/Makefile.in +++ /dev/null @@ -1,631 +0,0 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -bin_PROGRAMS = dmp$(EXEEXT) makempx$(EXEEXT) mpto$(EXEEXT) \ - newer$(EXEEXT) -subdir = mpware -DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - ChangeLog -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-asm.m4 \ - $(top_srcdir)/../../m4/kpse-common.m4 \ - $(top_srcdir)/../../m4/kpse-cross.m4 \ - $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ - $(top_srcdir)/../../m4/kpse-fontconfig-flags.m4 \ - $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ - $(top_srcdir)/../../m4/kpse-graphite-flags.m4 \ - $(top_srcdir)/../../m4/kpse-icu-flags.m4 \ - $(top_srcdir)/../../m4/kpse-kpathsea-flags.m4 \ - $(top_srcdir)/../../m4/kpse-lex.m4 \ - $(top_srcdir)/../../m4/kpse-libpng-flags.m4 \ - $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ - $(top_srcdir)/../../m4/kpse-obsdcompat-flags.m4 \ - $(top_srcdir)/../../m4/kpse-socket-libs.m4 \ - $(top_srcdir)/../../m4/kpse-teckit-flags.m4 \ - $(top_srcdir)/../../m4/kpse-web2c.m4 \ - $(top_srcdir)/../../m4/kpse-win32.m4 \ - $(top_srcdir)/../../m4/kpse-xpdf-flags.m4 \ - $(top_srcdir)/../../m4/kpse-zlib-flags.m4 \ - $(top_srcdir)/../../m4/libtool.m4 \ - $(top_srcdir)/../../m4/ltoptions.m4 \ - $(top_srcdir)/../../m4/ltsugar.m4 \ - $(top_srcdir)/../../m4/ltversion.m4 \ - $(top_srcdir)/../../m4/lt~obsolete.m4 \ - $(top_srcdir)/ac/web2c.ac $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/../../build-aux/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/c-auto.h $(top_builddir)/ff-config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -PROGRAMS = $(bin_PROGRAMS) -am_dmp_OBJECTS = dmp.$(OBJEXT) dmp_ffile.$(OBJEXT) -dmp_OBJECTS = $(am_dmp_OBJECTS) -am__DEPENDENCIES_1 = -dmp_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am_makempx_OBJECTS = makempx.$(OBJEXT) -makempx_OBJECTS = $(am_makempx_OBJECTS) -makempx_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am_mpto_OBJECTS = mpto.$(OBJEXT) -mpto_OBJECTS = $(am_mpto_OBJECTS) -mpto_LDADD = $(LDADD) -am_newer_OBJECTS = newer.$(OBJEXT) -newer_OBJECTS = $(am_newer_OBJECTS) -newer_LDADD = $(LDADD) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/../../build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(dmp_SOURCES) $(makempx_SOURCES) $(mpto_SOURCES) \ - $(newer_SOURCES) -DIST_SOURCES = $(dmp_SOURCES) $(makempx_SOURCES) $(mpto_SOURCES) \ - $(newer_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CTANGLE = @CTANGLE@ -CTANGLEBOOT = @CTANGLEBOOT@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CXXLD = @CXXLD@ -CXX_HACK_DEPS = @CXX_HACK_DEPS@ -CXX_HACK_LIBS = @CXX_HACK_LIBS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -FONTCONFIG_INCLUDES = @FONTCONFIG_INCLUDES@ -FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ -FREETYPE2_DEPEND = @FREETYPE2_DEPEND@ -FREETYPE2_INCLUDES = @FREETYPE2_INCLUDES@ -FREETYPE2_LIBS = @FREETYPE2_LIBS@ -FT2_CONFIG = @FT2_CONFIG@ -GRAPHITE_DEPEND = @GRAPHITE_DEPEND@ -GRAPHITE_INCLUDES = @GRAPHITE_INCLUDES@ -GRAPHITE_LIBS = @GRAPHITE_LIBS@ -GREP = @GREP@ -ICU_DEPEND = @ICU_DEPEND@ -ICU_INCLUDES = @ICU_INCLUDES@ -ICU_LIBS = @ICU_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -KPATHSEA_DEPEND = @KPATHSEA_DEPEND@ -KPATHSEA_INCLUDES = @KPATHSEA_INCLUDES@ -KPATHSEA_LIBS = @KPATHSEA_LIBS@ -KPATHSEA_PATHS_H = @KPATHSEA_PATHS_H@ -KPSEWHICH = @KPSEWHICH@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LEX = @LEX@ -LEXLIB = @LEXLIB@ -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LIBOBJS = @LIBOBJS@ -LIBPNG_DEPEND = @LIBPNG_DEPEND@ -LIBPNG_INCLUDES = @LIBPNG_INCLUDES@ -LIBPNG_LIBS = @LIBPNG_LIBS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LUATANGLE = @LUATANGLE@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OBSDCOMPAT_DEPEND = @OBSDCOMPAT_DEPEND@ -OBSDCOMPAT_INCLUDES = @OBSDCOMPAT_INCLUDES@ -OBSDCOMPAT_LIBS = @OBSDCOMPAT_LIBS@ -OTANGLE = @OTANGLE@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -TANGLE = @TANGLE@ -TANGLEBOOT = @TANGLEBOOT@ -TECKIT_DEPEND = @TECKIT_DEPEND@ -TECKIT_INCLUDES = @TECKIT_INCLUDES@ -TECKIT_LIBS = @TECKIT_LIBS@ -TIE = @TIE@ -VERSION = @VERSION@ -WEB2CVERSION = @WEB2CVERSION@ -XMKMF = @XMKMF@ -XPDF_DEPEND = @XPDF_DEPEND@ -XPDF_INCLUDES = @XPDF_INCLUDES@ -XPDF_LIBS = @XPDF_LIBS@ -X_CFLAGS = @X_CFLAGS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_LIBS = @X_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -ZLIB_DEPEND = @ZLIB_DEPEND@ -ZLIB_INCLUDES = @ZLIB_INCLUDES@ -ZLIB_LIBS = @ZLIB_LIBS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -ipc_socketlibs = @ipc_socketlibs@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -lua_socketlibs = @lua_socketlibs@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -wlibs = @wlibs@ -x_ext_lib = @x_ext_lib@ -x_tool_libs = @x_tool_libs@ -INCLUDES = -I$(top_builddir)/.. -I$(top_srcdir) $(KPATHSEA_INCLUDES) -proglib = ../lib/lib.a -dmp_SOURCES = dmp.c dmp.h dmp_ffile.c -dmp_LDADD = $(proglib) $(KPATHSEA_LIBS) -makempx_SOURCES = makempx.c -makempx_LDADD = $(proglib) $(KPATHSEA_LIBS) -mpto_SOURCES = mpto.c -newer_SOURCES = newer.c -EXTRA_DIST = makempx.in Makefile.in.orig -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign mpware/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign mpware/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -dmp$(EXEEXT): $(dmp_OBJECTS) $(dmp_DEPENDENCIES) - @rm -f dmp$(EXEEXT) - $(LINK) $(dmp_OBJECTS) $(dmp_LDADD) $(LIBS) -makempx$(EXEEXT): $(makempx_OBJECTS) $(makempx_DEPENDENCIES) - @rm -f makempx$(EXEEXT) - $(LINK) $(makempx_OBJECTS) $(makempx_LDADD) $(LIBS) -mpto$(EXEEXT): $(mpto_OBJECTS) $(mpto_DEPENDENCIES) - @rm -f mpto$(EXEEXT) - $(LINK) $(mpto_OBJECTS) $(mpto_LDADD) $(LIBS) -newer$(EXEEXT): $(newer_OBJECTS) $(newer_DEPENDENCIES) - @rm -f newer$(EXEEXT) - $(LINK) $(newer_OBJECTS) $(newer_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dmp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dmp_ffile.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makempx.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mpto.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newer.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-binPROGRAMS - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir 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-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 - - -$(proglib): $(KPATHSEA_DEPEND) ${top_srcdir}/lib/*.c - cd ../lib && $(MAKE) $(AM_MAKEFLAGS) - -@KPATHSEA_RULE@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/Build/source/texk/web2c/mpware/Makefile.in.orig b/Build/source/texk/web2c/mpware/Makefile.in.orig deleted file mode 100644 index d898b37884f..00000000000 --- a/Build/source/texk/web2c/mpware/Makefile.in.orig +++ /dev/null @@ -1,63 +0,0 @@ -# @configure_input@ -# 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 dmp_ffile.o - $(kpathsea_link) dmp.o dmp_ffile.o $(LOADLIBES) -mpto: mpto.o - $(kpathsea_link) mpto.o -newer: newer.o - $(link_command) newer.o -makempx: makempx.o - $(kpathsea_link) makempx.o $(LOADLIBES) - -dmp.o dmp_ffile.o: dmp.h - -newer.o dmp.o makempx.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_LIBTOOL_PROG) makempx $(bindir) -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 deleted file mode 100644 index a7c792cda81..00000000000 --- a/Build/source/texk/web2c/mpware/README +++ /dev/null @@ -1,6 +0,0 @@ -$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/dmp.c b/Build/source/texk/web2c/mpware/dmp.c deleted file mode 100644 index 9d8e4a21cef..00000000000 --- a/Build/source/texk/web2c/mpware/dmp.c +++ /dev/null @@ -1,1561 +0,0 @@ -/* $Id: dmp.c,v 1.14 2005/08/24 10:54:02 taco Exp $ - Public domain. */ - -/* dmp x - * - * 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 1.002"; /* first line of output */ -char *term_banner = "This is DMP, Version 1.002"; - -#include -#include -#include -#include -#include - -#include "dmp.h" - -#ifndef NULL -#define NULL ((char*) 0) -#endif - -#ifndef PI -#define PI 3.14159265358979323846 -#endif - -#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 307 /* much bigger than max(chars/font,fonts/job) */ -#define MAXCHARS 256 /* 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) (!gflag && (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 */ -int lnno = 0; /* line num. in troff output file (our input) */ -float sizescale; /* groff font size scaling factor */ -int gflag = 0; /* non-zero if using groff fonts */ - -void -quit(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(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(char c) -{ - if (poolsize == POOLMAX) { - fprintf(stderr, "%s", strpool); - 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(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(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(void) -{ - if (failure == (Hcell *) 0) - return 1; - failure->lab = NULL; - return 0; -} - - - -/************************************************************** - 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(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(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(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(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 - \t,PostScript-name>\t - or just \t,PostScript-name> if the TeX name matches the - PostScript name. ("\t" means one or more tabs.) -*/ - -void -read_fmap(char *dbase) -{ - FILE *fin; - int c; /* last character read */ - char *nam; /* a font name being read */ - - nfonts = 0; - fin = fsearch(dbase, "", DB_TYPE); - 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)) { - if (c == EOF) - break; - 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)) { - if (c == EOF) - break; - 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(char *adjfile) -{ - FILE *fin; - char buf[200]; - int i; - - fin = fsearch(adjfile, "", DB_TYPE); - 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); -} - -/* Read the DESC file of the troff device to gather information - about sizescale and whether running under groff. -*/ -void -read_desc(void) -{ - /* Ignore all commands not specially handled. This relieves - of collecting commands without arguments here and also - makes the program more robust in case of future DESC - extensions. - */ - const char *const k1[] = { - "res", "hor", "vert", "unitwidth", "paperwidth", - "paperlength", "biggestfont", "spare2", "encoding", - NULL - }; - const char *const g1[] = { - "family", "paperheight", "postpro", "prepro", - "print", "image_generator", "broken", - NULL - }; - char cmd[200]; - FILE *fp; - int i, n; - - fp = fsearch("DESC", "", TRFONTS_TYPE); - while (fscanf(fp, "%199s", cmd) != EOF) { - if (*cmd == '#') { - while ((i = getc(fp)) != EOF && i != '\n'); - continue; - } - if (strcmp(cmd, "fonts") == 0) { - if (fscanf(fp, "%d", &n) != 1) - return; - for (i = 0; i < n; i++) - if (fscanf(fp, "%*s") == EOF) - return; - } else if (strcmp(cmd, "sizes") == 0) { - while (fscanf(fp, "%d", &n) == 1 && n != 0); - } else if (strcmp(cmd, "styles") == 0 || - strcmp(cmd, "papersize") == 0) { - gflag++; - while ((i = getc(fp)) != EOF && i != '\n'); - } else if (strcmp(cmd, "sizescale") == 0) { - if (fscanf(fp, "%d", &n) == 1) - sizescale = n; - gflag++; - } else if (strcmp(cmd, "charset") == 0) { - return; - } else { - for (i = 0; k1[i]; i++) - if (strcmp(cmd, k1[i]) == 0) { - if (fscanf(fp, "%*s") == EOF) - return; - break; - } - if (k1[i] == 0) - for (i = 0; g1[i]; i++) - if (strcmp(cmd, g1[i]) == 0) { - if (fscanf(fp, "%*s") == EOF) - return; - gflag = 1; - break; - } - } - } -} - - -/************************************************************** - 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(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", TEXFONTS_TYPE); - 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(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 == '"') { - if (lastcode < MAXCHARS) - *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; - if (lastcode < MAXCHARS) - *hfind(s, charcodes[f]) = lastcode; - } - 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(char *nam) -{ /* troff name */ - 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, "", TRFONTS_TYPE); - 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(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(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(void) -{ - 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(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(void) -{ - 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(void) -{ - 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(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(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(void) -{ - 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(void) -{ - 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.. -*/ -char specintro[] = "vardef "; /* MetaPost name follows this */ -#define speci 7 /* length of the above string */ - -/* TH: A bit of trickery is added here for case-insensitive - file systems. This aliasing allows the CHARLIB directory - to exist on DVDs, for example. - It is a hack, I know. I've stuck to names on TeXLive. -*/ - -#define test_redo_search if ((c=getc(deff))==EOF) \ - deff = fsearch(cname, "", CHARLIB_TYPE); \ - else ungetc(c,deff) - - -int -copy_spec_char(char *cname) -{ - int k = 0; /* how much of specintro so far */ - FILE *deff; - int c, s; - if (strcmp(cname, "ao") == 0) { - deff = fsearch("ao.x", "", CHARLIB_TYPE); - test_redo_search; - } else if (strcmp(cname, "lh") == 0) { - deff = fsearch("lh.x", "", CHARLIB_TYPE); - test_redo_search; - } else if (strcmp(cname, "~=") == 0) { - deff = fsearch("twiddle", "", CHARLIB_TYPE); - test_redo_search; - } else { - deff = fsearch(cname, "", CHARLIB_TYPE); - } - while (k < speci) { - if ((c = getc(deff)) == EOF) - quit("No vardef in charlib/", cname, ""); - putc(c, mpxf); - if (c == specintro[k]) - k++; - else - k = 0; - } - s = poolsize; - while ((c = getc(deff)) != '(') { - if (c == EOF) - quit("vardef in charlib/", 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(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(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(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(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(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(void) -{ - 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(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(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(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(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(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(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(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 (sizescale) { - if (unit != 0.0) - Xheight *= unit; /* ??? */ - else - Xheight /= sizescale; - } - 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(void) -{ - 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 (sizescale) { - if (unit != 0.0) - cursize *= unit; /* ??? */ - else - cursize /= sizescale; - } - 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 -usage(char *name, int status) -{ - 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(int argc, char **argv) -{ - int more; - - fsearch_init(argc, argv); - trf = stdin; - mpxf = stdout; - 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 - || strcmp(argv[1], "-help") == 0)) { - usage(argv[0], 0); - } else if (argc > 1 && (strcmp(argv[1], "--version") == 0 - || strcmp(argv[1], "-version") == 0)) { - fputs(term_banner, stdout); - fputs("\nThis program is in the public domain.\n\ -Primary author of dmp: John Hobby.\n\ -Current maintainer: Taco Hoekwater.\n", stdout); - exit(0); - } - if (argc > 3) - 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_desc(); - read_fmap(dbname); - if (!gflag) - 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); - } - exit(0); -} diff --git a/Build/source/texk/web2c/mpware/dmp.h b/Build/source/texk/web2c/mpware/dmp.h deleted file mode 100644 index 4cb6b874249..00000000000 --- a/Build/source/texk/web2c/mpware/dmp.h +++ /dev/null @@ -1,21 +0,0 @@ -/* $Id: dmp.h,v 1.2 2004/09/19 21:51:38 karl Exp $ - Public domain. */ - -#ifndef DMP_H -#define DMP_H - -#define TEXFONTS_TYPE 1 -#define DB_TYPE 2 -#define CHARLIB_TYPE 3 -#define TRFONTS_TYPE 4 - -extern FILE *fsearch(char *nam, char *ext, int path_type); -extern void fsearch_init(int argc, char **argv); - -#define POOLMAX 65000 /* total characters in all font and char names */ - -extern int poolsize; /* chars used so far in strpool */ -extern char strpool[]; /* chars used so far in strpool */ - - -#endif diff --git a/Build/source/texk/web2c/mpware/dmp_ffile.c b/Build/source/texk/web2c/mpware/dmp_ffile.c deleted file mode 100644 index 6d6a439e22d..00000000000 --- a/Build/source/texk/web2c/mpware/dmp_ffile.c +++ /dev/null @@ -1,356 +0,0 @@ -/* $Id: dmp_ffile.c,v 1.4 2005/08/24 10:54:02 taco Exp $ - * - * File searching for dmp. This is a unified source file implementing two - * different strategies: kpathsea lookups vs. recursive searching. - * - * There is a #define to switch between the two personalities, with - * kpathsea the default option - * - * Public domain. - */ - -#include -#include - -#include "dmp.h" - -#ifndef FFSEARCH - -#include "config.h" -#include -#include -#include - -static int - kpse_types[5] = { 0, - kpse_tfm_format, /* tex fonts */ - kpse_mpsupport_format, /* mapfile */ - kpse_mpsupport_format, /* charlib */ - kpse_troff_font_format -}; - - -void -fsearch_init(int argc, char **argv) -{ - kpse_set_progname(argv[0]); -} - -FILE * -fsearch(char *nam, char *ext, int path_type) -{ - { - FILE *f = NULL; - int format = kpse_types[path_type]; - 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; - } - -} - -#else - -void pathexpand(char *buf, int dirlen, int bufsize); - -/* Where dmp looks for tex font metric files */ -#define TEXFONTS ".:/usr/lib/tex/fonts/tfm" - -/* Where dmp looks for troff font tables */ -#define TRFONTS "/usr/share/groff/current/font/devps" - -/* Where dmp looks for font map data and spec chars */ -#define MPPOOL ".:/usr/lib/mp" - - -char *tfmpath = TEXFONTS; /* directories to search for TFM files */ -char *dbpath = MPPOOL; /* directories for font map data */ -char *charpath = MPPOOL; /* directories for spec chars */ -char *trpath = TRFONTS; /* search path for troff font data */ - -/************************************************************** - Search Paths -***************************************************************/ - -#ifdef MS_DOS -#define PATH_DELIM ';' -#else -#ifdef WIN32 -#define PATH_DELIM ';' -#else -#define PATH_DELIM ':' -#endif -#endif - -void -fsearch_init(int argc, char **argv) -{ - char *envpath; - - if ((envpath = getenv("TEXFONTS")) != NULL) - tfmpath = envpath; - if ((envpath = getenv("MPPOOL")) != NULL) { - dbpath = envpath; - charpath = envpath; - } - if ((envpath = getenv("TRFONTS")) != NULL) - trpath = envpath; -} - - -FILE * -fsearch(char *nam, char *ext, int path_type) -{ - FILE *f; - char *s, *p; - int dirlen; - char *path; - if (path_type == TEXFONTS_TYPE) { - path = tfmpath; - } else if (path_type == DB_TYPE) { - path = dbpath; - } else if (path_type == CHARLIB_TYPE) { - path = charpath; - /* somewhat sneaky trick to unify 'fsearch' API with - the smallest possible code impact */ - ext = nam; - nam = "charlib/"; - } else if (path_type == TRFONTS_TYPE) { - path = trpath; - } - - if (nam[0] == '/') /* file name has absolute path */ - path = NULL; - do { - s = &strpool[poolsize]; - if (path != NULL) { - while ((*path != PATH_DELIM) && (*path != '\0')) - add_to_pool(*path++); - if (*path == '\0') - path = NULL; - else - path++; - add_to_pool('/'); - } - dirlen = &strpool[poolsize] - s; - for (p = nam; *p != '\0'; p++) - add_to_pool(*p); - for (p = ext; *p != '\0'; p++) - add_to_pool(*p); - add_to_pool('\0'); - pathexpand(s, dirlen, &strpool[POOLMAX] - s); - f = fopen(s, "r"); - poolsize = s - &strpool[0]; - } while (f == NULL && path != NULL); - if (f == NULL) - quit("Cannot find ", nam, ext); - return f; -} - - - -/********************************************************** - You might have to modify the following includes and defines. - They are supposed to declare opendir(), readdir(), closedir() - and define how to access the result of readdir(). - **********************************************************/ -#ifdef BSD -#include -#include -#define DIRentry struct direct /* readdir() returns pointer to this */ -#define de_name d_name /* field in DIRentry for file name */ - -#else -/* This is for SYSV and _POSIX_SOURCE; I don't know about other systems - */ -#include -#define DIRentry struct dirent /* readdir() returns pointer to this */ -#define de_name d_name /* field in DIRentry for file name */ -#endif - - -/********************************************************** - Nothing below here should need changing - **********************************************************/ - -#include - -#include - -extern void exit(); -extern int access(); - - -#ifdef PEDEBUG -/* The PEDEBUG flag is meant for seperate debugging of this file. Do not - set it when compiling MetaPost. -*/ -int -myaccess(nam, mode) -{ - int r; - r = access(nam, mode); - printf("can%s access %s\n", (r == 0 ? "" : "not"), nam); - return r; -} -#else -#define myaccess access -#endif - - -void -move_str(dest, src) /* strcpy() for overlapping strings */ -char *dest, *src; -{ - char *s, *d; - int n; - - if (dest < src) { - while (*src != '\0') - *dest++ = *src++; - *dest = '\0'; - } else { - n = strlen(src); - d = dest + n; - s = src + n; - *d = '\0'; - while (s != src) - *--d = *--s; - } -} - - -/* Find the first "//" within the first dirlen characters of buf[], or return - * zero to indicate failure. - */ -char * -find_dblslash(buf, dirlen) -char *buf; -int dirlen; -{ - char *p; - int k; - - k = 0; - dirlen--; - while ((p = strchr(buf + k, '/')) != 0) { - if (p - buf >= dirlen) - return 0; - if (p[1] == '/') - return p; - k = 1 + p - buf; - } - return 0; -} - - -/* Pretend the string ends at endp and call opendir(). - */ -DIR * -pe_opendir(buf, endp) -char *buf, *endp; -{ - DIR *dirp; - char s; - - s = *endp; - *endp = '\0'; - dirp = opendir(buf); -#ifdef PEDEBUG - printf("%s directory %s\n", (dirp == 0 ? "cannot open" : "opening"), - buf); -#endif - *endp = s; - return dirp; -} - - -/* A file name begins at buf and has a slash at slash followed by a final - * component of length tail. Append one or more intermediate directories and - * then the final component so as to make an accessible path name. If this can - * be done, return the length of the path name; otherwise return something - * negative and leave buf set to a bad path name. On exit, *tailp is pointed - * to the tail string. Buffer overflow happens when the tail string would have - * to start at a position greater than lim. - * The algorithm is depth-first search with pruning based on the idea that - * directories contain files or subdirectories, but not both. - */ -int -expand_dblslash(buf, slash, tail, lim, tailp) -char *buf, *slash, *lim; -int tail; -char **tailp; -{ - DIR *dirp; - DIRentry *de; - char *t, *tt; /* old and new positions of tail string */ - char *ds; - int r; - - t = slash + 1; - *tailp = t; - dirp = pe_opendir(buf, slash); - if (dirp == 0) - return -2; - if (myaccess(buf, 04) == 0) { - closedir(dirp); - return (slash - buf) + 1 + tail; - } - while ((de = readdir(dirp)) != 0) { - ds = de->de_name; - if (ds[0] == '.' && (ds[1] == 0 || ds[1] == '.' && ds[2] == 0)) - continue; - tt = slash + 2 + strlen(ds); - if (tt > lim) { - *slash = '\0'; - fprintf(stderr, "> %s/%s/%s\n", buf, de->de_name, t); - fprintf(stderr, "! Fatal error: %s\n", - "// expansion makes path name too long"); - exit(1); - } - move_str(tt, t); - strcpy(slash + 1, ds); - tt[-1] = '/'; - r = expand_dblslash(buf, tt - 1, tail, lim, &t); - if (r != -1) { - *tailp = t; - closedir(dirp); - return (r < 0) ? -1 : r; - } - } - closedir(dirp); - *tailp = t; - return -1; -} - - - -/* Assume that buf points to an array of length at least bufsize that - * contains a path name. Modify the path name by expanding "//" if it occurs - * in the first dirlen characters. The expansions consist of zero or more - * intermediate directories. If the expansion fails, buf will contain an - * invalid path name. - */ -void -pathexpand(buf, dirlen, bufsize) -char *buf; /* input path */ -int dirlen; /* limit search to buf[0]..buf[dirlen-1] */ -int bufsize; /* number of character in buf array */ -{ - char *p; - int tail, junk; - - if ((p = find_dblslash(buf, dirlen)) != 0) { - tail = strlen(p + 1); - move_str(p, p + 1); - expand_dblslash(buf, p, tail, buf + bufsize - tail - 1, &junk); - } -} - -#endif /* FFSEARCH */ diff --git a/Build/source/texk/web2c/mpware/makempx.c b/Build/source/texk/web2c/mpware/makempx.c deleted file mode 100644 index 51350126f9b..00000000000 --- a/Build/source/texk/web2c/mpware/makempx.c +++ /dev/null @@ -1,786 +0,0 @@ -/* $Id$ - - Make an MPX file from the labels in a MetaPost source file, - using mpto and either dvitomp (TeX) or dmp (troff). - - Started from a shell script initially based on John Hobby's original - version, that was then translated to C by Akira Kakuto (Aug 1997, - Aug 2001), and updated and largely rewritten by Taco Hoekwater (Nov 2006). - - Public Domain. - - indent -kr -psl -*/ - -/* Differences between the script and this C version: - - * The script trapped HUP, INT, QUIT and TERM for cleaning up - temporary files. This is a refinement, and not portable. - - * The command 'newer' became a function. - - * The script put its own directory in front of the - executable search PATH. This is not portable either, and - it seems a safe bet that normal users do not have 'mpto', - 'dvitomp', or 'dmp' commands in their path. - - * The command-line '-troff' now also accepts an optional argument. - - * The troff infile for error diagnostics is renamed "mpxerr.i", - not plain "mpxerr". - - * The original script deleted mpx*.* in the cleanup process. - - That is a bit harder in C, because it requires reading the contents - of the current directory. The current program assumes that - opendir(), readdir() and closedir() are known everywhere where - the function getcwd() exists (except on WIN32, where it uses - _findfirst & co). - - If this assumption is false, you can define NO_GETCWD, and makempx - will revert to trying to delete only a few known extensions - - * There is a -debug switch, preventing the removal of tmp files -*/ - - -#include -#include -#include -#ifdef WIN32 -#include -#include -#include -#else -#include -#include -#include -#include -#endif -#include -#include -#include - -#if !defined(HAVE_MKSTEMP) && ! defined (HAVE_MKTEMP) -#include "time.h" -#endif - -#include -#include "c-auto.h" - -#define INLINE_NEWER 1 - -/* We may have high-res timers in struct stat. If we do, use them. */ -#ifdef HAVE_STRUCT_STAT_ST_MTIM -#define ISNEWER(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 ISNEWER(S,T) (S.st_mtime >= T.st_mtime) -#endif - -#ifdef WIN32 -#define nuldev "nul" -#define ACCESS_MODE 4 -#define DUP _dup -#define DUPP _dup2 -#define uexit exit -#define GETCWD _getcwd -#else -#define nuldev "/dev/null" -#define ACCESS_MODE R_OK -#define DUP dup -#define DUPP dup2 -#define uexit _exit -#define GETCWD getcwd -#endif - -#define version "1.002" - -#define ERRLOG "mpxerr.log" -#define TEXERR "mpxerr.tex" -#define DVIERR "mpxerr.dvi" -#define TROFF_INERR "mpxerr.i" -#define TROFF_OUTERR "mpxerr.t" -#define DMP "dmp" -#define DVITOMP "dvitomp" -#define NEWER "newer" -#define MPTO "mpto" -#define MPTOTEXOPT "-tex" -#define MPTOTROPT "-troff" -#define TROFF "soelim | eqn -Tps -d$$ | troff -Tps" -#define TEX "tex" - -#define LNAM 255 -#define SNAM 128 -#define COMMAND_PARTS 10 - -#define ARGUMENT_IS(a) (!strncmp(av[curarg],(a),strlen((a)))) - -#define TMPNAME_EXT(a,b) { strcpy(a,tmpname); strcat(a,b); } - -#define RENAME(a,b) { if (debug) fprintf(stderr,"%s: renaming %s to %s\n",progname,a,b); \ - rename(a,b); } - -#define split_command(a,b) do_split_command(a,b,' ') - -#define split_pipes(a,b) do_split_command(a,b,'|') - -/* Define 'getcwd' for systems that do not implement it */ - -#ifdef NO_GETCWD -#define GETCWD(p,s) NULL -#endif - - -/* Temporary files */ -char mp_i[SNAM], mp_t[SNAM], mp_tmp[SNAM], mp_log[SNAM]; - -char *mp_tex = NULL; - -int debug = 0; - -char *progname; - - -void -mess(char *progname) -{ - fprintf(stderr, "Try `%s --help' for more information.\n", progname); - uexit(1); -} - -void -default_erasetmp(void) -{ - char wrk[SNAM]; - char *p; - strcpy(wrk, mp_tex); - p = strrchr(wrk, '.'); - *p = '\0'; strcat(wrk, ".aux"); remove(wrk); - *p = '\0'; strcat(wrk, ".pdf"); remove(wrk); - *p = '\0'; strcat(wrk, ".toc"); remove(wrk); - *p = '\0'; strcat(wrk, ".idx"); remove(wrk); - *p = '\0'; strcat(wrk, ".ent"); remove(wrk); - *p = '\0'; strcat(wrk, ".out"); remove(wrk); - *p = '\0'; strcat(wrk, ".nav"); remove(wrk); - *p = '\0'; strcat(wrk, ".snm"); remove(wrk); - *p = '\0'; strcat(wrk, ".tui"); remove(wrk); -} - -void -erasetmp(void) -{ - char wrk[SNAM]; - char *p; - char cur_path[1024]; -#ifdef _WIN32 - struct _finddata_t c_file; - long hFile; -#else - struct dirent *entry; - DIR *d; -#endif - if (debug) - return; - - if (mp_tex != NULL) { - remove(mp_tex); - strcpy(wrk, mp_tex); - if ((p = strrchr(wrk, '.'))) { - *p = '\0'; - /* now wrk is identical to tmpname */ - if(GETCWD(cur_path,1020) == NULL) { - /* don't know where we are, back to old behaviour */ - default_erasetmp(); - } else { -#ifdef _WIN32 - strcat(cur_path,"/*"); - if ((hFile = _findfirst (cur_path, &c_file)) == -1L) { - default_erasetmp(); - } else { - if (strstr(c_file.name,wrk)==c_file.name) - remove(c_file.name); - while (_findnext (hFile, &c_file) != -1L) { - if (strstr(c_file.name,wrk)==c_file.name) - remove(c_file.name); - } - _findclose (hFile); /* no more entries => close directory */ - } -#else - if ((d = opendir(cur_path)) == NULL) { - default_erasetmp(); - } else { - while ((entry = readdir (d)) != NULL) { - if (strstr(entry->d_name,wrk)==entry->d_name) - remove(entry->d_name); - } - closedir(d); - } -#endif - } - } - } - if (mp_i[0]) { - remove(mp_i); - } - if (mp_t[0]) { - remove(mp_t); - } - if (mp_tmp[0]) { - remove(mp_tmp); - } - if (mp_log[0]) { - remove(mp_log); - } -} - -FILE * -makempx_xfopen(char *name, char *mode) -{ - FILE *ret; - if (!(ret = fopen(name, mode))) { - if (*mode == 'r') { - fprintf(stderr, "Cannot open %s for reading.\n", name); - } else { - fprintf(stderr, "Cannot open %s for writing.\n", name); - } - erasetmp(); - uexit(1); - } - return ret; -} - - -int -run_command(int count, char **cmdl) -{ - int i; - char *cmd; - int retcode; -#ifndef WIN32 - pid_t child; -#endif - char **options = NULL; - /* return non-zero by default, signalling an error */ - retcode = -1; - - if (count < 1 || cmdl == NULL || cmdl[0] == NULL) - return retcode; - - options = xmalloc(sizeof(char *) * (count + 1)); - cmd = xstrdup(cmdl[0]); - - for (i = 0; i < count; i++) - options[i] = cmdl[i]; - options[count] = NULL; - if (debug) { - fprintf(stderr, "%s: running command", progname); - for (i = 0; i < count; i++) - fprintf(stderr, " %s", options[i]); - fprintf(stderr, "\n"); - } -#ifndef WIN32 - { - child = fork(); - if (child >= 0) { - if (child == 0) { - execvp(cmd, options); - } else - wait(&retcode); - } - free(cmd); - free(options); - } - return WEXITSTATUS(retcode); -#else - retcode = spawnvp(P_WAIT, cmd, options); - free(cmd); - free(options); - return retcode; -#endif -} - -int -do_split_command(char *maincmd, char **cmdline, char target) -{ - char *piece; - char *cmd; - unsigned int i; - int ret = 0; - int in_string = 0; - if (strlen(maincmd) == 0) - return 0; - cmd = xstrdup(maincmd); - i = 0; - while (cmd[i] == ' ') - i++; - piece = cmd; - for (; i <= strlen(maincmd); i++) { - if (in_string == 1) { - if (cmd[i] == '"') { - in_string = 0; - } - } else if (in_string == 2) { - if (cmd[i] == '\'') { - in_string = 0; - } - } else { - if (cmd[i] == '"') { - in_string = 1; - } else if (cmd[i] == '\'') { - in_string = 2; - } else if (cmd[i] == target) { - cmd[i] = 0; - if (ret == COMMAND_PARTS) { - fprintf(stderr, - "%s: Executable command too complex.\n", - progname); - mess(progname); - } - cmdline[ret++] = xstrdup(piece); - while (i < strlen(maincmd) && cmd[(i + 1)] == ' ') - i++; - piece = cmd + i + 1; - } - } - } - if (*piece) { - if (ret == COMMAND_PARTS) { - fprintf(stderr, "%s: Executable command too complex.\n", - progname); - mess(progname); - } - cmdline[ret++] = xstrdup(piece); - } - return ret; -} - - -int -do_newer(char *source, char *target) -{ -#ifndef INLINE_NEWER - char *cmdline[] = { NEWER, source, target }; - return run_command(3, cmdline); -#else - struct stat source_stat, target_stat; - - /* check the target file */ - if (stat(target, &target_stat) < 0) - return 0; /* true */ - - /* check the source file */ - if (stat(source, &source_stat) < 0) - return 1; /* false */ - - if (ISNEWER(source_stat, target_stat)) - return 0; - - return 1; -#endif -} - -#define MBUF 512 - -void -prepare_tex(char *texname, char *tmpname) -{ - int i; - FILE *fr, *fw; - char buffer[MBUF]; - char *tmpfile = NULL; - char *texkeep = NULL; /* for debugging */ - char *mptexpre = NULL; - - mptexpre = kpse_var_value("MPTEXPRE"); - - if (!mptexpre) - mptexpre = xstrdup("mptexpre.tex"); - - if (!access(mptexpre, ACCESS_MODE)) { - tmpfile = concat(tmpname, ".tmp"); - fr = makempx_xfopen(mptexpre, "r"); - fw = makempx_xfopen(tmpfile, "wb"); - - while ((i = fread(buffer, 1, MBUF, fr))) - fwrite(buffer, 1, i, fw); - fclose(fr); - fr = makempx_xfopen(texname, "r"); - while ((i = fread(buffer, 1, MBUF, fr))) - fwrite(buffer, 1, i, fw); - fclose(fr); - fclose(fw); - if (debug) { - texkeep = concat(texname, ".keep"); - RENAME(texname, texkeep); - } else { - remove(texname); - } - RENAME(tmpfile, texname); - } -} - -int -main(int ac, char **av) -{ - char **cmdline, **cmdbits; - char whatever_to_mpx[SNAM], infile[SNAM], inerror[SNAM]; - int retcode, i, sav_o, sav_e, sav_i; - FILE *fr, *fw, *few, *fnulr, *fnulw; - - /* TeX command name */ - char maincmd[(LNAM + 1)]; - - int mpmode = 0; - char tmpname[] = "mpXXXXXX"; - - char *mpfile = NULL; - char *mpxfile = NULL; - char *tmpstring = NULL; - - int cmdlength = 1; - int cmdbitlength = 1; - - int curarg = 0; - - cmdline = xmalloc(sizeof(char *) * COMMAND_PARTS); - cmdbits = xmalloc(sizeof(char *) * COMMAND_PARTS); - for (i = 0; i < COMMAND_PARTS; i++) { - cmdline[i] = NULL; - cmdbits[i] = NULL; - } - - progname = av[0]; - - /* Initialize buffer for temporary file names */ - for (i = 0; i < SNAM; i++) { - mp_i[i] = '\0'; - mp_t[i] = '\0'; - mp_tmp[i] = '\0'; - mp_log[i] = '\0'; - } - - kpse_set_progname(progname); - - /* Set TeX command */ - if ((tmpstring = kpse_var_value("TEX"))) - strncpy(maincmd, tmpstring, LNAM); - else if ((tmpstring = kpse_var_value("MPXMAINCMD"))) - strncpy(maincmd, tmpstring, LNAM); - else - strncpy(maincmd, TEX, LNAM); - if (tmpstring) - free(tmpstring); - - strncat(maincmd, " --parse-first-line --interaction=nonstopmode", - (LNAM - strlen(maincmd))); - - while (curarg < (ac - 1)) { - - curarg++; - - if (ARGUMENT_IS("-help") || ARGUMENT_IS("--help")) { - - fprintf(stderr, - "Usage: %s [-tex[=]|-troff[=]] MPFILE MPXFILE.\n", - av[0]); - fputs - (" If MPXFILE is older than MPFILE, translate the labels from the MetaPost\n" - " input file MPFILE to low-level commands in MPXFILE, by running\n" - " " MPTO " " MPTOTEXOPT ", " TEX ", and " DVITOMP "\n" - " by default; or, if -troff is specified,\n" " " MPTO - " " MPTOTROPT ", " TROFF ", and " DMP ".\n\n" - " The current directory is used for writing temporary files. Errors are\n" - " left in mpxerr.{tex,log,dvi}.\n\n" - " If the file named in $MPTEXPRE (mptexpre.tex by default) exists, it is\n" - " prepended to the output in tex mode.\n\n" - "Email bug reports to metapost@tug.org.\n", stderr); - uexit(0); - - } else if (ARGUMENT_IS("-version") || ARGUMENT_IS("--version")) { - - fprintf(stdout, "%s %s\n", progname, version); - fputs - ("There is NO warranty. This program is in the public domain.\n" - "Original author: John Hobby.\n" - "Current maintainer: Taco Hoekwater.\n", stdout); - uexit(0); - - } else if (ARGUMENT_IS("-debug") || ARGUMENT_IS("--debug")) { - - debug = 1; - - } else if (ARGUMENT_IS("-troff") || ARGUMENT_IS("--troff")) { - - mpmode = 1; - - if (ARGUMENT_IS("-troff=") || ARGUMENT_IS("--troff=")) { - i = 7; - if (*(av[curarg] + i) == '=') - i++; - if (*(av[curarg] + i) == '\'' || *(av[curarg] + i) == '\"') { - strncpy(maincmd, av[curarg] + i + 1, LNAM); - *(maincmd + strlen(maincmd)) = 0; - } else { - strncpy(maincmd, av[curarg] + i, LNAM); - } - } else { - strncpy(maincmd, TROFF, LNAM); - } - - } else if (ARGUMENT_IS("-tex") || ARGUMENT_IS("--tex")) { - - mpmode = 0; - - if (ARGUMENT_IS("-tex=") || ARGUMENT_IS("--tex=")) { - i = 5; - if (*(av[curarg] + i) == '=') - i++; - if (*(av[curarg] + i) == '\'' || *(av[curarg] + i) == '\"') { - strncpy(maincmd, av[curarg] + i + 1, LNAM); - *(maincmd + strlen(maincmd)) = 0; - } else { - strncpy(maincmd, av[curarg] + i, LNAM); - } - } - - } else if (ARGUMENT_IS("-")) { - fprintf(stderr, "%s: Invalid option: %s.\n", progname, - av[curarg]); - mess(progname); - } else { - if (mpfile == NULL) { - - if (strchr(av[curarg], ' ') && (av[curarg][0] != '\"')) - mpfile = concat3("\"", av[curarg], "\""); - else - mpfile = strdup(av[curarg]); - - } else if (mpxfile == NULL) { - - if (strchr(av[curarg], ' ') && (av[curarg][0] != '\"')) - mpxfile = concat3("\"", av[curarg], "\""); - else - mpxfile = strdup(av[curarg]); - - } else { - fprintf(stderr, "%s: Extra argument %s.\n", progname, - av[curarg]); - mess(progname); - } - } - } - - if (mpfile == NULL || mpxfile == NULL) { - fprintf(stderr, "%s: Need exactly two file arguments.\n", - progname); - mess(progname); - } - - /* Check if mpfile is newer than mpxfile */ - - retcode = do_newer(mpfile, mpxfile); - - /* If MPX file is up-to-date or if MP file does not exist, do nothing. */ - if (retcode) - uexit(0); - -#ifdef HAVE_MKSTEMP - i = mkstemp(tmpname); - if (i == -1) - uexit(1); - close(i); - remove(tmpname); -#else -#ifdef HAVE_MKTEMP - tmpstring = mktemp(tmpname); - if ((tmpstring == NULL) || strlen(tmpname) == 0) - uexit(1); - /* this should not really be needed, but better - safe than sorry. */ - if (tmpstring != tmpname) { - i = strlen(tmpstring); - if (i > 8) i = 8; - strncpy(tmpname, tmpstring, i); - } -#else - sprintf(tmpname, "mp%06d", (time(NULL) % 1000000)); -#endif -#endif - - mp_tex = concat(tmpname, ".tex"); - - /* step 1: */ - - fw = makempx_xfopen(mp_tex, "wb"); - few = makempx_xfopen(ERRLOG, "wb"); - - cmdline[0] = MPTO; - cmdline[1] = (mpmode == 0 ? MPTOTEXOPT : MPTOTROPT); - cmdline[2] = mpfile; - - sav_o = DUP(fileno(stdout)); - DUPP(fileno(fw), fileno(stdout)); - sav_e = DUP(fileno(stderr)); - DUPP(fileno(few), fileno(stderr)); - - retcode = run_command(3, cmdline); - - DUPP(sav_o, fileno(stdout)); - close(sav_o); - fclose(fw); - - DUPP(sav_e, fileno(stderr)); - close(sav_e); - fclose(few); - - if (retcode) { - fprintf(stderr, "%s: Command failed: %s %s %s\n", - progname, cmdline[0], cmdline[1], cmdline[2]); - erasetmp(); - uexit(1); - } - - /* step 2: */ - - if (mpmode == 0) { /* TeX mode */ - - prepare_tex(mp_tex, tmpname); /* check for mptexpre.tex */ - - if (strlen(maincmd) > (LNAM - strlen(mp_tex) - 1)) { - fprintf(stderr, "%s: Command too complex: %s\n", progname, - maincmd); - erasetmp(); - uexit(1); - } - strcat(maincmd, " "); - strcat(maincmd, mp_tex); - cmdlength = split_command(maincmd, cmdline); - - fnulr = makempx_xfopen(nuldev, "r"); - sav_i = DUP(fileno(stdin)); - DUPP(fileno(fnulr), fileno(stdin)); - - fnulw = makempx_xfopen(nuldev, "w"); - sav_o = DUP(fileno(stdout)); - DUPP(fileno(fnulw), fileno(stdout)); - - retcode = run_command(cmdlength, cmdline); - - DUPP(sav_i, fileno(stdin)); - close(sav_i); - fclose(fnulr); - DUPP(sav_o, fileno(stdout)); - close(sav_o); - fclose(fnulw); - - TMPNAME_EXT(mp_log, ".log"); - - if (!retcode) { - strcpy(whatever_to_mpx, DVITOMP); - TMPNAME_EXT(infile, ".dvi"); - strcpy(inerror, DVIERR); - } else { - RENAME(mp_tex, TEXERR); - RENAME(mp_log, ERRLOG); - fprintf(stderr, "%s: Command failed:", progname); - for (i = 0; i < (cmdlength - 1); i++) - fprintf(stderr, " %s", cmdline[i]); - fprintf(stderr, " %s", TEXERR); - fprintf(stderr, "; see mpxerr.log\n"); - erasetmp(); - uexit(2); - } - } else if (mpmode == 1) { /* troff mode */ - - TMPNAME_EXT(mp_i, ".i"); - RENAME(mp_tex, mp_i); - TMPNAME_EXT(mp_t, ".t"); - fr = makempx_xfopen(mp_i, "r"); - TMPNAME_EXT(mp_tmp, ".tmp"); - fw = makempx_xfopen(mp_tmp, "wb"); - - /* split the command in bits */ - cmdbitlength = split_pipes(maincmd, cmdbits); - - for (i = 0; i < cmdbitlength; i++) { - cmdlength = split_command(cmdbits[i], cmdline); - - sav_i = DUP(fileno(stdin)); - sav_o = DUP(fileno(stdout)); - DUPP(fileno(fr), fileno(stdin)); - DUPP(fileno(fw), fileno(stdout)); - - retcode = run_command(cmdlength, cmdline); - - DUPP(sav_i, fileno(stdin)); - close(sav_i); - DUPP(sav_o, fileno(stdout)); - close(sav_o); - fclose(fr); - fclose(fw); - if (retcode) { - RENAME(mp_i, TROFF_INERR); - - fprintf(stderr, "%s: Command failed:", progname); - for (i = 0; i < cmdlength; i++) { - if (strcmp(cmdline[i], mp_i) == 0) - fprintf(stderr, " %s", TROFF_INERR); - else - fprintf(stderr, " %s", cmdline[i]); - } - fprintf(stderr, "\n"); - erasetmp(); - uexit(2); - } - if (i < cmdbitlength - 1) { - if (i % 2 == 0) { - fr = makempx_xfopen(mp_tmp, "r"); - fw = makempx_xfopen(mp_t, "wb"); - strcpy(infile, mp_t); - } else { - fr = makempx_xfopen(mp_t, "r"); - fw = makempx_xfopen(mp_tmp, "wb"); - strcpy(infile, mp_tmp); - } - } - } - strcpy(whatever_to_mpx, DMP); - strcpy(inerror, TROFF_OUTERR); - } - - /* Step 3: */ - - fw = makempx_xfopen(ERRLOG, "wb"); - - sav_o = DUP(fileno(stdout)); - DUPP(fileno(fw), fileno(stdout)); - - cmdline[0] = whatever_to_mpx; - cmdline[1] = infile; - cmdline[2] = mpxfile; - retcode = run_command(3, cmdline); - - DUPP(sav_o, fileno(stdout)); - close(sav_o); - fclose(fw); - - if (retcode) { - RENAME(infile, inerror); - if (mpmode == 1) - RENAME(mp_i, TROFF_INERR); - if (!debug) - remove(mpxfile); - fprintf(stderr, "%s: Command failed: %s %s %s\n", - progname, whatever_to_mpx, inerror, mpxfile); - erasetmp(); - uexit(3); - } - if (!debug) { - remove(ERRLOG); - remove(infile); - } - erasetmp(); - uexit(0); -} diff --git a/Build/source/texk/web2c/mpware/makempx.in b/Build/source/texk/web2c/mpware/makempx.in deleted file mode 100644 index 45cd678ec64..00000000000 --- a/Build/source/texk/web2c/mpware/makempx.in +++ /dev/null @@ -1,182 +0,0 @@ -#!/bin/sh -# $Id: makempx.in,v 1.7 2005/04/28 06:45:21 taco 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.992 - -: ${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='soelim -k | 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=|-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. -Current maintainer: Taco Hoekwater." - 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; 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 deleted file mode 100644 index 04ee33a6271..00000000000 --- a/Build/source/texk/web2c/mpware/mpto.c +++ /dev/null @@ -1,490 +0,0 @@ -/* $Id: mpto.c,v 1.15 2005/08/28 11:42:55 taco 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, for AMIGA - */ - -#include -#include - -#include - - -/* 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 = "\n\\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 or 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 *t; /* for finding start of last line */ - char c; - char *res = NULL; - do { - if (*aa == 0) - if ((aa = getline()) == NULL) - err("btex section does not end"); - - if (getbta(aa) && *tt == 'e') { - s = tt; - } else { - if (*tt == 'b') - err("btex in TeX mode"); - if (*tt == 'v') - err("verbatimtex in TeX mode"); - s = aa; - } - c = *s; - *s = 0; - if (res==NULL) { - res = malloc(strlen(bb)+2); - if (res==NULL) - err("memory allocation failure"); - res = strncpy(res,bb,(strlen(bb)+1)); - } else { - res = realloc(res,strlen(res)+strlen(bb)+2); - if (res==NULL) - err("memory allocation failure"); - res = strncat(res,bb, strlen(bb)); - } - if (c == '\0') - res = strncat(res, "\n", 1); - *s = c; - } while (*tt != 'e'); - /* whitespace at the end */ - for (s = res + strlen(res) - 1; - s >= res && (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'); s--); - t = s; - *(++s) = '\0'; - /* whitespace at the start */ - for (s = res; - s < (res + strlen(res)) && (*s == ' ' || *s == '\t' || *s == '\r' - || *s == '\n'); s++); - for (; *t != '\n' && t > s; t--); - printf("%s", s); - /* put no '%' at end if it's only 1 line total, starting with '%'; - * this covers the special case "%&format" in a single line. */ - if (t != s || *t != '%') - printf("%%"); - free(res); -} - - -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]", 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 1.003\n\ -This program is in the public domain.\n\ -Primary author of mpto: John Hobby.\n\ -Current maintainer: Taco Hoekwater.\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/newer.c b/Build/source/texk/web2c/mpware/newer.c deleted file mode 100644 index 749c091a7c7..00000000000 --- a/Build/source/texk/web2c/mpware/newer.c +++ /dev/null @@ -1,147 +0,0 @@ -/* $Id: newer.c,v 1.10 2005/11/30 08:49:55 taco Exp $ - * 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 -#include -#if !defined(WIN32) || defined(__MINGW32__) -#include -#include -#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. */ -#ifdef HAVE_STRUCT_STAT_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 = 0; -int quiet = 0; -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) { - - quiet = 1; - 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 files, including missing target files\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 1.002\n\ -This program is in the public domain.\n\ -Primary author of newer: John Hobby.\n\ -Current maintainer: Taco Hoekwater.\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 && !quiet) { - 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 (!quiet) { - 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; -} -- cgit v1.2.3