summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/dvipdfmx/ChangeLog.TL5
-rw-r--r--Build/source/texk/dvipdfmx/src/cff.c1
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxutil.c1
-rw-r--r--Build/source/texk/dvipdfmx/src/mem.c1
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencoding.c1
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencrypt.c1
-rw-r--r--Build/source/texk/kpathsea/ChangeLog132
-rw-r--r--Build/source/texk/kpathsea/Makefile.in2
-rw-r--r--Build/source/texk/kpathsea/absolute.c17
-rw-r--r--Build/source/texk/kpathsea/absolute.h6
-rw-r--r--Build/source/texk/kpathsea/access.c2
-rw-r--r--Build/source/texk/kpathsea/atou.c3
-rw-r--r--Build/source/texk/kpathsea/cnf.c58
-rw-r--r--Build/source/texk/kpathsea/cnf.h7
-rw-r--r--Build/source/texk/kpathsea/concat.c2
-rw-r--r--Build/source/texk/kpathsea/concat3.c10
-rwxr-xr-xBuild/source/texk/kpathsea/configure24
-rw-r--r--Build/source/texk/kpathsea/configure.in6
-rw-r--r--Build/source/texk/kpathsea/db.c142
-rw-r--r--Build/source/texk/kpathsea/db.h30
-rw-r--r--Build/source/texk/kpathsea/debug.c20
-rw-r--r--Build/source/texk/kpathsea/debug.h12
-rw-r--r--Build/source/texk/kpathsea/default.h7
-rw-r--r--Build/source/texk/kpathsea/dir.c46
-rw-r--r--Build/source/texk/kpathsea/elt-dirs.c98
-rw-r--r--Build/source/texk/kpathsea/expand.c97
-rw-r--r--Build/source/texk/kpathsea/expand.h13
-rw-r--r--Build/source/texk/kpathsea/extend-fname.c2
-rw-r--r--Build/source/texk/kpathsea/file-p.c2
-rw-r--r--Build/source/texk/kpathsea/find-suffix.c2
-rw-r--r--Build/source/texk/kpathsea/fn.c16
-rw-r--r--Build/source/texk/kpathsea/fn.h14
-rw-r--r--Build/source/texk/kpathsea/fontmap.c46
-rw-r--r--Build/source/texk/kpathsea/fontmap.h6
-rw-r--r--Build/source/texk/kpathsea/hash.c61
-rw-r--r--Build/source/texk/kpathsea/hash.h19
-rw-r--r--Build/source/texk/kpathsea/kdefault.c13
-rw-r--r--Build/source/texk/kpathsea/kpathsea.c228
-rw-r--r--Build/source/texk/kpathsea/kpsestat.c2
-rw-r--r--Build/source/texk/kpathsea/kpsewhich.c90
-rw-r--r--Build/source/texk/kpathsea/lib.h118
-rw-r--r--Build/source/texk/kpathsea/line.c2
-rw-r--r--Build/source/texk/kpathsea/line.h2
-rw-r--r--Build/source/texk/kpathsea/magstep.c14
-rw-r--r--Build/source/texk/kpathsea/magstep.h7
-rw-r--r--Build/source/texk/kpathsea/make-suffix.c2
-rw-r--r--Build/source/texk/kpathsea/mingw32.c219
-rw-r--r--Build/source/texk/kpathsea/mingw32.h20
-rw-r--r--Build/source/texk/kpathsea/path-elt.c56
-rw-r--r--Build/source/texk/kpathsea/pathsearch.c184
-rw-r--r--Build/source/texk/kpathsea/pathsearch.h60
-rw-r--r--Build/source/texk/kpathsea/proginit.c39
-rw-r--r--Build/source/texk/kpathsea/proginit.h10
-rw-r--r--Build/source/texk/kpathsea/progname.c167
-rw-r--r--Build/source/texk/kpathsea/progname.h25
-rw-r--r--Build/source/texk/kpathsea/readable.c17
-rw-r--r--Build/source/texk/kpathsea/readable.h6
-rw-r--r--Build/source/texk/kpathsea/readlink.c2
-rw-r--r--Build/source/texk/kpathsea/recorder.h6
-rw-r--r--Build/source/texk/kpathsea/rm-suffix.c2
-rw-r--r--Build/source/texk/kpathsea/stamp-aclocal2
-rw-r--r--Build/source/texk/kpathsea/stamp-auto.in2
-rw-r--r--Build/source/texk/kpathsea/stamp-configure2
-rw-r--r--Build/source/texk/kpathsea/str-list.c12
-rw-r--r--Build/source/texk/kpathsea/str-list.h12
-rw-r--r--Build/source/texk/kpathsea/str-llist.c4
-rw-r--r--Build/source/texk/kpathsea/str-llist.h4
-rw-r--r--Build/source/texk/kpathsea/tex-file.c263
-rw-r--r--Build/source/texk/kpathsea/tex-file.h184
-rw-r--r--Build/source/texk/kpathsea/tex-glyph.c171
-rw-r--r--Build/source/texk/kpathsea/tex-glyph.h27
-rw-r--r--Build/source/texk/kpathsea/tex-hush.c15
-rw-r--r--Build/source/texk/kpathsea/tex-hush.h6
-rw-r--r--Build/source/texk/kpathsea/tex-make.c106
-rw-r--r--Build/source/texk/kpathsea/tex-make.h17
-rw-r--r--Build/source/texk/kpathsea/tilde.c15
-rw-r--r--Build/source/texk/kpathsea/tilde.h6
-rw-r--r--Build/source/texk/kpathsea/truncate.c12
-rw-r--r--Build/source/texk/kpathsea/truncate.h6
-rw-r--r--Build/source/texk/kpathsea/types.h231
-rw-r--r--Build/source/texk/kpathsea/uppercasify.c2
-rw-r--r--Build/source/texk/kpathsea/variable.c90
-rw-r--r--Build/source/texk/kpathsea/variable.h9
-rw-r--r--Build/source/texk/kpathsea/version.c2
-rw-r--r--Build/source/texk/kpathsea/xbasename.c2
-rw-r--r--Build/source/texk/kpathsea/xcalloc.c2
-rw-r--r--Build/source/texk/kpathsea/xdirname.c4
-rw-r--r--Build/source/texk/kpathsea/xfopen.c5
-rw-r--r--Build/source/texk/kpathsea/xfseek.c4
-rw-r--r--Build/source/texk/kpathsea/xfseeko.c4
-rw-r--r--Build/source/texk/kpathsea/xftell.c2
-rw-r--r--Build/source/texk/kpathsea/xftello.c2
-rw-r--r--Build/source/texk/kpathsea/xgetcwd.c8
-rw-r--r--Build/source/texk/kpathsea/xmalloc.c2
-rw-r--r--Build/source/texk/kpathsea/xopendir.c4
-rw-r--r--Build/source/texk/kpathsea/xopendir.h4
-rw-r--r--Build/source/texk/kpathsea/xputenv.c46
-rw-r--r--Build/source/texk/kpathsea/xrealloc.c4
-rw-r--r--Build/source/texk/kpathsea/xstat.c7
-rw-r--r--Build/source/texk/kpathsea/xstat.h4
-rw-r--r--Build/source/texk/kpathsea/xstrdup.c2
-rw-r--r--Build/source/texk/xdvipdfmx/ChangeLog.TL25
-rw-r--r--Build/source/texk/xdvipdfmx/src/cff.c92
-rw-r--r--Build/source/texk/xdvipdfmx/src/dpxutil.c1
-rw-r--r--Build/source/texk/xdvipdfmx/src/mem.c1
-rw-r--r--Build/source/texk/xdvipdfmx/src/pdfencoding.c1
-rw-r--r--Build/source/texk/xdvipdfmx/src/pdfencrypt.c3
107 files changed, 2230 insertions, 1402 deletions
diff --git a/Build/source/texk/dvipdfmx/ChangeLog.TL b/Build/source/texk/dvipdfmx/ChangeLog.TL
index b8fb14f073b..157c1f6e854 100644
--- a/Build/source/texk/dvipdfmx/ChangeLog.TL
+++ b/Build/source/texk/dvipdfmx/ChangeLog.TL
@@ -1,6 +1,11 @@
ChangeLog.TL: Changes for dvipdfmx (teTeX / TeX live)
=====================================================
+2009-03-16 Peter Breitenlohner <peb@mppmu.mpg.de>
+ * src/cff.c, src/dpxutil.c, src/mem.c, src/pdfencoding.c,
+ src/pdfencrypt.c: Must include Kpathsea headers (via `system.h')
+ before including `mem.h'.
+
2008-04-06 Peter Breitenlohner <peb@mppmu.mpg.de>
* configure.in: respect library dependencies.
diff --git a/Build/source/texk/dvipdfmx/src/cff.c b/Build/source/texk/dvipdfmx/src/cff.c
index e2f7a7b3c37..70adb996fcd 100644
--- a/Build/source/texk/dvipdfmx/src/cff.c
+++ b/Build/source/texk/dvipdfmx/src/cff.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.c b/Build/source/texk/dvipdfmx/src/dpxutil.c
index c87568b96a5..a30a3269dfa 100644
--- a/Build/source/texk/dvipdfmx/src/dpxutil.c
+++ b/Build/source/texk/dvipdfmx/src/dpxutil.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <time.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
diff --git a/Build/source/texk/dvipdfmx/src/mem.c b/Build/source/texk/dvipdfmx/src/mem.c
index e474f407e6d..97e46cdd0d9 100644
--- a/Build/source/texk/dvipdfmx/src/mem.c
+++ b/Build/source/texk/dvipdfmx/src/mem.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
diff --git a/Build/source/texk/dvipdfmx/src/pdfencoding.c b/Build/source/texk/dvipdfmx/src/pdfencoding.c
index 4f50b312372..296674d9880 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencoding.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencoding.c
@@ -28,6 +28,7 @@
#include <string.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "dpxutil.h"
diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.c b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
index 932b3960da1..e76f18eedaa 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencrypt.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
@@ -36,6 +36,7 @@
#include <unistd.h>
#endif /* WIN32 */
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "pdfobj.h"
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 8f75899a6e6..983b83b762e 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,135 @@
+2009-03-16 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * db.c, debug.c, debug.h, dir.c, elt-dirs.c, hash.c, pathsearch.c,
+ progname.c, tex-file.c, variable.c:
+ Rename KPSE_DEBUG_P into KPATHSEA_DEBUG_P (using kpse->debug)
+ Define KPSE_DEBUG_SET and KPSE_DEBUG_P (using kpathsea_debug)
+ compatible with old API.
+
+2009-03-12 Taco Hoekwater <taco@luatex.org>
+
+ New Kpathsea API: Make libkpathsea reenterable.
+
+ * src/texk/kpathsea/extend-fname.c, src/texk/kpathsea/file-p.c,
+ src/texk/kpathsea/xftello.c, src/texk/kpathsea/make-suffix.c,
+ src/texk/kpathsea/xcalloc.c, src/texk/kpathsea/line.c,
+ src/texk/kpathsea/readlink.c, src/texk/kpathsea/concat3.c,
+ src/texk/kpathsea/line.h, src/texk/kpathsea/str-llist.c,
+ src/texk/kpathsea/kpsestat.c, src/texk/kpathsea/xmalloc.c,
+ src/texk/kpathsea/str-llist.h, src/texk/kpathsea/xbasename.c,
+ src/texk/kpathsea/xfseeko.c, src/texk/kpathsea/xgetcwd.c,
+ src/texk/kpathsea/concat.c, src/texk/kpathsea/xstat.h,
+ src/texk/kpathsea/atou.c, src/texk/kpathsea/rm-suffix.c,
+ src/texk/kpathsea/str-list.c, src/texk/kpathsea/find-suffix.c,
+ src/texk/kpathsea/hash.c, src/texk/kpathsea/xfseek.c,
+ src/texk/kpathsea/debug.c, src/texk/kpathsea/str-list.h,
+ src/texk/kpathsea/hash.h, src/texk/kpathsea/xopendir.c,
+ src/texk/kpathsea/uppercasify.c, src/texk/kpathsea/debug.h,
+ src/texk/kpathsea/xopendir.h, src/texk/kpathsea/xftell.c,
+ src/texk/kpathsea/xfopen.c, src/texk/kpathsea/access.c,
+ src/texk/kpathsea/fn.c, src/texk/kpathsea/xdirname.c,
+ src/texk/kpathsea/fn.h, src/texk/kpathsea/xstrdup.c,
+ src/texk/kpathsea/xrealloc.c, src/texk/kpathsea/xstat.c:
+ All of these files have stopped using the PxC and PxH macros.
+
+ Besides this change, there are a few extra changes to specific
+ files.
+
+ * debug.c: add a guard that disables debug reporting if
+ the oldinterface is not compiled in the library, and uses the
+ kpse_def_inst structure otherwise.
+
+ * hash.c (hash_free): new function.
+
+ * concat3.c: now allows the second and third argument to be NULL
+
+ * src/texk/kpathsea/tex-hush.h, src/texk/kpathsea/tex-make.c,
+ src/texk/kpathsea/progname.h, src/texk/kpathsea/dir.c,
+ src/texk/kpathsea/absolute.c, src/texk/kpathsea/expand.c,
+ src/texk/kpathsea/tex-make.h, src/texk/kpathsea/tex-glyph.c,
+ src/texk/kpathsea/tex-file.h, src/texk/kpathsea/absolute.h,
+ src/texk/kpathsea/expand.h, src/texk/kpathsea/truncate.c,
+ src/texk/kpathsea/variable.c, src/texk/kpathsea/tex-glyph.h,
+ src/texk/kpathsea/default.h, src/texk/kpathsea/variable.h,
+ src/texk/kpathsea/truncate.h, src/texk/kpathsea/kdefault.c,
+ src/texk/kpathsea/readable.c, src/texk/kpathsea/tilde.c,
+ src/texk/kpathsea/fontmap.c, src/texk/kpathsea/readable.h,
+ src/texk/kpathsea/tilde.h, src/texk/kpathsea/cnf.c,
+ src/texk/kpathsea/fontmap.h, src/texk/kpathsea/cnf.h,
+ src/texk/kpathsea/path-elt.c, src/texk/kpathsea/pathsearch.c,
+ src/texk/kpathsea/elt-dirs.c, src/texk/kpathsea/db.c,
+ src/texk/kpathsea/pathsearch.h, src/texk/kpathsea/db.h,
+ src/texk/kpathsea/proginit.c, src/texk/kpathsea/magstep.c,
+ src/texk/kpathsea/proginit.h, src/texk/kpathsea/magstep.h,
+ src/texk/kpathsea/tex-hush.c:
+ All of these files have stopped using the PxC and PxH macros.
+
+ In all of these files, the exported functions whose names
+ started with 'kpse_' have been renamed to use the prefix
+ 'kpathsea_' instead, and they now required an extra argument
+ that is a kpathsea instance structure. New one-line functions
+ with the old exported names have been added that use a default
+ kpathsea instance. The functions are build and exported only if
+ the preprocessor macro KPSE_COMPAT_API is defined (which it
+ usually is, though).
+
+ Besides these changes, there are a few extra changes to speficic
+ files.
+
+ * progname.c: Removed the variables program_invocation_name and
+ program_invocation_short_name, these are now part of the
+ kpathsea instance (in renamed form)
+
+ * progname.c, xputenv.c, lib.h: Some extra preprocessor macros
+ (LIB_FATALx) are added and a few others are changed so that
+ the library functions can give the proper invocation_name
+ in fatal error messages
+
+ * tex-file.c: The default instance variable is moved to the new
+ file kpathsea.c
+
+ * src/texk/kpathsea/kpathsea.c: New file containing the default
+ instance variables and the new functions kpathsea_new() and
+ kpathsea_finish()
+
+ * src/texk/kpathsea/version.c: Variable kpse_bug_address renamed
+ to kpathsea_bug_address.
+
+ * src/texk/kpathsea/types.h:
+ Added a preprocessor define KPSE_COMPAT_API, used throughout the
+ library. If it is undefined then the old-style functions and
+ definitions are not compiled.
+ Removed the win32-specific 'cached_home_directory' and 'volumes'
+ variables from the instance structure.
+ Added 'invocation_name' and 'invocation_short_name' variables to
+ the instance structure.
+ Removed the 'kpse_' prefix from the instance variables fallback_font,
+ fallback_resolutions_string, fallback_resolutions, and format_info.
+ Added prototypes for kpathsea_new() and kpathsea_finish().
+ Added #defines for kpse_bug_address, kpse_fallback_font,
+ kpse_fallback_resolutions_string, kpse_fallback_resolutions,
+ kpse_format_info, program_invocation_name, and
+ program_invocation_short_name
+
+ * src/texk/kpathsea/mingw32.c:
+ Disabled home directory caching: removed the function
+ uncache_home_directory() and the cached_home_directory
+ structure item.
+ Disabled volume queries: removed win32_volumes typedef,
+ the static functions lookup_volume_info(), add_volume_info(),
+ and GetCachedVolumeInformation(), as well as the functions
+ get_volume_info() and is_fat_volume().
+
+ * src/texk/kpathsea/mingw32.h: Removed volume_user_date typedef
+ and added declaration for get_home_directory()
+
+ * src/texk/kpathsea/kpsewhich.c: stop using PxC macros and
+ switch to new API interface
+
+ * src/texk/kpathsea/configure.ac: Bump the version numbers to 5.0.0 (provisionally)
+
+ * src/texk/kpathsea/Makefile.am: Add kpathsea.c
+
2009-03-05 Peter Breitenlohner <peb@mppmu.mpg.de>
Part 2 of patches from Taco Hoekwater for __MINGW32__
diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in
index 593a0188eb1..3fb569e9f1c 100644
--- a/Build/source/texk/kpathsea/Makefile.in
+++ b/Build/source/texk/kpathsea/Makefile.in
@@ -24,7 +24,7 @@ install_headers = *.h $(srcdir)/*.h
objects = tex-file.lo absolute.lo atou.lo cnf.lo concat.lo concat3.lo \
concatn.lo db.lo debug.lo dir.lo elt-dirs.lo expand.lo extend-fname.lo \
file-p.lo find-suffix.lo fn.lo fontmap.lo getopt.lo getopt1.lo hash.lo \
-kdefault.lo line.lo magstep.lo make-suffix.lo mingw32.lo path-elt.lo \
+kdefault.lo kpathsea.lo line.lo magstep.lo make-suffix.lo mingw32.lo path-elt.lo \
pathsearch.lo proginit.lo progname.lo readable.lo rm-suffix.lo \
str-list.lo str-llist.lo tex-glyph.lo tex-hush.lo tex-make.lo \
tilde.lo truncate.lo uppercasify.lo variable.lo version.lo xbasename.lo \
diff --git a/Build/source/texk/kpathsea/absolute.c b/Build/source/texk/kpathsea/absolute.c
index b25ecc919d4..6012c398b5b 100644
--- a/Build/source/texk/kpathsea/absolute.c
+++ b/Build/source/texk/kpathsea/absolute.c
@@ -25,8 +25,9 @@
to usefully generalize. */
boolean
-kpse_absolute_p P2C(const_string, filename, boolean, relative_ok)
+kpathsea_absolute_p (kpathsea kpse, const_string filename, boolean relative_ok)
{
+ (void)kpse; /* currenty not used */
#ifdef VMS
#include <string.h>
return strcspn (filename, "]>:") != strlen (filename);
@@ -58,6 +59,14 @@ kpse_absolute_p P2C(const_string, filename, boolean, relative_ok)
#endif /* not VMS */
}
+#if defined (KPSE_COMPAT_API)
+boolean
+kpse_absolute_p (const_string filename, boolean relative_ok)
+{
+ return kpathsea_absolute_p (kpse_def, filename, relative_ok);
+}
+#endif
+
#ifdef TEST
int main()
{
@@ -69,3 +78,9 @@ int main()
}
}
#endif /* TEST */
+
+/*
+Local variables:
+standalone-compile-command: "gcc -g -I. -I.. -DTEST absolute.c kpathsea.a"
+End:
+*/
diff --git a/Build/source/texk/kpathsea/absolute.h b/Build/source/texk/kpathsea/absolute.h
index 54a44778d78..85c07a15fca 100644
--- a/Build/source/texk/kpathsea/absolute.h
+++ b/Build/source/texk/kpathsea/absolute.h
@@ -26,6 +26,10 @@
/* True if FILENAME is absolute (/foo) or, if RELATIVE_OK is true,
explicitly relative (./foo, ../foo), else false (foo). */
-extern KPSEDLL boolean kpse_absolute_p P2H(const_string filename, boolean relative_ok);
+extern KPSEDLL boolean kpathsea_absolute_p (kpathsea kpse, const_string filename, boolean relative_ok);
+
+#if defined(KPSE_COMPAT_API)
+extern KPSEDLL boolean kpse_absolute_p (const_string filename, boolean relative_ok);
+#endif
#endif /* not KPATHSEA_ABSOLUTE_H */
diff --git a/Build/source/texk/kpathsea/access.c b/Build/source/texk/kpathsea/access.c
index 19bbdc49d54..81a6b238bce 100644
--- a/Build/source/texk/kpathsea/access.c
+++ b/Build/source/texk/kpathsea/access.c
@@ -28,7 +28,7 @@
*/
int
-main P2C(int, argc, char **, argv)
+main (int argc, char **argv)
{
int mode;
int status;
diff --git a/Build/source/texk/kpathsea/atou.c b/Build/source/texk/kpathsea/atou.c
index c609cc1d2f2..54edb046b82 100644
--- a/Build/source/texk/kpathsea/atou.c
+++ b/Build/source/texk/kpathsea/atou.c
@@ -18,12 +18,11 @@
#include "config.h"
unsigned
-atou P1C(const_string, s)
+atou (const_string s)
{
int i = atoi (s);
if (i < 0)
FATAL1 ("I expected a positive number, not %d", i);
-
return i;
}
diff --git a/Build/source/texk/kpathsea/cnf.c b/Build/source/texk/kpathsea/cnf.c
index 89fc9c93da8..3ec7e8678e7 100644
--- a/Build/source/texk/kpathsea/cnf.c
+++ b/Build/source/texk/kpathsea/cnf.c
@@ -31,10 +31,6 @@
#include <kpathsea/tex-file.h>
#include <kpathsea/variable.h>
-/* Declared in recorder.h, used in fontmap.c, web2c/lib/texmfmp.c. */
-void (*kpse_record_input) (const_string);
-void (*kpse_record_output) (const_string);
-
/* By using our own hash table, instead of the environment, we
complicate variable expansion (because we have to look in two
places), but we don't bang so much on the system. DOS and System V
@@ -42,7 +38,7 @@ void (*kpse_record_output) (const_string);
`kpse_init_format' can distinguish between values originating from
the cnf file and ones from environment variables, which can be useful
for users trying to figure out what's going on. */
-static hash_table_type cnf_hash;
+
#define CNF_HASH_SIZE 751
#define CNF_NAME "texmf.cnf"
@@ -53,7 +49,7 @@ static hash_table_type cnf_hash;
looking for the cnf value. */
static void
-do_line P1C(string, line)
+do_line (kpathsea kpse, string line)
{
unsigned len;
string start;
@@ -146,7 +142,7 @@ do_line P1C(string, line)
free (prog);
var = lhs;
}
- hash_insert (&cnf_hash, var, value);
+ hash_insert (&(kpse->cnf_hash), var, value);
/* We could check that anything remaining is preceded by a comment
character, but let's not bother. */
@@ -155,21 +151,21 @@ do_line P1C(string, line)
/* Read all the configuration files in the path. */
static void
-read_all_cnf P1H(void)
+read_all_cnf (kpathsea kpse)
{
string *cnf_files;
string *cnf;
- const_string cnf_path = kpse_init_format (kpse_cnf_format);
+ const_string cnf_path = kpathsea_init_format (kpse, kpse_cnf_format);
- cnf_hash = hash_create (CNF_HASH_SIZE);
+ kpse->cnf_hash = hash_create (CNF_HASH_SIZE);
- cnf_files = kpse_all_path_search (cnf_path, CNF_NAME);
+ cnf_files = kpathsea_all_path_search (kpse, cnf_path, CNF_NAME);
if (cnf_files && *cnf_files) {
for (cnf = cnf_files; *cnf; cnf++) {
string line;
FILE *cnf_file = xfopen (*cnf, FOPEN_R_MODE);
- if (kpse_record_input)
- kpse_record_input (*cnf);
+ if (kpse->record_input)
+ kpse->record_input (*cnf);
while ((line = read_line (cnf_file)) != NULL) {
unsigned len = strlen (line);
@@ -193,7 +189,7 @@ read_all_cnf P1H(void)
}
}
- do_line (line);
+ do_line (kpse, line);
free (line);
}
@@ -214,11 +210,10 @@ read_all_cnf P1H(void)
returned list -- this will be from the last-read cnf file. */
string
-kpse_cnf_get P1C(const_string, name)
+kpathsea_cnf_get (kpathsea kpse, const_string name)
{
string ret, ctry;
string *ret_list;
- static boolean doing_cnf_init = false;
/* When we expand the compile-time value for DEFAULT_TEXMFCNF,
we end up needing the value for TETEXDIR and other variables,
@@ -226,31 +221,31 @@ kpse_cnf_get P1C(const_string, name)
code is not sufficient, somehow the ls-R path needs to be
computed when initializing the cnf path. Better to ensure that the
compile-time path does not contain variable references. */
- if (doing_cnf_init)
+ if (kpse->doing_cnf_init)
return NULL;
- if (cnf_hash.size == 0) {
+ if (kpse->cnf_hash.size == 0) {
/* Read configuration files and initialize databases. */
- doing_cnf_init = true;
- read_all_cnf ();
- doing_cnf_init = false;
+ kpse->doing_cnf_init = true;
+ read_all_cnf (kpse);
+ kpse->doing_cnf_init = false;
/* Since `kpse_init_db' recursively calls us, we must call it from
outside a `kpse_path_element' loop (namely, the one in
`read_all_cnf' above): `kpse_path_element' is not reentrant. */
- kpse_init_db ();
+ kpathsea_init_db (kpse);
}
- /* First look up NAME.`kpse_program_name', then NAME. */
- assert (kpse_program_name);
- ctry = concat3 (name, ".", kpse_program_name);
- ret_list = hash_lookup (cnf_hash, ctry);
+ /* First look up NAME.`kpse->program_name', then NAME. */
+ assert (kpse->program_name);
+ ctry = concat3 (name, ".", kpse->program_name);
+ ret_list = hash_lookup (kpse->cnf_hash, ctry);
free (ctry);
if (ret_list) {
ret = *ret_list;
free (ret_list);
} else {
- ret_list = hash_lookup (cnf_hash, name);
+ ret_list = hash_lookup (kpse->cnf_hash, name);
if (ret_list) {
ret = *ret_list;
free (ret_list);
@@ -261,3 +256,12 @@ kpse_cnf_get P1C(const_string, name)
return ret;
}
+
+#if defined(KPSE_COMPAT_API)
+string
+kpse_cnf_get (const_string name)
+{
+ return kpathsea_cnf_get(kpse_def, name);
+}
+#endif
+
diff --git a/Build/source/texk/kpathsea/cnf.h b/Build/source/texk/kpathsea/cnf.h
index 0853364b3a7..dca285a3da7 100644
--- a/Build/source/texk/kpathsea/cnf.h
+++ b/Build/source/texk/kpathsea/cnf.h
@@ -25,6 +25,11 @@
/* Return the value in the last-read cnf file for VAR, or NULL if none.
On the first call, also read all the `texmf.cnf' files in the
path for kpse_cnf_format (and initialize the path). */
-extern KPSEDLL string kpse_cnf_get P1H(const_string var);
+
+extern KPSEDLL string kpathsea_cnf_get (kpathsea kpse, const_string name);
+
+#if defined(KPSE_COMPAT_API)
+extern KPSEDLL string kpse_cnf_get (const_string var);
+#endif
#endif /* not KPATHSEA_CNF_H */
diff --git a/Build/source/texk/kpathsea/concat.c b/Build/source/texk/kpathsea/concat.c
index 88401a8b901..fe5298fcbfa 100644
--- a/Build/source/texk/kpathsea/concat.c
+++ b/Build/source/texk/kpathsea/concat.c
@@ -23,7 +23,7 @@
`concatn', which takes a variable number of arguments. */
string
-concat P2C(const_string, s1, const_string, s2)
+concat (const_string s1, const_string s2)
{
unsigned s1len = strlen(s1);
unsigned s2len = strlen(s2);
diff --git a/Build/source/texk/kpathsea/concat3.c b/Build/source/texk/kpathsea/concat3.c
index c2349de97d0..6e98a13dac6 100644
--- a/Build/source/texk/kpathsea/concat3.c
+++ b/Build/source/texk/kpathsea/concat3.c
@@ -19,13 +19,15 @@
string
-concat3 P3C(const_string, s1, const_string, s2, const_string, s3)
+concat3 (const_string s1, const_string s2, const_string s3)
{
+ int s2l = s2 ? strlen (s2) : 0;
+ int s3l = s3 ? strlen (s3) : 0;
string answer
- = (string) xmalloc (strlen (s1) + strlen (s2) + strlen (s3) + 1);
+ = (string) xmalloc (strlen(s1) + s2l + s3l + 1);
strcpy (answer, s1);
- strcat (answer, s2);
- strcat (answer, s3);
+ if (s2) strcat (answer, s2);
+ if (s3) strcat (answer, s3);
return answer;
}
diff --git a/Build/source/texk/kpathsea/configure b/Build/source/texk/kpathsea/configure
index f2488e65951..c1f4a47824c 100755
--- a/Build/source/texk/kpathsea/configure
+++ b/Build/source/texk/kpathsea/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for kpathsea 3.5.7.
+# Generated by GNU Autoconf 2.63 for kpathsea 3.5.7dev.
#
# Report bugs to <tex-k@mail.tug.org>.
#
@@ -755,8 +755,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='kpathsea'
PACKAGE_TARNAME='kpathsea'
-PACKAGE_VERSION='3.5.7'
-PACKAGE_STRING='kpathsea 3.5.7'
+PACKAGE_VERSION='3.5.7dev'
+PACKAGE_STRING='kpathsea 3.5.7dev'
PACKAGE_BUGREPORT='tex-k@mail.tug.org'
ac_unique_file="pathsearch.c"
@@ -1454,7 +1454,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures kpathsea 3.5.7 to adapt to many kinds of systems.
+\`configure' configures kpathsea 3.5.7dev to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1519,7 +1519,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of kpathsea 3.5.7:";;
+ short | recursive ) echo "Configuration of kpathsea 3.5.7dev:";;
esac
cat <<\_ACEOF
@@ -1624,7 +1624,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-kpathsea configure 3.5.7
+kpathsea configure 3.5.7dev
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1638,7 +1638,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by kpathsea $as_me 3.5.7, which was
+It was created by kpathsea $as_me 3.5.7dev, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -2008,13 +2008,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-KPSEVERSION=3.5.7
+KPSEVERSION=3.5.7dev
cat >>confdefs.h <<\_ACEOF
-#define KPSEVERSION "kpathsea version 3.5.7"
+#define KPSEVERSION "kpathsea version 3.5.7dev"
_ACEOF
-KPSE_LT_VERS=5:0:1
+KPSE_LT_VERS=5:0:0
ac_config_headers="$ac_config_headers c-auto.h:c-auto.in"
@@ -11652,7 +11652,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by kpathsea $as_me 3.5.7, which was
+This file was extended by kpathsea $as_me 3.5.7dev, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -11711,7 +11711,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-kpathsea config.status 3.5.7
+kpathsea config.status 3.5.7dev
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/Build/source/texk/kpathsea/configure.in b/Build/source/texk/kpathsea/configure.in
index e52ec24ac28..67c9b4b9bb2 100644
--- a/Build/source/texk/kpathsea/configure.in
+++ b/Build/source/texk/kpathsea/configure.in
@@ -21,11 +21,11 @@ dnl
m4_define([kpse_major_version], [3])[]dnl
m4_define([kpse_minor_version], [5])[]dnl
m4_define([kpse_micro_version], [7])[]dnl
-m4_define([kpse_devel_version], [])[]dnl
+m4_define([kpse_devel_version], [dev])[]dnl
m4_define([kpse_version], [kpse_major_version.kpse_minor_version.kpse_micro_version[]kpse_devel_version])[]dnl
-m4_define([kpse_lib_major], [4])[]dnl
-m4_define([kpse_lib_minor], [1])[]dnl
+m4_define([kpse_lib_major], [5])[]dnl
+m4_define([kpse_lib_minor], [0])[]dnl
m4_define([kpse_lib_micro], [0])[]dnl
m4_define([kpse_lt_version],[m4_eval(kpse_lib_major + kpse_lib_minor):kpse_lib_micro:kpse_lib_minor])[]dnl
diff --git a/Build/source/texk/kpathsea/db.c b/Build/source/texk/kpathsea/db.c
index 70a95cc9773..650eab72b8a 100644
--- a/Build/source/texk/kpathsea/db.c
+++ b/Build/source/texk/kpathsea/db.c
@@ -30,7 +30,6 @@
#include <kpathsea/tex-file.h>
#include <kpathsea/variable.h>
-static hash_table_type db; /* The hash table for all the ls-R's. */
#ifndef DB_HASH_SIZE
/* Based on the size of 2008 texmf-dist/ls-R, about 62000 entries. But
we don't want to make it too big, since texmf/ls-R only has about
@@ -50,7 +49,6 @@ static const_string db_names[] = {
NULL
};
-static hash_table_type alias_db;
#ifndef ALIAS_NAME
#define ALIAS_NAME "aliases"
#endif
@@ -58,14 +56,13 @@ static hash_table_type alias_db;
#define ALIAS_HASH_SIZE 1009
#endif
-static str_list_type db_dir_list;
/* If DIRNAME contains any element beginning with a `.' (that is more
than just `./'), return true. This is to allow ``hidden''
directories -- ones that don't get searched. */
static boolean
-ignore_dir_p P1C(const_string, dirname)
+ignore_dir_p (const_string dirname)
{
const_string dot_pos = dirname;
@@ -82,7 +79,7 @@ ignore_dir_p P1C(const_string, dirname)
Otherwise, add entries from DB_FILENAME to TABLE, and return true. */
static boolean
-db_build P2C(hash_table_type *, table, const_string, db_filename)
+db_build (kpathsea kpse, hash_table_type *table, const_string db_filename)
{
string line;
unsigned dir_count = 0, file_count = 0, ignore_dir_count = 0;
@@ -102,7 +99,7 @@ db_build P2C(hash_table_type *, table, const_string, db_filename)
and explicitly relative (./...) names here. It's a kludge to
pass in the directory name with the trailing : still attached,
but it doesn't actually hurt. */
- if (len > 0 && line[len - 1] == ':' && kpse_absolute_p (line, true)) {
+ if (len > 0 && line[len - 1] == ':' && kpathsea_absolute_p (kpse, line, true)) {
/* New directory line. */
if (!ignore_dir_p (line)) {
/* If they gave a relative name, prepend full directory name now. */
@@ -146,11 +143,11 @@ db_build P2C(hash_table_type *, table, const_string, db_filename)
WARNING ("kpathsea: See the manual for how to generate ls-R");
db_file = NULL;
} else {
- str_list_add (&db_dir_list, xstrdup (top_dir));
+ str_list_add (&(kpse->db_dir_list), xstrdup (top_dir));
}
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_HASH)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_HASH)) {
/* Don't make this a debugging bit, since the output is so
voluminous, and being able to specify -1 is too useful.
Instead, let people who want it run the program under
@@ -177,11 +174,11 @@ db_build P2C(hash_table_type *, table, const_string, db_filename)
rebuilt. */
void
-kpse_db_insert P1C(const_string, passed_fname)
+kpathsea_db_insert (kpathsea kpse, const_string passed_fname)
{
/* We might not have found ls-R, or even had occasion to look for it
yet, so do nothing if we have no hash table. */
- if (db.buckets) {
+ if (kpse->db.buckets) {
const_string dir_part;
string fname = xstrdup (passed_fname);
string baseptr = (string)xbasename (fname);
@@ -191,16 +188,24 @@ kpse_db_insert P1C(const_string, passed_fname)
dir_part = fname; /* That leaves the dir, with the trailing /. */
/* Note that we do not assuse that these names have been normalized. */
- hash_insert (&db, file_part, dir_part);
+ hash_insert (&(kpse->db), file_part, dir_part);
}
}
+
+#if defined(KPSE_COMPAT_API)
+void
+kpse_db_insert (const_string passed_fname)
+{
+ kpathsea_db_insert(kpse_def, passed_fname);
+}
+#endif
/* Return true if FILENAME could be in PATH_ELT, i.e., if the directory
part of FILENAME matches PATH_ELT. Have to consider // wildcards, but
$ and ~ expansion have already been done. */
static boolean
-match P2C(const_string, filename, const_string, path_elt)
+match (const_string filename, const_string path_elt)
{
const_string original_filename = filename;
boolean matched = false;
@@ -267,7 +272,7 @@ match P2C(const_string, filename, const_string, path_elt)
search in it, which is all we do anyway. */
static boolean
-elt_in_db P2C(const_string, db_dir, const_string, path_elt)
+elt_in_db (const_string db_dir, const_string path_elt)
{
boolean found = false;
@@ -288,7 +293,7 @@ elt_in_db P2C(const_string, db_dir, const_string, path_elt)
/* If ALIAS_FILENAME exists, read it into TABLE. */
static boolean
-alias_build P2C(hash_table_type *, table, const_string, alias_filename)
+alias_build (kpathsea kpse, hash_table_type *table, const_string alias_filename)
{
string line, real, alias;
unsigned count = 0;
@@ -322,7 +327,7 @@ alias_build P2C(hash_table_type *, table, const_string, alias_filename)
}
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_HASH)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_HASH)) {
/* As with ls-R above ... */
boolean hash_summary_only = true;
DEBUGF2 ("%s: %u aliases.\n", alias_filename, count);
@@ -339,10 +344,10 @@ alias_build P2C(hash_table_type *, table, const_string, alias_filename)
}
/* Initialize the path for ls-R files, and read them all into the hash
- table `db'. If no usable ls-R's are found, set db.buckets to NULL. */
+ table `db'. If no usable ls-R's are found, set kpse->db.buckets to NULL. */
void
-kpse_init_db P1H(void)
+kpathsea_init_db (kpathsea kpse)
{
boolean ok = false;
const_string db_path;
@@ -351,16 +356,16 @@ kpse_init_db P1H(void)
assert (sizeof(DB_NAME) == sizeof(DB_NAME_LC));
- db_path = kpse_init_format (kpse_db_format);
- db_files = kpse_all_path_search_list (db_path, db_names);
+ db_path = kpathsea_init_format (kpse, kpse_db_format);
+ db_files = kpathsea_all_path_search_list (kpse, db_path, db_names);
orig_db_files = db_files;
/* Must do this after the path searching (which ends up calling
- kpse_db_search recursively), so db.buckets stays NULL. */
- db = hash_create (DB_HASH_SIZE);
+ kpse_db_search recursively), so kpse->db.buckets stays NULL. */
+ kpse->db = hash_create (DB_HASH_SIZE);
while (db_files && *db_files) {
- if (db_build (&db, *db_files))
+ if (db_build (kpse, &(kpse->db), *db_files))
ok = true;
free (*db_files);
db_files++;
@@ -369,8 +374,8 @@ kpse_init_db P1H(void)
if (!ok) {
/* If db can't be built, leave `size' nonzero (so we don't
rebuild it), but clear `buckets' (so we don't look in it). */
- free (db.buckets);
- db.buckets = NULL;
+ free (kpse->db.buckets);
+ kpse->db.buckets = NULL;
}
free (orig_db_files);
@@ -379,44 +384,52 @@ kpse_init_db P1H(void)
one alias file along DB_NAME files. This duplicates the above code
-- should be a function. */
ok = false;
- db_files = kpse_all_path_search (db_path, ALIAS_NAME);
+ db_files = kpathsea_all_path_search (kpse, db_path, ALIAS_NAME);
orig_db_files = db_files;
- alias_db = hash_create (ALIAS_HASH_SIZE);
+ kpse->alias_db = hash_create (ALIAS_HASH_SIZE);
while (db_files && *db_files) {
- if (alias_build (&alias_db, *db_files))
+ if (alias_build (kpse, &(kpse->alias_db), *db_files))
ok = true;
free (*db_files);
db_files++;
}
if (!ok) {
- free (alias_db.buckets);
- alias_db.buckets = NULL;
+ free (kpse->alias_db.buckets);
+ kpse->alias_db.buckets = NULL;
}
free (orig_db_files);
}
+
+#if defined(KPSE_COMPAT_API)
+void
+kpse_init_db (void)
+{
+ kpathsea_init_db(kpse_def);
+}
+#endif
+
/* Avoid doing anything if this PATH_ELT is irrelevant to the databases. */
-
str_list_type *
-kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
- boolean, all)
+kpathsea_db_search (kpathsea kpse, const_string name,
+ const_string orig_path_elt, boolean all)
{
string *db_dirs, *orig_dirs, *r;
const_string last_slash;
string path_elt;
boolean done;
- str_list_type *ret;
unsigned e;
+ str_list_type *ret = NULL;
string *aliases = NULL;
boolean relevant = false;
/* If we failed to build the database (or if this is the recursive
call to build the db path), quit. */
- if (db.buckets == NULL)
+ if (kpse->db.buckets == NULL)
return NULL;
/* When tex-glyph.c calls us looking for, e.g., dpi600/cmr10.pk, we
@@ -441,15 +454,15 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
extra couple of hash lookups matter -- they don't -- but rather
because we want to return NULL in this case, so path_search can
know to do a disk search. */
- for (e = 0; !relevant && e < STR_LIST_LENGTH (db_dir_list); e++) {
- relevant = elt_in_db (STR_LIST_ELT (db_dir_list, e), path_elt);
+ for (e = 0; !relevant && e < STR_LIST_LENGTH (kpse->db_dir_list); e++) {
+ relevant = elt_in_db (STR_LIST_ELT (kpse->db_dir_list, e), path_elt);
}
if (!relevant)
return NULL;
/* If we have aliases for this name, use them. */
- if (alias_db.buckets)
- aliases = hash_lookup (alias_db, name);
+ if (kpse->alias_db.buckets)
+ aliases = hash_lookup (kpse->alias_db, name);
if (!aliases) {
aliases = XTALLOC1 (string);
@@ -472,7 +485,7 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
string ctry = *r;
/* We have an ls-R db. Look up `try'. */
- orig_dirs = db_dirs = hash_lookup (db, ctry);
+ orig_dirs = db_dirs = hash_lookup (kpse->db, ctry);
ret = XTALLOC1 (str_list_type);
*ret = str_list_init ();
@@ -485,7 +498,7 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
boolean matched = match (db_file, path_elt);
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
DEBUGF3 ("db:match(%s,%s) = %d\n", db_file, path_elt, matched);
#endif
@@ -493,7 +506,7 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
exists, possibly under an alias. */
if (matched) {
string found = NULL;
- if (kpse_readable_file (db_file)) {
+ if (kpathsea_readable_file (kpse, db_file)) {
found = db_file;
} else {
@@ -509,7 +522,7 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
if one of the aliases actually exists, we use that. */
for (a = aliases + 1; *a && !found; a++) {
string atry = concat (*db_dirs, *a);
- if (kpse_readable_file (atry))
+ if (kpathsea_readable_file (kpse, atry))
found = atry;
else
free (atry);
@@ -544,23 +557,32 @@ kpse_db_search P3C(const_string, name, const_string, orig_path_elt,
return ret;
}
+
+#if defined(KPSE_COMPAT_API)
+str_list_type *
+kpse_db_search (const_string name, const_string orig_path_elt,
+ boolean all)
+{
+ return kpathsea_db_search (kpse_def, name, orig_path_elt, all);
+}
+#endif
str_list_type *
-kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
- boolean, all)
+kpathsea_db_search_list (kpathsea kpse, const_string* names,
+ const_string path_elt, boolean all)
{
string *db_dirs, *orig_dirs, *r;
const_string last_slash, name, path;
boolean done;
- str_list_type *ret;
unsigned e;
string *aliases;
- boolean relevant = false;
int n;
+ str_list_type *ret = NULL;
+ boolean relevant = false;
/* If we failed to build the database (or if this is the recursive
call to build the db path), quit. */
- if (db.buckets == NULL)
+ if (kpse->db.buckets == NULL)
return NULL;
/* Don't bother doing any lookups if this `path_elt' isn't covered by
@@ -568,8 +590,8 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
extra couple of hash lookups matter -- they don't -- but rather
because we want to return NULL in this case, so path_search can
know to do a disk search. */
- for (e = 0; !relevant && e < STR_LIST_LENGTH (db_dir_list); e++) {
- relevant = elt_in_db (STR_LIST_ELT (db_dir_list, e), path_elt);
+ for (e = 0; !relevant && e < STR_LIST_LENGTH (kpse->db_dir_list); e++) {
+ relevant = elt_in_db (STR_LIST_ELT (kpse->db_dir_list, e), path_elt);
}
if (!relevant)
return NULL;
@@ -580,7 +602,7 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
name = names[n];
/* Absolute names should have been caught in our caller. */
- if (kpse_absolute_p(name, true))
+ if (kpathsea_absolute_p(kpse, name, true))
continue;
/* When tex-glyph.c calls us looking for, e.g., dpi600/cmr10.pk, we
@@ -603,8 +625,8 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
}
/* If we have aliases for this name, use them. */
- if (alias_db.buckets)
- aliases = hash_lookup (alias_db, name);
+ if (kpse->alias_db.buckets)
+ aliases = hash_lookup (kpse->alias_db, name);
else
aliases = NULL;
@@ -628,7 +650,7 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
string ctry = *r;
/* We have an ls-R db. Look up `try'. */
- orig_dirs = db_dirs = hash_lookup (db, ctry);
+ orig_dirs = db_dirs = hash_lookup (kpse->db, ctry);
ret = XTALLOC1 (str_list_type);
*ret = str_list_init ();
@@ -641,7 +663,7 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
boolean matched = match (db_file, path);
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
DEBUGF3 ("db:match(%s,%s) = %d\n", db_file, path, matched);
#endif
@@ -649,7 +671,7 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
exists, possibly under an alias. */
if (matched) {
string found = NULL;
- if (kpse_readable_file (db_file)) {
+ if (kpathsea_readable_file (kpse, db_file)) {
found = db_file;
} else {
@@ -665,7 +687,7 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
if one of the aliases actually exists, we use that. */
for (a = aliases + 1; *a && !found; a++) {
string atry = concat (*db_dirs, *a);
- if (kpse_readable_file (atry))
+ if (kpathsea_readable_file (kpse, atry))
found = atry;
else
free (atry);
@@ -699,3 +721,11 @@ kpse_db_search_list P3C(const_string*, names, const_string, path_elt,
}
+#if defined(KPSE_COMPAT_API)
+str_list_type *
+kpse_db_search_list (const_string* names, const_string path_elt,
+ boolean all)
+{
+ return kpathsea_db_search_list (kpse_def, names, path_elt, all);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/db.h b/Build/source/texk/kpathsea/db.h
index f79cc9c203c..11e33745af8 100644
--- a/Build/source/texk/kpathsea/db.h
+++ b/Build/source/texk/kpathsea/db.h
@@ -25,22 +25,38 @@
/* Initialize the database. Until this is called, no ls-R matches will
be found. */
-extern void kpse_init_db P1H(void);
+extern void kpathsea_init_db (kpathsea kpse);
/* Return list of matches for NAME in the ls-R file matching PATH_ELT. If
ALL is set, return (null-terminated list) of all matches, else just
the first. If no matches, return a pointer to an empty list. If no
databases can be read, or PATH_ELT is not in any of the databases,
return NULL. */
-extern str_list_type *kpse_db_search P3H(const_string name,
- const_string path_elt, boolean all);
-extern str_list_type *kpse_db_search_list P3H(const_string* names,
- const_string path_elt,
- boolean all);
+extern str_list_type *kpathsea_db_search (kpathsea kpse, const_string name,
+ const_string path_elt, boolean all);
+
+extern str_list_type *kpathsea_db_search_list (kpathsea kpse,
+ const_string* names,
+ const_string path_elt,
+ boolean all);
/* Insert the filename FNAME into the database.
Called by mktexpk et al. */
-extern KPSEDLL void kpse_db_insert P1H(const_string fname);
+extern KPSEDLL void kpathsea_db_insert (kpathsea kpse, const_string fname);
+
+#if defined(KPSE_COMPAT_API)
+extern void kpse_init_db (void);
+
+extern str_list_type *kpse_db_search (const_string name,
+ const_string path_elt, boolean all);
+
+extern str_list_type *kpse_db_search_list (const_string* names,
+ const_string path_elt,
+ boolean all);
+
+extern KPSEDLL void kpse_db_insert (const_string fname);
+
+#endif
#endif /* not KPATHSEA_DB_H */
diff --git a/Build/source/texk/kpathsea/debug.c b/Build/source/texk/kpathsea/debug.c
index a8a178f6839..9cddaae3854 100644
--- a/Build/source/texk/kpathsea/debug.c
+++ b/Build/source/texk/kpathsea/debug.c
@@ -19,32 +19,32 @@
#ifdef KPSE_DEBUG /* whole file */
-unsigned kpathsea_debug = 0;
-
/* If the real definitions of fopen or fclose are macros, we lose -- the
#undef won't restore them. */
FILE *
-fopen P2C(const_string, filename, const_string, mode)
+fopen (const char *filename, const char *mode)
{
#undef fopen
FILE *ret = fopen (filename, mode);
-
- if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
+#if defined (KPSE_COMPAT_API)
+ kpathsea kpse = kpse_def;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN))
DEBUGF3 ("fopen(%s, %s) => 0x%lx\n", filename, mode, (unsigned long) ret);
-
+#endif
return ret;
}
int
-fclose P1C(FILE *, f)
+fclose (FILE * f)
{
#undef fclose
int ret = fclose (f);
-
- if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
+#if defined (KPSE_COMPAT_API)
+ kpathsea kpse = kpse_def;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN))
DEBUGF2 ("fclose(0x%lx) => %d\n", (unsigned long) f, ret);
-
+#endif
return ret;
}
diff --git a/Build/source/texk/kpathsea/debug.h b/Build/source/texk/kpathsea/debug.h
index 89299d1d0ff..790f5e7e101 100644
--- a/Build/source/texk/kpathsea/debug.h
+++ b/Build/source/texk/kpathsea/debug.h
@@ -52,8 +52,10 @@
/* OK, we'll have tracing support. */
#define KPSE_DEBUG
-/* Bit vector defining what we should trace. */
-extern KPSEDLL unsigned kpathsea_debug;
+/* Test if a bit is on. */
+#define KPATHSEA_DEBUG_P(bit) (kpse->debug & (1 << (bit)))
+
+#if defined (KPSE_COMPAT_API)
/* Set a bit. */
#define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
@@ -61,6 +63,8 @@ extern KPSEDLL unsigned kpathsea_debug;
/* Test if a bit is on. */
#define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
+#endif /* KPSE_COMPAT_API */
+
#define KPSE_DEBUG_STAT 0 /* stat calls */
#define KPSE_DEBUG_HASH 1 /* hash lookups */
#define KPSE_DEBUG_FOPEN 2 /* fopen/fclose calls */
@@ -87,10 +91,10 @@ extern KPSEDLL unsigned kpathsea_debug;
#undef fopen
#define fopen kpse_fopen_trace
-extern KPSEDLL FILE *fopen P2H(const_string filename, const_string mode);
+extern KPSEDLL FILE *fopen (const char *filename, const char *mode);
#undef fclose
#define fclose kpse_fclose_trace
-extern KPSEDLL int fclose P1H(FILE *);
+extern KPSEDLL int fclose (FILE *);
#endif /* not NO_DEBUG */
diff --git a/Build/source/texk/kpathsea/default.h b/Build/source/texk/kpathsea/default.h
index 75013828bb3..2b3e0efea7b 100644
--- a/Build/source/texk/kpathsea/default.h
+++ b/Build/source/texk/kpathsea/default.h
@@ -26,6 +26,11 @@
no extra colons, return PATH. Only one extra colon is replaced.
DFLT may not be NULL. The result is always in new memory. */
-extern string kpse_expand_default P2H(const_string path, const_string dflt);
+extern string kpathsea_expand_default (kpathsea kpse, const_string path,
+ const_string dflt);
+
+#if defined(KPSE_COMPAT_API)
+extern string kpse_expand_default (const_string path, const_string dflt);
+#endif
#endif /* not KPATHSEA_DEFAULT_H */
diff --git a/Build/source/texk/kpathsea/dir.c b/Build/source/texk/kpathsea/dir.c
index 4ad1c46ce8f..54b1551c53c 100644
--- a/Build/source/texk/kpathsea/dir.c
+++ b/Build/source/texk/kpathsea/dir.c
@@ -27,7 +27,7 @@
false if not. */
boolean
-dir_p P1C(const_string, fn)
+kpathsea_dir_p (kpathsea kpse, const_string fn)
{
/* FIXME : using the stat() replacement in gnuw32,
we could avoid this win32 specific code. However,
@@ -39,7 +39,7 @@ dir_p P1C(const_string, fn)
kpse_normalize_path((string)fn);
fa = GetFileAttributes(fn);
- if (KPSE_DEBUG_P(KPSE_DEBUG_STAT)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_STAT)) {
if (fa == 0xFFFFFFFF) {
fprintf(stderr, "failed to get file attributes for %s (%d)\n",
fn, GetLastError());
@@ -56,6 +56,15 @@ dir_p P1C(const_string, fn)
#endif
}
+#if defined(KPSE_COMPAT_API)
+boolean
+dir_p (const_string fn)
+{
+ return kpathsea_dir_p(kpse_def,fn);
+}
+#endif
+
+
/*
Return -1 if FN isn't a directory, else its number of links.
Duplicate the call to stat; no need to incur overhead of a function
@@ -65,26 +74,25 @@ dir_p P1C(const_string, fn)
memoizes the nlinks value, the following ones retrieve it.
*/
int
-dir_links P2C(const_string, fn, long, nlinks)
+kpathsea_dir_links (kpathsea kpse, const_string fn, long nlinks)
{
- static hash_table_type link_table;
string *hash_ret;
- if (link_table.size == 0)
- link_table = hash_create (457);
+ if (kpse->link_table.size == 0)
+ kpse->link_table = hash_create (457);
#ifdef KPSE_DEBUG
/* This is annoying, but since we're storing integers as pointers, we
can't print them as strings. */
- if (KPSE_DEBUG_P (KPSE_DEBUG_HASH))
- kpse_debug_hash_lookup_int = true;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_HASH))
+ kpse->debug_hash_lookup_int = true;
#endif
- hash_ret = hash_lookup (link_table, fn);
+ hash_ret = hash_lookup (kpse->link_table, fn);
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_HASH))
- kpse_debug_hash_lookup_int = false;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_HASH))
+ kpse->debug_hash_lookup_int = false;
#endif
/* Have to cast the int we need to/from the const_string that the hash
@@ -103,7 +111,7 @@ dir_links P2C(const_string, fn, long, nlinks)
memcpy(str_nlinks, (char *)&nlinks, sizeof(nlinks));
str_nlinks[sizeof(nlinks)] = '\0';
/* It's up to us to copy the value. */
- hash_insert(&link_table, xstrdup(fn), (const_string)str_nlinks);
+ hash_insert(&(kpse->link_table), xstrdup(fn), (const_string)str_nlinks);
}
#else
struct stat stats;
@@ -112,11 +120,11 @@ dir_links P2C(const_string, fn, long, nlinks)
else
nlinks = -1;
/* It's up to us to copy the value. */
- hash_insert(&link_table, xstrdup(fn), (const_string)nlinks);
+ hash_insert(&(kpse->link_table), xstrdup(fn), (const_string)nlinks);
#endif
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_STAT))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_STAT))
DEBUGF2 ("dir_links(%s) => %ld\n", fn, nlinks);
#endif
}
@@ -125,3 +133,13 @@ dir_links P2C(const_string, fn, long, nlinks)
(either 0, the value inserted or the value retrieved. */
return nlinks;
}
+
+#if defined (KPSE_COMPAT_API)
+int
+dir_links (const_string fn, long nlinks)
+{
+ return kpathsea_dir_links(kpse_def, fn, nlinks);
+}
+#endif
+
+
diff --git a/Build/source/texk/kpathsea/elt-dirs.c b/Build/source/texk/kpathsea/elt-dirs.c
index 9c223b37845..415de99753b 100644
--- a/Build/source/texk/kpathsea/elt-dirs.c
+++ b/Build/source/texk/kpathsea/elt-dirs.c
@@ -32,7 +32,7 @@
DIR ends with a DIR_SEP for the benefit of later searches. */
static void
-dir_list_add P2C(str_llist_type *, l, const_string, dir)
+dir_list_add (str_llist_type *l, const_string dir)
{
char last_char = dir[strlen (dir) - 1];
string saved_dir
@@ -47,9 +47,9 @@ dir_list_add P2C(str_llist_type *, l, const_string, dir)
/* If DIR is a directory, add it to the list L. */
static void
-checked_dir_list_add P2C(str_llist_type *, l, const_string, dir)
+checked_dir_list_add (kpathsea kpse, str_llist_type *l, const_string dir)
{
- if (dir_p (dir))
+ if (kpathsea_dir_p (kpse, dir))
dir_list_add (l, dir);
}
@@ -59,16 +59,6 @@ checked_dir_list_add P2C(str_llist_type *, l, const_string, dir)
the dir_links call, that's not enough -- without this path element
caching as well, the execution time doubles. */
-typedef struct
-{
- const_string key;
- str_llist_type *value;
-} cache_entry;
-
-static cache_entry *the_cache = NULL;
-static unsigned cache_length = 0;
-
-
/* Associate KEY with VALUE. We implement the cache as a simple linear
list, since it's unlikely to ever be more than a dozen or so elements
long. We don't bother to check here if PATH has already been saved;
@@ -76,26 +66,26 @@ static unsigned cache_length = 0;
that's right, but it seems to be all that's needed. */
static void
-cache P2C(const_string, key, str_llist_type *, value)
+cache (kpathsea kpse, const_string key, str_llist_type *value)
{
- cache_length++;
- XRETALLOC (the_cache, cache_length, cache_entry);
- the_cache[cache_length - 1].key = xstrdup (key);
- the_cache[cache_length - 1].value = value;
+ kpse->cache_length++;
+ XRETALLOC (kpse->the_cache, kpse->cache_length, cache_entry);
+ kpse->the_cache[kpse->cache_length - 1].key = xstrdup (key);
+ kpse->the_cache[kpse->cache_length - 1].value = value;
}
/* To retrieve, just check the list in order. */
static str_llist_type *
-cached P1C(const_string, key)
+cached (kpathsea kpse, const_string key)
{
unsigned p;
- for (p = 0; p < cache_length; p++)
+ for (p = 0; p < kpse->cache_length; p++)
{
- if (FILESTRCASEEQ (the_cache[p].key, key))
- return the_cache[p].value;
+ if (FILESTRCASEEQ (kpse->the_cache[p].key, key))
+ return kpse->the_cache[p].value;
}
return NULL;
@@ -104,7 +94,7 @@ cached P1C(const_string, key)
/* Handle the magic path constructs. */
/* Declare recursively called routine. */
-static void expand_elt P3H(str_llist_type *, const_string, unsigned);
+static void expand_elt (kpathsea, str_llist_type *, const_string, unsigned);
/* POST is a pointer into the original element (which may no longer be
@@ -118,8 +108,8 @@ static char dirname[MAX_PATH];
#endif
static void
-do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
- unsigned, elt_length, const_string, post)
+do_subdir (kpathsea kpse, str_llist_type *str_list_ptr, const_string elt,
+ unsigned elt_length, const_string post)
{
#ifdef WIN32
WIN32_FIND_DATA find_file_data;
@@ -156,7 +146,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
example, POST might be `pk/ljfour', and they might have a
directory `$TEXMF/fonts/pk/ljfour' that we should find. */
fn_str_grow (&name, post);
- expand_elt (str_list_ptr, FN_STRING (name), elt_length);
+ expand_elt (kpse, str_list_ptr, FN_STRING (name), elt_length);
fn_shrink_to (&name, elt_length);
}
proceed = 1;
@@ -170,7 +160,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
/* Maybe we have cached the leafness of this directory.
The function will return 0 if unknown,
else the actual (Unix-like) value. */
- links = dir_links (FN_STRING (name), 0);
+ links = kpathsea_dir_links (kpse, FN_STRING (name), 0);
if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
unsigned potential_len = FN_LENGTH (name);
@@ -186,7 +176,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
name here, we just have a path spec. This means we
may descend into a leaf directory cm/pk, if the
spec is ...fonts//pk//. */
- expand_elt (str_list_ptr, FN_STRING (name), potential_len);
+ expand_elt (kpse, str_list_ptr, FN_STRING (name), potential_len);
fn_shrink_to (&name, potential_len);
}
/* Should we recurse? To see if the subdirectory is a
@@ -198,7 +188,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
if (links == 0 || links > 2)
/* All criteria are met; find subdirectories. */
- do_subdir (str_list_ptr, FN_STRING (name),
+ do_subdir (kpse, str_list_ptr, FN_STRING (name),
potential_len, post);
else if (*post == 0)
/* Nothing to match, no recursive subdirectories to
@@ -210,7 +200,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
proceed = FindNextFile (hnd, &find_file_data);
}
/* Update the leafness of name. */
- dir_links(FN_STRING(name), nlinks);
+ kpathsea_dir_links(kpse, FN_STRING(name), nlinks);
fn_free (&name);
FindClose(hnd);
@@ -232,7 +222,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
example, POST might be `pk/ljfour', and they might have a
directory `$TEXMF/fonts/pk/ljfour' that we should find. */
fn_str_grow (&name, post);
- expand_elt (str_list_ptr, FN_STRING (name), elt_length);
+ expand_elt (kpse, str_list_ptr, FN_STRING (name), elt_length);
fn_shrink_to (&name, elt_length);
}
@@ -247,7 +237,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
fn_str_grow (&name, e->d_name);
/* If we can't stat it, or if it isn't a directory, continue. */
- links = dir_links (FN_STRING (name), 0);
+ links = kpathsea_dir_links (kpse, FN_STRING (name), 0);
if (links >= 0)
{
@@ -264,7 +254,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
name here, we just have a path spec. This means we
may descend into a leaf directory cm/pk, if the
spec is ...fonts//pk//. */
- expand_elt (str_list_ptr, FN_STRING (name), potential_len);
+ expand_elt (kpse, str_list_ptr, FN_STRING (name), potential_len);
fn_shrink_to (&name, potential_len);
}
@@ -288,7 +278,7 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
if (links != 2)
#endif /* ST_NLINK_TRICK */
/* All criteria are met; find subdirectories. */
- do_subdir (str_list_ptr, FN_STRING (name),
+ do_subdir (kpse, str_list_ptr, FN_STRING (name),
potential_len, post);
#ifdef ST_NLINK_TRICK
else if (*post == 0)
@@ -314,8 +304,8 @@ do_subdir P4C(str_llist_type *, str_list_ptr, const_string, elt,
looking for magic constructs at START. */
static void
-expand_elt P3C(str_llist_type *, str_list_ptr, const_string, elt,
- unsigned, start)
+expand_elt (kpathsea kpse, str_llist_type * str_list_ptr, const_string elt,
+ unsigned start)
{
const_string dir = elt + start, post;
@@ -327,7 +317,7 @@ expand_elt P3C(str_llist_type *, str_list_ptr, const_string, elt,
if (IS_DIR_SEP (dir[1]))
{
for (post = dir + 1; IS_DIR_SEP (*post); post++) ;
- do_subdir (str_list_ptr, elt, dir - elt + 1, post);
+ do_subdir (kpse, str_list_ptr, elt, dir - elt + 1, post);
return;
}
@@ -338,7 +328,7 @@ expand_elt P3C(str_llist_type *, str_list_ptr, const_string, elt,
}
/* When we reach the end of ELT, it will be a normal filename. */
- checked_dir_list_add (str_list_ptr, elt);
+ checked_dir_list_add (kpse, str_list_ptr, elt);
}
/* The first bits of a path element can be problematic because they
@@ -359,7 +349,7 @@ expand_elt P3C(str_llist_type *, str_list_ptr, const_string, elt,
expanding from the root of a UNIX filesystem tree. */
unsigned
-kpse_normalize_path P1C(string, elt)
+kpathsea_normalize_path (kpathsea kpse, string elt)
{
unsigned ret;
unsigned i;
@@ -386,16 +376,24 @@ kpse_normalize_path P1C(string, elt)
;
}
- if (KPSE_DEBUG_P (KPSE_DEBUG_STAT) && ret != 1)
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_STAT) && ret != 1)
DEBUGF2 ("kpse_normalize_path (%s) => %u\n", elt, ret);
return ret;
}
+
+#if defined(KPSE_COMPAT_API)
+unsigned
+kpse_normalize_path (string elt)
+{
+ return kpathsea_normalize_path(kpse_def, elt);
+}
+#endif
/* Here is the entry point. Returns directory list for ELT. */
str_llist_type *
-kpse_element_dirs P1C(string, elt)
+kpathsea_element_dirs (kpathsea kpse, string elt)
{
str_llist_type *ret;
@@ -404,7 +402,7 @@ kpse_element_dirs P1C(string, elt)
return NULL;
/* If we've already cached the answer for ELT, return it. */
- ret = cached (elt);
+ ret = cached (kpse, elt);
if (ret)
return ret;
@@ -413,14 +411,14 @@ kpse_element_dirs P1C(string, elt)
*ret = NULL;
/* We handle the hard case in a subroutine. */
- expand_elt (ret, elt, kpse_normalize_path (elt));
+ expand_elt (kpse, ret, elt, kpathsea_normalize_path (kpse, elt));
/* Remember the directory list we just found, in case future calls are
made with the same ELT. */
- cache (elt, ret);
+ cache (kpse, elt, ret);
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_EXPAND))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_EXPAND))
{
DEBUGF1 ("path element %s =>", elt);
if (ret)
@@ -436,6 +434,14 @@ kpse_element_dirs P1C(string, elt)
return ret;
}
+
+#if defined(KPSE_COMPAT_API)
+str_llist_type *
+kpse_element_dirs (string elt)
+{
+ return kpathsea_element_dirs(kpse_def, elt);
+}
+#endif
#ifdef TEST
@@ -497,6 +503,6 @@ main ()
/*
Local variables:
-test-compile-command: "gcc -g -I. -I.. -DTEST elt-dirs.c kpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST elt-dirs.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/expand.c b/Build/source/texk/kpathsea/expand.c
index 4f3d02d7e09..0d9d16c7262 100644
--- a/Build/source/texk/kpathsea/expand.c
+++ b/Build/source/texk/kpathsea/expand.c
@@ -31,10 +31,10 @@
shells do.) */
string
-kpse_expand P1C(const_string, s)
+kpathsea_expand (kpathsea kpse, const_string s)
{
- string var_expansion = kpse_var_expand (s);
- string tilde_expansion = kpse_tilde_expand (var_expansion);
+ string var_expansion = kpathsea_var_expand (kpse, s);
+ string tilde_expansion = kpathsea_tilde_expand (kpse, var_expansion);
/* `kpse_var_expand' always gives us new memory; `kpse_tilde_expand'
doesn't, necessarily. So be careful that we don't free what we are
@@ -45,15 +45,22 @@ kpse_expand P1C(const_string, s)
return tilde_expansion;
}
+#if defined(KPSE_COMPAT_API)
+string
+kpse_expand (const_string s)
+{
+ return kpathsea_expand (kpse_def, s);
+}
+#endif
/* Forward declarations of functions from the original expand.c */
-static str_list_type brace_expand P1H(const_string*);
+static str_list_type brace_expand (kpathsea, const_string*);
/* If $KPSE_DOT is defined in the environment, prepend it to any relative
path components. */
static string
-kpse_expand_kpse_dot P1C(string, path)
+kpathsea_expand_kpse_dot (kpathsea kpse, string path)
{
string ret, elt;
string kpse_dot = getenv("KPSE_DOT");
@@ -80,12 +87,13 @@ kpse_expand_kpse_dot P1C(string, path)
}
#endif
- for (elt = kpse_path_element (path); elt; elt = kpse_path_element (NULL)) {
+ for (elt = kpathsea_path_element (kpse, path); elt;
+ elt = kpathsea_path_element (kpse, NULL)) {
string save_ret = ret;
boolean ret_copied = true;
/* We assume that the !! magic is only used on absolute components.
Single "." gets special treatment, as does "./" or its equivalent. */
- if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!')) {
+ if (kpathsea_absolute_p (kpse, elt, false) || (elt[0] == '!' && elt[1] == '!')) {
ret = concat3(ret, elt, ENV_SEP_STRING);
} else if (elt[0] == '.' && elt[1] == 0) {
ret = concat3 (ret, kpse_dot, ENV_SEP_STRING);
@@ -118,16 +126,16 @@ kpse_expand_kpse_dot P1C(string, path)
string comprising all of the results separated by ENV_SEP_STRING. */
static string
-kpse_brace_expand_element P1C(const_string, elt)
+kpathsea_brace_expand_element (kpathsea kpse, const_string elt)
{
unsigned i;
- str_list_type expansions = brace_expand (&elt);
+ str_list_type expansions = brace_expand (kpse, &elt);
string ret = (string)xmalloc (1);
*ret = 0;
for (i = 0; i != STR_LIST_LENGTH(expansions); i++) {
/* Do $ and ~ expansion on each element. */
- string x = kpse_expand (STR_LIST_ELT(expansions,i));
+ string x = kpathsea_expand (kpse, STR_LIST_ELT(expansions,i));
string save_ret = ret;
if (!STREQ (x, STR_LIST_ELT(expansions,i))) {
/* If we did any expansions, do brace expansion again. Since
@@ -135,7 +143,7 @@ kpse_brace_expand_element P1C(const_string, elt)
must terminate. (In practice, it's unlikely there will ever be
more than one level of recursion.) */
string save_x = x;
- x = kpse_brace_expand_element (x);
+ x = kpathsea_brace_expand_element (kpse, x);
free (save_x);
}
ret = concat3 (ret, x, ENV_SEP_STRING);
@@ -153,7 +161,7 @@ kpse_brace_expand_element P1C(const_string, elt)
/* Be careful to not waste all the memory we allocate for each element. */
string
-kpse_brace_expand P1C(const_string, path)
+kpathsea_brace_expand (kpathsea kpse, const_string path)
{
string kpse_dot_expansion;
string elt;
@@ -164,14 +172,15 @@ kpse_brace_expand P1C(const_string, path)
we want to end up with TEXINPUTS = .:/home/karl.
Since kpse_path_element is not reentrant, we must get all
the path elements before we start the loop. */
- string xpath = kpse_var_expand (path);
+ string xpath = kpathsea_var_expand (kpse, path);
string ret = (string)xmalloc (1);
*ret = 0;
- for (elt = kpse_path_element (xpath); elt; elt = kpse_path_element (NULL)) {
+ for (elt = kpathsea_path_element (kpse, xpath); elt;
+ elt = kpathsea_path_element (kpse, NULL)) {
string save_ret = ret;
/* Do brace expansion first, so tilde expansion happens in {~ka,~kb}. */
- string expansion = kpse_brace_expand_element (elt);
+ string expansion = kpathsea_brace_expand_element (kpse, elt);
ret = concat3 (ret, expansion, ENV_SEP_STRING);
free (expansion);
free (save_ret);
@@ -183,17 +192,25 @@ kpse_brace_expand P1C(const_string, path)
ret[len - 1] = 0;
free (xpath);
- kpse_dot_expansion = kpse_expand_kpse_dot (ret);
+ kpse_dot_expansion = kpathsea_expand_kpse_dot (kpse, ret);
if (kpse_dot_expansion != ret)
free (ret);
return kpse_dot_expansion;
}
+
+#if defined(KPSE_COMPAT_API)
+string
+kpse_brace_expand (const_string path)
+{
+ return kpathsea_brace_expand (kpse_def, path);
+}
+#endif
/* Expand all special constructs in a path, and include only the actually
existing directories in the result. */
string
-kpse_path_expand P1C(const_string, path)
+kpathsea_path_expand (kpathsea kpse, const_string path)
{
string ret;
string xpath;
@@ -206,10 +223,11 @@ kpse_path_expand P1C(const_string, path)
len = 0;
/* Expand variables and braces first. */
- xpath = kpse_brace_expand (path);
+ xpath = kpathsea_brace_expand (kpse, path);
/* Now expand each of the path elements, printing the results */
- for (elt = kpse_path_element (xpath); elt; elt = kpse_path_element (NULL)) {
+ for (elt = kpathsea_path_element (kpse, xpath); elt;
+ elt = kpathsea_path_element (kpse, NULL)) {
str_llist_type *dirs;
/* Skip and ignore magic leading chars. */
@@ -218,7 +236,7 @@ kpse_path_expand P1C(const_string, path)
/* Search the disk for all dirs in the component specified.
Be faster to check the database, but this is more reliable. */
- dirs = kpse_element_dirs (elt);
+ dirs = kpathsea_element_dirs (kpse, elt);
if (dirs && *dirs) {
str_llist_elt_type *dir;
@@ -252,9 +270,17 @@ kpse_path_expand P1C(const_string, path)
return ret;
}
+#if defined(KPSE_COMPAT_API)
+string
+kpse_path_expand (const_string path)
+{
+ return kpathsea_path_expand (kpse_def, path);
+}
+#endif
+
/* ... */
-static void expand_append P3C(str_list_type*, partial,
- const_string, text, const_string, p)
+static void expand_append (str_list_type* partial,
+ const_string text, const_string p)
{
string new_string;
unsigned len;
@@ -270,7 +296,8 @@ static void expand_append P3C(str_list_type*, partial,
-static str_list_type brace_expand P1C(const_string *, text)
+static str_list_type
+brace_expand (kpathsea kpse, const_string *text)
{
str_list_type result, partial, recurse;
const_string p;
@@ -287,7 +314,7 @@ static str_list_type brace_expand P1C(const_string *, text)
} else if (*p == '{') {
expand_append(&partial, *text, p);
++p;
- recurse = brace_expand(&p);
+ recurse = brace_expand(kpse, &p);
str_list_concat_elements(&partial, recurse);
str_list_free(&recurse);
/* Check for missing closing brace. */
@@ -327,13 +354,14 @@ report_error (format, arg1, arg2)
fprintf (stderr, "\n");
}
-main ()
+main (int argc, char **argv)
{
char example[256];
+ kpse_set_program_name(argv[0], NULL);
for (;;)
{
- char **result;
+ char *result;
int i;
fprintf (stderr, "brace_expand> ");
@@ -345,19 +373,18 @@ main ()
if (strlen (example))
example[strlen (example) - 1] = 0;
- result = brace_expand (example);
+ result = kpse_brace_expand (example);
- for (i = 0; result[i]; i++)
- printf ("%s\n", result[i]);
+ printf ("%s\n", result);
- free_array (result);
}
}
-/*
- * Local variables:
- * test-compile-command: "gcc -g -DTEST -I.. -I. -o brace_expand braces.c -L. -lkpathsea"
- * end:
- */
#endif /* TEST */
+
+/*
+Local variables:
+standalone-compile-command: "gcc -g -I. -I.. -DTEST expand.c kpathsea.a"
+end:
+*/
diff --git a/Build/source/texk/kpathsea/expand.h b/Build/source/texk/kpathsea/expand.h
index 7cb8a99de72..3bf21766d7b 100644
--- a/Build/source/texk/kpathsea/expand.h
+++ b/Build/source/texk/kpathsea/expand.h
@@ -24,19 +24,26 @@
/* Call kpse_var_expand and kpse_tilde_expand (in that order). Result
is always in fresh memory, even if no expansions were done. */
-extern KPSEDLL string kpse_expand P1H(const_string s);
+extern KPSEDLL string kpathsea_expand (kpathsea kpse, const_string s);
/* Do brace expansion and call `kpse_expand' on each element of the
result; return the final expansion (always in fresh memory, even if
no expansions were done). We don't call `kpse_expand_default'
because there is a whole sequence of defaults to run through; see
`kpse_init_format'. */
-extern KPSEDLL string kpse_brace_expand P1H(const_string path);
+extern KPSEDLL string kpathsea_brace_expand (kpathsea kpse, const_string path);
/* Do brace expansion and call `kpse_expand' on each argument of the
result, then expand any `//' constructs. The final expansion (always
in fresh memory) is a path of all the existing directories that match
the pattern. */
-extern KPSEDLL string kpse_path_expand P1H(const_string path);
+extern KPSEDLL string kpathsea_path_expand (kpathsea kpse, const_string path);
+
+#if defined(KPSE_COMPAT_API)
+extern KPSEDLL string kpse_expand (const_string s);
+extern KPSEDLL string kpse_brace_expand (const_string path);
+extern KPSEDLL string kpse_path_expand (const_string path);
+#endif
+
#endif /* not KPATHSEA_EXPAND_H */
diff --git a/Build/source/texk/kpathsea/extend-fname.c b/Build/source/texk/kpathsea/extend-fname.c
index ca0e42165be..b4a79eb297d 100644
--- a/Build/source/texk/kpathsea/extend-fname.c
+++ b/Build/source/texk/kpathsea/extend-fname.c
@@ -22,7 +22,7 @@
the return value is modifiable. */
string
-extend_filename P2C(const_string, name, const_string, default_suffix)
+extend_filename (const_string name, const_string default_suffix)
{
string new_s;
const_string suffix = find_suffix (name);
diff --git a/Build/source/texk/kpathsea/file-p.c b/Build/source/texk/kpathsea/file-p.c
index 1beb25ac87c..23218c94467 100644
--- a/Build/source/texk/kpathsea/file-p.c
+++ b/Build/source/texk/kpathsea/file-p.c
@@ -24,7 +24,7 @@
stat fails on either of the names, we return false, without error. */
boolean
-same_file_p P2C(const_string, filename1, const_string, filename2)
+same_file_p (const_string filename1, const_string filename2)
{
struct stat sb1, sb2;
/* These are put in variables only so the results can be inspected
diff --git a/Build/source/texk/kpathsea/find-suffix.c b/Build/source/texk/kpathsea/find-suffix.c
index d62a9cf6f7d..499f8189feb 100644
--- a/Build/source/texk/kpathsea/find-suffix.c
+++ b/Build/source/texk/kpathsea/find-suffix.c
@@ -24,7 +24,7 @@
of NAME. If the name is `foo' or `/foo.bar/baz', we have no extension. */
string
-find_suffix P1C(const_string, name)
+find_suffix (const_string name)
{
const_string slash_pos;
string dot_pos = strrchr (name, '.');
diff --git a/Build/source/texk/kpathsea/fn.c b/Build/source/texk/kpathsea/fn.c
index 24956cc505f..3bfb468cb40 100644
--- a/Build/source/texk/kpathsea/fn.c
+++ b/Build/source/texk/kpathsea/fn.c
@@ -27,7 +27,7 @@
fn_type
-fn_init P1H(void)
+fn_init (void)
{
fn_type ret;
@@ -39,7 +39,7 @@ fn_init P1H(void)
fn_type
-fn_copy0 P2C(const_string, s, unsigned, len)
+fn_copy0 (const_string s, unsigned len)
{
fn_type ret;
@@ -57,7 +57,7 @@ fn_copy0 P2C(const_string, s, unsigned, len)
empty, so give fatal error if nothing allocated. */
void
-fn_free P1C(fn_type *, f)
+fn_free (fn_type *f)
{
assert (FN_STRING (*f) != NULL);
free (FN_STRING (*f));
@@ -72,7 +72,7 @@ fn_free P1C(fn_type *, f)
presumably follow. */
static void
-grow P2C(fn_type *, f, unsigned, len)
+grow (fn_type *f, unsigned len)
{
while (FN_LENGTH (*f) + len > FN_ALLOCATED (*f))
{
@@ -83,7 +83,7 @@ grow P2C(fn_type *, f, unsigned, len)
void
-fn_1grow P2C(fn_type *, f, char, c)
+fn_1grow (fn_type *f, char c)
{
grow (f, 1);
FN_STRING (*f)[FN_LENGTH (*f)] = c;
@@ -92,7 +92,7 @@ fn_1grow P2C(fn_type *, f, char, c)
void
-fn_grow P3C(fn_type *, f, const_string, source, unsigned, len)
+fn_grow (fn_type *f, const_string source, unsigned len)
{
grow (f, len);
strncpy (FN_STRING (*f) + FN_LENGTH (*f), source, len);
@@ -101,7 +101,7 @@ fn_grow P3C(fn_type *, f, const_string, source, unsigned, len)
void
-fn_str_grow P2C(fn_type *, f, const_string, s)
+fn_str_grow (fn_type *f, const_string s)
{
unsigned more_len = strlen (s);
grow (f, more_len);
@@ -111,7 +111,7 @@ fn_str_grow P2C(fn_type *, f, const_string, s)
void
-fn_shrink_to P2C(fn_type *, f, unsigned, loc)
+fn_shrink_to (fn_type *f, unsigned loc)
{
assert (FN_LENGTH (*f) > loc);
FN_STRING (*f)[loc] = 0;
diff --git a/Build/source/texk/kpathsea/fn.h b/Build/source/texk/kpathsea/fn.h
index 80638c0d785..af27bdd8d2b 100644
--- a/Build/source/texk/kpathsea/fn.h
+++ b/Build/source/texk/kpathsea/fn.h
@@ -41,27 +41,27 @@ typedef struct
/* Create a new empty fn. */
-extern KPSEDLL fn_type fn_init P1H(void);
+extern KPSEDLL fn_type fn_init (void);
/* Create a new fn from the first LEN characters from S and a null. */
-extern KPSEDLL fn_type fn_copy0 P2H(const_string s, unsigned len);
+extern KPSEDLL fn_type fn_copy0 (const_string s, unsigned len);
/* Free what's been allocated. Can also just free the string if it's
been extracted out. Fatal error if nothing allocated in F. */
-extern KPSEDLL void fn_free P1H(fn_type *f);
+extern KPSEDLL void fn_free (fn_type *f);
/* Append the character C to the fn F. Don't append trailing null. */
-extern KPSEDLL void fn_1grow P2H(fn_type *f, char c);
+extern KPSEDLL void fn_1grow (fn_type *f, char c);
/* Append LENGTH bytes from SOURCE to F. */
-extern KPSEDLL void fn_grow P3H(fn_type *f, const_string source, unsigned length);
+extern KPSEDLL void fn_grow (fn_type *f, const_string source, unsigned length);
/* Concatenate the component S to the fn F. Assumes string currently in
F is null terminated. */
-extern KPSEDLL void fn_str_grow P2H(fn_type *f, const_string s);
+extern KPSEDLL void fn_str_grow (fn_type *f, const_string s);
/* Add a null to F's string at position LOC, and update its length.
Fatal error if LOC is past the end of the string. */
-extern KPSEDLL void fn_shrink_to P2H(fn_type *f, unsigned loc);
+extern KPSEDLL void fn_shrink_to (fn_type *f, unsigned loc);
#endif /* not KPATHSEA_FN_H */
diff --git a/Build/source/texk/kpathsea/fontmap.c b/Build/source/texk/kpathsea/fontmap.c
index 2604caa3742..756fe936399 100644
--- a/Build/source/texk/kpathsea/fontmap.c
+++ b/Build/source/texk/kpathsea/fontmap.c
@@ -30,7 +30,7 @@
/* We have one and only one fontmap, so may as well make it static
instead of passing it around. */
-static hash_table_type map;
+
#ifndef MAP_NAME
#define MAP_NAME "texfonts.map"
#endif
@@ -38,12 +38,11 @@ static hash_table_type map;
#define MAP_HASH_SIZE 4001
#endif
-static const_string map_path; /* Only want to create this once. */
/* Return next whitespace-delimited token in STR or NULL if none. */
static string
-token P1C(const_string, str)
+token (const_string str)
{
unsigned len;
const_string start;
@@ -74,14 +73,14 @@ token P1C(const_string, str)
will both read the same file. */
static void
-map_file_parse P1C(const_string, map_filename)
+map_file_parse (kpathsea kpse, const_string map_filename)
{
char *orig_l;
unsigned map_lineno = 0;
FILE *f = xfopen (map_filename, FOPEN_R_MODE);
- if (kpse_record_input)
- kpse_record_input (map_filename);
+ if (kpse->record_input)
+ kpse->record_input (map_filename);
while ((orig_l = read_line (f)) != NULL) {
string filename;
@@ -112,9 +111,10 @@ map_file_parse P1C(const_string, map_filename)
WARNING2 ("%s:%u: Filename argument for include directive missing",
map_filename, map_lineno);
} else {
- string include_fname = kpse_path_search (map_path, alias, false);
+ string include_fname = kpathsea_path_search (kpse,
+ kpse->map_path, alias, false);
if (include_fname) {
- map_file_parse (include_fname);
+ map_file_parse (kpse, include_fname);
if (include_fname != alias)
free (include_fname);
} else {
@@ -135,7 +135,7 @@ map_file_parse P1C(const_string, map_filename)
/* We've got everything. Insert the new entry. They were
already dynamically allocated by token(), so don't bother
with xstrdup. */
- hash_insert_normalized (&map, alias, filename);
+ hash_insert_normalized (&(kpse->map), alias, filename);
}
}
@@ -150,17 +150,17 @@ map_file_parse P1C(const_string, map_filename)
later files. */
static void
-read_all_maps P1H(void)
+read_all_maps (kpathsea kpse)
{
string *filenames;
- map_path = kpse_init_format (kpse_fontmap_format);
- filenames = kpse_all_path_search (map_path, MAP_NAME);
+ kpse->map_path = kpathsea_init_format (kpse, kpse_fontmap_format);
+ filenames = kpathsea_all_path_search (kpse, kpse->map_path, MAP_NAME);
- map = hash_create (MAP_HASH_SIZE);
+ kpse->map = hash_create (MAP_HASH_SIZE);
while (*filenames) {
- map_file_parse (*filenames);
+ map_file_parse (kpse, *filenames);
filenames++;
}
}
@@ -169,23 +169,23 @@ read_all_maps P1H(void)
from KEY and try again. Create the map if necessary. */
string *
-kpse_fontmap_lookup P1C(const_string, key)
+kpathsea_fontmap_lookup (kpathsea kpse, const_string key)
{
string *ret;
string suffix = find_suffix (key);
- if (map.size == 0) {
- read_all_maps ();
+ if (kpse->map.size == 0) {
+ read_all_maps (kpse);
}
- ret = hash_lookup (map, key);
+ ret = hash_lookup (kpse->map, key);
if (!ret) {
/* OK, the original KEY didn't work. Let's check for the KEY without
an extension -- perhaps they gave foobar.tfm, but the mapping only
defines `foobar'. */
if (suffix) {
string base_key = remove_suffix (key);
- ret = hash_lookup (map, base_key);
+ ret = hash_lookup (kpse->map, base_key);
free (base_key);
}
}
@@ -200,3 +200,11 @@ kpse_fontmap_lookup P1C(const_string, key)
return ret;
}
+
+#if defined(KPSE_COMPAT_API)
+string *
+kpse_fontmap_lookup (const_string key)
+{
+ return kpathsea_fontmap_lookup(kpse_def, key);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/fontmap.h b/Build/source/texk/kpathsea/fontmap.h
index 82ae0f9d98c..fcfe137ce11 100644
--- a/Build/source/texk/kpathsea/fontmap.h
+++ b/Build/source/texk/kpathsea/fontmap.h
@@ -25,6 +25,10 @@
/* Look up KEY in all texfonts.map's in the glyph_format path, and
return a null-terminated list of all matching entries, or NULL. */
-extern string *kpse_fontmap_lookup P1H(const_string key);
+extern string *kpathsea_fontmap_lookup (kpathsea kpse, const_string key);
+
+#if defined (KPSE_COMPAT_API)
+extern string *kpse_fontmap_lookup (const_string key);
+#endif
#endif /* not FONTMAP_H */
diff --git a/Build/source/texk/kpathsea/hash.c b/Build/source/texk/kpathsea/hash.c
index 9c19afa9576..02bcb865d97 100644
--- a/Build/source/texk/kpathsea/hash.c
+++ b/Build/source/texk/kpathsea/hash.c
@@ -38,7 +38,7 @@
#endif
static unsigned
-hash P2C(hash_table_type, table, const_string, key)
+hash (hash_table_type table, const_string key)
{
unsigned n = 0;
@@ -52,7 +52,7 @@ hash P2C(hash_table_type, table, const_string, key)
/* Identical has function as above, but does not normalize keys. */
static unsigned
-hash_normalized P2C(hash_table_type, table, const_string, key)
+hash_normalized (hash_table_type table, const_string key)
{
unsigned n = 0;
@@ -65,11 +65,13 @@ hash_normalized P2C(hash_table_type, table, const_string, key)
}
hash_table_type
-hash_create P1C(unsigned, size)
+hash_create (unsigned size)
{
- /* hash_table_type ret; changed into "static ..." to work around gcc
- optimizer bug for Alpha. */
- static hash_table_type ret;
+ /* The was "static ..." since Oct3, 1997 to work around a gcc
+ optimizer bug for Alpha. That particular optimization bug
+ should be gone by now (Mar4, 2009).
+ */
+ hash_table_type ret;
unsigned b;
ret.buckets = XTALLOC (size, hash_element_type *);
ret.size = size;
@@ -85,9 +87,9 @@ hash_create P1C(unsigned, size)
duplicate the strings, in case they're being purposefully shared. */
void
-hash_insert P3C(hash_table_type *, table,
- const_string, key,
- const_string, value)
+hash_insert (hash_table_type *table,
+ const_string key,
+ const_string value)
{
unsigned n = hash (*table, key);
hash_element_type *new_elt = XTALLOC1 (hash_element_type);
@@ -111,9 +113,9 @@ hash_insert P3C(hash_table_type *, table,
/* Same as above, for normalized keys. */
void
-hash_insert_normalized P3C(hash_table_type *, table,
- const_string, key,
- const_string, value)
+hash_insert_normalized (hash_table_type *table,
+ const_string key,
+ const_string value)
{
unsigned n = hash_normalized (*table, key);
hash_element_type *new_elt = XTALLOC1 (hash_element_type);
@@ -138,8 +140,8 @@ hash_insert_normalized P3C(hash_table_type *, table,
/* Remove a (KEY, VALUE) pair. */
void
-hash_remove P3C(hash_table_type *, table, const_string, key,
- const_string, value)
+hash_remove (hash_table_type *table, const_string key,
+ const_string value)
{
hash_element_type *p;
hash_element_type *q;
@@ -160,13 +162,8 @@ hash_remove P3C(hash_table_type *, table, const_string, key,
/* Look up STR in MAP. Return a (dynamically-allocated) list of the
corresponding strings or NULL if no match. */
-#ifdef KPSE_DEBUG
-/* Print the hash values as integers if this is nonzero. */
-boolean kpse_debug_hash_lookup_int = false;
-#endif
-
string *
-hash_lookup P2C(hash_table_type, table, const_string, key)
+hash_lookup (hash_table_type table, const_string key)
{
hash_element_type *p;
str_list_type ret;
@@ -184,7 +181,9 @@ hash_lookup P2C(hash_table_type, table, const_string, key)
str_list_add (&ret, NULL);
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_HASH))
+#if defined (KPSE_COMPAT_API)
+ kpathsea kpse = kpse_def;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_HASH))
{
DEBUGF1 ("hash_lookup(%s) =>", key);
if (!STR_LIST (ret))
@@ -195,7 +194,7 @@ hash_lookup P2C(hash_table_type, table, const_string, key)
for (r = STR_LIST (ret); *r; r++)
{
putc (' ', stderr);
- if (kpse_debug_hash_lookup_int)
+ if (kpse->debug_hash_lookup_int)
fprintf (stderr, "%ld", (long) *r);
else
fputs (*r, stderr);
@@ -205,6 +204,7 @@ hash_lookup P2C(hash_table_type, table, const_string, key)
fflush (stderr);
}
#endif
+#endif
return STR_LIST (ret);
}
@@ -212,7 +212,7 @@ hash_lookup P2C(hash_table_type, table, const_string, key)
/* We only print nonempty buckets, to decrease output volume. */
void
-hash_print P2C(hash_table_type, table, boolean, summary_only)
+hash_print (hash_table_type table, boolean summary_only)
{
unsigned b;
unsigned total_elements = 0, total_buckets = 0;
@@ -248,3 +248,18 @@ hash_print P2C(hash_table_type, table, boolean, summary_only)
total_elements,
total_buckets ? total_elements / (double) total_buckets : 0.0);
}
+
+void
+hash_free (hash_table_type table)
+{
+ struct hash_element_struct *p, *q;
+ p = (struct hash_element_struct *)table.buckets;
+ while (p != NULL) {
+ q = p->next;
+ free ((char *)p->key);
+ free ((char *)p->value);
+ free (p);
+ p = q;
+ }
+}
+
diff --git a/Build/source/texk/kpathsea/hash.h b/Build/source/texk/kpathsea/hash.h
index f79182bb628..a88233fed6f 100644
--- a/Build/source/texk/kpathsea/hash.h
+++ b/Build/source/texk/kpathsea/hash.h
@@ -38,36 +38,35 @@ typedef struct
unsigned size;
} hash_table_type;
-#ifdef KPSE_DEBUG
-/* How to print the hash results when debugging. */
-extern KPSEDLL boolean kpse_debug_hash_lookup_int;
-#endif
/* Create a hash table of size SIZE. */
-extern KPSEDLL hash_table_type hash_create P1H(unsigned size);
+extern KPSEDLL hash_table_type hash_create (unsigned size);
/* Insert the (KEY,VALUE) association into TABLE. KEY may have more
than one VALUE. Neither KEY nor VALUE is copied. */
-extern KPSEDLL void hash_insert P3H(hash_table_type *table,
+extern KPSEDLL void hash_insert (hash_table_type *table,
const_string key,
const_string value);
/* Insert the (KEY, VALUE) association into TABLE. KEY may have more
than one VALUE. Neither KEY nor VALUE is copied. Assume that KEY
is already normalized (all lowercase) on platforms where this matters. */
-extern KPSEDLL void hash_insert_normalized P3H(hash_table_type *table,
+extern KPSEDLL void hash_insert_normalized (hash_table_type *table,
const_string key,
const_string value);
/* Remove the (KEY,VALUE) association from TABLE. */
-extern KPSEDLL void hash_remove P3H(hash_table_type *table, const_string key,
+extern KPSEDLL void hash_remove (hash_table_type *table, const_string key,
const_string value);
/* Look up KEY in MAP, and return NULL-terminated list of all matching
values (not copies), in insertion order. If none, return NULL. */
-extern KPSEDLL string *hash_lookup P2H(hash_table_type table, const_string key);
+extern KPSEDLL string *hash_lookup (hash_table_type table, const_string key);
/* Print TABLE to stderr. */
-extern void hash_print P2H(hash_table_type table, boolean summary_only);
+extern void hash_print (hash_table_type table, boolean summary_only);
+
+/* Drop the TABLE */
+extern void hash_free (hash_table_type table);
#endif /* not HASH_H */
diff --git a/Build/source/texk/kpathsea/kdefault.c b/Build/source/texk/kpathsea/kdefault.c
index b5fa764a4ea..235be28cd9b 100644
--- a/Build/source/texk/kpathsea/kdefault.c
+++ b/Build/source/texk/kpathsea/kdefault.c
@@ -29,10 +29,11 @@
that is fastest. Usually it will be leading or trailing. */
string
-kpse_expand_default P2C(const_string, path, const_string, fallback)
+kpathsea_expand_default (kpathsea kpse, const_string path, const_string fallback)
{
unsigned path_length;
string expansion;
+ (void)kpse; /* currenty not used */
/* The default path better not be null. */
assert (fallback);
@@ -82,6 +83,14 @@ kpse_expand_default P2C(const_string, path, const_string, fallback)
return expansion;
}
+#if defined (KPSE_COMPAT_API)
+string
+kpse_expand_default (const_string path, const_string fallback)
+{
+ return kpathsea_expand_default (kpse_def, path, fallback);
+}
+#endif
+
#ifdef TEST
@@ -116,6 +125,6 @@ main ()
/*
Local variables:
-standalone-compile-command: "gcc -g -I. -I.. -DTEST default.c kpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST kdefault.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/kpathsea.c b/Build/source/texk/kpathsea/kpathsea.c
new file mode 100644
index 00000000000..e6395ab96f0
--- /dev/null
+++ b/Build/source/texk/kpathsea/kpathsea.c
@@ -0,0 +1,228 @@
+/* kpathsea.c: creating and freeing library instances
+
+ Copyright 2009 Taco Hoekwater.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, see <http://www.gnu.org/licenses/>. */
+
+/* One big global struct, and a variable that points to it */
+
+#include <kpathsea/config.h>
+
+kpathsea
+kpathsea_new (void)
+{
+ kpathsea ret;
+ ret = xcalloc(1, sizeof(kpathsea_instance));
+ return ret;
+}
+
+#define string_free(a) if((a)!=NULL) free((char *)(a))
+
+void
+str_llist_free (str_llist_type p)
+{
+ str_llist_type q;
+ while (p!=NULL) {
+ q = p->next;
+ free (p->str);
+ free (p);
+ p = q;
+ }
+}
+
+void
+cache_free (cache_entry *the_cache, int cache_size)
+{
+ int f ;
+ for (f=0;f<cache_size;f++) {
+ string_free (the_cache[f].key);
+ str_llist_free (the_cache[f].value[0]);
+ }
+ free (the_cache);
+}
+
+/* Sadly, quite a lot of the freeing is not safe:
+ it seems there are literals used all over. */
+void
+kpathsea_finish (kpathsea kpse)
+{
+ int i;
+ kpse_format_info_type f;
+ if (kpse==NULL)
+ return;
+#if 0
+ /* free internal stuff */
+ hash_free (kpse->cnf_hash);
+ hash_free (kpse->db);
+ hash_free (kpse->alias_db);
+ str_list_free(&kpse->db_dir_list);
+ hash_free (kpse->link_table);
+ cache_free (kpse->the_cache, kpse->cache_length);
+ hash_free (kpse->map);
+ string_free (kpse->map_path);
+ string_free (kpse->elt);
+ /*string_free (kpse->path);*/
+ if (kpse->log_file != (FILE *)NULL)
+ fclose(kpse->log_file);
+ string_free (kpse->invocation_name);
+ string_free (kpse->invocation_short_name);
+ string_free (kpse->program_name);
+ string_free (kpse->fallback_font);
+ string_free (kpse->fallback_resolutions_string);
+ if(kpse->fallback_resolutions != NULL)
+ free(kpse->fallback_resolutions);
+ for (i = 0; i != kpse_last_format; ++i) {
+ f = kpse->format_info[i];
+ /*string_free ((string)f.path);*/
+ string_free ((string)f.override_path);
+ string_free ((string)f.client_path);
+ /*string_free ((string)f.cnf_path);*/
+ }
+
+ if (kpse->missfont != (FILE *)NULL)
+ fclose(kpse->missfont);
+
+ for (i = 0; i < (int)kpse->expansion_len; i++) {
+ string_free (kpse->expansions[i].var);
+ }
+ free (kpse->expansions);
+ if (kpse->saved_env!=NULL) {
+ for (i = 0; i != kpse->saved_count; ++i)
+ string_free (kpse->saved_env[i]);
+ free (kpse->saved_env);
+ }
+#endif /* zero */
+#if defined (KPSE_COMPAT_API)
+ if (kpse==kpse_def)
+ return;
+#endif
+ free(kpse);
+}
+
+
+#if defined (KPSE_COMPAT_API)
+
+#define NULL_FORMAT_INFO(kpse_file_format_type) { \
+ NULL, /* const_string type */ \
+ NULL, /* const_string path */ \
+ NULL, /* const_string raw_path */ \
+ NULL, /* const_string path_source */ \
+ NULL, /* const_string override_path */ \
+ NULL, /* const_string client_path */ \
+ NULL, /* const_string cnf_path */ \
+ NULL, /* const_string default_path */ \
+ NULL, /* const_string *suffix */ \
+ NULL, /* const_string *alt_suffix */ \
+ false, /* boolean suffix_search_only */ \
+ NULL, /* const_string program */ \
+ 0, /* int argc */ \
+ NULL, /* const_string *argv */ \
+ false, /* boolean program_enabled_p */ \
+ 0, /* kpse_src_type program_enable_level */ \
+ false /* boolean binmode */ \
+ }
+
+kpathsea_instance kpse_def_inst = {
+ NULL, /* p_record_input record_input */
+ NULL, /* p_record_output record_output */
+ {NULL, 0}, /* hash_table_type cnf_hash */
+ false, /* boolean doing_cnf_init */
+ {NULL, 0}, /* hash_table_type db */
+ {NULL, 0}, /* hash_table_type alias_db */
+ {0, NULL}, /* str_list_type db_dir_list */
+ 0, /* unsigned debug */
+ {NULL, 0}, /* hash_table_type link_table */
+ NULL, /* cache_entry *the_cache */
+ 0, /* unsigned cache_length */
+ {NULL, 0}, /* hash_table_type map */
+ NULL, /* const_string map_path */
+ false, /* boolean debug_hash_lookup_int */
+ NULL, /* string elt */
+ 0, /* unsigned elt_alloc */
+ NULL, /* const_string path */
+ false, /* boolean followup_search */
+ NULL, /* FILE *log_file */
+ false, /* boolean log_opened */
+ NULL, /* string invocation_name */
+ NULL, /* string invocation_short_name */
+ NULL, /* string program_name */
+ 0, /* int ll_verbose */
+ NULL, /* const_string fallback_font */
+ NULL, /* const_string fallback_resolutions_string */
+ 0, /* unsigned *fallback_resolutions */
+ { /* kpse_format_info_type format_info[kpse_last_format] */
+ NULL_FORMAT_INFO(kpse_gf_format),
+ NULL_FORMAT_INFO(kpse_pk_format),
+ NULL_FORMAT_INFO(kpse_any_glyph_format),
+ NULL_FORMAT_INFO(kpse_tfm_format),
+ NULL_FORMAT_INFO(kpse_afm_format),
+ NULL_FORMAT_INFO(kpse_base_format),
+ NULL_FORMAT_INFO(kpse_bib_format),
+ NULL_FORMAT_INFO(kpse_bst_format),
+ NULL_FORMAT_INFO(kpse_cnf_format),
+ NULL_FORMAT_INFO(kpse_db_format),
+ NULL_FORMAT_INFO(kpse_fmt_format),
+ NULL_FORMAT_INFO(kpse_fontmap_format),
+ NULL_FORMAT_INFO(kpse_mem_format),
+ NULL_FORMAT_INFO(kpse_mf_format),
+ NULL_FORMAT_INFO(kpse_mfpool_format),
+ NULL_FORMAT_INFO(kpse_mft_format),
+ NULL_FORMAT_INFO(kpse_mp_format),
+ NULL_FORMAT_INFO(kpse_mppool_format),
+ NULL_FORMAT_INFO(kpse_mpsupport_format),
+ NULL_FORMAT_INFO(kpse_ocp_format),
+ NULL_FORMAT_INFO(kpse_ofm_format),
+ NULL_FORMAT_INFO(kpse_opl_format),
+ NULL_FORMAT_INFO(kpse_otp_format),
+ NULL_FORMAT_INFO(kpse_ovf_format),
+ NULL_FORMAT_INFO(kpse_ovp_format),
+ NULL_FORMAT_INFO(kpse_pict_format),
+ NULL_FORMAT_INFO(kpse_tex_format),
+ NULL_FORMAT_INFO(kpse_texdoc_format),
+ NULL_FORMAT_INFO(kpse_texpool_format),
+ NULL_FORMAT_INFO(kpse_texsource_format),
+ NULL_FORMAT_INFO(kpse_tex_ps_header_format),
+ NULL_FORMAT_INFO(kpse_troff_font_format),
+ NULL_FORMAT_INFO(kpse_type1_format),
+ NULL_FORMAT_INFO(kpse_vf_format),
+ NULL_FORMAT_INFO(kpse_dvips_config_format),
+ NULL_FORMAT_INFO(kpse_ist_format),
+ NULL_FORMAT_INFO(kpse_truetype_format),
+ NULL_FORMAT_INFO(kpse_type42_format),
+ NULL_FORMAT_INFO(kpse_web2c_format),
+ NULL_FORMAT_INFO(kpse_program_text_format),
+ NULL_FORMAT_INFO(kpse_program_binary_format),
+ NULL_FORMAT_INFO(kpse_miscfonts_format),
+ NULL_FORMAT_INFO(kpse_web_format),
+ NULL_FORMAT_INFO(kpse_cweb_format),
+ NULL_FORMAT_INFO(kpse_enc_format),
+ NULL_FORMAT_INFO(kpse_cmap_format),
+ NULL_FORMAT_INFO(kpse_sfd_format),
+ NULL_FORMAT_INFO(kpse_opentype_format),
+ NULL_FORMAT_INFO(kpse_pdftex_config_format),
+ NULL_FORMAT_INFO(kpse_lig_format),
+ NULL_FORMAT_INFO(kpse_texmfscripts_format),
+ NULL_FORMAT_INFO(kpse_lua_format)
+ },
+ false, /* boolean make_tex_discard_errors */
+ NULL, /* FILE *missfont */
+ NULL, /* expansion_type *expansions */
+ 0, /* unsigned expansion_len */
+ NULL, /* char **saved_env */
+ 0 /* int saved_count */
+};
+
+kpathsea kpse_def = &kpse_def_inst;
+
+#endif
diff --git a/Build/source/texk/kpathsea/kpsestat.c b/Build/source/texk/kpathsea/kpsestat.c
index a98ede22655..04a0d9835a5 100644
--- a/Build/source/texk/kpathsea/kpsestat.c
+++ b/Build/source/texk/kpathsea/kpsestat.c
@@ -27,7 +27,7 @@
*/
int
-main P2C(int, argc, char **, argv)
+main (int argc, char **argv)
{
char * mode_string;
int to_set, to_keep, to_clear;
diff --git a/Build/source/texk/kpathsea/kpsewhich.c b/Build/source/texk/kpathsea/kpsewhich.c
index 84194dbb58e..e8bb6ddbf65 100644
--- a/Build/source/texk/kpathsea/kpsewhich.c
+++ b/Build/source/texk/kpathsea/kpsewhich.c
@@ -72,7 +72,7 @@ string engine = NULL;
that form. If it doesn't, return 0. */
static unsigned
-find_dpi P1C(string, s)
+find_dpi (string s)
{
unsigned dpi_number = 0;
string extension = find_suffix (s);
@@ -93,7 +93,7 @@ find_dpi P1C(string, s)
differ from what would be inferred from their extensions. */
static kpse_file_format_type
-find_format P2C(string, name, boolean, is_filename)
+find_format (kpathsea kpse, string name, boolean is_filename)
{
kpse_file_format_type ret;
@@ -136,19 +136,19 @@ find_format P2C(string, name, boolean, is_filename)
const_string ftry;
boolean found = false;
- if (!kpse_format_info[f].type)
- kpse_init_format ((kpse_file_format_type) f);
+ if (!kpse->format_info[f].type)
+ kpathsea_init_format (kpse, (kpse_file_format_type) f);
if (!is_filename) {
/* Allow the long name, but only in the -format option. We don't
want a filename confused with a format name. */
- ftry = kpse_format_info[f].type;
+ ftry = kpse->format_info[f].type;
found = TRY_SUFFIX (ftry);
}
- for (ext = kpse_format_info[f].suffix; !found && ext && *ext; ext++) {
+ for (ext = kpse->format_info[f].suffix; !found && ext && *ext; ext++) {
found = TRY_SUFFIX (*ext);
}
- for (ext = kpse_format_info[f].alt_suffix; !found && ext && *ext; ext++){
+ for (ext = kpse->format_info[f].alt_suffix; !found && ext && *ext; ext++){
found = TRY_SUFFIX (*ext);
}
@@ -190,7 +190,7 @@ find_format P2C(string, name, boolean, is_filename)
Perhaps later we will implement wildcards or // or something. */
static string *
-subdir_match P2C(str_list_type, subdirs, string *, matches)
+subdir_match (str_list_type subdirs, string *matches)
{
string *ret = XTALLOC1 (string);
unsigned len = 1;
@@ -232,7 +232,7 @@ subdir_match P2C(str_list_type, subdirs, string *, matches)
/* Look up a single filename NAME. Return 0 if success, 1 if failure. */
static unsigned
-lookup P1C(string, name)
+lookup (kpathsea kpse, string name)
{
int i;
string ret = NULL;
@@ -240,14 +240,14 @@ lookup P1C(string, name)
if (user_path) {
if (show_all) {
- ret_list = kpse_all_path_search (user_path, name);
+ ret_list = kpathsea_all_path_search (kpse, user_path, name);
} else {
- ret = kpse_path_search (user_path, name, must_exist);
+ ret = kpathsea_path_search (kpse, user_path, name, must_exist);
}
} else {
/* No user-specified search path, check user format or guess from NAME. */
- kpse_file_format_type fmt = find_format (name, true);
+ kpse_file_format_type fmt = find_format (kpse, name, true);
switch (fmt) {
case kpse_pk_format:
@@ -259,8 +259,8 @@ lookup P1C(string, name)
unsigned local_dpi = find_dpi (name);
if (!local_dpi)
local_dpi = dpi;
- ret = kpse_find_glyph (remove_suffix (name), local_dpi, fmt,
- &glyph_ret);
+ ret = kpathsea_find_glyph (kpse, remove_suffix (name), local_dpi, fmt,
+ &glyph_ret);
}
break;
@@ -271,9 +271,9 @@ lookup P1C(string, name)
default:
if (show_all) {
- ret_list = kpse_find_file_generic (name, fmt, must_exist, true);
+ ret_list = kpathsea_find_file_generic (kpse, name, fmt, must_exist, true);
} else {
- ret = kpse_find_file (name, fmt, must_exist);
+ ret = kpathsea_find_file (kpse, name, fmt, must_exist);
}
}
}
@@ -368,7 +368,7 @@ static struct option long_options[]
{ 0, 0, 0, 0 } };
static void
-read_command_line P2C(int, argc, string *, argv)
+read_command_line (kpathsea kpse, int argc, string *argv)
{
int g; /* `getopt' return code. */
int option_index;
@@ -385,7 +385,7 @@ read_command_line P2C(int, argc, string *, argv)
assert (g == 0); /* We have no short option names. */
if (ARGUMENT_IS ("debug")) {
- kpathsea_debug |= atoi (optarg);
+ kpse->debug |= atoi (optarg);
} else if (ARGUMENT_IS ("dpi") || ARGUMENT_IS ("D")) {
dpi = atoi (optarg);
@@ -407,30 +407,30 @@ read_command_line P2C(int, argc, string *, argv)
} else if (ARGUMENT_IS ("help")) {
int f; /* kpse_file_format_type */
- extern KPSEDLL char *kpse_bug_address; /* from version.c */
+ extern KPSEDLL char *kpathsea_bug_address; /* from version.c */
printf ("Usage: %s [OPTION]... [FILENAME]...\n", argv[0]);
fputs (USAGE, stdout);
putchar ('\n');
- fputs (kpse_bug_address, stdout);
+ fputs (kpathsea_bug_address, stdout);
/* Have to set this for init_format to work. */
- kpse_set_program_name (argv[0], progname);
+ kpathsea_set_program_name (kpse, argv[0], progname);
puts ("\nRecognized format names and their suffixes:");
for (f = 0; f < kpse_last_format; f++) {
const_string *ext;
- kpse_init_format ((kpse_file_format_type)f);
- printf ("%s:", kpse_format_info[f].type);
- for (ext = kpse_format_info[f].suffix; ext && *ext; ext++) {
+ kpathsea_init_format (kpse, (kpse_file_format_type)f);
+ printf ("%s:", kpse->format_info[f].type);
+ for (ext = kpse->format_info[f].suffix; ext && *ext; ext++) {
putchar (' ');
fputs (*ext, stdout);
}
- if (kpse_format_info[f].alt_suffix) {
+ if (kpse->format_info[f].alt_suffix) {
/* leave extra space between default and alt suffixes */
putchar (' ');
}
- for (ext = kpse_format_info[f].alt_suffix; ext && *ext; ext++) {
+ for (ext = kpse->format_info[f].alt_suffix; ext && *ext; ext++) {
putchar (' ');
fputs (*ext, stdout);
}
@@ -440,13 +440,13 @@ read_command_line P2C(int, argc, string *, argv)
exit (0);
} else if (ARGUMENT_IS ("mktex")) {
- kpse_maketex_option (optarg, true);
+ kpathsea_maketex_option (kpse, optarg, true);
} else if (ARGUMENT_IS ("mode")) {
mode = optarg;
} else if (ARGUMENT_IS ("no-mktex")) {
- kpse_maketex_option (optarg, false);
+ kpathsea_maketex_option (kpse, optarg, false);
} else if (ARGUMENT_IS ("path")) {
user_path = optarg;
@@ -493,23 +493,23 @@ There is NO WARRANTY, to the extent permitted by law.\n");
}
int
-main P2C(int, argc, string *, argv)
+main (int argc, string *argv)
{
unsigned unfound = 0;
+ kpathsea kpse = kpathsea_new();
+ read_command_line (kpse, argc, argv);
- read_command_line (argc, argv);
-
- kpse_set_program_name (argv[0], progname);
+ kpathsea_set_program_name (kpse, argv[0], progname);
if (engine)
- xputenv ("engine", engine);
+ kpathsea_xputenv (kpse, "engine", engine);
/* NULL for no fallback font. */
- kpse_init_prog (uppercasify (kpse_program_name), dpi, mode, NULL);
+ kpathsea_init_prog (kpse, uppercasify (kpse->program_name), dpi, mode, NULL);
/* Have to do this after setting the program name. */
if (user_format_string) {
- user_format = find_format (user_format_string, false);
+ user_format = find_format (kpse, user_format_string, false);
if (user_format == kpse_last_format) {
WARNING1 ("kpsewhich: Ignoring unknown file type `%s'",
user_format_string);
@@ -518,22 +518,22 @@ main P2C(int, argc, string *, argv)
/* Variable expansion. */
if (var_to_expand)
- puts (kpse_var_expand (var_to_expand));
+ puts (kpathsea_var_expand (kpse, var_to_expand));
/* Brace expansion. */
if (braces_to_expand)
- puts (kpse_brace_expand (braces_to_expand));
+ puts (kpathsea_brace_expand (kpse, braces_to_expand));
/* Path expansion. */
if (path_to_expand)
- puts (kpse_path_expand (path_to_expand));
+ puts (kpathsea_path_expand (kpse, path_to_expand));
/* Show a search path. */
if (path_to_show) {
if (user_format != kpse_last_format) {
- if (!kpse_format_info[user_format].type) /* needed if arg was numeric */
- kpse_init_format (user_format);
- puts (kpse_format_info[user_format].path);
+ if (!kpse->format_info[user_format].type) /* needed if arg was numeric */
+ kpathsea_init_format (kpse, user_format);
+ puts (kpse->format_info[user_format].path);
} else {
WARNING ("kpsewhich: Cannot show path for unknown file type");
}
@@ -541,7 +541,7 @@ main P2C(int, argc, string *, argv)
/* Var to value. */
if (var_to_value) {
- const_string value = kpse_var_value (var_to_value);
+ const_string value = kpathsea_var_value (kpse, var_to_value);
if (!value) {
unfound++;
value="";
@@ -556,17 +556,17 @@ main P2C(int, argc, string *, argv)
}
for (; optind < argc; optind++) {
- unfound += lookup (argv[optind]);
+ unfound += lookup (kpse, argv[optind]);
}
if (interactive) {
for (;;) {
string name = read_line (stdin);
if (!name || STREQ (name, "q") || STREQ (name, "quit")) break;
- unfound += lookup (name);
+ unfound += lookup (kpse, name);
free (name);
}
}
-
+ kpathsea_finish(kpse);
return unfound > 255 ? 1 : unfound;
}
diff --git a/Build/source/texk/kpathsea/lib.h b/Build/source/texk/kpathsea/lib.h
index 3b7a84f69db..721c3b185e2 100644
--- a/Build/source/texk/kpathsea/lib.h
+++ b/Build/source/texk/kpathsea/lib.h
@@ -28,29 +28,45 @@
/* This should be called only after a system call fails. Don't exit
with status `errno', because that might be 256, which would mean
success (exit statuses are truncated to eight bits). */
+
+#if defined (KPSE_COMPAT_API)
+/* This branch works as expected also in programs that use the new interface,
+ because kpathsea_set_program_name() sets up the kpse_def->invocation_name
+ whenever it is available.
+*/
+#define FATAL_PERROR(str) do { \
+ fprintf (stderr, "%s: ", kpse_def->invocation_name); \
+ perror (str); exit (EXIT_FAILURE); } while (0)
+#else
+/* If there is no global variable available, just output the error */
#define FATAL_PERROR(str) do { \
- fprintf (stderr, "%s: ", program_invocation_name); \
perror (str); exit (EXIT_FAILURE); } while (0)
+#endif
+#if defined (KPSE_COMPAT_API)
+#define START_FATAL() do { \
+ fprintf (stderr, "%s: fatal: ", kpse_def->invocation_name);
+#else
#define START_FATAL() do { \
- fprintf (stderr, "%s: fatal: ", program_invocation_name);
+ fprintf (stderr, "fatal: ");
+#endif
+
#define END_FATAL() fputs (".\n", stderr); exit (1); } while (0)
#define FATAL(str) \
START_FATAL (); fputs (str, stderr); END_FATAL ()
#define FATAL1(str, e1) \
START_FATAL (); fprintf (stderr, str, e1); END_FATAL ()
-#define FATAL2(str, e1, e2) \
- START_FATAL (); fprintf (stderr, str, e1, e2); END_FATAL ()
-#define FATAL3(str, e1, e2, e3) \
- START_FATAL (); fprintf (stderr, str, e1, e2, e3); END_FATAL ()
-#define FATAL4(str, e1, e2, e3, e4) \
- START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4); END_FATAL ()
-#define FATAL5(str, e1, e2, e3, e4, e5) \
- START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5); END_FATAL ()
-#define FATAL6(str, e1, e2, e3, e4, e5, e6) \
- START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5, e6); END_FATAL ()
-
+#define FATAL2(str, e1, e2) \
+ START_FATAL (); fprintf (stderr, str, e1, e2); END_FATAL ()
+#define FATAL3(str, e1, e2, e3) \
+ START_FATAL (); fprintf (stderr, str, e1, e2, e3); END_FATAL ()
+#define FATAL4(str, e1, e2, e3, e4) \
+ START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4); END_FATAL ()
+#define FATAL5(str, e1, e2, e3, e4, e5) \
+ START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5); END_FATAL ()
+#define FATAL6(str, e1, e2, e3, e4, e5, e6) \
+ START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5, e6); END_FATAL ()
#define START_WARNING() do { fputs ("warning: ", stderr)
#define END_WARNING() fputs (".\n", stderr); fflush (stderr); } while (0)
@@ -66,6 +82,16 @@
#define WARNING4(str, e1, e2, e3, e4) \
START_WARNING (); fprintf (stderr, str, e1, e2, e3, e4); END_WARNING ()
+#define LIB_START_FATAL() do { \
+ fprintf (stderr, "%s: fatal: ", kpse->invocation_name);
+
+#define LIB_FATAL(str) \
+ LIB_START_FATAL (); fputs (str, stderr); END_FATAL ()
+#define LIB_FATAL1(str, e1) \
+ LIB_START_FATAL (); fprintf (stderr, str, e1); END_FATAL ()
+#define LIB_FATAL2(str, e1, e2) \
+ LIB_START_FATAL (); fprintf (stderr, str, e1, e2); END_FATAL ()
+
/* I find this easier to read. */
#define STREQ(s1, s2) ((s1) && (s2) && (strcmp (s1, s2) == 0))
@@ -93,88 +119,98 @@
#define ENVVAR(test, default) (getenv (test) ? (test) : (default))
/* Return a fresh copy of S1 followed by S2, et al. */
-extern KPSEDLL string concat P2H(const_string s1, const_string s2);
-extern KPSEDLL string concat3 P3H(const_string, const_string, const_string);
+extern KPSEDLL string concat (const_string s1, const_string s2);
+extern KPSEDLL string concat3 (const_string, const_string, const_string);
/* `concatn' is declared in its own include file, to avoid pulling in
all the varargs stuff. */
/* A fresh copy of just S. */
-extern KPSEDLL string xstrdup P1H(const_string s);
+extern KPSEDLL string xstrdup (const_string s);
/* Convert all lowercase characters in S to uppercase. */
-extern KPSEDLL string uppercasify P1H(const_string s);
+extern KPSEDLL string uppercasify (const_string s);
/* Like `atoi', but disallow negative numbers. */
-extern KPSEDLL unsigned atou P1H(const_string);
+extern KPSEDLL unsigned atou (const_string);
/* True if FILENAME1 and FILENAME2 are the same file. If stat fails on
either name, return false, no error message.
Cf. `SAME_FILE_P' in xstat.h. */
-extern KPSEDLL boolean same_file_p P2H(const_string filename1,
+extern KPSEDLL boolean same_file_p (const_string filename1,
const_string filename2);
/* Return NAME with any leading path stripped off. This returns a
pointer into NAME. */
-extern KPSEDLL const_string xbasename P1H(const_string name);
+extern KPSEDLL const_string xbasename (const_string name);
/* Return directory part of NAME. This returns a new string. */
-extern KPSEDLL string xdirname P1H(const_string name);
+extern KPSEDLL string xdirname (const_string name);
#if !HAVE_DECL_STRSTR
-extern string strstr P2H(const_string haystack, const_string needle);
+extern string strstr (const_string haystack, const_string needle);
#endif
/* If NAME has a suffix, return a pointer to its first character (i.e.,
the one after the `.'); otherwise, return NULL. */
-extern KPSEDLL string find_suffix P1H(const_string name);
+extern KPSEDLL string find_suffix (const_string name);
/* Return NAME with any suffix removed. */
-extern KPSEDLL string remove_suffix P1H(const_string name);
+extern KPSEDLL string remove_suffix (const_string name);
/* Return S with the suffix SUFFIX, removing any suffix already present.
For example, `make_suffix ("/foo/bar.baz", "quux")' returns
`/foo/bar.quux'. Returns a string allocated with malloc. */
-extern KPSEDLL string make_suffix P2H(const_string s, const_string suffix);
+extern KPSEDLL string make_suffix (const_string s, const_string suffix);
/* Return NAME with STEM_PREFIX prepended to the stem. For example,
`make_prefix ("/foo/bar.baz", "x")' returns `/foo/xbar.baz'.
Returns a string allocated with malloc. */
-extern KPSEDLL string make_prefix P2H(string stem_prefix, string name);
+extern KPSEDLL string make_prefix (string stem_prefix, string name);
/* If NAME has a suffix, simply return it; otherwise, return
`NAME.SUFFIX'. */
-extern KPSEDLL string extend_filename P2H(const_string name,
+extern KPSEDLL string extend_filename (const_string name,
const_string suffix);
/* Call putenv with the string `VAR=VALUE' and abort on error. */
-extern KPSEDLL void xputenv P2H(const_string var, const_string value);
-extern KPSEDLL void xputenv_int P2H(const_string var, int value);
+extern KPSEDLL void kpathsea_xputenv (kpathsea kpse, const_string var, const_string value);
+extern KPSEDLL void kpathsea_xputenv_int (kpathsea kpse, const_string var, int value);
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL void xputenv (const_string var, const_string value);
+extern KPSEDLL void xputenv_int (const_string var, int value);
+#endif
/* Return the current working directory. */
-extern KPSEDLL string xgetcwd P1H(void);
+extern KPSEDLL string xgetcwd (void);
/* Returns true if FN is a directory or a symlink to a directory. */
-extern KPSEDLL boolean dir_p P1H(const_string fn);
+extern KPSEDLL boolean kpathsea_dir_p (kpathsea kpse, const_string fn);
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL boolean dir_p (const_string fn);
+#endif
/* If FN is a readable directory, return the number of links it has.
Otherwise, return -1. The nlinks parameter is a dummy on UNIX. */
-extern KPSEDLL int dir_links P2H(const_string fn, long nlinks);
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL int dir_links (const_string fn, long nlinks);
+#endif
+extern KPSEDLL int kpathsea_dir_links (kpathsea kpse, const_string fn, long nlinks);
/* Like their stdio counterparts, but abort on error, after calling
perror(3) with FILENAME as its argument. */
-extern KPSEDLL FILE *xfopen P2H(const_string filename, const_string mode);
-extern KPSEDLL void xfclose P2H(FILE *, const_string filename);
-extern KPSEDLL void xfseek P4H(FILE *, long, int, string filename);
-extern KPSEDLL void xfseeko P4H(FILE *, off_t, int, string filename);
-extern KPSEDLL unsigned long xftell P2H(FILE *, string filename);
-extern KPSEDLL off_t xftello P2H(FILE *, string filename);
+extern KPSEDLL FILE *xfopen (const_string filename, const_string mode);
+extern KPSEDLL void xfclose (FILE *, const_string filename);
+extern KPSEDLL void xfseek (FILE *, long, int, string filename);
+extern KPSEDLL void xfseeko (FILE *, off_t, int, string filename);
+extern KPSEDLL unsigned long xftell (FILE *, string filename);
+extern KPSEDLL off_t xftello (FILE *, string filename);
/* These call the corresponding function in the standard library, and
abort if those routines fail. Also, `xrealloc' calls `xmalloc' if
OLD_ADDRESS is null. */
-extern KPSEDLL address xmalloc P1H(unsigned size);
-extern KPSEDLL address xrealloc P2H(address old_address, unsigned new_size);
-extern KPSEDLL address xcalloc P2H(unsigned nelem, unsigned elsize);
+extern KPSEDLL address xmalloc (unsigned size);
+extern KPSEDLL address xrealloc (address old_address, unsigned new_size);
+extern KPSEDLL address xcalloc (unsigned nelem, unsigned elsize);
/* (Re)Allocate N items of type T using xmalloc/xrealloc. */
#define XTALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t)))
diff --git a/Build/source/texk/kpathsea/line.c b/Build/source/texk/kpathsea/line.c
index 3e2fb686e38..04d193a8d91 100644
--- a/Build/source/texk/kpathsea/line.c
+++ b/Build/source/texk/kpathsea/line.c
@@ -23,7 +23,7 @@
#define BLOCK_SIZE 75
char *
-read_line P1C(FILE*, f)
+read_line (FILE*f)
{
int c;
unsigned limit = BLOCK_SIZE;
diff --git a/Build/source/texk/kpathsea/line.h b/Build/source/texk/kpathsea/line.h
index 6e657a0acea..f2a8d89b946 100644
--- a/Build/source/texk/kpathsea/line.h
+++ b/Build/source/texk/kpathsea/line.h
@@ -26,6 +26,6 @@
/* Return NULL if we are at EOF, else the next line of F. The newline
character at the end of string is removed. The string is allocated
with malloc. */
-extern KPSEDLL string read_line P1H(FILE *f);
+extern KPSEDLL string read_line (FILE *f);
#endif /* not LINE_H */
diff --git a/Build/source/texk/kpathsea/magstep.c b/Build/source/texk/kpathsea/magstep.c
index 37889271a44..4ce398b10e5 100644
--- a/Build/source/texk/kpathsea/magstep.c
+++ b/Build/source/texk/kpathsea/magstep.c
@@ -25,7 +25,7 @@
magstep.h) for resolution BDPI. From Tom Rokicki's dvips. */
static int
-magstep P2C(int, n, int, bdpi)
+magstep (int n, int bdpi)
{
double t;
int step;
@@ -76,12 +76,13 @@ magstep P2C(int, n, int, bdpi)
#define MAGSTEP_MAX 40
unsigned
-kpse_magstep_fix P3C(unsigned, dpi, unsigned, bdpi, int *, m_ret)
+kpathsea_magstep_fix (kpathsea kpse, unsigned dpi, unsigned bdpi, int *m_ret)
{
int m;
int mdpi = -1;
unsigned real_dpi = 0;
int sign = dpi < bdpi ? -1 : 1; /* negative or positive magsteps? */
+ (void)kpse; /* currenty not used */
for (m = 0; !real_dpi && m < MAGSTEP_MAX; m++) /* don't go forever */
{
@@ -100,3 +101,12 @@ kpse_magstep_fix P3C(unsigned, dpi, unsigned, bdpi, int *, m_ret)
/* Always return the true dpi found. */
return real_dpi ? real_dpi : dpi;
}
+
+#if defined (KPSE_COMPAT_API)
+unsigned
+kpse_magstep_fix (unsigned dpi, unsigned bdpi, int *m_ret)
+{
+ return kpathsea_magstep_fix(kpse_def, dpi, bdpi, m_ret);
+}
+#endif
+
diff --git a/Build/source/texk/kpathsea/magstep.h b/Build/source/texk/kpathsea/magstep.h
index 3170819f5c2..0359562d4d2 100644
--- a/Build/source/texk/kpathsea/magstep.h
+++ b/Build/source/texk/kpathsea/magstep.h
@@ -40,6 +40,11 @@
file, but before you look up any files -- do the usual floating-point
computations, and then fix up the result. */
-extern KPSEDLL unsigned kpse_magstep_fix P3H(unsigned dpi, unsigned bdpi, int *m_ret);
+extern KPSEDLL unsigned kpathsea_magstep_fix (kpathsea kpse, unsigned dpi,
+ unsigned bdpi, int *m_ret);
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL unsigned kpse_magstep_fix (unsigned dpi, unsigned bdpi, int *m_ret);
+#endif
#endif /* not KPATHSEA_MAGSTEP_H */
diff --git a/Build/source/texk/kpathsea/make-suffix.c b/Build/source/texk/kpathsea/make-suffix.c
index 51a4bdf1715..8962d7cc2ee 100644
--- a/Build/source/texk/kpathsea/make-suffix.c
+++ b/Build/source/texk/kpathsea/make-suffix.c
@@ -23,7 +23,7 @@
was before. This returns a newly allocated string. */
string
-make_suffix P2C(const_string, s, const_string, suffix)
+make_suffix (const_string s, const_string suffix)
{
string new_s;
const_string dot_pos = strrchr (s, '.');
diff --git a/Build/source/texk/kpathsea/mingw32.c b/Build/source/texk/kpathsea/mingw32.c
index 32d0f379bdb..69de2af2e1b 100644
--- a/Build/source/texk/kpathsea/mingw32.c
+++ b/Build/source/texk/kpathsea/mingw32.c
@@ -35,10 +35,15 @@ static int static_variable_mingw32_c = 0;
#include <shlobj.h>
#include <errno.h>
-
/* Emulate getpwuid, getpwnam and others. */
-char *get_home_directory(void);
+typedef HWND (WINAPI *pGetDesktopWindow)(void);
+
+typedef HRESULT (WINAPI * pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
+
+extern int __cdecl _set_osfhnd (int fd, long h);
+extern int __cdecl _free_osfhnd (int fd);
+
int _parse_root (char * name, char ** pPath);
void
@@ -70,42 +75,27 @@ init_user_info (void)
}
}
-static char *cached_home_directory;
-
-
-void
-uncache_home_directory (void)
-{
- cached_home_directory = NULL; /* in some cases, this may cause the leaking
- of a few bytes */
-}
-
/* This function could go away */
void
set_home_warning (void)
{
}
-typedef HWND (WINAPI *pGetDesktopWindow)(void);
-typedef HRESULT (WINAPI * pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
-
/* Returns the home directory, in external format */
char *
get_home_directory (void)
{
+ char *found_home_directory = NULL;
- if (cached_home_directory != NULL)
- goto done;
-
- if ((cached_home_directory = getenv("HOME")) != NULL) {
+ if ((found_home_directory = getenv("HOME")) != NULL) {
char q[MAXPATHLEN];
/* In case it is %HOMEDRIVE%%HOMEPATH% */
- if (ExpandEnvironmentStrings(cached_home_directory, q, sizeof(q)) == 0) {
+ if (ExpandEnvironmentStrings(found_home_directory, q, sizeof(q)) == 0) {
/* Error */
- cached_home_directory = NULL;
+ found_home_directory = NULL;
}
else {
- cached_home_directory = xstrdup(q);
+ found_home_directory = xstrdup(q);
goto done;
}
}
@@ -114,7 +104,7 @@ get_home_directory (void)
char *homedrive, *homepath;
if ((homedrive = getenv("HOMEDRIVE")) != NULL &&
(homepath = getenv("HOMEPATH")) != NULL) {
- cached_home_directory = concat(homedrive, homepath);
+ found_home_directory = concat(homedrive, homepath);
goto done;
}
}
@@ -138,11 +128,11 @@ get_home_directory (void)
if (hwnd && (h = LoadLibrary("shell32.dll"))) {
if ((p1 = (pSHGetSpecialFolderPathA)GetProcAddress(h, "SHGetSpecialFolderPathA")))
if ((*p1)(hwnd, q, CSIDL_PERSONAL, TRUE)) {
- cached_home_directory = xstrdup(q);
+ found_home_directory = xstrdup(q);
}
FreeLibrary(h);
}
- if (cached_home_directory) goto done;
+ if (found_home_directory) goto done;
}
if (1) {
@@ -150,20 +140,14 @@ get_home_directory (void)
" directory, and will be using the value:\n"
" %s\n"
" This is probably incorrect.\n",
- cached_home_directory
+ found_home_directory
);
}
done:
- return cached_home_directory;
+ return found_home_directory;
}
-extern int __cdecl _set_osfhnd (int fd, long h);
-extern int __cdecl _free_osfhnd (int fd);
-
-/* Global referenced by various functions. */
-volume_info_data volume_info;
-
/* Consider cached volume information to be stale if older than 10s,
at least for non-local drives. Info for fixed drives is never stale. */
#define DRIVE_INDEX( c ) ( (c) <= 'Z' ? (c) - 'A' : (c) - 'a' )
@@ -171,175 +155,6 @@ volume_info_data volume_info;
( ( isalpha (root_dir[0]) ) \
|| GetTickCount () - info->timestamp < 10000 )
-/* Cache support functions. */
-
-/* this typedef will eventually replace the two separate static
- variables volume_cache and volume_info
-*/
-
-typedef struct win32_volumes {
- volume_info_data info;
- volume_info_data *cache;
-} win32_volumes ;
-
-/* Simple linked list with linear search is sufficient. */
-static volume_info_data *volume_cache = NULL;
-
-static volume_info_data *
-lookup_volume_info (char * root_dir)
-{
- volume_info_data * info;
-
- for (info = volume_cache; info; info = info->next)
- if (stricmp (info->root_dir, root_dir) == 0)
- break;
- return info;
-}
-
-static void
-add_volume_info (char * root_dir, volume_info_data * info)
-{
- info->root_dir = xstrdup (root_dir);
- info->next = volume_cache;
- volume_cache = info;
-}
-
-
-/* Wrapper for GetVolumeInformation, which uses caching to avoid
- performance penalty (~2ms on 486 for local drives, 7.5ms for local
- cdrom drive, ~5-10ms or more for remote drives on LAN). */
-volume_info_data *
-GetCachedVolumeInformation (char * root_dir)
-{
- volume_info_data * info;
- char default_root[ MAX_PATH ];
-
- /* NULL for root_dir means use root from current directory. */
- if (root_dir == NULL)
- {
- if (GetCurrentDirectory (MAX_PATH, default_root) == 0)
- return NULL;
- _parse_root (default_root, &root_dir);
- *root_dir = 0;
- root_dir = default_root;
- }
-
- /* Local fixed drives can be cached permanently. Removable drives
- cannot be cached permanently, since the volume name and serial
- number (if nothing else) can change. Remote drives should be
- treated as if they are removable, since there is no sure way to
- tell whether they are or not. Also, the UNC association of drive
- letters mapped to remote volumes can be changed at any time (even
- by other processes) without notice.
-
- As a compromise, so we can benefit from caching info for remote
- volumes, we use a simple expiry mechanism to invalidate cache
- entries that are more than ten seconds old. */
-
- info = lookup_volume_info (root_dir);
-
- if (info == NULL || ! VOLINFO_STILL_VALID (root_dir, info))
- {
- char name[ 256 ];
- DWORD serialnum;
- DWORD maxcomp;
- DWORD flags;
- char type[ 256 ];
-
- /* Info is not cached, or is stale. */
- if (!GetVolumeInformation (root_dir,
- name, sizeof (name),
- &serialnum,
- &maxcomp,
- &flags,
- type, sizeof (type)))
- return NULL;
-
- /* Cache the volume information for future use, overwriting existing
- entry if present. */
- if (info == NULL)
- {
- info = (volume_info_data *) xmalloc (sizeof (volume_info_data));
- add_volume_info (root_dir, info);
- }
- else
- {
- free (info->name);
- free (info->type);
- }
-
- info->name = xstrdup (name);
- info->serialnum = serialnum;
- info->maxcomp = maxcomp;
- info->flags = flags;
- info->type = xstrdup (type);
- info->timestamp = GetTickCount ();
- }
-
- return info;
-}
-
-/* Get information on the volume where name is held; set path pointer to
- start of pathname in name (past UNC header\volume header if present). */
-int
-get_volume_info (const char * name, const char ** pPath)
-{
- char temp[MAX_PATH];
- char *rootname = NULL; /* default to current volume */
- volume_info_data * info;
-
- if (name == NULL)
- return FALSE;
-
- /* find the root name of the volume if given */
- if (isalpha (name[0]) && name[1] == ':')
- {
- rootname = temp;
- temp[0] = *name++;
- temp[1] = *name++;
- temp[2] = '\\';
- temp[3] = 0;
- }
- else if (IS_DIR_SEP (name[0]) && IS_DIR_SEP (name[1]))
- {
- char *str = temp;
- int slashes = 4;
- rootname = temp;
- do
- {
- if (IS_DIR_SEP (*name) && --slashes == 0)
- break;
- *str++ = *name++;
- }
- while ( *name );
-
- *str++ = '\\';
- *str = 0;
- }
-
- if (pPath)
- *pPath = name;
-
- info = GetCachedVolumeInformation (rootname);
- if (info != NULL)
- {
- /* Set global referenced by other functions. */
- volume_info = *info;
- return TRUE;
- }
- return FALSE;
-}
-
-/* Determine if volume is FAT format (ie. only supports short 8.3
- names); also set path pointer to start of pathname in name. */
-int
-is_fat_volume (const char * name, const char ** pPath)
-{
- if (get_volume_info (name, pPath))
- return (volume_info.maxcomp == 12);
- return FALSE;
-}
-
/* Normalize filename by converting all path separators to
the specified separator. Also conditionally convert upper
diff --git a/Build/source/texk/kpathsea/mingw32.h b/Build/source/texk/kpathsea/mingw32.h
index 8ce67b31347..dd6913b64de 100644
--- a/Build/source/texk/kpathsea/mingw32.h
+++ b/Build/source/texk/kpathsea/mingw32.h
@@ -42,24 +42,10 @@
&& IS_DIR_SEP(*(name+1)) && isalnum(*(name+2)))
#endif
-typedef struct volume_info_data {
- struct volume_info_data * next;
-
- /* time when info was obtained */
- DWORD timestamp;
-
- /* actual volume info */
- char * root_dir;
- DWORD serialnum;
- DWORD maxcomp;
- DWORD flags;
- char * name;
- char * type;
-} volume_info_data;
-
void init_user_info (void);
-BOOL win32_get_long_filename (char *, char *, int);
void set_home_warning (void);
-BOOL look_for_cmd(const char *, char **);
+char *get_home_directory (void);
+BOOL look_for_cmd (const char *, char **);
+BOOL win32_get_long_filename (char *, char *, int);
#endif
diff --git a/Build/source/texk/kpathsea/path-elt.c b/Build/source/texk/kpathsea/path-elt.c
index ff022966d4f..3cc3a1d1cff 100644
--- a/Build/source/texk/kpathsea/path-elt.c
+++ b/Build/source/texk/kpathsea/path-elt.c
@@ -22,15 +22,6 @@
#include <kpathsea/pathsearch.h>
-/* The static (but dynamically allocated) area we return the answer in,
- and how much we've currently allocated for it. */
-static string elt = NULL;
-static unsigned elt_alloc = 0;
-
-/* The path we're currently working on. */
-static const_string path = NULL;
-
-
/* Upon entry, the static `path' is at the first (and perhaps last)
character of the return value, or else NULL if we're at the end (or
haven't been called). I make no provision for caching the results;
@@ -40,7 +31,7 @@ static const_string path = NULL;
IS_ENV_SEP; else use IS_DIR_SEP. */
static string
-element P2C(const_string, passed_path, boolean, env_p)
+element (kpathsea kpse, const_string passed_path, boolean env_p)
{
const_string p;
string ret;
@@ -48,15 +39,15 @@ element P2C(const_string, passed_path, boolean, env_p)
unsigned len;
if (passed_path)
- path = passed_path;
+ kpse->path = passed_path;
/* Check if called with NULL, and no previous path (perhaps we reached
the end). */
- else if (!path)
+ else if (!kpse->path)
return NULL;
/* OK, we have a non-null `path' if we get here. */
- assert (path);
- p = path;
+ assert (kpse->path);
+ p = kpse->path;
/* Find the next colon not enclosed by braces (or the end of the path). */
brace_level = 0;
@@ -68,38 +59,47 @@ element P2C(const_string, passed_path, boolean, env_p)
}
/* Return the substring starting at `path'. */
- len = p - path;
+ len = p - kpse->path;
/* Make sure we have enough space (including the null byte). */
- if (len + 1 > elt_alloc)
+ if (len + 1 > kpse->elt_alloc)
{
- elt_alloc = len + 1;
- elt = (string)xrealloc (elt, elt_alloc);
+ kpse->elt_alloc = len + 1;
+ kpse->elt = (string)xrealloc (kpse->elt, kpse->elt_alloc);
}
- strncpy (elt, path, len);
- elt[len] = 0;
- ret = elt;
+ strncpy (kpse->elt, kpse->path, len);
+ kpse->elt[len] = 0;
+ ret = kpse->elt;
/* If we are at the end, return NULL next time. */
- if (path[len] == 0)
- path = NULL;
+ if (kpse->path[len] == 0)
+ kpse->path = NULL;
else
- path += len + 1;
+ kpse->path += len + 1;
return ret;
}
string
-kpse_path_element P1C(const_string, p)
+kpathsea_path_element (kpathsea kpse, const_string p)
+{
+ return element (kpse, p, true);
+}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_path_element (const_string p)
{
- return element (p, true);
+ return kpathsea_path_element (kpse_def, p);
}
+#endif
+
string
-kpse_filename_component P1C(const_string, p)
+kpathsea_filename_component (kpathsea kpse, const_string p)
{
- return element (p, false);
+ return element (kpse, p, false);
}
#ifdef TEST
diff --git a/Build/source/texk/kpathsea/pathsearch.c b/Build/source/texk/kpathsea/pathsearch.c
index 12e526c1a8b..a2222f3e152 100644
--- a/Build/source/texk/kpathsea/pathsearch.c
+++ b/Build/source/texk/kpathsea/pathsearch.c
@@ -40,7 +40,6 @@
need to do various special things in this case, since we obviously
don't yet have the configuration files when we're searching for the
configuration files. */
-static boolean first_search = true;
@@ -49,24 +48,22 @@ static boolean first_search = true;
record the filename(s) found in $TEXMFLOG. */
static void
-log_search P1C(str_list_type, filenames)
+log_search (kpathsea kpse, str_list_type filenames)
{
- static FILE *log_file = NULL;
- static boolean first_time = true; /* Need to open the log file? */
- if (first_time) {
+ if (kpse->log_opened==false) {
/* Get name from either envvar or config file. */
- string log_name = kpse_var_value ("TEXMFLOG");
- first_time = false;
+ string log_name = kpathsea_var_value (kpse, "TEXMFLOG");
+ kpse->log_opened = true;
if (log_name) {
- log_file = fopen (log_name, FOPEN_A_MODE);
- if (!log_file)
+ kpse->log_file = fopen (log_name, FOPEN_A_MODE);
+ if (!kpse->log_file)
perror (log_name);
free (log_name);
}
}
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH) || log_file) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH) || kpse->log_file) {
unsigned e;
/* FILENAMES should never be null, but safety doesn't hurt. */
@@ -75,14 +72,14 @@ log_search P1C(str_list_type, filenames)
string filename = STR_LIST_ELT (filenames, e);
/* Only record absolute filenames, for privacy. */
- if (log_file && kpse_absolute_p (filename, false))
- fprintf (log_file, "%lu %s\n", (long unsigned) time (NULL),
+ if (kpse->log_file && kpathsea_absolute_p (kpse, filename, false))
+ fprintf (kpse->log_file, "%lu %s\n", (long unsigned) time (NULL),
filename);
/* And show them online, if debugging. We've already started
the debugging line in `search', where this is called, so
just print the filename here, don't use DEBUGF. */
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH)) {
putc (' ', stderr);
fputs (filename, stderr);
}
@@ -103,8 +100,8 @@ log_search P1C(str_list_type, filenames)
#define INIT_ALLOC 75 /* Doesn't much matter what this number is. */
static str_list_type
-dir_list_search P3C(str_llist_type *, dirs, const_string, name,
- boolean, search_all)
+dir_list_search (kpathsea kpse, str_llist_type *dirs, const_string name,
+ boolean search_all)
{
str_llist_elt_type *elt;
str_list_type ret;
@@ -128,7 +125,7 @@ dir_list_search P3C(str_llist_type *, dirs, const_string, name,
strcpy (potential, dir);
strcat (potential, name);
- if (kpse_readable_file (potential))
+ if (kpathsea_readable_file (kpse, potential))
{
str_list_add (&ret, potential);
@@ -155,8 +152,8 @@ dir_list_search P3C(str_llist_type *, dirs, const_string, name,
}
static str_list_type
-dir_list_search_list P3C(str_llist_type *, dirs, const_string*, names,
- boolean, search_all)
+dir_list_search_list (kpathsea kpse, str_llist_type *dirs, const_string* names,
+ boolean search_all)
{
str_llist_elt_type *elt;
str_list_type ret;
@@ -175,7 +172,7 @@ dir_list_search_list P3C(str_llist_type *, dirs, const_string*, names,
unsigned name_len;
/* Don't bother with absolute & explicit relative. */
- if (kpse_absolute_p(name, true))
+ if (kpathsea_absolute_p(kpse, name, true))
continue;
name_len = strlen(name);
@@ -188,7 +185,7 @@ dir_list_search_list P3C(str_llist_type *, dirs, const_string*, names,
strcpy (potential, dir);
strcat (potential+dir_len, name);
- if (kpse_readable_file (potential)) {
+ if (kpathsea_readable_file (kpse, potential)) {
str_list_add (&ret, potential);
/* Move this element towards the top of the list. */
@@ -218,10 +215,10 @@ dir_list_search_list P3C(str_llist_type *, dirs, const_string*, names,
readable, return (a list containing) it; otherwise, return NULL. */
static str_list_type
-absolute_search P1C(string, name)
+absolute_search (kpathsea kpse, string name)
{
str_list_type ret_list;
- string found = kpse_readable_file (name);
+ string found = kpathsea_readable_file (kpse, name);
/* Some old compilers can't initialize structs. */
ret_list = str_list_init ();
@@ -241,16 +238,16 @@ absolute_search P1C(string, name)
return the first file found. Otherwise, search all elements of PATH. */
static str_list_type
-path_search P4C(const_string, path, string, name,
- boolean, must_exist, boolean, all)
+path_search (kpathsea kpse, const_string path, string name,
+ boolean must_exist, boolean all)
{
string elt;
str_list_type ret_list;
boolean done = false;
ret_list = str_list_init (); /* some compilers lack struct initialization */
- for (elt = kpse_path_element (path); !done && elt;
- elt = kpse_path_element (NULL)) {
+ for (elt = kpathsea_path_element (kpse, path); !done && elt;
+ elt = kpathsea_path_element (kpse, NULL)) {
str_list_type *found;
boolean allow_disk_search = true;
@@ -262,11 +259,11 @@ path_search P4C(const_string, path, string, name,
}
/* See elt-dirs.c for side effects of this function */
- kpse_normalize_path(elt);
+ kpathsea_normalize_path(kpse, elt);
/* Try ls-R, unless we're searching for texmf.cnf. Our caller
(search), also tests first_search, and does the resetting. */
- found = first_search ? NULL : kpse_db_search (name, elt, all);
+ found = kpse->followup_search ? kpathsea_db_search (kpse, name, elt, all) : NULL;
/* Search the filesystem if (1) the path spec allows it, and either
(2a) we are searching for texmf.cnf ; or
@@ -276,11 +273,11 @@ path_search P4C(const_string, path, string, name,
In (2*), `found' will be NULL.
In (3), `found' will be an empty list. */
if (allow_disk_search && (!found || (must_exist && !STR_LIST (*found)))) {
- str_llist_type *dirs = kpse_element_dirs (elt);
+ str_llist_type *dirs = kpathsea_element_dirs (kpse, elt);
if (dirs && *dirs) {
if (!found)
found = XTALLOC1 (str_list_type);
- *found = dir_list_search (dirs, name, all);
+ *found = dir_list_search (kpse, dirs, name, all);
}
}
@@ -317,8 +314,8 @@ path_search P4C(const_string, path, string, name,
terminated with NULL. */
static string *
-search P4C(const_string, path, const_string, original_name,
- boolean, must_exist, boolean, all)
+search (kpathsea kpse, const_string path, const_string original_name,
+ boolean must_exist, boolean all)
{
str_list_type ret_list;
string name;
@@ -348,19 +345,19 @@ search P4C(const_string, path, const_string, original_name,
#endif
/* Make a leading ~ count as an absolute filename, and expand $FOO's. */
- name = kpse_expand (original_name);
+ name = kpathsea_expand (kpse, original_name);
/* If the first name is absolute or explicitly relative, no need to
consider PATH at all. */
- absolute_p = kpse_absolute_p (name, true);
+ absolute_p = kpathsea_absolute_p (kpse, name, true);
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
DEBUGF4 ("start search(file=%s, must_exist=%d, find_all=%d, path=%s).\n",
name, must_exist, all, path);
/* Find the file(s). */
- ret_list = absolute_p ? absolute_search (name)
- : path_search (path, name, must_exist, all);
+ ret_list = absolute_p ? absolute_search (kpse, name)
+ : path_search (kpse, path, name, must_exist, all);
/* Append NULL terminator if we didn't find anything at all, or we're
supposed to find ALL and the list doesn't end in NULL now. */
@@ -370,15 +367,15 @@ search P4C(const_string, path, const_string, original_name,
/* The very first search is for texmf.cnf. We can't log that, since
we want to allow setting TEXMFLOG in texmf.cnf. */
- if (first_search) {
- first_search = false;
+ if (kpse->followup_search==false) {
+ kpse->followup_search = true;
} else {
/* Record the filenames we found, if desired. And wrap them in a
debugging line if we're doing that. */
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
DEBUGF1 ("search(%s) =>", original_name);
- log_search (ret_list);
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ log_search (kpse, ret_list);
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
putc ('\n', stderr);
}
@@ -396,8 +393,8 @@ search P4C(const_string, path, const_string, original_name,
contain just NULL. If ALL is true, the list will be
terminated with NULL. */
static string *
-search_list P4C(const_string, path, const_string*, names,
- boolean, must_exist, boolean, all)
+search_list (kpathsea kpse, const_string path, const_string* names,
+ boolean must_exist, boolean all)
{
str_list_type ret_list;
const_string* namep;
@@ -430,7 +427,7 @@ search_list P4C(const_string, path, const_string*, names,
ret_list = str_list_init();
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH)) {
DEBUGF1 ("start search(files=[%s", *names);
for (namep = names+1; *namep != NULL; namep++) {
fputc(' ', stderr);
@@ -444,8 +441,8 @@ search_list P4C(const_string, path, const_string*, names,
/* First catch any absolute or explicit relative names. */
for (namep = names; *namep; namep++) {
- if (kpse_absolute_p(*namep, true)) {
- if (kpse_readable_file(*namep)) {
+ if (kpathsea_absolute_p(kpse, *namep, true)) {
+ if (kpathsea_readable_file(kpse, *namep)) {
str_list_add(&ret_list, xstrdup(*namep));
/* I know, I know... */
if (!all)
@@ -462,8 +459,8 @@ search_list P4C(const_string, path, const_string*, names,
goto out;
/* Look at each path element in turn. */
- for (elt = kpse_path_element (path); !done && elt;
- elt = kpse_path_element (NULL))
+ for (elt = kpathsea_path_element (kpse, path); !done && elt;
+ elt = kpathsea_path_element (kpse, NULL))
{
str_list_type *found;
boolean allow_disk_search = true;
@@ -474,10 +471,10 @@ search_list P4C(const_string, path, const_string*, names,
}
/* See elt-dirs.c for side effects of this function. */
- kpse_normalize_path(elt);
+ kpathsea_normalize_path(kpse, elt);
/* Try ls-R, unless we're searching for texmf.cnf. */
- found = first_search ? NULL : kpse_db_search_list(names, elt, all);
+ found = kpse->followup_search ? kpathsea_db_search_list(kpse, names, elt, all) : NULL;
/* Search the filesystem if (1) the path spec allows it, and either
(2a) we are searching for texmf.cnf ; or
@@ -487,11 +484,11 @@ search_list P4C(const_string, path, const_string*, names,
In (2*), `found' will be NULL.
In (3), `found' will be an empty list. */
if (allow_disk_search && (!found || (must_exist && !STR_LIST(*found)))) {
- str_llist_type *dirs = kpse_element_dirs (elt);
+ str_llist_type *dirs = kpathsea_element_dirs (kpse, elt);
if (dirs && *dirs) {
if (!found)
found = XTALLOC1 (str_list_type);
- *found = dir_list_search_list (dirs, names, all);
+ *found = dir_list_search_list (kpse, dirs, names, all);
}
}
@@ -516,12 +513,12 @@ search_list P4C(const_string, path, const_string*, names,
|| (all && STR_LIST_LAST_ELT (ret_list) != NULL))
str_list_add (&ret_list, NULL);
- if (first_search) {
- first_search = false;
+ if (kpse->followup_search==false) {
+ kpse->followup_search = true;
} else {
/* Record the filenames we found, if desired. And wrap them in a
debugging line if we're doing that. */
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH)) {
DEBUGF1 ("search([%s", *names);
for (namep = names+1; *namep != NULL; namep++) {
fputc (' ', stderr);
@@ -529,8 +526,8 @@ search_list P4C(const_string, path, const_string*, names,
}
fputs ("]) =>", stderr);
}
- log_search (ret_list);
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ log_search (kpse, ret_list);
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
putc ('\n', stderr);
}
@@ -545,10 +542,10 @@ search_list P4C(const_string, path, const_string*, names,
/* Search PATH for the first NAME according to MUST_EXIST. */
string
-kpse_path_search P3C(const_string, path, const_string, name,
- boolean, must_exist)
+kpathsea_path_search (kpathsea kpse, const_string path, const_string name,
+ boolean must_exist)
{
- string *ret_list = search (path, name, must_exist, false);
+ string *ret_list = search (kpse, path, name, must_exist, false);
string ret = *ret_list;
free (ret_list);
return ret;
@@ -557,11 +554,11 @@ kpse_path_search P3C(const_string, path, const_string, name,
/* Many inputs, return (more or less indeterminate) one matching string. */
string
-kpse_path_search_list P3C(const_string, path, const_string*, names,
- boolean, must_exist)
+kpathsea_path_search_list (kpathsea kpse, const_string path, const_string* names,
+ boolean must_exist)
{
string *ret_list
- = kpse_path_search_list_generic (path, names, must_exist, false);
+ = kpathsea_path_search_list_generic (kpse, path, names, must_exist, false);
string ret = *ret_list;
free (ret_list);
return ret;
@@ -571,9 +568,9 @@ kpse_path_search_list P3C(const_string, path, const_string*, names,
to assert `must_exist' here, but it's too late to change. */
string *
-kpse_all_path_search P2C(const_string, path, const_string, name)
+kpathsea_all_path_search (kpathsea kpse, const_string path, const_string name)
{
- string *ret = search (path, name, true, true);
+ string *ret = search (kpse, path, name, true, true);
return ret;
}
@@ -581,10 +578,11 @@ kpse_all_path_search P2C(const_string, path, const_string, name)
/* Many inputs, return list, allow specifying MUST_EXIST and ALL. */
string *
-kpse_path_search_list_generic P4C(const_string, path, const_string*, names,
- boolean, must_exist, boolean, all)
+kpathsea_path_search_list_generic (kpathsea kpse,
+ const_string path, const_string* names,
+ boolean must_exist, boolean all)
{
- string *ret = search_list (path, names, must_exist, all);
+ string *ret = search_list (kpse, path, names, must_exist, all);
return ret;
}
@@ -592,10 +590,47 @@ kpse_path_search_list_generic P4C(const_string, path, const_string*, names,
/* Many inputs, return list, MUST_EXIST and ALL always true. */
string *
-kpse_all_path_search_list P2C(const_string, path, const_string*, names)
+kpathsea_all_path_search_list (kpathsea kpse, const_string path,
+ const_string* names)
{
- return kpse_path_search_list_generic (path, names, true, true);
+ return kpathsea_path_search_list_generic (kpse, path, names, true, true);
}
+
+#if defined (KPSE_COMPAT_API)
+
+string
+kpse_path_search (const_string path, const_string name, boolean must_exist)
+{
+ return kpathsea_path_search (kpse_def, path, name, must_exist);
+}
+
+string
+kpse_path_search_list (const_string path, const_string* names, boolean must_exist)
+{
+ return kpathsea_path_search_list (kpse_def, path, names, must_exist);
+}
+
+string *
+kpse_all_path_search (const_string path, const_string name)
+{
+ return kpathsea_all_path_search (kpse_def, path, name);
+}
+
+string *
+kpse_path_search_list_generic (const_string path, const_string* names,
+ boolean must_exist, boolean all)
+{
+ return kpathsea_path_search_list_generic (kpse_def, path, names, must_exist, all);
+}
+
+string *
+kpse_all_path_search_list (const_string path, const_string* names)
+{
+ return kpathsea_all_path_search_list (kpse_def, path, names);
+}
+
+#endif
+
#ifdef TEST
@@ -606,7 +641,7 @@ test_path_search (const_string path, const_string file)
string *answer_list;
printf ("\nSearch %s for %s:\t", path, file);
- answer = kpse_path_search (path, file);
+ answer = kpse_path_search (path, file, 0);
puts (answer ? answer : "(nil)");
printf ("Search %s for all %s:\t", path, file);
@@ -623,8 +658,9 @@ test_path_search (const_string path, const_string file)
#define TEXFONTS "/usr/local/lib/tex/fonts"
int
-main ()
+main (int argc, char **argv)
{
+ kpse_set_program_name(argv[0], NULL);
/* All lists end with NULL. */
test_path_search (".", "nonexistent");
test_path_search (".", "/nonexistent");
@@ -656,6 +692,6 @@ main ()
/*
Local variables:
-test-compile-command: "gcc -posix -g -I. -I.. -DTEST pathsearch.c kpathsea.a"
+standalone-compile-command: "gcc -posix -g -I. -I.. -DTEST pathsearch.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/pathsearch.h b/Build/source/texk/kpathsea/pathsearch.h
index c7971826999..81b723d19c8 100644
--- a/Build/source/texk/kpathsea/pathsearch.h
+++ b/Build/source/texk/kpathsea/pathsearch.h
@@ -29,17 +29,17 @@
the empty string. When at the end of PATH, return NULL. In any
case, return a pointer to an area that may be overwritten on
subsequent calls. */
-extern KPSEDLL string kpse_path_element P1H(const_string path);
+extern KPSEDLL string kpathsea_path_element (kpathsea kpse, const_string path);
-/* Like `kpse_path_element', but for filename components (using
- IS_DIR_SEP). Uses same area as `kpse_path_element'. */
-extern string kpse_filename_component P1H(const_string path);
+/* Like `kpathsea_path_element', but for filename components (using
+ IS_DIR_SEP). Uses same area as `kpathsea_path_element'. */
+extern string kpathsea_filename_component (kpathsea kpse, const_string path);
/*
This function may rewrite its argument to avoid bugs when calling
stat() or equivalent under Win32. Also, it returns the index after
which the program should start to look for expandable constructs. */
-extern unsigned kpse_normalize_path P1H(string elt);
+extern unsigned kpathsea_normalize_path (kpathsea kpse, string elt);
/* Given a path element ELT, return a pointer to a NULL-terminated list
of the corresponding (existing) directory or directories, with
@@ -47,12 +47,12 @@ extern unsigned kpse_normalize_path P1H(string elt);
current working directory.
It's up to the caller to expand ELT. This is because this routine is
- most likely only useful to be called from `kpse_path_search', which
+ most likely only useful to be called from `kpathsea_path_search', which
has already assumed expansion has been done. */
-extern KPSEDLL str_llist_type *kpse_element_dirs P1H(string elt);
+extern KPSEDLL str_llist_type *kpathsea_element_dirs (kpathsea kpse, string elt);
-/* Call `kpse_expand' on NAME. If the result is an absolute or
+/* Call `kpathsea_expand' on NAME. If the result is an absolute or
explicitly relative filename, check whether it is a readable
(regular) file.
@@ -71,28 +71,48 @@ extern KPSEDLL str_llist_type *kpse_element_dirs P1H(string elt);
In any case, return a matching filename if found, otherwise NULL.
If more than one file matches, which one gets returned is
unspecified. */
-extern KPSEDLL string kpse_path_search
- P3H(const_string path, const_string name, boolean must_exist);
+extern KPSEDLL string kpathsea_path_search
+ (kpathsea kpse, const_string path, const_string name, boolean must_exist);
-/* Like `kpse_path_search', except look for a list of NAMES. */
-extern KPSEDLL string kpse_path_search_list
- P3H(const_string path, const_string* names, boolean must_exist);
+/* Like `kpathsea_path_search', except look for a list of NAMES. */
+extern KPSEDLL string kpathsea_path_search_list
+ (kpathsea kpse, const_string path, const_string* names, boolean must_exist);
-/* Like `kpse_path_search' with MUST_EXIST true, but always return all
+/* Like `kpathsea_path_search' with MUST_EXIST true, but always return all
matches in a NULL-terminated list. */
-extern KPSEDLL string *kpse_all_path_search
- P2H(const_string path, const_string name);
+extern KPSEDLL string *kpathsea_all_path_search
+ (kpathsea kpse, const_string path, const_string name);
/* Search for any of the NAMES in PATH, and allow specifying both
MUST_EXIST and ALL. */
-extern KPSEDLL string *kpse_path_search_list_generic
- P4H(const_string path, const_string* names, boolean must_exist, boolean all);
+extern KPSEDLL string *kpathsea_path_search_list_generic
+ (kpathsea kpse, const_string path, const_string* names, boolean must_exist, boolean all);
/* Search for any of NAMES, with MUST_EXIST and ALL true. */
-extern KPSEDLL string *kpse_all_path_search_list
- P2H(const_string path, const_string* names);
+extern KPSEDLL string *kpathsea_all_path_search_list
+ (kpathsea kpse, const_string path, const_string* names);
/* The naming of all these functions is rather scattered and
inconsistent, but they grew over time, and we don't want to change
the meaning of existing names. */
+
+#if defined(KPSE_COMPAT_API)
+
+extern KPSEDLL string kpse_path_element (const_string path);
+extern string kpse_filename_component (const_string path);
+extern unsigned kpse_normalize_path (string elt);
+extern KPSEDLL str_llist_type *kpse_element_dirs (string elt);
+extern KPSEDLL string kpse_path_search
+ (const_string path, const_string name, boolean must_exist);
+extern KPSEDLL string kpse_path_search_list
+ (const_string path, const_string* names, boolean must_exist);
+extern KPSEDLL string *kpse_all_path_search
+ (const_string path, const_string name);
+extern KPSEDLL string *kpse_path_search_list_generic
+ (const_string path, const_string* names, boolean must_exist, boolean all);
+extern KPSEDLL string *kpse_all_path_search_list
+ (const_string path, const_string* names);
+
+#endif
+
#endif /* not KPATHSEA_PATHSEARCH_H */
diff --git a/Build/source/texk/kpathsea/proginit.c b/Build/source/texk/kpathsea/proginit.c
index 2c4b89d124b..a2127d6500b 100644
--- a/Build/source/texk/kpathsea/proginit.c
+++ b/Build/source/texk/kpathsea/proginit.c
@@ -27,8 +27,8 @@
mess, but still better than repeating the code. */
void
-kpse_init_prog P4C(const_string, prefix, unsigned, dpi, const_string, mode,
- const_string, fallback)
+kpathsea_init_prog (kpathsea kpse, const_string prefix, unsigned dpi,
+ const_string mode, const_string fallback)
{
string font_var = concat (prefix, "FONTS");
string header_var = concat (prefix, "HEADERS");
@@ -42,35 +42,44 @@ kpse_init_prog P4C(const_string, prefix, unsigned, dpi, const_string, mode,
/* Might have a program-specific name for mktexpk itself. */
if (getenv (makepk_var)) {
/* If we did, we want to enable the program, I think. */
- kpse_set_program_enabled (kpse_pk_format, 1, kpse_src_env);
- kpse_set_program_enabled (kpse_any_glyph_format, 1, kpse_src_env);
+ kpathsea_set_program_enabled (kpse, kpse_pk_format, 1, kpse_src_env);
+ kpathsea_set_program_enabled (kpse, kpse_any_glyph_format, 1, kpse_src_env);
- kpse_format_info[kpse_pk_format].program
- = kpse_format_info[kpse_any_glyph_format].program
+ kpse->format_info[kpse_pk_format].program
+ = kpse->format_info[kpse_any_glyph_format].program
= getenv (makepk_var);
}
/* A couple font paths have traditionally had application-specific
environment variables to override all else; namely, XDVIFONTS and
DVIPSHEADERS. So set those if we have them. */
- kpse_format_info[kpse_pk_format].override_path
- = kpse_format_info[kpse_gf_format].override_path
- = kpse_format_info[kpse_any_glyph_format].override_path
- = kpse_format_info[kpse_tfm_format].override_path
+ kpse->format_info[kpse_pk_format].override_path
+ = kpse->format_info[kpse_gf_format].override_path
+ = kpse->format_info[kpse_any_glyph_format].override_path
+ = kpse->format_info[kpse_tfm_format].override_path
= getenv (font_var);
- kpse_format_info[kpse_tex_ps_header_format].override_path
+ kpse->format_info[kpse_tex_ps_header_format].override_path
= getenv (header_var);
- kpse_init_fallback_resolutions (size_var);
- xputenv_int ("MAKETEX_BASE_DPI", dpi);
- kpse_fallback_font = fallback;
+ kpathsea_init_fallback_resolutions (kpse, size_var);
+ kpathsea_xputenv_int (kpse, "MAKETEX_BASE_DPI", dpi);
+ kpse->fallback_font = fallback;
/* Ugliness. See comments in kpse_make_tex in kpathsea/tex-make.c. */
- xputenv ("MAKETEX_MODE", mode ? mode : DIR_SEP_STRING);
+ kpathsea_xputenv (kpse, "MAKETEX_MODE", mode ? mode : DIR_SEP_STRING);
free (font_var);
free (header_var);
free (makepk_var);
free (size_var);
}
+
+#if defined (KPSE_COMPAT_API)
+void
+kpse_init_prog (const_string prefix, unsigned dpi,
+ const_string mode, const_string fallback)
+{
+ kpathsea_init_prog(kpse_def,prefix,dpi,mode,fallback);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/proginit.h b/Build/source/texk/kpathsea/proginit.h
index 8cf66affc6d..c6b8a8e657e 100644
--- a/Build/source/texk/kpathsea/proginit.h
+++ b/Build/source/texk/kpathsea/proginit.h
@@ -28,7 +28,13 @@
etc., etc. See the source. */
extern KPSEDLL void
-kpse_init_prog P4H(const_string prefix, unsigned dpi, const_string mode,
- const_string fallback);
+kpathsea_init_prog (kpathsea kpse, const_string prefix, unsigned dpi,
+ const_string mode, const_string fallback);
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL void
+kpse_init_prog (const_string prefix, unsigned dpi, const_string mode,
+ const_string fallback);
+#endif
#endif /* not KPATHSEA_PROGINIT_H */
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c
index 5aee83ca7a0..2a8fdfb692a 100644
--- a/Build/source/texk/kpathsea/progname.c
+++ b/Build/source/texk/kpathsea/progname.c
@@ -72,24 +72,6 @@
#define S_IXOTH 0001
#endif
-#ifndef HAVE_PROGRAM_INVOCATION_NAME
-/* Don't redefine the variables if glibc already has. However, we do
- not check for HAVE_PROGRAM_INVOCATION_NAME anywhere else in this
- file; rather, we always use our own code to compute them, overwriting
- anything that glibc may have provided. This avoids
- difficult-to-debug system-dependent behavior, and also universally
- supports the second (`progname') argument for dotted texmf.cnf values.
-
- It would have been better to simply use our own variable names (and
- computations) in the first place, but it's not worth losing backward
- compatibility to rename them now. */
-
-string program_invocation_name = NULL;
-string program_invocation_short_name = NULL;
-#endif
-
-/* And the variable for the program we pretend to be. */
-string kpse_program_name = NULL;
#ifndef WIN32
/* From a standalone program `ll' to expand symlinks written by Kimbo Mundy.
@@ -99,8 +81,6 @@ string kpse_program_name = NULL;
that's what kimbo liked. */
#ifdef S_ISLNK
-static int ll_verbose = 0;
-static int ll_loop = 0;
#undef BSIZE
#define BSIZE 2048 /* sorry */
@@ -109,7 +89,7 @@ static int ll_loop = 0;
/* Read link FN into SYM. */
static void
-ReadSymLink P2C(char *, fn, char *, sym)
+ReadSymLink (char *fn, char *sym)
{
register int n = readlink (fn, sym, BSIZE);
if (n < 0) {
@@ -123,7 +103,7 @@ ReadSymLink P2C(char *, fn, char *, sym)
/* Strip first component from S, and also return it in a static buffer. */
static char *
-StripFirst P1C(register char *, s)
+StripFirst (register char *s)
{
static char buf[BSIZE];
register char *s1;
@@ -151,7 +131,7 @@ StripFirst P1C(register char *, s)
/* Strip last component from S, and also return it in a static buffer. */
static char *
-StripLast P1C(register char *, s)
+StripLast (register char *s)
{
static char buf[BSIZE];
register char *s1;
@@ -168,7 +148,7 @@ StripLast P1C(register char *, s)
/* Copy first path element from B to A, removing it from B. */
static void
-CopyFirst P2C(register char *, a, char *, b)
+CopyFirst (register char *a, char *b)
{
register int length = strlen (a);
@@ -187,7 +167,7 @@ CopyFirst P2C(register char *, a, char *, b)
#define EXPRE EX(pre)
static char *
-expand_symlinks P1C(char *, s)
+expand_symlinks (kpathsea kpse, char *s)
{
static char pre[BSIZE]; /* return value */
char post[BSIZE], sym[BSIZE], tmp[BSIZE], before[BSIZE];
@@ -200,7 +180,9 @@ expand_symlinks P1C(char *, s)
possibilities ourselves, so let the kernel do it. And make it
conditional so that people can see where the infinite loop is
being caused (see engtools#1536). */
- if (!ll_loop) {
+ /* There used to be a test for a variable |ll_loop| here, but
+ it was initialized to zero and never updated */
+ if (0) {
FILE *f = fopen (s, "r");
if (!f && errno == ELOOP) {
/* Not worried about other errors, we'll get to them in due course. */
@@ -226,7 +208,7 @@ expand_symlinks P1C(char *, s)
ReadSymLink (pre, sym);
if (!strncmp (sym, "/", 1)) {
- if (ll_verbose)
+ if (kpse->ll_verbose)
printf ("[%s]%s%s -> [%s]%s%s\n", pre, EXPOS, post, sym, EXPOS,post);
strcpy (pre, "");
@@ -236,7 +218,7 @@ expand_symlinks P1C(char *, s)
if (!strlen (pre) && a == '/')
strcpy (pre, "/");
- if (ll_verbose) {
+ if (kpse->ll_verbose) {
sprintf (before, "%s%s[%s]%s%s", pre, EXPRE, tmp, EXPOS, post);
printf ("%s -> %s%s[%s]%s%s\n", before, pre, EXPRE, sym, EXPOS,post);
}
@@ -257,7 +239,7 @@ expand_symlinks P1C(char *, s)
StripLast (pre);
}
- if (done && ll_verbose) {
+ if (done && kpse->ll_verbose) {
for (cp = before; *cp;)
*cp++ = ' ';
if (strlen (sym))
@@ -280,14 +262,14 @@ expand_symlinks P1C(char *, s)
return pre;
}
#else /* not S_ISLNK */
-#define expand_symlinks(s) (s)
+#define expand_symlinks(k,s) (s)
#endif /* not S_ISLNK */
/* Remove .'s and ..'s in DIR, to avoid problems with relative symlinks
as the program name, etc. This does not canonicalize symlinks. */
static string
-remove_dots P1C(string, dir)
+remove_dots (kpathsea kpse, string dir)
{
#ifdef AMIGA
return dir;
@@ -296,8 +278,8 @@ remove_dots P1C(string, dir)
unsigned len;
string ret = (string) ""; /* We always reassign. */
- for (c = kpse_filename_component (dir); c;
- c = kpse_filename_component (NULL)) {
+ for (c = kpathsea_filename_component (kpse, dir); c;
+ c = kpathsea_filename_component (kpse, NULL)) {
if (STREQ (c, ".")) {
/* If leading ., replace with cwd. Else ignore. */
if (*ret == 0) {
@@ -356,12 +338,12 @@ remove_dots P1C(string, dir)
absolute. */
string
-kpse_selfdir P1C(const_string, argv0)
+kpathsea_selfdir (kpathsea kpse, const_string argv0)
{
string ret = NULL;
string self = NULL;
- if (kpse_absolute_p (argv0, true)) {
+ if (kpathsea_absolute_p (kpse, argv0, true)) {
self = xstrdup (argv0);
} else {
#ifdef AMIGA
@@ -391,8 +373,8 @@ kpse_selfdir P1C(const_string, argv0)
/* Have to check PATH. But don't call kpse_path_search since we don't
want to search any ls-R's or do anything special with //'s. */
- for (elt = kpse_path_element (getenv ("PATH")); !self && elt;
- elt = kpse_path_element (NULL)) {
+ for (elt = kpathsea_path_element (kpse, getenv ("PATH")); !self && elt;
+ elt = kpathsea_path_element (kpse, NULL)) {
string name;
/* UNIX tradition interprets the empty path element as "." */
@@ -420,16 +402,26 @@ kpse_selfdir P1C(const_string, argv0)
if (!self)
self = concat3 (".", DIR_SEP_STRING, argv0);
- ret = xdirname (remove_dots (expand_symlinks (self)));
+ ret = xdirname (remove_dots (kpse, expand_symlinks (kpse, self)));
free (self);
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_selfdir (const_string argv0)
+{
+ return kpathsea_selfdir (kpse_def, argv0);
+}
+#endif
+
+
#endif /* not WIN32 */
void
-kpse_set_program_name P2C(const_string, argv0, const_string, progname)
+kpathsea_set_program_name (kpathsea kpse, const_string argv0, const_string progname)
{
string ext, sdir, sdir_parent, sdir_grandparent;
string s = getenv ("KPATHSEA_DEBUG");
@@ -442,14 +434,14 @@ kpse_set_program_name P2C(const_string, argv0, const_string, progname)
/* Set debugging stuff first, in case we end up doing debuggable stuff
during this initialization. */
if (s) {
- kpathsea_debug |= atoi (s);
+ kpse->debug |= atoi (s);
}
#if defined(WIN32)
/* Set various info about user. Among many things,
ensure that HOME is set. If debug_paths is on,
turn on some message if $HOME is not found. */
- if (KPSE_DEBUG_P(KPSE_DEBUG_PATHS)) {
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_PATHS)) {
set_home_warning();
}
init_user_info();
@@ -466,7 +458,7 @@ kpse_set_program_name P2C(const_string, argv0, const_string, progname)
flags = _O_CREAT | _O_APPEND | _O_WRONLY;
} else {
flags = _O_CREAT | _O_TRUNC | _O_WRONLY;
- xputenv("KPATHSEA_DEBUG_APPEND", "yes");
+ kpathsea_xputenv(kpse, "KPATHSEA_DEBUG_APPEND", "yes");
}
}
@@ -494,16 +486,16 @@ kpse_set_program_name P2C(const_string, argv0, const_string, progname)
/* SearchPath() always gives back an absolute directory */
if (SearchPath(NULL, argv0, ".exe", PATH_MAX, short_path, &fp) == 0)
- FATAL1("Can't determine where the executable %s is.\n", argv0);
+ LIB_FATAL1("Can't determine where the executable %s is.\n", argv0);
if (!win32_get_long_filename(short_path, path, sizeof(path))) {
- FATAL1("This path points to an invalid file : %s\n", short_path);
+ LIB_FATAL1("This path points to an invalid file : %s\n", short_path);
}
/* slashify the dirname */
for (fp = path; fp && *fp; fp++)
if (IS_DIR_SEP(*fp)) *fp = DIR_SEP;
/* sdir will be the directory of the executable, ie: c:/TeX/bin */
sdir = xdirname(path);
- program_invocation_name = xstrdup(xbasename(path));
+ kpse->invocation_name = xstrdup(xbasename(path));
}
#elif defined(__DJGPP__)
@@ -555,85 +547,110 @@ kpse_set_program_name P2C(const_string, argv0, const_string, progname)
if (IS_DIR_SEP (*fp))
*fp = DIR_SEP;
- program_invocation_name = xstrdup (long_progname);
+ kpse->invocation_name = xstrdup (long_progname);
}
else
/* If `_truename' failed, God help them, because we won't... */
- program_invocation_name = xstrdup (argv0);
+ kpse->invocation_name = xstrdup (argv0);
}
else
- program_invocation_name = xstrdup (argv0);
+ kpse->invocation_name = xstrdup (argv0);
#else /* !WIN32 && !__DJGPP__ */
- program_invocation_name = xstrdup (argv0);
+ kpse->invocation_name = xstrdup (argv0);
#endif
/* We need to find SELFAUTOLOC *before* removing the ".exe" suffix from
the program_name, otherwise the PATH search inside kpse_selfdir will fail,
since `prog' doesn't exists as a file, there's `prog.exe' instead. */
#ifndef WIN32
- sdir = kpse_selfdir (program_invocation_name);
+ sdir = kpathsea_selfdir (kpse, kpse->invocation_name);
#endif
/* SELFAUTODIR is actually the parent of the invocation directory,
and SELFAUTOPARENT the grandparent. This is how teTeX did it. */
- xputenv ("SELFAUTOLOC", sdir);
+ kpathsea_xputenv (kpse, "SELFAUTOLOC", sdir);
sdir_parent = xdirname (sdir);
- xputenv ("SELFAUTODIR", sdir_parent);
+ kpathsea_xputenv (kpse, "SELFAUTODIR", sdir_parent);
sdir_grandparent = xdirname (sdir_parent);
- xputenv ("SELFAUTOPARENT", sdir_grandparent);
+ kpathsea_xputenv (kpse, "SELFAUTOPARENT", sdir_grandparent);
free (sdir);
free (sdir_parent);
free (sdir_grandparent);
- program_invocation_short_name = (string)xbasename (program_invocation_name);
+ kpse->invocation_short_name = xstrdup((string)xbasename (kpse->invocation_name));
if (progname) {
- kpse_program_name = xstrdup (progname);
+ kpse->program_name = xstrdup (progname);
} else {
/* If configured --enable-shared and running from the build directory
with the wrapper scripts (e.g., for make check), the binaries will
be named foo.exe instead of foo. Or possibly if we're running on a
DOSISH system. */
- ext = find_suffix (program_invocation_short_name);
+ ext = find_suffix (kpse->invocation_short_name);
if (ext && FILESTRCASEEQ (ext, "exe")) {
- kpse_program_name = remove_suffix (program_invocation_short_name);
+ kpse->program_name = remove_suffix (kpse->invocation_short_name);
} else {
- kpse_program_name = xstrdup (program_invocation_short_name);
+ kpse->program_name = xstrdup (kpse->invocation_short_name);
}
}
- xputenv ("progname", kpse_program_name);
+ /* Some of the utility routines (like atou() and xfopen()) will use
+ FATAL and variations thereof (see lib.h) if there is a problem.
+
+ The next trick makes it possible for that message to report some useful
+ name instead of (NULL), if the backward compatible is compiled in. */
+
+#if defined (KPSE_COMPAT_API)
+ if (kpse!=kpse_def) {
+ kpse_def->invocation_name = xstrdup(kpse->invocation_name);
+ kpse_def->invocation_short_name = xstrdup(kpse->invocation_short_name);
+ }
+#endif
+
+ kpathsea_xputenv (kpse, "progname", kpse->program_name);
}
+
/* This function is deprecated, because when we pretend to have a different
- name it will look for _that_ name in the PATH if program_invocation_name
+ name it will look for _that_ name in the PATH if kpse->invocation_name
is not defined. */
+#if defined (KPSE_COMPAT_API)
void
-kpse_set_progname P1C(const_string, argv0)
+kpse_set_program_name (const_string argv0, const_string progname)
{
- kpse_set_program_name (argv0, NULL);
+ kpathsea_set_program_name (kpse_def, argv0, progname);
}
+
+void
+kpse_set_progname (const_string argv0)
+{
+ kpathsea_set_program_name (kpse_def, argv0, NULL);
+}
+#endif
+
#ifdef TEST
-void
+int
main (int argc, char **argv)
{
- puts (remove_dots ("/w/kpathsea"));
- puts (remove_dots ("/w//kpathsea"));
- puts (remove_dots ("/w/./kpathsea"));
- puts (remove_dots ("."));
- puts (remove_dots ("./"));
- puts (remove_dots ("./."));
- puts (remove_dots ("../kpathsea"));
- puts (remove_dots ("/kpathsea/../foo"));
- puts (remove_dots ("/../w/kpathsea"));
- puts (remove_dots ("/../w/kpathsea/."));
- puts (remove_dots ("/te/share/texmf/../../../../bin/gnu"));
+ kpathsea kpse = xcalloc(1, sizeof(kpathsea_instance));
+ kpathsea_set_program_name(kpse, argv[0], NULL);
+ puts (remove_dots (kpse,"/w/kpathsea"));
+ puts (remove_dots (kpse,"/w//kpathsea"));
+ puts (remove_dots (kpse,"/w/./kpathsea"));
+ puts (remove_dots (kpse,"."));
+ puts (remove_dots (kpse,"./"));
+ puts (remove_dots (kpse,"./."));
+ puts (remove_dots (kpse,"../kpathsea"));
+ puts (remove_dots (kpse,"/kpathsea/../foo"));
+ puts (remove_dots (kpse,"/../w/kpathsea"));
+ puts (remove_dots (kpse,"/../w/kpathsea/."));
+ puts (remove_dots (kpse,"/te/share/texmf/../../../../bin/gnu"));
}
/*
Local variables:
-standalone-compile-command: "gcc -g -I. -I.. -DTEST progname.c STATIC/libkpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST progname.c kpathsea.a"
End:
*/
#endif /* TEST */
diff --git a/Build/source/texk/kpathsea/progname.h b/Build/source/texk/kpathsea/progname.h
index afcb461c455..b69c2c88b0f 100644
--- a/Build/source/texk/kpathsea/progname.h
+++ b/Build/source/texk/kpathsea/progname.h
@@ -22,14 +22,10 @@
#include <kpathsea/c-proto.h>
#include <kpathsea/types.h>
-extern KPSEDLL string program_invocation_name;
-extern KPSEDLL string program_invocation_short_name;
-extern KPSEDLL string kpse_program_name;
-
/* Return directory ARGV0 comes from. Check PATH if ARGV0 is not
absolute. */
-extern KPSEDLL string selfdir P1H(const_string argv0);
+extern KPSEDLL string kpathsea_selfdir (kpathsea kpse, const_string argv0);
/* Set the first two variables above (if they're not predefined) to a copy
of ARGV0 and everything in ARGV0 after the last directory separator,
@@ -37,21 +33,30 @@ extern KPSEDLL string selfdir P1H(const_string argv0);
or the value of program_invocation_short_name if PROGNAME is NULL.
This function also determines the AUTO* variables. */
-extern KPSEDLL void kpse_set_program_name P2H(const_string argv0,
- const_string progname);
+extern KPSEDLL void kpathsea_set_program_name (kpathsea kpse,
+ const_string argv0, const_string progname);
-/* See also `kpse_reset_program_name' which is defined in tex-file.c
+/* See also `kpathsea_reset_program_name' which is defined in tex-file.c
- That function is to be used to set kpse_program_name to a different
+ That function is to be used to set kpse->program_name to a different
value. It clears the path searching information, to ensure that
the search paths are appropriate to the new name. */
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL string kpse_selfdir (const_string argv0);
+
+extern KPSEDLL void kpse_set_program_name (const_string argv0,
+ const_string progname);
+
/* DEPRECATED
Set first two variables above (if they're not predefined) to a copy of
ARGV0 and everything in ARGV0 after the last directory separator,
respectively. kpse_program_name is _always_ set to a copy of everything
in ARGV0 after the last directory separator. */
-extern KPSEDLL void kpse_set_progname P1H(const_string argv0);
+extern KPSEDLL void kpse_set_progname (const_string argv0);
+
+#endif
#endif /* not KPATHSEA_PROGNAME_H */
diff --git a/Build/source/texk/kpathsea/readable.c b/Build/source/texk/kpathsea/readable.c
index e25d2aa9d01..fecd305b0f0 100644
--- a/Build/source/texk/kpathsea/readable.c
+++ b/Build/source/texk/kpathsea/readable.c
@@ -69,7 +69,7 @@ READABLE(const_string fn, unsigned int st)
Generic const return warning. See extend-fname.c. */
string
-kpse_readable_file P1C(const_string, name)
+kpathsea_readable_file (kpathsea kpse, const_string name)
{
string ret;
@@ -79,12 +79,12 @@ kpse_readable_file P1C(const_string, name)
struct stat st;
#endif
- kpse_normalize_path((string)name);
+ kpathsea_normalize_path(kpse, (string)name);
if (READABLE (name, st)) {
ret = (string) name;
#ifdef ENAMETOOLONG
} else if (errno == ENAMETOOLONG) {
- ret = kpse_truncate_filename (name);
+ ret = kpathsea_truncate_filename (kpse, name);
/* Perhaps some other error will occur with the truncated name, so
let's call access again. */
@@ -95,7 +95,7 @@ kpse_readable_file P1C(const_string, name)
#endif /* ENAMETOOLONG */
} else { /* Some other error. */
if (errno == EACCES) { /* Maybe warn them if permissions are bad. */
- if (!kpse_tex_hush ("readable")) {
+ if (!kpathsea_tex_hush (kpse, "readable")) {
perror (name);
}
}
@@ -103,3 +103,12 @@ kpse_readable_file P1C(const_string, name)
}
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_readable_file (const_string name)
+{
+ return kpathsea_readable_file (kpse_def, name);
+}
+#endif
+
diff --git a/Build/source/texk/kpathsea/readable.h b/Build/source/texk/kpathsea/readable.h
index 2276babe3ea..ec3a6988d45 100644
--- a/Build/source/texk/kpathsea/readable.h
+++ b/Build/source/texk/kpathsea/readable.h
@@ -26,6 +26,10 @@
ENAMETOOLONG, truncate any too-long path components, and if the
result is a readable file, return that. Otherwise return NULL. */
-extern KPSEDLL string kpse_readable_file P1H(const_string name);
+extern KPSEDLL string kpathsea_readable_file (kpathsea kpse, const_string name);
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL string kpse_readable_file (const_string name);
+#endif
#endif /* not KPATHSEA_READABLE_H */
diff --git a/Build/source/texk/kpathsea/readlink.c b/Build/source/texk/kpathsea/readlink.c
index e06ec61c76b..2020b06312a 100644
--- a/Build/source/texk/kpathsea/readlink.c
+++ b/Build/source/texk/kpathsea/readlink.c
@@ -32,7 +32,7 @@
*/
int
-main P2C(int, argc, char **, argv)
+main (int argc, char **argv)
{
#ifdef S_ISLNK
int status;
diff --git a/Build/source/texk/kpathsea/recorder.h b/Build/source/texk/kpathsea/recorder.h
index 392a82c14b1..3c5621ff0d7 100644
--- a/Build/source/texk/kpathsea/recorder.h
+++ b/Build/source/texk/kpathsea/recorder.h
@@ -18,10 +18,4 @@
#ifndef KPATHSEA_RECORDER_H
#define KPATHSEA_RECORDER_H
-/* These variables are set by web2c and are used to record filenames for its
- filename -recorder option. This way they can also be used for files
- opened by kpathsea, e.g., texmf.cnf */
-extern void (*kpse_record_input) (const_string);
-extern void (*kpse_record_output) (const_string);
-
#endif /* not KPATHSEA_RECORDER_H */
diff --git a/Build/source/texk/kpathsea/rm-suffix.c b/Build/source/texk/kpathsea/rm-suffix.c
index b21878cbf94..0b6c179ccae 100644
--- a/Build/source/texk/kpathsea/rm-suffix.c
+++ b/Build/source/texk/kpathsea/rm-suffix.c
@@ -23,7 +23,7 @@
/* Generic const warning -- see extend-fname.c. */
string
-remove_suffix P1C(const_string, s)
+remove_suffix (const_string s)
{
string ret;
const_string suffix = find_suffix (s);
diff --git a/Build/source/texk/kpathsea/stamp-aclocal b/Build/source/texk/kpathsea/stamp-aclocal
index 048b8f06cc3..1ca5e4406c2 100644
--- a/Build/source/texk/kpathsea/stamp-aclocal
+++ b/Build/source/texk/kpathsea/stamp-aclocal
@@ -1 +1 @@
-Fri Feb 27 15:55:25 CET 2009
+Mon Mar 16 16:07:35 CET 2009
diff --git a/Build/source/texk/kpathsea/stamp-auto.in b/Build/source/texk/kpathsea/stamp-auto.in
index 5bf977c03cd..cba46f741f7 100644
--- a/Build/source/texk/kpathsea/stamp-auto.in
+++ b/Build/source/texk/kpathsea/stamp-auto.in
@@ -1 +1 @@
-Fri Feb 27 15:55:26 CET 2009
+Mon Mar 16 16:07:36 CET 2009
diff --git a/Build/source/texk/kpathsea/stamp-configure b/Build/source/texk/kpathsea/stamp-configure
index 5bf977c03cd..cba46f741f7 100644
--- a/Build/source/texk/kpathsea/stamp-configure
+++ b/Build/source/texk/kpathsea/stamp-configure
@@ -1 +1 @@
-Fri Feb 27 15:55:26 CET 2009
+Mon Mar 16 16:07:36 CET 2009
diff --git a/Build/source/texk/kpathsea/str-list.c b/Build/source/texk/kpathsea/str-list.c
index 8bbfa6ae02d..86498f8fdd2 100644
--- a/Build/source/texk/kpathsea/str-list.c
+++ b/Build/source/texk/kpathsea/str-list.c
@@ -25,7 +25,7 @@
str_list_type
-str_list_init P1H(void)
+str_list_init (void)
{
str_list_type ret;
@@ -37,7 +37,7 @@ str_list_init P1H(void)
void
-str_list_add P2C(str_list_type *, l, string, s)
+str_list_add (str_list_type *l, string s)
{
STR_LIST_LENGTH (*l)++;
XRETALLOC (STR_LIST (*l), STR_LIST_LENGTH (*l), string);
@@ -49,7 +49,7 @@ str_list_add P2C(str_list_type *, l, string, s)
instead of calling str_list_add on each element. */
void
-str_list_concat P2C(str_list_type *, target, str_list_type, more)
+str_list_concat (str_list_type *target, str_list_type more)
{
unsigned e;
unsigned prev_len = STR_LIST_LENGTH (*target);
@@ -67,7 +67,7 @@ str_list_concat P2C(str_list_type *, target, str_list_type, more)
/* Note that we free the old elements of target as well. */
void
-str_list_concat_elements P2C(str_list_type *, target, str_list_type, more)
+str_list_concat_elements (str_list_type *target, str_list_type more)
{
if (STR_LIST_LENGTH(more) == 0) {
return;
@@ -107,7 +107,7 @@ str_list_concat_elements P2C(str_list_type *, target, str_list_type, more)
/* Free the list (but not the elements within it). */
void
-str_list_free P1C(str_list_type *, l)
+str_list_free (str_list_type *l)
{
if (STR_LIST (*l))
{
@@ -122,7 +122,7 @@ str_list_free P1C(str_list_type *, l)
lists are so short, we do a maximally inefficient bubble search. */
void
-str_list_uniqify P1C(str_list_type *, l)
+str_list_uniqify (str_list_type *l)
{
unsigned e;
str_list_type ret = str_list_init ();
diff --git a/Build/source/texk/kpathsea/str-list.h b/Build/source/texk/kpathsea/str-list.h
index c57e95512a6..c9fe6ad26f9 100644
--- a/Build/source/texk/kpathsea/str-list.h
+++ b/Build/source/texk/kpathsea/str-list.h
@@ -37,25 +37,25 @@ typedef struct
#define STR_LIST_LAST_ELT(l) STR_LIST_ELT (l, STR_LIST_LENGTH (l) - 1)
/* Return a new, empty, list. */
-extern str_list_type str_list_init P1H(void);
+extern str_list_type str_list_init (void);
/* Append the string S to the list L. It's up to the caller to not
deallocate S; we don't copy it. Also up to the caller to terminate
the list with a null entry. */
-extern void str_list_add P2H(str_list_type *l, string s);
+extern void str_list_add (str_list_type *l, string s);
/* Append all the elements from MORE to TARGET. */
-extern void str_list_concat P2H(str_list_type * target, str_list_type more);
+extern void str_list_concat (str_list_type * target, str_list_type more);
/* Free the space for the list elements (but not the list elements
themselves). */
-extern void str_list_free P1H(str_list_type *l);
+extern void str_list_free (str_list_type *l);
/* Append each element of MORE to each element of TARGET. */
extern void str_list_concat_elements
- P2H(str_list_type *target, str_list_type more);
+ (str_list_type *target, str_list_type more);
/* Remove duplicate elements from L, freeing their space. */
-extern void str_list_uniqify P1H(str_list_type *l);
+extern void str_list_uniqify (str_list_type *l);
#endif /* not KPATHSEA_STR_LIST_H */
diff --git a/Build/source/texk/kpathsea/str-llist.c b/Build/source/texk/kpathsea/str-llist.c
index 3221a739b2d..45c8778aebf 100644
--- a/Build/source/texk/kpathsea/str-llist.c
+++ b/Build/source/texk/kpathsea/str-llist.c
@@ -23,7 +23,7 @@
/* Add the new string STR to the end of the list L. */
void
-str_llist_add P2C(str_llist_type *, l, string, str)
+str_llist_add (str_llist_type *l, string str)
{
str_llist_elt_type *e;
str_llist_elt_type *new_elt = XTALLOC1 (str_llist_elt_type);
@@ -49,7 +49,7 @@ str_llist_add P2C(str_llist_type *, l, string, str)
is thus a waste. */
void
-str_llist_float P2C(str_llist_type *, l, str_llist_elt_type *, mover)
+str_llist_float (str_llist_type *l, str_llist_elt_type *mover)
{
str_llist_elt_type *last_moved, *unmoved;
diff --git a/Build/source/texk/kpathsea/str-llist.h b/Build/source/texk/kpathsea/str-llist.h
index 8aeee2e4aec..5b0c8f86277 100644
--- a/Build/source/texk/kpathsea/str-llist.h
+++ b/Build/source/texk/kpathsea/str-llist.h
@@ -46,10 +46,10 @@ typedef struct str_llist_elt *str_llist_type;
/* Add the new string E to the end of the list L. */
-extern void str_llist_add P2H(str_llist_type *l, string e);
+extern void str_llist_add (str_llist_type *l, string e);
/* Reorganize L so that E is below only other elements that have already
been moved. Set `moved' member for E. */
-extern void str_llist_float P2H(str_llist_type *l, str_llist_elt_type *e);
+extern void str_llist_float (str_llist_type *l, str_llist_elt_type *e);
#endif /* not STR_LLIST_H */
diff --git a/Build/source/texk/kpathsea/tex-file.c b/Build/source/texk/kpathsea/tex-file.c
index 8c1670429ec..baec2c026da 100644
--- a/Build/source/texk/kpathsea/tex-file.c
+++ b/Build/source/texk/kpathsea/tex-file.c
@@ -33,12 +33,6 @@
#include <kpathsea/variable.h>
-/* See tex-file.h. */
-const_string kpse_fallback_font = NULL;
-const_string kpse_fallback_resolutions_string = NULL;
-unsigned *kpse_fallback_resolutions = NULL;
-kpse_format_info_type kpse_format_info[kpse_last_format];
-
/* These are not in the structure
because it's annoying to initialize lists in C. */
#define GF_ENVS "GFFONTS", GLYPH_ENVS
@@ -100,21 +94,21 @@ kpse_format_info_type kpse_format_info[kpse_last_format];
#endif
void
-kpse_init_fallback_resolutions P1C(string, envvar)
+kpathsea_init_fallback_resolutions (kpathsea kpse, string envvar)
{
string size;
const_string size_var = ENVVAR (envvar, "TEXSIZES");
string size_str = getenv (size_var);
unsigned *last_resort_sizes = NULL;
unsigned size_count = 0;
- const_string default_sizes = kpse_fallback_resolutions_string
- ? kpse_fallback_resolutions_string
+ const_string default_sizes = kpse->fallback_resolutions_string
+ ? kpse->fallback_resolutions_string
: DEFAULT_FONT_SIZES;
- string size_list = kpse_expand_default (size_str, default_sizes);
+ string size_list = kpathsea_expand_default (kpse, size_str, default_sizes);
/* Initialize the list of last-resort sizes. */
- for (size = kpse_path_element (size_list); size != NULL;
- size = kpse_path_element (NULL))
+ for (size = kpathsea_path_element (kpse, size_list); size != NULL;
+ size = kpathsea_path_element (kpse, NULL))
{
unsigned s;
if (! *size) /* Skip empty elements. */
@@ -138,17 +132,26 @@ kpse_init_fallback_resolutions P1C(string, envvar)
free (size_list);
- kpse_fallback_resolutions = last_resort_sizes;
+ kpse->fallback_resolutions = last_resort_sizes;
}
+
+#if defined (KPSE_COMPAT_API)
+void
+kpse_init_fallback_resolutions ( string envvar)
+{
+ kpathsea_init_fallback_resolutions (kpse_def, envvar);
+}
+#endif
+
/* We should be able to set the program arguments in the same way. Not
to mention the path values themselves. */
void
-kpse_set_program_enabled P3C(kpse_file_format_type, fmt, boolean, value,
- kpse_src_type, level)
+kpathsea_set_program_enabled (kpathsea kpse, kpse_file_format_type fmt,
+ boolean value, kpse_src_type level)
{
- kpse_format_info_type *f = &kpse_format_info[fmt];
+ kpse_format_info_type *f = &(kpse->format_info[fmt]);
if (level >= f->program_enable_level) {
f->program_enabled_p = value;
f->program_enable_level = level;
@@ -156,11 +159,22 @@ kpse_set_program_enabled P3C(kpse_file_format_type, fmt, boolean, value,
}
+#if defined (KPSE_COMPAT_API)
+void
+kpse_set_program_enabled (kpse_file_format_type fmt,
+ boolean value, kpse_src_type level)
+{
+ kpathsea_set_program_enabled(kpse_def, fmt, value, level);
+}
+
+#endif
+
+
/* Web2c and kpsewhich have command-line options to set this stuff. May
as well have a common place. */
void
-kpse_maketex_option P2C(const_string, fmtname, boolean, value)
+kpathsea_maketex_option (kpathsea kpse, const_string fmtname, boolean value)
{
kpse_file_format_type fmt = kpse_last_format;
@@ -183,9 +197,18 @@ kpse_maketex_option P2C(const_string, fmtname, boolean, value)
fmt = kpse_ocp_format;
}
if (fmt != kpse_last_format) {
- kpse_set_program_enabled (fmt, value, kpse_src_cmdline);
+ kpathsea_set_program_enabled (kpse, fmt, value, kpse_src_cmdline);
}
}
+
+#if defined (KPSE_COMPAT_API)
+void
+kpse_maketex_option (const_string fmtname, boolean value)
+{
+ kpathsea_maketex_option (kpse_def, fmtname, value);
+}
+#endif
+
/* Macro subroutines for `init_path'. TRY_ENV checks if an envvar ENAME
is set and non-null, and sets var to ENAME if so. */
@@ -198,7 +221,7 @@ kpse_maketex_option P2C(const_string, fmtname, boolean, value)
#define EXPAND_DEFAULT(try_path, source_string) \
if (try_path) { \
info->raw_path = try_path; \
- info->path = kpse_expand_default (try_path, info->path); \
+ info->path = kpathsea_expand_default (kpse, try_path, info->path); \
info->path_source = source_string; \
}
@@ -209,7 +232,7 @@ kpse_maketex_option P2C(const_string, fmtname, boolean, value)
`client_path' member must already be set upon entry. */
static void
-init_path PVAR2C(kpse_format_info_type *, info, const_string, default_path, ap)
+init_path PVAR3C(kpathsea, kpse, kpse_format_info_type *, info, const_string, default_path, ap)
{
string env_name;
string env_value = NULL;
@@ -226,13 +249,13 @@ init_path PVAR2C(kpse_format_info_type *, info, const_string, default_path, ap)
/* Since sh doesn't like envvar names with `.', check PATH_prog
as well as PATH.prog. */
if (!var) { /* Try PATH.prog. */
- string evar = concat3 (env_name, ".", kpse_program_name);
+ string evar = concat3 (env_name, ".", kpse->program_name);
env_value = getenv (evar);
if (env_value && *env_value) {
var = evar;
} else { /* Try PATH_prog. */
free (evar);
- evar = concat3 (env_name, "_", kpse_program_name);
+ evar = concat3 (env_name, "_", kpse->program_name);
env_value = getenv (evar);
if (env_value && *env_value) {
var = evar;
@@ -248,8 +271,8 @@ init_path PVAR2C(kpse_format_info_type *, info, const_string, default_path, ap)
/* If we are initializing the cnf path, don't try to get any
values from the cnf files; that's infinite loop time. */
- if (!info->cnf_path && info != &kpse_format_info[kpse_cnf_format])
- info->cnf_path = kpse_cnf_get (env_name);
+ if (!info->cnf_path && info != &(kpse->format_info[kpse_cnf_format]))
+ info->cnf_path = kpathsea_cnf_get (kpse, env_name);
if (var && info->cnf_path)
break;
@@ -285,7 +308,7 @@ init_path PVAR2C(kpse_format_info_type *, info, const_string, default_path, ap)
}
EXPAND_DEFAULT (info->override_path, "application override variable");
- info->path = kpse_brace_expand (info->path);
+ info->path = kpathsea_brace_expand (kpse, info->path);
}}
@@ -293,7 +316,7 @@ init_path PVAR2C(kpse_format_info_type *, info, const_string, default_path, ap)
convenient to modify the list of searched suffixes. */
void
-kpse_set_suffixes PVAR2C(kpse_file_format_type, format,
+kpathsea_set_suffixes PVAR3C(kpathsea, kpse, kpse_file_format_type, format,
boolean, alternate, ap)
{
const_string **list;
@@ -301,9 +324,9 @@ kpse_set_suffixes PVAR2C(kpse_file_format_type, format,
int count = 0;
if (alternate) {
- list = &kpse_format_info[format].alt_suffix;
+ list = &(kpse->format_info[format].alt_suffix);
} else {
- list = &kpse_format_info[format].suffix;
+ list = &(kpse->format_info[format].suffix);
}
while ((s = va_arg (ap, string)) != NULL) {
@@ -315,17 +338,28 @@ kpse_set_suffixes PVAR2C(kpse_file_format_type, format,
(*list)[count] = NULL;
}}
+
+#if defined (KPSE_COMPAT_API)
+void
+kpse_set_suffixes PVAR2C(kpse_file_format_type, format,
+ boolean, alternate, ap)
+{
+ kpathsea_set_suffixes (kpse_def, format, alternate, ap);
+}}
+#endif
+
+
/* The path spec we are defining, one element of the global array. */
-#define FMT_INFO kpse_format_info[format]
+#define FMT_INFO (kpse->format_info[format])
/* Call kpse_set_add_suffixes. */
-#define SUFFIXES(args) kpse_set_suffixes(format, false, args, NULL)
-#define ALT_SUFFIXES(args) kpse_set_suffixes(format, true, args, NULL)
+#define SUFFIXES(args) kpathsea_set_suffixes(kpse, format, false, args, NULL)
+#define ALT_SUFFIXES(args) kpathsea_set_suffixes(kpse, format, true, args, NULL)
/* Call `init_path', including appending the trailing NULL to the envvar
list. Also initialize the fields not needed in setting the path. */
#define INIT_FORMAT(text, default_path, envs) \
FMT_INFO.type = text; \
- init_path (&FMT_INFO, default_path, envs, NULL); \
+ init_path (kpse, &FMT_INFO, default_path, envs, NULL); \
envvar_list = concatn_with_spaces (envs, NULL);
@@ -336,12 +370,12 @@ kpse_set_suffixes PVAR2C(kpse_file_format_type, format,
name to 0 or 1. */
static void
-init_maketex PVAR2C(kpse_file_format_type, fmt, const_string, dflt_prog, ap)
+init_maketex PVAR3C(kpathsea, kpse, kpse_file_format_type, fmt, const_string, dflt_prog, ap)
{
- kpse_format_info_type *f = &kpse_format_info[fmt];
+ kpse_format_info_type *f = &(kpse->format_info[fmt]);
const_string prog = f->program ? f->program : dflt_prog; /* mktexpk */
string PROG = uppercasify (prog); /* MKTEXPK */
- string progval = kpse_var_value (PROG); /* ENV/cnf{"MKTEXPK"} */
+ string progval = kpathsea_var_value (kpse, PROG); /* ENV/cnf{"MKTEXPK"} */
const_string arg;
/* Doesn't hurt to always set this info. */
@@ -361,7 +395,7 @@ init_maketex PVAR2C(kpse_file_format_type, fmt, const_string, dflt_prog, ap)
if (progval && *progval) {
/* This might actually be from an environment variable value, but in
that case, we'll have previously set it from kpse_init_prog. */
- kpse_set_program_enabled (fmt, *progval == '1', kpse_src_client_cnf);
+ kpathsea_set_program_enabled (kpse, fmt, *progval == '1', kpse_src_client_cnf);
}
free (PROG);
@@ -376,7 +410,7 @@ init_maketex PVAR2C(kpse_file_format_type, fmt, const_string, dflt_prog, ap)
NULL
static string
-remove_dbonly P1C(const_string, path)
+remove_dbonly (const_string path)
{
string ret = XTALLOC(strlen (path) + 1, char), q=ret;
const_string p=path;
@@ -423,7 +457,7 @@ concatn_with_spaces PVAR1C(const_string, str1, ap)
/* Initialize everything for FORMAT. */
const_string
-kpse_init_format P1C(kpse_file_format_type, format)
+kpathsea_init_format (kpathsea kpse, kpse_file_format_type format)
{
string envvar_list; /* only for debug output, set in INIT_FORMAT */
@@ -441,21 +475,21 @@ kpse_init_format P1C(kpse_file_format_type, format)
FMT_INFO.binmode = true;
break;
case kpse_pk_format:
- init_maketex (format, "mktexpk", MKTEXPK_ARGS);
+ init_maketex (kpse, format, "mktexpk", MKTEXPK_ARGS);
INIT_FORMAT ("pk", DEFAULT_PKFONTS, PK_ENVS);
SUFFIXES ("pk");
FMT_INFO.suffix_search_only = true;
FMT_INFO.binmode = true;
break;
case kpse_any_glyph_format:
- init_maketex (format, "mktexpk", MKTEXPK_ARGS);
+ init_maketex (kpse, format, "mktexpk", MKTEXPK_ARGS);
INIT_FORMAT ("bitmap font", DEFAULT_GLYPHFONTS, GLYPH_ENVS);
FMT_INFO.suffix_search_only = true;
FMT_INFO.binmode = true;
break;
case kpse_tfm_format:
/* Must come before kpse_ofm_format. */
- init_maketex (format, "mktextfm", NULL);
+ init_maketex (kpse, format, "mktextfm", NULL);
INIT_FORMAT ("tfm", DEFAULT_TFMFONTS, TFM_ENVS);
SUFFIXES (".tfm");
FMT_INFO.suffix_search_only = true;
@@ -466,7 +500,7 @@ kpse_init_format P1C(kpse_file_format_type, format)
SUFFIXES (".afm");
break;
case kpse_base_format:
- init_maketex (format, "mktexfmt", NULL);
+ init_maketex (kpse, format, "mktexfmt", NULL);
INIT_FORMAT ("base", DEFAULT_MFBASES, BASE_ENVS);
SUFFIXES (".base");
FMT_INFO.binmode = true;
@@ -491,7 +525,7 @@ kpse_init_format P1C(kpse_file_format_type, format)
FMT_INFO.path = remove_dbonly (FMT_INFO.path);
break;
case kpse_fmt_format:
- init_maketex (format, "mktexfmt", NULL);
+ init_maketex (kpse, format, "mktexfmt", NULL);
INIT_FORMAT ("fmt", DEFAULT_TEXFORMATS, FMT_ENVS);
SUFFIXES (".fmt");
FMT_INFO.binmode = true;
@@ -501,13 +535,13 @@ kpse_init_format P1C(kpse_file_format_type, format)
SUFFIXES (".map");
break;
case kpse_mem_format:
- init_maketex (format, "mktexfmt", NULL);
+ init_maketex (kpse, format, "mktexfmt", NULL);
INIT_FORMAT ("mem", DEFAULT_MPMEMS, MEM_ENVS);
SUFFIXES (".mem");
FMT_INFO.binmode = true;
break;
case kpse_mf_format:
- init_maketex (format, "mktexmf", NULL);
+ init_maketex (kpse, format, "mktexmf", NULL);
INIT_FORMAT ("mf", DEFAULT_MFINPUTS, MF_ENVS);
SUFFIXES (".mf");
break;
@@ -531,14 +565,14 @@ kpse_init_format P1C(kpse_file_format_type, format)
INIT_FORMAT ("MetaPost support", DEFAULT_MPSUPPORT, MPSUPPORT_ENVS);
break;
case kpse_ocp_format:
- init_maketex (format, "mkocp", NULL);
+ init_maketex (kpse, format, "mkocp", NULL);
INIT_FORMAT ("ocp", DEFAULT_OCPINPUTS, OCP_ENVS);
SUFFIXES (".ocp");
FMT_INFO.suffix_search_only = true;
FMT_INFO.binmode = true;
break;
case kpse_ofm_format:
- init_maketex (format, "mkofm", NULL);
+ init_maketex (kpse, format, "mkofm", NULL);
INIT_FORMAT ("ofm", DEFAULT_OFMFONTS, OFM_ENVS);
#define OFM_SUFFIXES ".ofm", ".tfm"
SUFFIXES (OFM_SUFFIXES);
@@ -573,7 +607,7 @@ kpse_init_format P1C(kpse_file_format_type, format)
FMT_INFO.binmode = true;
break;
case kpse_tex_format:
- init_maketex (format, "mktextex", NULL);
+ init_maketex (kpse, format, "mktextex", NULL);
INIT_FORMAT ("tex", DEFAULT_TEXINPUTS, TEX_ENVS);
SUFFIXES (".tex");
/* TeX files can have any obscure suffix in the world (or none at
@@ -643,14 +677,14 @@ kpse_init_format P1C(kpse_file_format_type, format)
case kpse_program_text_format:
INIT_FORMAT ("other text files",
concatn (".", ENV_SEP_STRING, "$TEXMF/",
- kpse_program_name, "//", NULL),
- concat (uppercasify (kpse_program_name), "INPUTS"));
+ kpse->program_name, "//", NULL),
+ concat (uppercasify (kpse->program_name), "INPUTS"));
break;
case kpse_program_binary_format:
INIT_FORMAT ("other binary files",
concatn (".", ENV_SEP_STRING, "$TEXMF/",
- kpse_program_name, "//", NULL),
- concat (uppercasify (kpse_program_name), "INPUTS"));
+ kpse->program_name, "//", NULL),
+ concat (uppercasify (kpse->program_name), "INPUTS"));
FMT_INFO.binmode = true;
break;
case kpse_miscfonts_format:
@@ -701,14 +735,14 @@ kpse_init_format P1C(kpse_file_format_type, format)
FMT_INFO.suffix_search_only = true;
break;
default:
- FATAL1 ("kpse_init_format: Unknown format %d", format);
+ LIB_FATAL1 ("kpse_init_format: Unknown format %d", format);
}
#ifdef KPSE_DEBUG
#define MAYBE(member) (FMT_INFO.member ? FMT_INFO.member : "(none)")
/* Describe the monster we've created. */
- if (KPSE_DEBUG_P (KPSE_DEBUG_PATHS))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_PATHS))
{
DEBUGF2 ("Search path for %s files (from %s)\n",
FMT_INFO.type, FMT_INFO.path_source);
@@ -759,6 +793,15 @@ kpse_init_format P1C(kpse_file_format_type, format)
return FMT_INFO.path;
}
+
+#if defined (KPSE_COMPAT_API)
+const_string
+kpse_init_format (kpse_file_format_type format)
+{
+ return kpathsea_init_format (kpse_def, format);
+}
+#endif
+
/* These are subroutines called twice when finding file, to construct
the list of names to search for. */
@@ -768,9 +811,9 @@ kpse_init_format P1C(kpse_file_format_type, format)
the support working nonetheless. */
static void
-target_fontmaps (const_string **target, unsigned *count, const_string name)
+target_fontmaps (kpathsea kpse, const_string **target, unsigned *count, const_string name)
{
- string *mapped_names = kpse_fontmap_lookup (name);
+ string *mapped_names = kpathsea_fontmap_lookup (kpse, name);
if (mapped_names != NULL) {
string mapped_name;
@@ -788,11 +831,12 @@ target_fontmaps (const_string **target, unsigned *count, const_string name)
in TARGET, depending on the various other parameters. */
static void
-target_asis_name (const_string **target, unsigned *count,
+target_asis_name (kpathsea kpse, const_string **target, unsigned *count,
kpse_file_format_type format,
const_string name, boolean use_fontmaps, boolean has_potential_suffix,
string has_any_suffix)
{
+ (void)has_any_suffix; /* -Wunused */
/* Look for the name we've been given, provided non-suffix
searches are allowed or the name already includes a suffix. */
if (has_potential_suffix || !FMT_INFO.suffix_search_only) {
@@ -801,7 +845,7 @@ target_asis_name (const_string **target, unsigned *count,
XRETALLOC ((*target), (*count)+1, const_string);
if (use_fontmaps) {
- target_fontmaps (target, count, name);
+ target_fontmaps (kpse, target, count, name);
}
}
}
@@ -812,7 +856,7 @@ target_asis_name (const_string **target, unsigned *count,
of the potential suffixes for FORMAT. */
static void
-target_suffixed_names (const_string **target, unsigned *count,
+target_suffixed_names (kpathsea kpse, const_string **target, unsigned *count,
kpse_file_format_type format,
const_string name, boolean use_fontmaps, boolean has_potential_suffix)
{
@@ -828,7 +872,7 @@ target_suffixed_names (const_string **target, unsigned *count,
XRETALLOC ((*target), (*count)+1, const_string);
if (use_fontmaps) {
- target_fontmaps (target, count, name_with_suffix);
+ target_fontmaps (kpse, target, count, name_with_suffix);
}
}
}
@@ -839,21 +883,30 @@ target_suffixed_names (const_string **target, unsigned *count,
thing for clients to call. */
string
-kpse_find_file P3C(const_string, name, kpse_file_format_type, format,
- boolean, must_exist)
+kpathsea_find_file (kpathsea kpse, const_string name, kpse_file_format_type format,
+ boolean must_exist)
{
- string *ret_list = kpse_find_file_generic (name, format, must_exist, false);
+ string *ret_list = kpathsea_find_file_generic (kpse, name, format, must_exist, false);
string ret = *ret_list;
free (ret_list);
return ret;
}
+#if defined (KPSE_COMPAT_API)
+string
+kpse_find_file (const_string name, kpse_file_format_type format,
+ boolean must_exist)
+{
+ return kpathsea_find_file(kpse_def, name, format, must_exist);
+}
+#endif
+
/* As with `kpse_find_file', but also allow passing ALL for the search,
hence we always return a NULL-terminated list. */
string *
-kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
- boolean, must_exist, boolean, all)
+kpathsea_find_file_generic (kpathsea kpse, const_string name, kpse_file_format_type format,
+ boolean must_exist, boolean all)
{
const_string *target;
const_string *ext;
@@ -873,16 +926,16 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
assert (name);
if (FMT_INFO.path == NULL)
- kpse_init_format (format);
+ kpathsea_init_format (kpse, format);
- if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH))
DEBUGF3 ("kpse_find_file: searching for %s of type %s (from %s)\n",
name, FMT_INFO.type, FMT_INFO.path_source);
/* Do variable and tilde expansion. */
- name = kpse_expand (name);
+ name = kpathsea_expand (kpse, name);
- try_std_extension_first = kpse_var_value ("try_std_extension_first");
+ try_std_extension_first = kpathsea_var_value (kpse, "try_std_extension_first");
has_any_suffix = strrchr (name, '.');
if (has_any_suffix) {
string p = strchr (has_any_suffix, DIR_SEP);
@@ -916,14 +969,14 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
if (has_any_suffix
&& (try_std_extension_first == NULL || *try_std_extension_first == 'f'
|| *try_std_extension_first == '0')) {
- target_asis_name (&target, &count, format, name, use_fontmaps,
+ target_asis_name (kpse, &target, &count, format, name, use_fontmaps,
has_potential_suffix, has_any_suffix);
- target_suffixed_names (&target, &count, format, name, use_fontmaps,
+ target_suffixed_names (kpse, &target, &count, format, name, use_fontmaps,
has_potential_suffix);
} else {
- target_suffixed_names (&target, &count, format, name, use_fontmaps,
+ target_suffixed_names (kpse, &target, &count, format, name, use_fontmaps,
has_potential_suffix);
- target_asis_name (&target, &count, format, name, use_fontmaps,
+ target_asis_name (kpse, &target, &count, format, name, use_fontmaps,
has_potential_suffix, has_any_suffix );
}
@@ -935,7 +988,7 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
}
/* Search, trying to minimize disk-pounding. */
- ret = kpse_path_search_list_generic (FMT_INFO.path, target, false, all);
+ ret = kpathsea_path_search_list_generic (kpse, FMT_INFO.path, target, false, all);
/* Do we need to pound the disk? */
if (! *ret && must_exist) {
for (count = 0; target[count]; count++)
@@ -952,7 +1005,7 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
target[count++] = xstrdup (name);
}
target[count] = NULL;
- ret = kpse_path_search_list_generic (FMT_INFO.path, target, true, all);
+ ret = kpathsea_path_search_list_generic (kpse, FMT_INFO.path, target, true, all);
}
/* Free the list we created. */
@@ -964,7 +1017,7 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
this returns a single string, morph it into a list. */
if (! *ret && must_exist) {
ret = XTALLOC (2, string);
- ret[0] = kpse_make_tex (format, name);
+ ret[0] = kpathsea_make_tex (kpse, format, name);
if (ret[0]) {
ret[1] = NULL;
}
@@ -975,16 +1028,25 @@ kpse_find_file_generic P4C(const_string, name, kpse_file_format_type, format,
return ret;
}
+#if defined (KPSE_COMPAT_API)
+string *
+kpse_find_file_generic (const_string name, kpse_file_format_type format,
+ boolean must_exist, boolean all)
+{
+ return kpathsea_find_file_generic(kpse_def, name, format, must_exist, all);
+}
+#endif
+
/* Open NAME along the search path for TYPE for reading and return the
resulting file, or exit with an error message. */
FILE *
-kpse_open_file P2C(const_string, name, kpse_file_format_type, type)
+kpathsea_open_file (kpathsea kpse, const_string name, kpse_file_format_type type)
{
- string fullname = kpse_find_file (name, type, true);
- const_string mode = kpse_format_info[type].binmode
+ string fullname = kpathsea_find_file (kpse, name, type, true);
+ const_string mode = kpse->format_info[type].binmode
? FOPEN_RBIN_MODE
: FOPEN_R_MODE;
FILE *f = fullname ? fopen (fullname, mode) : NULL;
@@ -993,12 +1055,21 @@ kpse_open_file P2C(const_string, name, kpse_file_format_type, type)
perror (fullname);
exit (1);
} else {
- FATAL2 ("%s file `%s' not found", kpse_format_info[type].type, name);
+ LIB_FATAL2 ("%s file `%s' not found", kpse->format_info[type].type, name);
}
}
return f;
}
+
+#if defined (KPSE_COMPAT_API)
+FILE *
+kpse_open_file (const_string name, kpse_file_format_type type)
+{
+ return kpathsea_open_file(kpse_def, name, type);
+}
+#endif
+
/* When using the %&<format> construct, we'd like to use the paths for
that format, rather than those for the name we were called with.
@@ -1007,22 +1078,22 @@ kpse_open_file P2C(const_string, name, kpse_file_format_type, type)
the paths for kpse_cnf_format and kpse_db_format are not cleared.
This function is defined here, and not in progname.c, because it
- need kpse_format_info, and would cause all of tex-file to be pulled
+ need format_info, and would cause all of tex-file to be pulled
in by programs that do not need it. */
void
-kpse_reset_program_name P1C(const_string, progname)
+kpathsea_reset_program_name (kpathsea kpse, const_string progname)
{
int i;
/* It is a fatal error for either of these to be NULL. */
- assert (progname && kpse_program_name);
+ assert (progname && kpse->program_name);
/* Do nothing if the name is unchanged. */
- if (STREQ(kpse_program_name, progname))
+ if (STREQ(kpse->program_name, progname))
return;
- free (kpse_program_name);
- kpse_program_name = xstrdup (progname);
- xputenv("progname", kpse_program_name);
+ free (kpse->program_name);
+ kpse->program_name = xstrdup (progname);
+ kpathsea_xputenv(kpse, "progname", kpse->program_name);
/* Clear paths -- do we want the db path to be cleared? */
for (i = 0; i != kpse_last_format; ++i) {
@@ -1034,17 +1105,25 @@ kpse_reset_program_name P1C(const_string, progname)
continue;
/* Wipe the path (it is tested) and the cnf_path and because their
values may differ with the new program name. */
- if (kpse_format_info[i].path != NULL) {
- free ((string)kpse_format_info[i].path);
- kpse_format_info[i].path = NULL;
+ if (kpse->format_info[i].path != NULL) {
+ free ((string)kpse->format_info[i].path);
+ kpse->format_info[i].path = NULL;
}
/* We cannot free the cnf_path: it points into the cnf hash, which
means all hell will break loose if we did. */
- if (kpse_format_info[i].cnf_path != NULL) {
- kpse_format_info[i].cnf_path = NULL;
+ if (kpse->format_info[i].cnf_path != NULL) {
+ kpse->format_info[i].cnf_path = NULL;
}
/* We do not wipe the override_path at this point, though arguably
we should provide new values. It is not likely to matter for
the programs that call this function. */
}
}
+
+#if defined (KPSE_COMPAT_API)
+void
+kpse_reset_program_name (const_string progname)
+{
+ kpathsea_reset_program_name (kpse_def, progname);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/tex-file.h b/Build/source/texk/kpathsea/tex-file.h
index 06ae0e1a9ff..7ced22fee23 100644
--- a/Build/source/texk/kpathsea/tex-file.h
+++ b/Build/source/texk/kpathsea/tex-file.h
@@ -24,160 +24,75 @@
#include <kpathsea/types.h>
-/* If non-NULL, try looking for this if can't find the real font. */
-extern const_string kpse_fallback_font;
-
-
-/* If non-NULL, default list of fallback resolutions comes from this
- instead of the compile-time value. Set by dvipsk for the R config
- cmd. *SIZES environment variables override/use as default. */
-extern KPSEDLL const_string kpse_fallback_resolutions_string;
-
-/* If non-NULL, check these if can't find (within a few percent of) the
- given resolution. List must end with a zero element. */
-extern unsigned *kpse_fallback_resolutions;
-
/* This initializes the fallback resolution list. If ENVVAR
is set, it is used; otherwise, the envvar `TEXSIZES' is looked at; if
that's not set either, a compile-time default is used. */
-extern void kpse_init_fallback_resolutions P1H(string envvar);
+extern void kpathsea_init_fallback_resolutions (kpathsea kpse, string envvar);
-/* We put the glyphs first so we don't waste space in an array in
- tex-glyph.c. Accompany a new format here with appropriate changes in
- tex-file.c and kpsewhich.c (the suffix variable). */
-typedef enum
-{
- kpse_gf_format,
- kpse_pk_format,
- kpse_any_glyph_format, /* ``any'' meaning gf or pk */
- kpse_tfm_format,
- kpse_afm_format,
- kpse_base_format,
- kpse_bib_format,
- kpse_bst_format,
- kpse_cnf_format,
- kpse_db_format,
- kpse_fmt_format,
- kpse_fontmap_format,
- kpse_mem_format,
- kpse_mf_format,
- kpse_mfpool_format,
- kpse_mft_format,
- kpse_mp_format,
- kpse_mppool_format,
- kpse_mpsupport_format,
- kpse_ocp_format,
- kpse_ofm_format,
- kpse_opl_format,
- kpse_otp_format,
- kpse_ovf_format,
- kpse_ovp_format,
- kpse_pict_format,
- kpse_tex_format,
- kpse_texdoc_format,
- kpse_texpool_format,
- kpse_texsource_format,
- kpse_tex_ps_header_format,
- kpse_troff_font_format,
- kpse_type1_format,
- kpse_vf_format,
- kpse_dvips_config_format,
- kpse_ist_format,
- kpse_truetype_format,
- kpse_type42_format,
- kpse_web2c_format,
- kpse_program_text_format,
- kpse_program_binary_format,
- kpse_miscfonts_format,
- kpse_web_format,
- kpse_cweb_format,
- kpse_enc_format,
- kpse_cmap_format,
- kpse_sfd_format,
- kpse_opentype_format,
- kpse_pdftex_config_format,
- kpse_lig_format,
- kpse_texmfscripts_format,
- kpse_lua_format,
- kpse_last_format /* one past last index */
-} kpse_file_format_type;
-
-
-/* Perhaps we could use this for path values themselves; for now, we use
- it only for the program_enabled_p value. */
-typedef enum
-{
- kpse_src_implicit, /* C initialization to zero */
- kpse_src_compile, /* configure/compile-time default */
- kpse_src_texmf_cnf, /* texmf.cnf, the kpathsea config file */
- kpse_src_client_cnf, /* application config file, e.g., config.ps */
- kpse_src_env, /* environment variable */
- kpse_src_x, /* X Window System resource */
- kpse_src_cmdline /* command-line option */
-} kpse_src_type;
-
-
-/* For each file format, we record the following information. The main
- thing that is not part of this structure is the environment variable
- lists. They are used directly in tex-file.c. We could incorporate
- them here, but it would complicate the code a bit. We could also do
- it via variable expansion, but not now, maybe not ever:
- ${PKFONTS-${TEXFONTS-/usr/local/lib/texmf/fonts//}}. */
-
-typedef struct
-{
- const_string type; /* Human-readable description. */
- const_string path; /* The search path to use. */
- const_string raw_path; /* Pre-$~ (but post-default) expansion. */
- const_string path_source; /* Where the path started from. */
- const_string override_path; /* From client environment variable. */
- const_string client_path; /* E.g., from dvips's config.ps. */
- const_string cnf_path; /* From texmf.cnf. */
- const_string default_path; /* If all else fails. */
- const_string *suffix; /* For kpse_find_file to check for/append. */
- const_string *alt_suffix; /* More suffixes to check for. */
- boolean suffix_search_only; /* Only search with a suffix? */
- const_string program; /* ``mktexpk'', etc. */
- int argc; /* Count of standard arguments. */
- const_string *argv; /* Standard arguments to `program'. */
- boolean program_enabled_p; /* Invoke `program'? */
- kpse_src_type program_enable_level; /* Who said to invoke `program'. */
- boolean binmode; /* The files must be opened in binary mode. */
-} kpse_format_info_type;
-
-/* The sole variable of that type, indexed by `kpse_file_format_type'.
- Initialized by calls to `kpse_find_file' for `kpse_init_format'. */
-extern KPSEDLL kpse_format_info_type kpse_format_info[kpse_last_format];
-
-
/* If LEVEL is higher than `program_enabled_level' for FMT, set
`program_enabled_p' to VALUE. */
-extern KPSEDLL void kpse_set_program_enabled P3H(kpse_file_format_type fmt,
- boolean value, kpse_src_type level);
+extern KPSEDLL void kpathsea_set_program_enabled (kpathsea kpse,
+ kpse_file_format_type fmt,
+ boolean value, kpse_src_type level);
/* Call kpse_set_program_enabled with VALUE and the format corresponding
to FMTNAME. */
-extern KPSEDLL void kpse_maketex_option P2H(const_string fmtname, boolean value);
+extern KPSEDLL void kpathsea_maketex_option (kpathsea kpse, const_string fmtname,
+ boolean value);
/* Change the list of searched suffixes (alternate suffixes if alternate is
true). */
-extern KPSEDLL void kpse_set_suffixes PVAR2H(kpse_file_format_type format,
- boolean alternate);
+extern KPSEDLL void kpathsea_set_suffixes PVAR3H(kpathsea kpse,
+ kpse_file_format_type format,
+ boolean alternate);
/* Initialize the info for the given format. This is called
automatically by `kpse_find_file', but the glyph searching (for
example) can't use that function, so make it available. */
-extern KPSEDLL const_string kpse_init_format P1H(kpse_file_format_type);
+extern KPSEDLL const_string kpathsea_init_format (kpathsea kpse,
+ kpse_file_format_type format);
/* If FORMAT has a non-null `suffix' member, append it to NAME "."
and call `kpse_path_search' with the result and the other arguments.
If that fails, try just NAME. */
-extern KPSEDLL string kpse_find_file P3H(const_string name,
+extern KPSEDLL string kpathsea_find_file (kpathsea kpse, const_string name,
kpse_file_format_type format, boolean must_exist);
/* Ditto, allowing ALL parameter and hence returning a NULL-terminated
list of results. */
+extern KPSEDLL string *kpathsea_find_file_generic
+ (kpathsea kpse, const_string name, kpse_file_format_type format,
+ boolean must_exist, boolean all);
+
+/* Don't just look up the name, actually open the file. */
+extern KPSEDLL FILE *kpathsea_open_file (kpathsea kpse, const_string name,
+ kpse_file_format_type format);
+
+/* This function is used to set kpse_program_name (from progname.c) to
+ a different value. It will clear the path searching information, to
+ ensure that the search paths are appropriate to the new name. */
+extern KPSEDLL void kpathsea_reset_program_name (kpathsea kpse,
+ const_string progname);
+
+
+#if defined (KPSE_COMPAT_API)
+
+extern void kpse_init_fallback_resolutions (string envvar);
+
+extern KPSEDLL void kpse_set_program_enabled (kpse_file_format_type fmt,
+ boolean value, kpse_src_type level);
+
+extern KPSEDLL void kpse_maketex_option (const_string fmtname, boolean value);
+
+extern KPSEDLL void kpse_set_suffixes PVAR2H(kpse_file_format_type format,
+ boolean alternate);
+
+extern KPSEDLL const_string kpse_init_format (kpse_file_format_type);
+
+extern KPSEDLL string kpse_find_file (const_string name,
+ kpse_file_format_type format, boolean must_exist);
+
extern KPSEDLL string *kpse_find_file_generic
- P4H(const_string name, kpse_file_format_type format,
+ (const_string name, kpse_file_format_type format,
boolean must_exist, boolean all);
/* Here are some abbreviations. */
@@ -194,12 +109,9 @@ extern KPSEDLL string *kpse_find_file_generic
#define kpse_find_vf(name) kpse_find_file (name, kpse_vf_format, false)
#define kpse_find_ovf(name) kpse_find_file (name, kpse_ovf_format, false)
-/* Don't just look up the name, actually open the file. */
-extern KPSEDLL FILE *kpse_open_file P2H(const_string, kpse_file_format_type);
+extern KPSEDLL FILE *kpse_open_file (const_string, kpse_file_format_type);
-/* This function is used to set kpse_program_name (from progname.c) to
- a different value. It will clear the path searching information, to
- ensure that the search paths are appropriate to the new name. */
-extern KPSEDLL void kpse_reset_program_name P1H(const_string progname);
+extern KPSEDLL void kpse_reset_program_name (const_string progname);
+#endif
#endif /* not KPATHSEA_TEX_FILE_H */
diff --git a/Build/source/texk/kpathsea/tex-glyph.c b/Build/source/texk/kpathsea/tex-glyph.c
index e3a833abdba..270d960fa70 100644
--- a/Build/source/texk/kpathsea/tex-glyph.c
+++ b/Build/source/texk/kpathsea/tex-glyph.c
@@ -38,23 +38,25 @@
EXTENSION. Return file found or NULL. */
static string
-try_format P3C(const_string, fontname, unsigned, dpi,
- kpse_file_format_type, format)
+try_format (kpathsea kpse, const_string fontname, unsigned dpi,
+ kpse_file_format_type format)
{
static const_string bitmap_specs[]
= { UNIX_BITMAP_SPEC, DPI_BITMAP_SPEC, NULL };
const_string *spec;
boolean must_exist;
- string ret = NULL;
- const_string path = kpse_format_info[format].path;
const_string *sfx;
+ string ret = NULL;
+ const_string path = kpse->format_info[format].path;
+ (void)dpi; /* -Wunused */
+ (void)fontname; /* -Wunused */
if (!path)
- path = kpse_init_format (format);
+ path = kpathsea_init_format (kpse, format);
/* Set the suffix on the name we'll be searching for. */
- sfx = kpse_format_info[format].suffix;
+ sfx = kpse->format_info[format].suffix;
if (sfx && *sfx)
- xputenv ("KPATHSEA_FORMAT", *sfx);
+ kpathsea_xputenv (kpse, "KPATHSEA_FORMAT", *sfx);
/* OK, the limits on this for loop are a little hokey, but it saves
having to repeat the body. We want to do it once with `must_exist'
@@ -65,8 +67,8 @@ try_format P3C(const_string, fontname, unsigned, dpi,
{
for (spec = bitmap_specs; !ret && *spec; spec++)
{
- string name = kpse_var_expand (*spec);
- ret = kpse_path_search (path, name, must_exist);
+ string name = kpathsea_var_expand (kpse, *spec);
+ ret = kpathsea_path_search (kpse, path, name, must_exist);
if (name != ret)
free (name);
}
@@ -80,19 +82,19 @@ try_format P3C(const_string, fontname, unsigned, dpi,
Return any filename found, and (if we succeeded) fill in GLYPH_FILE. */
static string
-try_size P4C(const_string, fontname, unsigned, dpi,
- kpse_file_format_type, format,
- kpse_glyph_file_type *, glyph_file)
+try_size (kpathsea kpse, const_string fontname, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
{
kpse_file_format_type format_found;
string ret;
boolean try_gf = format == kpse_gf_format || format == kpse_any_glyph_format;
boolean try_pk = format == kpse_pk_format || format == kpse_any_glyph_format;
- xputenv_int ("KPATHSEA_DPI", dpi);
+ kpathsea_xputenv_int (kpse, "KPATHSEA_DPI", dpi);
/* Look for PK first (since it's more likely to be found), then GF. */
- ret = try_pk ? try_format (fontname, dpi, kpse_pk_format) : NULL;
+ ret = try_pk ? try_format (kpse, fontname, dpi, kpse_pk_format) : NULL;
if (ret != NULL)
format_found = kpse_pk_format;
@@ -100,7 +102,7 @@ try_size P4C(const_string, fontname, unsigned, dpi,
{
if (try_gf)
{
- ret = try_format (fontname, dpi, kpse_gf_format);
+ ret = try_format (kpse, fontname, dpi, kpse_gf_format);
format_found = kpse_gf_format;
}
}
@@ -119,11 +121,11 @@ try_size P4C(const_string, fontname, unsigned, dpi,
KPSE_BITMAP_TOLERANCE of DPI. */
static string
-try_resolution P4C(const_string, fontname, unsigned, dpi,
- kpse_file_format_type, format,
- kpse_glyph_file_type *, glyph_file)
+try_resolution (kpathsea kpse, const_string fontname, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
{
- string ret = try_size (fontname, dpi, format, glyph_file);
+ string ret = try_size (kpse, fontname, dpi, format, glyph_file);
if (!ret)
{
@@ -137,7 +139,7 @@ try_resolution P4C(const_string, fontname, unsigned, dpi,
character features (Tom did this in dvips). */
for (r = lower_bound; !ret && r <= upper_bound; r++)
if (r != dpi)
- ret = try_size (fontname, r, format, glyph_file);
+ ret = try_size (kpse, fontname, r, format, glyph_file);
}
return ret;
@@ -150,28 +152,28 @@ try_resolution P4C(const_string, fontname, unsigned, dpi,
mktexpk to only deal with real names.) */
static string
-try_fontmap P4C(string *, fontname_ptr, unsigned, dpi,
- kpse_file_format_type, format,
- kpse_glyph_file_type *, glyph_file)
+try_fontmap (kpathsea kpse, string *fontname_ptr, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
{
string *mapped_names;
string fontname = *fontname_ptr;
string ret = NULL;
- mapped_names = kpse_fontmap_lookup (fontname);
+ mapped_names = kpathsea_fontmap_lookup (kpse, fontname);
if (mapped_names) {
string mapped_name;
string first_name = *mapped_names;
while (!ret && (mapped_name = *mapped_names++)) {
- xputenv ("KPATHSEA_NAME", mapped_name);
- ret = try_resolution (mapped_name, dpi, format, glyph_file);
+ kpathsea_xputenv (kpse, "KPATHSEA_NAME", mapped_name);
+ ret = try_resolution (kpse, mapped_name, dpi, format, glyph_file);
}
if (ret) {
/* If some alias succeeeded, return that alias. */
*fontname_ptr = xstrdup (mapped_name);
/* Return first alias name, unless that itself is an alias,
in which case do nothing. */
- } else if (!kpse_fontmap_lookup (first_name)) {
+ } else if (!kpathsea_fontmap_lookup (kpse, first_name)) {
*fontname_ptr = xstrdup (first_name);
}
}
@@ -184,9 +186,10 @@ try_fontmap P4C(string *, fontname_ptr, unsigned, dpi,
along as usual. Assume `kpse_fallback_resolutions' is sorted. */
static string
-try_fallback_resolutions P4C(const_string, fontname, unsigned, dpi,
- kpse_file_format_type, format,
- kpse_glyph_file_type *, glyph_file)
+try_fallback_resolutions (kpathsea kpse,
+ const_string fontname, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
{
unsigned s;
int loc, max_loc;
@@ -194,11 +197,11 @@ try_fallback_resolutions P4C(const_string, fontname, unsigned, dpi,
unsigned lower_diff, upper_diff;
unsigned closest_diff = UINT_MAX;
string ret = NULL; /* In case the only fallback resolution is DPI. */
-
+ loc = 0; /* -Wall */
/* First find the fallback size closest to DPI, even including DPI. */
- for (s = 0; kpse_fallback_resolutions[s] != 0; s++)
+ for (s = 0; kpse->fallback_resolutions[s] != 0; s++)
{
- unsigned this_diff = abs (kpse_fallback_resolutions[s] - dpi);
+ unsigned this_diff = abs (kpse->fallback_resolutions[s] - dpi);
if (this_diff < closest_diff)
{
closest_diff = this_diff;
@@ -214,20 +217,20 @@ try_fallback_resolutions P4C(const_string, fontname, unsigned, dpi,
for (;;)
{
- unsigned fallback = kpse_fallback_resolutions[loc];
+ unsigned fallback = kpse->fallback_resolutions[loc];
/* Don't bother to try DPI itself again. */
if (fallback != dpi)
{
- ret = try_resolution (fontname, fallback, format, glyph_file);
+ ret = try_resolution (kpse, fontname, fallback, format, glyph_file);
if (ret)
break;
}
/* That didn't work. How far away are the locs above or below? */
lower_diff = lower_loc > -1
- ? dpi - kpse_fallback_resolutions[lower_loc] : INT_MAX;
+ ? dpi - kpse->fallback_resolutions[lower_loc] : INT_MAX;
upper_diff = upper_loc < max_loc
- ? kpse_fallback_resolutions[upper_loc] - dpi : INT_MAX;
+ ? kpse->fallback_resolutions[upper_loc] - dpi : INT_MAX;
/* But if we're at the end in both directions, quit. */
if (lower_diff == INT_MAX && upper_diff == INT_MAX)
@@ -252,9 +255,10 @@ try_fallback_resolutions P4C(const_string, fontname, unsigned, dpi,
/* See the .h file for description. This is the entry point. */
string
-kpse_find_glyph P4C(const_string, passed_fontname, unsigned, dpi,
- kpse_file_format_type, format,
- kpse_glyph_file_type *, glyph_file)
+kpathsea_find_glyph (kpathsea kpse,
+ const_string passed_fontname, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
{
string ret;
kpse_glyph_source_type source;
@@ -262,22 +266,22 @@ kpse_find_glyph P4C(const_string, passed_fontname, unsigned, dpi,
/* Start the search: try the name we're given. */
source = kpse_glyph_source_normal;
- xputenv ("KPATHSEA_NAME", fontname);
- ret = try_resolution (fontname, dpi, format, glyph_file);
+ kpathsea_xputenv (kpse, "KPATHSEA_NAME", fontname);
+ ret = try_resolution (kpse, fontname, dpi, format, glyph_file);
/* Try all the various possibilities in order of preference. */
if (!ret) {
/* Maybe FONTNAME was an alias. */
source = kpse_glyph_source_alias;
- ret = try_fontmap (&fontname, dpi, format, glyph_file);
+ ret = try_fontmap (kpse, &fontname, dpi, format, glyph_file);
/* If not an alias, try creating it on the fly with mktexpk,
unless FONTNAME is absolute or explicitly relative. */
- if (!ret && !kpse_absolute_p (fontname, true)) {
+ if (!ret && !kpathsea_absolute_p (kpse, fontname, true)) {
source = kpse_glyph_source_maketex;
/* `try_resolution' leaves the envvar set randomly. */
- xputenv_int ("KPATHSEA_DPI", dpi);
- ret = kpse_make_tex (format, fontname);
+ kpathsea_xputenv_int (kpse, "KPATHSEA_DPI", dpi);
+ ret = kpathsea_make_tex (kpse, format, fontname);
}
/* If mktex... succeeded, set return struct. Doesn't make sense for
@@ -290,21 +294,21 @@ kpse_find_glyph P4C(const_string, passed_fontname, unsigned, dpi,
/* If mktex... failed, try any fallback resolutions. */
else {
- if (kpse_fallback_resolutions)
- ret = try_fallback_resolutions (fontname, dpi, format, glyph_file);
+ if (kpse->fallback_resolutions)
+ ret = try_fallback_resolutions (kpse, fontname, dpi, format, glyph_file);
/* We're down to the font of last resort. */
- if (!ret && kpse_fallback_font) {
- const_string name = kpse_fallback_font;
+ if (!ret && kpse->fallback_font) {
+ const_string name = kpse->fallback_font;
source = kpse_glyph_source_fallback;
- xputenv ("KPATHSEA_NAME", name);
+ kpathsea_xputenv (kpse, "KPATHSEA_NAME", name);
/* As before, first try it at the given size. */
- ret = try_resolution (name, dpi, format, glyph_file);
+ ret = try_resolution (kpse, name, dpi, format, glyph_file);
/* The fallback font at the fallback resolutions. */
- if (!ret && kpse_fallback_resolutions)
- ret = try_fallback_resolutions (name, dpi, format, glyph_file);
+ if (!ret && kpse->fallback_resolutions)
+ ret = try_fallback_resolutions (kpse, name, dpi, format, glyph_file);
}
}
}
@@ -322,31 +326,52 @@ kpse_find_glyph P4C(const_string, passed_fontname, unsigned, dpi,
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_find_glyph (const_string passed_fontname, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file)
+{
+ return kpathsea_find_glyph(kpse_def, passed_fontname, dpi, format, glyph_file);
+}
+#endif
+
/* The tolerances change whether we base things on DPI1 or DPI2. */
boolean
-kpse_bitmap_tolerance P2C(double, dpi1, double, dpi2)
+kpathsea_bitmap_tolerance (kpathsea kpse, double dpi1, double dpi2)
{
unsigned tolerance = KPSE_BITMAP_TOLERANCE (dpi2);
unsigned lower_bound = (int) (dpi2 - tolerance) < 0 ? 0 : dpi2 - tolerance;
unsigned upper_bound = dpi2 + tolerance;
+ (void)kpse; /* currenty not used */
return lower_bound <= dpi1 && dpi1 <= upper_bound;
}
+
+#if defined (KPSE_COMPAT_API)
+boolean
+kpse_bitmap_tolerance (double dpi1, double dpi2)
+{
+ return kpathsea_bitmap_tolerance (kpse_def, dpi1, dpi2);
+}
+#endif
+
#ifdef TEST
void
-test_find_glyph (const_string fontname, unsigned dpi)
+test_find_glyph (kpathsea kpse, const_string fontname, unsigned dpi)
{
string answer;
kpse_glyph_file_type ret;
printf ("\nSearch for %s@%u:\n\t", fontname, dpi);
- answer = kpse_find_glyph_format (fontname, dpi,
- kpse_any_glyph_format, &ret);
+ answer = kpathsea_find_glyph (kpse, fontname, dpi,
+ kpse_any_glyph_format, &ret);
if (answer)
{
string format = ret.format == kpse_pk_format ? "pk" : "gf";
@@ -360,21 +385,23 @@ test_find_glyph (const_string fontname, unsigned dpi)
int
-main ()
+main (int argc, char **argv)
{
- test_find_glyph ("/usr/local/lib/tex/fonts/cm/cmr10", 300); /* absolute */
- test_find_glyph ("cmr10", 300); /* normal */
- test_find_glyph ("logo10", 300); /* find gf */
- test_find_glyph ("cmr10", 299); /* find 300 */
- test_find_glyph ("circle10", 300); /* in fontmap */
- test_find_glyph ("none", 300); /* do not find */
- kpse_fallback_font = "cmr10";
- test_find_glyph ("fallback", 300); /* find fallback font cmr10 */
- kpse_init_fallback_resolutions ("KPATHSEA_TEST_SIZES");
- test_find_glyph ("fallbackdpi", 759); /* find fallback font cmr10@300 */
+ kpathsea kpse = xcalloc(1,sizeof(kpathsea_instance));
+ kpathsea_set_program_name(kpse, argv[0], NULL);
+ test_find_glyph (kpse, "/usr/local/lib/tex/fonts/cm/cmr10", 300); /* absolute */
+ test_find_glyph (kpse, "cmr10", 300); /* normal */
+ test_find_glyph (kpse, "logo10", 300); /* find gf */
+ test_find_glyph (kpse, "cmr10", 299); /* find 300 */
+ test_find_glyph (kpse, "circle10", 300); /* in fontmap */
+ test_find_glyph (kpse, "none", 300); /* do not find */
+ kpse->kpse_fallback_font = "cmr10";
+ test_find_glyph (kpse, "fallback", 300); /* find fallback font cmr10 */
+ kpathsea_init_fallback_resolutions (kpse, "KPATHSEA_TEST_SIZES");
+ test_find_glyph (kpse, "fallbackdpi", 759); /* find fallback font cmr10@300 */
- xputenv ("GFFONTS", ".");
- test_find_glyph ("cmr10", 300); /* different GFFONTS/TEXFONTS */
+ kpathsea_xputenv (kpse,"GFFONTS", ".");
+ test_find_glyph (kpse, "cmr10", 300); /* different GFFONTS/TEXFONTS */
return 0;
}
@@ -384,6 +411,6 @@ main ()
/*
Local variables:
-test-compile-command: "gcc -g -I. -I.. -DTEST tex-glyph.c kpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST tex-glyph.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/tex-glyph.h b/Build/source/texk/kpathsea/tex-glyph.h
index c573ae0c302..5ee80276790 100644
--- a/Build/source/texk/kpathsea/tex-glyph.h
+++ b/Build/source/texk/kpathsea/tex-glyph.h
@@ -56,16 +56,11 @@ typedef struct
for kpse_fallback_name. Then fail. Return either the filename
found, or NULL. Also return information about the file found in
*GLYPH_FILE. */
-extern KPSEDLL string kpse_find_glyph P4H(const_string font_name, unsigned dpi,
+extern KPSEDLL string kpathsea_find_glyph (kpathsea kpse,
+ const_string font_name, unsigned dpi,
kpse_file_format_type format,
kpse_glyph_file_type *glyph_file);
-/* Look for a specific format only. */
-#define kpse_find_pk(font_name, dpi, glyph_file) \
- kpse_find_glyph (font_name, dpi, kpse_pk_format, glyph_file)
-#define kpse_find_gf(font_name, dpi, glyph_file) \
- kpse_find_glyph (font_name, dpi, kpse_gf_format, glyph_file)
-
/* Defines how far away a pixel file can be found from its stated size.
The DVI standard says any resolution within 0.2% of the stated size
@@ -73,6 +68,22 @@ extern KPSEDLL string kpse_find_glyph P4H(const_string font_name, unsigned dpi,
#define KPSE_BITMAP_TOLERANCE(r) ((r) / 500.0 + 1)
/* Check whether DPI1 is within KPSE_BITMAP_TOLERANCE of DPI2. */
-extern KPSEDLL boolean kpse_bitmap_tolerance P2H(double dpi1, double dpi2);
+extern KPSEDLL boolean kpathsea_bitmap_tolerance (kpathsea kpse,
+ double dpi1, double dpi2);
+
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL string kpse_find_glyph (const_string font_name, unsigned dpi,
+ kpse_file_format_type format,
+ kpse_glyph_file_type *glyph_file);
+
+/* Look for a specific format only. */
+#define kpse_find_pk(font_name, dpi, glyph_file) \
+ kpse_find_glyph (font_name, dpi, kpse_pk_format, glyph_file)
+#define kpse_find_gf(font_name, dpi, glyph_file) \
+ kpse_find_glyph (font_name, dpi, kpse_gf_format, glyph_file)
+
+extern KPSEDLL boolean kpse_bitmap_tolerance (double dpi1, double dpi2);
+#endif
#endif /* not KPATHSEA_TEX_GLYPH_H */
diff --git a/Build/source/texk/kpathsea/tex-hush.c b/Build/source/texk/kpathsea/tex-hush.c
index 2713ea0ec83..05df3ddb1db 100644
--- a/Build/source/texk/kpathsea/tex-hush.c
+++ b/Build/source/texk/kpathsea/tex-hush.c
@@ -23,16 +23,17 @@
#include <kpathsea/variable.h>
boolean
-kpse_tex_hush P1C(const_string, what)
+kpathsea_tex_hush (kpathsea kpse, const_string what)
{
string h;
- string hush = kpse_var_value ("TEX_HUSH");
+ string hush = kpathsea_var_value (kpse, "TEX_HUSH");
if (hush) {
if (STREQ (hush, "all"))
return true;
if (STREQ (hush, "none"))
return false;
- for (h = kpse_path_element (hush); h; h = kpse_path_element (NULL)) {
+ for (h = kpathsea_path_element (kpse, hush); h;
+ h = kpathsea_path_element (kpse, NULL)) {
/* Don't do anything special with empty elements. */
if (STREQ (h, what))
return true;
@@ -41,3 +42,11 @@ kpse_tex_hush P1C(const_string, what)
return false;
}
+
+#if defined (KPSE_COMPAT_API)
+boolean
+kpse_tex_hush (const_string what)
+{
+ return kpathsea_tex_hush (kpse_def, what);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/tex-hush.h b/Build/source/texk/kpathsea/tex-hush.h
index ba68a0b106d..3c322f4fa89 100644
--- a/Build/source/texk/kpathsea/tex-hush.h
+++ b/Build/source/texk/kpathsea/tex-hush.h
@@ -23,6 +23,10 @@
/* Return true if WHAT is included in the TEX_HUSH environment
variable/config value. */
-extern KPSEDLL boolean kpse_tex_hush P1H(const_string what);
+extern KPSEDLL boolean kpathsea_tex_hush (kpathsea kpse, const_string what);
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL boolean kpse_tex_hush (const_string what);
+#endif
#endif /* not KPATHSEA_TEX_HUSH_H */
diff --git a/Build/source/texk/kpathsea/tex-make.c b/Build/source/texk/kpathsea/tex-make.c
index c00058553ee..69a6c9f2134 100644
--- a/Build/source/texk/kpathsea/tex-make.c
+++ b/Build/source/texk/kpathsea/tex-make.c
@@ -27,17 +27,16 @@
#include <kpathsea/tex-make.h>
#include <kpathsea/variable.h>
+#if !defined (AMIGA) && !(defined (MSDOS) && !defined(DJGPP)) && !defined (WIN32)
+#include <sys/wait.h>
+#endif
-/* We never throw away stdout, since that is supposed to be the filename
- found, if all is successful. This variable controls whether stderr
- is thrown away. */
-boolean kpse_make_tex_discard_errors = false;
/* We set the envvar MAKETEX_MAG, which is part of the default spec for
MakeTeXPK above, based on KPATHSEA_DPI and MAKETEX_BASE_DPI. */
static void
-set_maketex_mag P1H(void)
+set_maketex_mag (kpathsea kpse)
{
char q[MAX_INT_LENGTH * 3 + 3];
int m;
@@ -51,7 +50,7 @@ set_maketex_mag P1H(void)
/* Fix up for roundoff error. Hopefully the driver has already fixed
up DPI, but may as well be safe, and also get the magstep number. */
- (void) kpse_magstep_fix (dpi, bdpi, &m);
+ (void) kpathsea_magstep_fix (kpse, dpi, bdpi, &m);
if (m == 0) {
if (bdpi <= 4000) {
@@ -83,7 +82,7 @@ set_maketex_mag P1H(void)
}
sprintf(q, "magstep\\(%s%d.%d\\)", sign, m / 2, (m & 1) * 5);
}
- xputenv ("MAKETEX_MAG", q);
+ kpathsea_xputenv (kpse, "MAKETEX_MAG", q);
}
/* This mktex... program was disabled, or the script failed. If this
@@ -91,9 +90,8 @@ set_maketex_mag P1H(void)
to a file missfont.log in the current directory. */
static void
-misstex P2C(kpse_file_format_type, format, string *, args)
+misstex (kpathsea kpse, kpse_file_format_type format, string *args)
{
- static FILE *missfont = NULL;
string *s;
/* If we weren't trying to make a font, do nothing. Maybe should
@@ -107,8 +105,8 @@ misstex P2C(kpse_file_format_type, format, string *, args)
/* If this is the first time, have to open the log file. But don't
bother logging anything if they were discarding errors. */
- if (!missfont && !kpse_make_tex_discard_errors) {
- const_string missfont_name = kpse_var_value ("MISSFONT_LOG");
+ if (!kpse->missfont && !kpse->make_tex_discard_errors) {
+ const_string missfont_name = kpathsea_var_value (kpse, "MISSFONT_LOG");
if (!missfont_name || *missfont_name == '1') {
missfont_name = "missfont.log"; /* take default name */
} else if (missfont_name
@@ -116,26 +114,26 @@ misstex P2C(kpse_file_format_type, format, string *, args)
missfont_name = NULL; /* user requested no missfont.log */
} /* else use user's name */
- missfont = missfont_name ? fopen (missfont_name, FOPEN_A_MODE) : NULL;
- if (!missfont && kpse_var_value ("TEXMFOUTPUT")) {
- missfont_name = concat3 (kpse_var_value ("TEXMFOUTPUT"), DIR_SEP_STRING,
+ kpse->missfont = missfont_name ? fopen (missfont_name, FOPEN_A_MODE) : NULL;
+ if (!kpse->missfont && kpathsea_var_value (kpse, "TEXMFOUTPUT")) {
+ missfont_name = concat3 (kpathsea_var_value (kpse, "TEXMFOUTPUT"), DIR_SEP_STRING,
missfont_name);
- missfont = fopen (missfont_name, FOPEN_A_MODE);
+ kpse->missfont = fopen (missfont_name, FOPEN_A_MODE);
}
- if (missfont)
+ if (kpse->missfont)
fprintf (stderr, "kpathsea: Appending font creation commands to %s.\n",
missfont_name);
}
/* Write the command if we have a log file. */
- if (missfont) {
- fputs (args[0], missfont);
+ if (kpse->missfont) {
+ fputs (args[0], kpse->missfont);
for (s = &args[1]; *s != NULL; s++) {
- putc(' ', missfont);
- fputs (*s, missfont);
+ putc(' ', kpse->missfont);
+ fputs (*s, kpse->missfont);
}
- putc ('\n', missfont);
+ putc ('\n', kpse->missfont);
}
}
@@ -144,7 +142,7 @@ misstex P2C(kpse_file_format_type, format, string *, args)
else) on standard output; hence, we run the script with `popen'. */
static string
-maketex P2C(kpse_file_format_type, format, string*, args)
+maketex (kpathsea kpse, kpse_file_format_type format, string* args)
{
/* New implementation, use fork/exec pair instead of popen, since
* the latter is virtually impossible to make safe.
@@ -154,7 +152,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
string ret;
string fn;
- if (!kpse_make_tex_discard_errors) {
+ if (!kpse->make_tex_discard_errors) {
fprintf (stderr, "\nkpathsea: Running");
for (s = &args[0]; *s != NULL; s++)
fprintf (stderr, " %s", *s);
@@ -178,6 +176,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
#elif defined (MSDOS) && !defined(DJGPP)
#error Implement new MSDOS mktex call interface here
#elif defined (WIN32)
+
/* We would vastly prefer to link directly with mktex.c here.
Unfortunately, it is not quite possible because kpathsea
is not reentrant. The progname is expected to be set in mktex.c
@@ -243,7 +242,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
si.hStdOutput = father_out_dup;
/* Child stderr */
- if (kpse_make_tex_discard_errors) {
+ if (kpse->make_tex_discard_errors) {
child_err = CreateFile("nul",
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -272,7 +271,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
&si, /* pointer to STARTUPINFO */
&pi /* pointer to PROCESS_INFORMATION */
) == 0) {
- FATAL2("kpathsea: CreateProcess() failed for `%s' (Error %x)\n", new_cmd, GetLastError());
+ LIB_FATAL2("kpathsea: CreateProcess() failed for `%s' (Error %x)\n", new_cmd, GetLastError());
}
CloseHandle(child_in);
@@ -288,7 +287,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
&& num > 0) {
if (num <= 0) {
if (GetLastError() != ERROR_BROKEN_PIPE) {
- FATAL2("kpathsea: read() error code for `%s' (Error %d)", new_cmd, GetLastError());
+ LIB_FATAL2("kpathsea: read() error code for `%s' (Error %d)", new_cmd, GetLastError());
break;
}
} else {
@@ -394,7 +393,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
}
/* stderr -- use /dev/null if we discard errors */
if (childerr != 2) {
- if (kpse_make_tex_discard_errors) {
+ if (kpse->make_tex_discard_errors) {
close(2);
dup(childerr);
}
@@ -445,7 +444,7 @@ maketex P2C(kpse_file_format_type, format, string*, args)
len--;
}
- ret = len == 0 ? NULL : kpse_readable_file (fn);
+ ret = len == 0 ? NULL : kpathsea_readable_file (kpse, fn);
if (!ret && len > 1) {
WARNING2("kpathsea: %s output `%s' instead of a filename",
args[0], fn);
@@ -461,9 +460,9 @@ maketex P2C(kpse_file_format_type, format, string*, args)
#endif
if (ret == NULL)
- misstex (format, args);
+ misstex (kpse, format, args);
else
- kpse_db_insert (ret);
+ kpathsea_db_insert (kpse, ret);
return ret;
}
@@ -473,15 +472,15 @@ maketex P2C(kpse_file_format_type, format, string*, args)
return NULL. */
string
-kpse_make_tex P2C(kpse_file_format_type, format, const_string, base)
+kpathsea_make_tex (kpathsea kpse, kpse_file_format_type format, const_string base)
{
kpse_format_info_type spec; /* some compilers lack struct initialization */
string ret = NULL;
- spec = kpse_format_info[format];
+ spec = kpse->format_info[format];
if (!spec.type) { /* Not initialized yet? */
- kpse_init_format (format);
- spec = kpse_format_info[format];
+ kpathsea_init_format (kpse, format);
+ spec = kpse->format_info[format];
}
if (spec.program && spec.program_enabled_p) {
@@ -522,7 +521,7 @@ kpse_make_tex P2C(kpse_file_format_type, format, const_string, base)
if (format == kpse_gf_format
|| format == kpse_pk_format
|| format == kpse_any_glyph_format)
- set_maketex_mag ();
+ set_maketex_mag (kpse);
/* Here's an awful kludge: if the mode is `/', mktexpk recognizes
it as a special case. `kpse_prog_init' sets it to this in the
@@ -537,12 +536,12 @@ kpse_make_tex P2C(kpse_file_format_type, format, const_string, base)
such sites are uncommon, so they shouldn't make things harder
for everyone else. */
for (argnum = 0; argnum < spec.argc; argnum++) {
- args[argnum] = kpse_var_expand (spec.argv[argnum]);
+ args[argnum] = kpathsea_var_expand (kpse, spec.argv[argnum]);
}
args[argnum++] = xstrdup(base);
args[argnum] = NULL;
- ret = maketex (format, args);
+ ret = maketex (kpse, format, args);
for (argnum = 0; args[argnum] != NULL; argnum++)
free (args[argnum]);
@@ -551,35 +550,46 @@ kpse_make_tex P2C(kpse_file_format_type, format, const_string, base)
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_make_tex (kpse_file_format_type format, const_string base)
+{
+ return kpathsea_make_tex (kpse_def, format, base);
+}
+#endif
+
#ifdef TEST
void
-test_make_tex (kpse_file_format_type fmt, const_string base)
+test_make_tex (kpathsea kpse, kpse_file_format_type fmt, const_string base)
{
string answer;
printf ("\nAttempting %s in format %d:\n", base, fmt);
- answer = kpse_make_tex (fmt, base);
+ answer = kpathsea_make_tex (kpse, fmt, base);
puts (answer ? answer : "(nil)");
}
int
-main ()
+main (int argc, char **argv)
{
- xputenv ("KPATHSEA_DPI", "781"); /* call mktexpk */
- xputenv ("MAKETEX_BASE_DPI", "300"); /* call mktexpk */
- KPSE_MAKE_SPEC_ENABLED (kpse_make_specs[kpse_pk_format]) = true;
- test_make_tex (kpse_pk_format, "cmr10");
+ kpathsea kpse = xcalloc(1, sizeof(kpathsea_instance));
+ kpathsea_set_program_name(kpse, argv[0], NULL);
+ kpathsea_xputenv (kpse, "KPATHSEA_DPI", "781"); /* call mktexpk */
+ kpathsea_xputenv (kpse,"MAKETEX_BASE_DPI", "300"); /* call mktexpk */
+ kpathsea_set_program_enabled(kpse, kpse_pk_format, 1, kpse_src_env);
+ test_make_tex (kpse, kpse_pk_format, "cmr10");
/* Fail with mktextfm. */
- KPSE_MAKE_SPEC_ENABLED (kpse_make_specs[kpse_tfm_format]) = true;
- test_make_tex (kpse_tfm_format, "foozler99");
+ kpathsea_set_program_enabled(kpse, kpse_tfm_format, 1, kpse_src_env);
+ test_make_tex (kpse, kpse_tfm_format, "foozler99");
/* Call something disabled. */
- test_make_tex (kpse_bst_format, "no-way");
+ test_make_tex (kpse, kpse_bst_format, "no-way");
return 0;
}
@@ -589,6 +599,6 @@ main ()
/*
Local variables:
-test-compile-command: "gcc -g -I. -I.. -DTEST tex-make.c kpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST tex-make.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/tex-make.h b/Build/source/texk/kpathsea/tex-make.h
index 33de4f226db..f2d3a24e322 100644
--- a/Build/source/texk/kpathsea/tex-make.h
+++ b/Build/source/texk/kpathsea/tex-make.h
@@ -23,17 +23,18 @@
#include <kpathsea/tex-file.h>
#include <kpathsea/types.h>
-
-/* If true, throw away standard error from the mktex... scripts.
- (Standard output is the filename, so we never throw that away.) */
-extern KPSEDLL boolean kpse_make_tex_discard_errors;
-
-
/* Run a program to create a file named by BASE_FILE in format FORMAT.
Return the full filename to it, or NULL. Any other information about
the file is passed through environment variables. See the mktexpk
stuff in `tex-make.c' for an example. */
-extern string kpse_make_tex P2H(kpse_file_format_type format,
- const_string base_file);
+
+extern string kpathsea_make_tex (kpathsea kpse,
+ kpse_file_format_type format,
+ const_string base_file);
+
+#if defined (KPSE_COMPAT_API)
+extern string kpse_make_tex (kpse_file_format_type format,
+ const_string base_file);
+#endif
#endif /* not KPATHSEA_TEX_MAKE_H */
diff --git a/Build/source/texk/kpathsea/tilde.c b/Build/source/texk/kpathsea/tilde.c
index 85d4e61cdbd..12e71434fd5 100644
--- a/Build/source/texk/kpathsea/tilde.c
+++ b/Build/source/texk/kpathsea/tilde.c
@@ -36,12 +36,13 @@
<pwd.h>, just return NAME. */
string
-kpse_tilde_expand P1C(const_string, name)
+kpathsea_tilde_expand (kpathsea kpse, const_string name)
{
const_string expansion;
const_string home;
const_string prefix;
+ (void)kpse; /* currenty not used */
assert (name);
/* If there is a leading "!!", set prefix to "!!", otherwise use
@@ -126,6 +127,14 @@ kpse_tilde_expand P1C(const_string, name)
be returning a malloc-ed string. Callers beware. Sorry. */
return (string) expansion;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_tilde_expand (const_string name)
+{
+ return kpathsea_tilde_expand (kpse_def, name);
+}
+#endif
#ifdef TEST
@@ -140,10 +149,10 @@ test_expand_tilde (const_string filename)
}
int
-main ()
+main (int argc, char **argv)
{
string tilde_path = "tilde";
-
+ kpse_set_program_name(argv[0],NULL);
test_expand_tilde ("");
test_expand_tilde ("none");
test_expand_tilde ("~root");
diff --git a/Build/source/texk/kpathsea/tilde.h b/Build/source/texk/kpathsea/tilde.h
index 25ff260a933..abf64ffa447 100644
--- a/Build/source/texk/kpathsea/tilde.h
+++ b/Build/source/texk/kpathsea/tilde.h
@@ -26,6 +26,10 @@
getenv ('USERPROFILE") on Windows, or with NAME's home directory,
respectively. Excise trailing slashes. FILENAME may not be null. */
-extern string kpse_tilde_expand P1H(const_string filename);
+extern string kpathsea_tilde_expand (kpathsea kpse, const_string filename);
+
+#if defined (KPSE_COMPAT_API)
+extern string kpse_tilde_expand (const_string filename);
+#endif
#endif /* not KPATHSEA_TILDE_H */
diff --git a/Build/source/texk/kpathsea/truncate.c b/Build/source/texk/kpathsea/truncate.c
index 9ff92b4f86f..081ebdfff83 100644
--- a/Build/source/texk/kpathsea/truncate.c
+++ b/Build/source/texk/kpathsea/truncate.c
@@ -27,13 +27,15 @@
too bad this is necessary. See comments in readable.c for why. */
string
-kpse_truncate_filename P1C(const_string, name)
+kpathsea_truncate_filename (kpathsea kpse, const_string name)
{
unsigned c_len = 0; /* Length of current component. */
unsigned ret_len = 0; /* Length of constructed result. */
/* Allocate enough space. */
string ret = (string) xmalloc (strlen (name) + 1);
+
+ (void)kpse; /* currenty not used */
for (; *name; name++)
{
@@ -54,3 +56,11 @@ kpse_truncate_filename P1C(const_string, name)
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_truncate_filename (const_string name)
+{
+ return kpathsea_truncate_filename (kpse_def, name);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/truncate.h b/Build/source/texk/kpathsea/truncate.h
index 966e2319287..893cc728f45 100644
--- a/Build/source/texk/kpathsea/truncate.h
+++ b/Build/source/texk/kpathsea/truncate.h
@@ -24,6 +24,10 @@
/* Truncate any component in NAME longer than the system NAME_MAX, and
return the result as a malloced string. If none, return a copy of
NAME. */
-extern string kpse_truncate_filename P1H(const_string name);
+extern string kpathsea_truncate_filename (kpathsea kpse, const_string name);
+
+#if defined (KPSE_COMPAT_API)
+extern string kpse_truncate_filename (const_string name);
+#endif
#endif /* not KPATHSEA_TRUNCATE_H */
diff --git a/Build/source/texk/kpathsea/types.h b/Build/source/texk/kpathsea/types.h
index 0de42972e89..08ed01b89f0 100644
--- a/Build/source/texk/kpathsea/types.h
+++ b/Build/source/texk/kpathsea/types.h
@@ -18,6 +18,8 @@
#ifndef KPATHSEA_TYPES_H
#define KPATHSEA_TYPES_H
+#define KPSE_COMPAT_API 1
+
/* Booleans. */
/* NeXT wants to define their own boolean type. */
#ifndef HAVE_BOOLEAN
@@ -39,6 +41,8 @@ typedef int boolean;
#define TRUE true
#endif /* FALSE */
+#include <stdio.h> /* for FILE* */
+
/* The usual null-terminated string. */
typedef char *string;
@@ -49,4 +53,231 @@ typedef const char *const_string;
/* A generic pointer. */
typedef void *address;
+/* function pointer prototype definitions for recorder */
+typedef void (*p_record_input) (const_string);
+typedef void (*p_record_output) (const_string);
+
+/* the cache structure from elt-dirs.c */
+#include <kpathsea/str-llist.h>
+
+typedef struct
+{
+ const_string key;
+ str_llist_type *value;
+} cache_entry;
+
+/* from variable.c */
+typedef struct {
+ const_string var;
+ boolean expanding;
+} expansion_type;
+
+
+#include <kpathsea/hash.h>
+#include <kpathsea/str-list.h>
+
+/* from old tex-file.h */
+
+/* We put the glyphs first so we don't waste space in an array in
+ tex-glyph.c. Accompany a new format here with appropriate changes in
+ tex-file.c and kpsewhich.c (the suffix variable). */
+typedef enum
+{
+ kpse_gf_format,
+ kpse_pk_format,
+ kpse_any_glyph_format, /* ``any'' meaning gf or pk */
+ kpse_tfm_format,
+ kpse_afm_format,
+ kpse_base_format,
+ kpse_bib_format,
+ kpse_bst_format,
+ kpse_cnf_format,
+ kpse_db_format,
+ kpse_fmt_format,
+ kpse_fontmap_format,
+ kpse_mem_format,
+ kpse_mf_format,
+ kpse_mfpool_format,
+ kpse_mft_format,
+ kpse_mp_format,
+ kpse_mppool_format,
+ kpse_mpsupport_format,
+ kpse_ocp_format,
+ kpse_ofm_format,
+ kpse_opl_format,
+ kpse_otp_format,
+ kpse_ovf_format,
+ kpse_ovp_format,
+ kpse_pict_format,
+ kpse_tex_format,
+ kpse_texdoc_format,
+ kpse_texpool_format,
+ kpse_texsource_format,
+ kpse_tex_ps_header_format,
+ kpse_troff_font_format,
+ kpse_type1_format,
+ kpse_vf_format,
+ kpse_dvips_config_format,
+ kpse_ist_format,
+ kpse_truetype_format,
+ kpse_type42_format,
+ kpse_web2c_format,
+ kpse_program_text_format,
+ kpse_program_binary_format,
+ kpse_miscfonts_format,
+ kpse_web_format,
+ kpse_cweb_format,
+ kpse_enc_format,
+ kpse_cmap_format,
+ kpse_sfd_format,
+ kpse_opentype_format,
+ kpse_pdftex_config_format,
+ kpse_lig_format,
+ kpse_texmfscripts_format,
+ kpse_lua_format,
+ kpse_last_format /* one past last index */
+} kpse_file_format_type;
+
+
+/* Perhaps we could use this for path values themselves; for now, we use
+ it only for the program_enabled_p value. */
+typedef enum
+{
+ kpse_src_implicit, /* C initialization to zero */
+ kpse_src_compile, /* configure/compile-time default */
+ kpse_src_texmf_cnf, /* texmf.cnf, the kpathsea config file */
+ kpse_src_client_cnf, /* application config file, e.g., config.ps */
+ kpse_src_env, /* environment variable */
+ kpse_src_x, /* X Window System resource */
+ kpse_src_cmdline /* command-line option */
+} kpse_src_type;
+
+
+/* For each file format, we record the following information. The main
+ thing that is not part of this structure is the environment variable
+ lists. They are used directly in tex-file.c. We could incorporate
+ them here, but it would complicate the code a bit. We could also do
+ it via variable expansion, but not now, maybe not ever:
+ ${PKFONTS-${TEXFONTS-/usr/local/lib/texmf/fonts//}}. */
+
+typedef struct
+{
+ const_string type; /* Human-readable description. */
+ const_string path; /* The search path to use. */
+ const_string raw_path; /* Pre-$~ (but post-default) expansion. */
+ const_string path_source; /* Where the path started from. */
+ const_string override_path; /* From client environment variable. */
+ const_string client_path; /* E.g., from dvips's config.ps. */
+ const_string cnf_path; /* From texmf.cnf. */
+ const_string default_path; /* If all else fails. */
+ const_string *suffix; /* For kpse_find_file to check for/append. */
+ const_string *alt_suffix; /* More suffixes to check for. */
+ boolean suffix_search_only; /* Only search with a suffix? */
+ const_string program; /* ``mktexpk'', etc. */
+ int argc; /* Count of standard arguments. */
+ const_string *argv; /* Standard arguments to `program'. */
+ boolean program_enabled_p; /* Invoke `program'? */
+ kpse_src_type program_enable_level; /* Who said to invoke `program'. */
+ boolean binmode; /* The files must be opened in binary mode. */
+} kpse_format_info_type;
+
+typedef struct kpathsea_instance *kpathsea;
+
+typedef struct kpathsea_instance {
+ /* from cnf.c */
+ p_record_input record_input; /* for --recorder */
+ p_record_output record_output; /* for --recorder */
+ hash_table_type cnf_hash; /* used by read_all_cnf */
+ boolean doing_cnf_init; /* for kpse_cnf_get */
+ /* from db.c */
+ hash_table_type db; /* The hash table for all the ls-R's. */
+ hash_table_type alias_db; /* The hash table for the aliases */
+ str_list_type db_dir_list; /* list of ls-R's */
+ /* from debug.c */
+ unsigned debug; /* for --kpathsea-debug */
+ /* from dir.c */
+ hash_table_type link_table; /* a hash of links-per-dir */
+ /* from elt-dir.c */
+ cache_entry *the_cache;
+ unsigned cache_length;
+ /* from fontmap.c */
+ hash_table_type map; /* the font mapping hash */
+ const_string map_path; /* holds the format path for kpse_fontmap_format */
+ /* from hash.c */
+ /* Print the hash values as integers if this is nonzero. */
+ boolean debug_hash_lookup_int;
+ /* from path-elt.c */
+ string elt; /* statically created buffer for return value of |element| */
+ unsigned elt_alloc;
+ const_string path; /* The path we're currently working on. */
+ /* from pathsearch.c */
+ boolean followup_search;
+ FILE *log_file;
+ boolean log_opened; /* Need to open the log file? */
+ /* from progname.c */
+ string invocation_name;
+ string invocation_short_name;
+ string program_name; /* pretended name */
+ int ll_verbose; /* for symlinks (conditional) */
+ /* from tex-file.c */
+ /* If non-NULL, try looking for this if can't find the real font. */
+ const_string fallback_font;
+ /* If non-NULL, default list of fallback resolutions comes from this
+ * instead of the compile-time value. Set by dvipsk for the R config
+ * cmd. *SIZES environment variables override/use as default.
+ */
+ const_string fallback_resolutions_string;
+ /* If non-NULL, check these if can't find (within a few percent of) the
+ * given resolution. List must end with a zero element.
+ */
+ unsigned *fallback_resolutions;
+ kpse_format_info_type format_info[kpse_last_format];
+ /* from tex-make.c */
+ /* We never throw away stdout, since that is supposed to be the filename
+ * found, if all is successful. This variable controls whether stderr
+ * is thrown away.
+ */
+ boolean make_tex_discard_errors;
+ FILE *missfont;
+ /* from variable.c */
+ expansion_type *expansions; /* The sole variable of this type. */
+ unsigned expansion_len ;
+ /* from xputenv.c */
+ /* These record the strings we've set and have to keep around.
+ * This function can be called many times during a run, and this
+ * allows us to reclaim memory we allocated.
+ */
+ char **saved_env; /* these keep track of changed items */
+ int saved_count;
+} kpathsea_instance;
+
+/* these come from kpathsea.c */
+extern KPSEDLL kpathsea kpathsea_new (void) ;
+extern KPSEDLL void kpathsea_finish (kpathsea kpse) ;
+
+#if defined (KPSE_COMPAT_API)
+
+#define kpse_bug_address kpathsea_bug_address
+
+extern kpathsea_instance kpse_def_inst;
+extern kpathsea kpse_def;
+
+#define kpathsea_debug kpse_def_inst.debug
+#define kpse_program_name kpse_def_inst.program_name
+#define kpse_record_input kpse_def_inst.record_input
+#define kpse_record_output kpse_def_inst.record_output
+#define kpse_make_tex_discard_errors kpse_def_inst.make_tex_discard_errors
+#define kpse_fallback_font kpse_def_inst.fallback_font
+#define kpse_fallback_resolutions_string kpse_def_inst.fallback_resolutions_string
+#define kpse_fallback_resolutions kpse_def_inst.fallback_resolutions
+#define kpse_format_info kpse_def_inst.format_info
+
+#undef program_invocation_name
+#define program_invocation_name kpse_def_inst.invocation_name
+#undef program_invocation_short_name
+#define program_invocation_short_name kpse_def_inst.invocation_short_name
+
+#endif /* KPSE_COMPAT_API */
+
#endif /* not KPATHSEA_TYPES_H */
+
diff --git a/Build/source/texk/kpathsea/uppercasify.c b/Build/source/texk/kpathsea/uppercasify.c
index 218b246ec24..dcfc8924b23 100644
--- a/Build/source/texk/kpathsea/uppercasify.c
+++ b/Build/source/texk/kpathsea/uppercasify.c
@@ -21,7 +21,7 @@
string
-uppercasify P1C(const_string, s)
+uppercasify (const_string s)
{
string target;
string ret = xstrdup (s);
diff --git a/Build/source/texk/kpathsea/variable.c b/Build/source/texk/kpathsea/variable.c
index 92576bf4e25..3fb45d13bec 100644
--- a/Build/source/texk/kpathsea/variable.c
+++ b/Build/source/texk/kpathsea/variable.c
@@ -28,20 +28,20 @@
/* Here's the simple one, when a program just wants a value. */
string
-kpse_var_value P1C(const_string, var)
+kpathsea_var_value (kpathsea kpse, const_string var)
{
string vtry, ret;
- assert (kpse_program_name);
+ assert (kpse->program_name);
/* First look for VAR.progname. */
- vtry = concat3 (var, ".", kpse_program_name);
+ vtry = concat3 (var, ".", kpse->program_name);
ret = getenv (vtry);
free (vtry);
if (!ret || !*ret) {
/* Now look for VAR_progname. */
- vtry = concat3 (var, "_", kpse_program_name);
+ vtry = concat3 (var, "_", kpse->program_name);
ret = getenv (vtry);
free (vtry);
}
@@ -52,7 +52,7 @@ kpse_var_value P1C(const_string, var)
/* Not in the environment; check a config file. */
if (!ret || !*ret)
- ret = kpse_cnf_get (var);
+ ret = kpathsea_cnf_get (kpse, var);
/* We have a value; do variable and tilde expansion. We want to use ~
in the cnf files, to adapt nicely to Windows and to avoid extra /'s
@@ -60,23 +60,32 @@ kpse_var_value P1C(const_string, var)
have any literal ~ characters, so our shell scripts don't have to
worry about doing the ~ expansion. */
if (ret) {
- string tmp = kpse_var_expand (ret);
+ string tmp = kpathsea_var_expand (kpse, ret);
/* We don't want to free the previous value of ret here; apparently
it's used later, somewhere, somehow. (The end result was a crash
when making tex.fmt.) Sigh. */
- ret = kpse_tilde_expand (tmp);
+ ret = kpathsea_tilde_expand (kpse, tmp);
if (ret != tmp) {
free (tmp);
}
}
#ifdef KPSE_DEBUG
- if (KPSE_DEBUG_P (KPSE_DEBUG_VARS))
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_VARS))
DEBUGF2("variable: %s = %s\n", var, ret ? ret : "(nil)");
#endif
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_var_value (const_string var)
+{
+ return kpathsea_var_value (kpse_def,var);
+}
+#endif
+
/* We have to keep track of variables being expanded, otherwise
constructs like TEXINPUTS = $TEXINPUTS result in an infinite loop.
@@ -84,41 +93,34 @@ kpse_var_value P1C(const_string, var)
add to a list each time an expansion is started, and check the list
before expanding. */
-typedef struct {
- const_string var;
- boolean expanding;
-} expansion_type;
-static expansion_type *expansions; /* The sole variable of this type. */
-static unsigned expansion_len = 0;
-
static void
-expanding P2C(const_string, var, boolean, xp)
+expanding (kpathsea kpse, const_string var, boolean xp)
{
unsigned e;
- for (e = 0; e < expansion_len; e++) {
- if (STREQ (expansions[e].var, var)) {
- expansions[e].expanding = xp;
+ for (e = 0; e < kpse->expansion_len; e++) {
+ if (STREQ (kpse->expansions[e].var, var)) {
+ kpse->expansions[e].expanding = xp;
return;
}
}
/* New variable, add it to the list. */
- expansion_len++;
- XRETALLOC (expansions, expansion_len, expansion_type);
- expansions[expansion_len - 1].var = xstrdup (var);
- expansions[expansion_len - 1].expanding = xp;
+ kpse->expansion_len++;
+ XRETALLOC (kpse->expansions, kpse->expansion_len, expansion_type);
+ kpse->expansions[kpse->expansion_len - 1].var = xstrdup (var);
+ kpse->expansions[kpse->expansion_len - 1].expanding = xp;
}
/* Return whether VAR is currently being expanding. */
static boolean
-expanding_p P1C(const_string, var)
+expanding_p (kpathsea kpse, const_string var)
{
unsigned e;
- for (e = 0; e < expansion_len; e++) {
- if (STREQ (expansions[e].var, var))
- return expansions[e].expanding;
+ for (e = 0; e < kpse->expansion_len; e++) {
+ if (STREQ (kpse->expansions[e].var, var))
+ return kpse->expansions[e].expanding;
}
return false;
@@ -129,7 +131,7 @@ expanding_p P1C(const_string, var)
This is a subroutine for the more complicated expansion function. */
static void
-expand P3C(fn_type *, expansion, const_string, start, const_string, end)
+expand (kpathsea kpse, fn_type *expansion, const_string start, const_string end)
{
string value;
unsigned len = end - start + 1;
@@ -137,10 +139,10 @@ expand P3C(fn_type *, expansion, const_string, start, const_string, end)
strncpy (var, start, len);
var[len] = 0;
- if (expanding_p (var)) {
+ if (expanding_p (kpse, var)) {
WARNING1 ("kpathsea: variable `%s' references itself (eventually)", var);
} else {
- string vtry = concat3 (var, "_", kpse_program_name);
+ string vtry = concat3 (var, "_", kpse->program_name);
/* Check for an environment variable. */
value = getenv (vtry);
free (vtry);
@@ -150,15 +152,15 @@ expand P3C(fn_type *, expansion, const_string, start, const_string, end)
/* If no envvar, check the config files. */
if (!value || !*value)
- value = kpse_cnf_get (var);
+ value = kpathsea_cnf_get (kpse, var);
if (value) {
- expanding (var, true);
- value = kpse_var_expand (value);
- expanding (var, false);
+ expanding (kpse, var, true);
+ value = kpathsea_var_expand (kpse, value);
+ expanding (kpse, var, false);
{ /* Do tilde expansion; see explanation above in kpse_var_value. */
- string tmp = kpse_tilde_expand (value);
+ string tmp = kpathsea_tilde_expand (kpse, value);
if (value != tmp) {
free (value);
value = tmp;
@@ -193,7 +195,7 @@ expand P3C(fn_type *, expansion, const_string, start, const_string, end)
constructs, especially ${var-value}. We do do ~ expansion. */
string
-kpse_var_expand P1C(const_string, src)
+kpathsea_var_expand (kpathsea kpse, const_string src)
{
const_string s;
string ret;
@@ -215,7 +217,7 @@ kpse_var_expand P1C(const_string, src)
} while (IS_VAR_CHAR (*var_end));
var_end--; /* had to go one past */
- expand (&expansion, s, var_end);
+ expand (kpse, &expansion, s, var_end);
s = var_end;
} else if (IS_VAR_BEGIN_DELIMITER (*s)) {
@@ -229,7 +231,7 @@ kpse_var_expand P1C(const_string, src)
WARNING1 ("%s: No matching } for ${", src);
s = var_end - 1; /* will incr to null at top of loop */
} else {
- expand (&expansion, s, var_end - 1);
+ expand (kpse, &expansion, s, var_end - 1);
s = var_end; /* will incr past } at top of loop*/
}
@@ -246,6 +248,15 @@ kpse_var_expand P1C(const_string, src)
ret = FN_STRING (expansion);
return ret;
}
+
+#if defined (KPSE_COMPAT_API)
+string
+kpse_var_expand (const_string src)
+{
+ return kpathsea_var_expand (kpse_def,src);
+}
+#endif
+
#ifdef TEST
@@ -262,8 +273,9 @@ test_var (string test, string right_answer)
int
-main ()
+main (int argc, char **argv)
{
+ kpse_set_program_name(argv[0], NULL);
test_var ("a", "a");
test_var ("$foo", "");
test_var ("a$foo", "a");
diff --git a/Build/source/texk/kpathsea/variable.h b/Build/source/texk/kpathsea/variable.h
index 4c92e0e00f2..2dd97c4cb30 100644
--- a/Build/source/texk/kpathsea/variable.h
+++ b/Build/source/texk/kpathsea/variable.h
@@ -24,7 +24,7 @@
/* Return the (variable-expanded) environment variable value or config
file value, or NULL. */
-extern KPSEDLL string kpse_var_value P1H(const_string var);
+extern KPSEDLL string kpathsea_var_value (kpathsea kpse, const_string var);
/* Expand $VAR, ${VAR}, and ~ references in SRC, returning the (always newly
dynamically-allocated) result. An unterminated ${ or any other
@@ -36,6 +36,11 @@ extern KPSEDLL string kpse_var_value P1H(const_string var);
In any case, ``expansion'' means calling `getenv'; if the variable is not
set, look in texmf.cnf files for a definition. If not set there, either,
the expansion is the empty string (no error). */
-extern KPSEDLL string kpse_var_expand P1H(const_string src);
+extern KPSEDLL string kpathsea_var_expand (kpathsea kpse, const_string src);
+
+#if defined (KPSE_COMPAT_API)
+extern KPSEDLL string kpse_var_value (const_string var);
+extern KPSEDLL string kpse_var_expand (const_string src);
+#endif
#endif /* not KPATHSEA_VARIABLE_H */
diff --git a/Build/source/texk/kpathsea/version.c b/Build/source/texk/kpathsea/version.c
index aaafcbe8d21..5259a8f51a9 100644
--- a/Build/source/texk/kpathsea/version.c
+++ b/Build/source/texk/kpathsea/version.c
@@ -29,5 +29,5 @@ KPSEDLL char *kpathsea_version_string = (char *) KPSEVERSION;
Thanks. --kb@cs.umb.edu */
-KPSEDLL char *kpse_bug_address = (char *)
+KPSEDLL char *kpathsea_bug_address = (char *)
"Email bug reports to tex-k@mail.tug.org.\n";
diff --git a/Build/source/texk/kpathsea/xbasename.c b/Build/source/texk/kpathsea/xbasename.c
index f4e060c0f03..6bf651713e9 100644
--- a/Build/source/texk/kpathsea/xbasename.c
+++ b/Build/source/texk/kpathsea/xbasename.c
@@ -26,7 +26,7 @@
returns "bar.baz". */
const_string
-xbasename P1C(const_string, name)
+xbasename (const_string name)
{
const_string base = NULL;
unsigned len;
diff --git a/Build/source/texk/kpathsea/xcalloc.c b/Build/source/texk/kpathsea/xcalloc.c
index 1973b9d934a..e01eb9c8da4 100644
--- a/Build/source/texk/kpathsea/xcalloc.c
+++ b/Build/source/texk/kpathsea/xcalloc.c
@@ -20,7 +20,7 @@
void *
-xcalloc P2C(unsigned, nelem, unsigned, elsize)
+xcalloc (unsigned nelem, unsigned elsize)
{
void *new_mem = (void*)calloc(nelem, elsize);
diff --git a/Build/source/texk/kpathsea/xdirname.c b/Build/source/texk/kpathsea/xdirname.c
index e687048b5a3..dee5374754b 100644
--- a/Build/source/texk/kpathsea/xdirname.c
+++ b/Build/source/texk/kpathsea/xdirname.c
@@ -26,7 +26,7 @@
#include <kpathsea/c-pathch.h>
string
-xdirname P1C(const_string, name)
+xdirname (const_string name)
{
string ret;
unsigned limit = 0, loc;
@@ -113,7 +113,7 @@ int main()
/*
Local variables:
-standalone-compile-command: "gcc -g -I. -I.. -DTEST variable.c kpathsea.a"
+standalone-compile-command: "gcc -g -I. -I.. -DTEST xdirname.c kpathsea.a"
End:
*/
diff --git a/Build/source/texk/kpathsea/xfopen.c b/Build/source/texk/kpathsea/xfopen.c
index 804dda0282f..74c02ee297a 100644
--- a/Build/source/texk/kpathsea/xfopen.c
+++ b/Build/source/texk/kpathsea/xfopen.c
@@ -23,7 +23,7 @@
routines and abort if an error happens. */
FILE *
-xfopen P2C(const_string, filename, const_string, mode)
+xfopen (const_string filename, const_string mode)
{
FILE *f;
@@ -38,10 +38,11 @@ xfopen P2C(const_string, filename, const_string, mode)
void
-xfclose P2C(FILE *, f, const_string, filename)
+xfclose (FILE *f, const_string filename)
{
assert(f);
if (fclose(f) == EOF)
FATAL_PERROR(filename);
+
}
diff --git a/Build/source/texk/kpathsea/xfseek.c b/Build/source/texk/kpathsea/xfseek.c
index ee6ccd7c9d2..20a304693c0 100644
--- a/Build/source/texk/kpathsea/xfseek.c
+++ b/Build/source/texk/kpathsea/xfseek.c
@@ -19,9 +19,9 @@
#include <kpathsea/config.h>
void
-xfseek P4C(FILE *, f, long, offset, int, wherefrom, string, filename)
+xfseek (FILE *f, long offset, int wherefrom, string filename)
{
if (fseek (f, offset, wherefrom) < 0) {
- FATAL_PERROR (filename);
+ FATAL_PERROR(filename);
}
}
diff --git a/Build/source/texk/kpathsea/xfseeko.c b/Build/source/texk/kpathsea/xfseeko.c
index ecc3d60240a..16e9c0fd4ba 100644
--- a/Build/source/texk/kpathsea/xfseeko.c
+++ b/Build/source/texk/kpathsea/xfseeko.c
@@ -18,9 +18,9 @@
#include <kpathsea/config.h>
void
-xfseeko P4C(FILE *, f, off_t, offset, int, wherefrom, string, filename)
+xfseeko (FILE *f, off_t offset, int wherefrom, string filename)
{
if (fseeko (f, offset, wherefrom) < 0) {
- FATAL_PERROR (filename);
+ FATAL_PERROR(filename);
}
}
diff --git a/Build/source/texk/kpathsea/xftell.c b/Build/source/texk/kpathsea/xftell.c
index 4679907ed5f..d1481bdf18c 100644
--- a/Build/source/texk/kpathsea/xftell.c
+++ b/Build/source/texk/kpathsea/xftell.c
@@ -20,7 +20,7 @@
unsigned long
-xftell P2C(FILE *, f, string, filename)
+xftell (FILE *f, string filename)
{
long where = ftello (f);
diff --git a/Build/source/texk/kpathsea/xftello.c b/Build/source/texk/kpathsea/xftello.c
index 4e6aec21dcb..9fd44df4257 100644
--- a/Build/source/texk/kpathsea/xftello.c
+++ b/Build/source/texk/kpathsea/xftello.c
@@ -20,7 +20,7 @@
off_t
-xftello P2C(FILE *, f, string, filename)
+xftello (FILE *f, string filename)
{
off_t where = ftello (f);
diff --git a/Build/source/texk/kpathsea/xgetcwd.c b/Build/source/texk/kpathsea/xgetcwd.c
index 2a512a6da68..1390da71c4f 100644
--- a/Build/source/texk/kpathsea/xgetcwd.c
+++ b/Build/source/texk/kpathsea/xgetcwd.c
@@ -27,10 +27,10 @@
static void
-xchdir P1C(string, dirname)
+xchdir (string dirname)
{
if (chdir(dirname) != 0)
- FATAL_PERROR(dirname);
+ _PERROR(dirname);
}
#endif /* not HAVE_GETCWD && not HAVE_GETWD */
@@ -39,7 +39,7 @@ xchdir P1C(string, dirname)
/* Return the pathname of the current directory, or give a fatal error. */
string
-xgetcwd P1H(void)
+xgetcwd (void)
{
/* If the system provides getcwd, use it. If not, use getwd if
available. But provide a way not to use getcwd: on some systems
@@ -105,7 +105,7 @@ xgetcwd P1H(void)
}
}
if (!found)
- FATAL2("No inode %d/device %d in parent directory",
+ LIB_FATAL2("No inode %d/device %d in parent directory",
cwd_stat.st_ino, cwd_stat.st_dev);
xclosedir(parent_dir);
diff --git a/Build/source/texk/kpathsea/xmalloc.c b/Build/source/texk/kpathsea/xmalloc.c
index 32dd8a71fd4..70871a5ae14 100644
--- a/Build/source/texk/kpathsea/xmalloc.c
+++ b/Build/source/texk/kpathsea/xmalloc.c
@@ -20,7 +20,7 @@
void *
-xmalloc P1C(unsigned, size)
+xmalloc (unsigned size)
{
void *new_mem = (void *)malloc(size ? size : 1);
diff --git a/Build/source/texk/kpathsea/xopendir.c b/Build/source/texk/kpathsea/xopendir.c
index caa4a2642d0..e948eb90131 100644
--- a/Build/source/texk/kpathsea/xopendir.c
+++ b/Build/source/texk/kpathsea/xopendir.c
@@ -22,7 +22,7 @@
#if !defined(WIN32) || defined(__MINGW32__)
DIR *
-xopendir P1C(string, dirname)
+xopendir (string dirname)
{
DIR *d = opendir(dirname);
@@ -34,7 +34,7 @@ xopendir P1C(string, dirname)
#endif /* not WIN32 */
void
-xclosedir P1C(DIR *, d)
+xclosedir (DIR *d)
{
#ifdef CLOSEDIR_VOID
closedir (d);
diff --git a/Build/source/texk/kpathsea/xopendir.h b/Build/source/texk/kpathsea/xopendir.h
index 67b3443fa3c..30988d90951 100644
--- a/Build/source/texk/kpathsea/xopendir.h
+++ b/Build/source/texk/kpathsea/xopendir.h
@@ -23,7 +23,7 @@
#include <kpathsea/types.h>
/* Like opendir and closedir, but abort on error. */
-extern DIR *xopendir P1H(string dirname);
-extern void xclosedir P1H(DIR *);
+extern DIR *xopendir (string dirname);
+extern void xclosedir (DIR *);
#endif /* not (KPATHSEA_XOPENDIR_H or WIN32) */
diff --git a/Build/source/texk/kpathsea/xputenv.c b/Build/source/texk/kpathsea/xputenv.c
index a42485000b3..a3a55bd4ff0 100644
--- a/Build/source/texk/kpathsea/xputenv.c
+++ b/Build/source/texk/kpathsea/xputenv.c
@@ -18,22 +18,16 @@
#include <kpathsea/config.h>
+#include <kpathsea/types.h>
#ifdef WIN32
#include <stdlib.h>
#else
#if !HAVE_DECL_PUTENV
-extern int putenv P1H(char* entry);
+extern int putenv (char* entry);
#endif
#endif /* not WIN32 */
-/* These record the strings we've set and have to keep around.
- * This function can be called many times during a run, and this
- * allows us to reclaim memory we allocated.
- */
-static char **saved_env;
-static int saved_count;
-
/*
* We have different arguments from the "standard" function. A separate
* var and value tends to be much more practical.
@@ -44,7 +38,7 @@ static int saved_count;
* which include making copies of the passed string, and more.
*/
void
-xputenv(const char *var, const char *value)
+kpathsea_xputenv(kpathsea kpse, const char *var, const char *value)
{
char *cur_item;
char *old_item;
@@ -60,8 +54,8 @@ xputenv(const char *var, const char *value)
var_lim = strlen(var) + 1;
/* Have we stored something for this value already? */
- for (cur_loc = 0; cur_loc != saved_count; ++cur_loc) {
- if (strncmp(saved_env[cur_loc], cur_item, var_lim) == 0) {
+ for (cur_loc = 0; cur_loc != kpse->saved_count; ++cur_loc) {
+ if (strncmp(kpse->saved_env[cur_loc], cur_item, var_lim) == 0) {
/* Get the old value. We need this is case another part
* of the program didn't use us to change the environment.
*/
@@ -77,7 +71,7 @@ xputenv(const char *var, const char *value)
} else {
/* We set a different value. */
if (putenv(cur_item) < 0)
- FATAL1("putenv(%s)", cur_item);
+ LIB_FATAL1("putenv(%s)", cur_item);
/* Get the new string. */
new_item = getenv(var);
if (new_item != cur_item+var_lim) {
@@ -90,15 +84,15 @@ xputenv(const char *var, const char *value)
/* If we get here, it means getenv() returned a reference to cur_item.
* So we save cur_item, and free the old string we also owned.
*/
- if (cur_loc == saved_count) {
+ if (cur_loc == kpse->saved_count) {
/* No old string. */
- saved_count++;
- saved_env = XRETALLOC(saved_env, saved_count, char *);
+ kpse->saved_count++;
+ kpse->saved_env = XRETALLOC(kpse->saved_env, kpse->saved_count, char *);
} else {
/* We owned the old string. */
- free(saved_env[cur_loc]);
+ free(kpse->saved_env[cur_loc]);
}
- saved_env[cur_loc] = cur_item;
+ kpse->saved_env[cur_loc] = cur_item;
return;
}
@@ -109,10 +103,24 @@ xputenv(const char *var, const char *value)
environment value. */
void
-xputenv_int P2C(const_string, var_name, int, num)
+kpathsea_xputenv_int (kpathsea kpse, const_string var_name, int num)
{
char str[MAX_INT_LENGTH];
sprintf (str, "%d", num);
- xputenv (var_name, str);
+ kpathsea_xputenv (kpse, var_name, str);
}
+
+#if defined (KPSE_COMPAT_API)
+void
+xputenv(const char *var, const char *value)
+{
+ kpathsea_xputenv(kpse_def, var, value);
+}
+
+void
+xputenv_int (const_string var_name, int num)
+{
+ kpathsea_xputenv_int(kpse_def, var_name, num);
+}
+#endif
diff --git a/Build/source/texk/kpathsea/xrealloc.c b/Build/source/texk/kpathsea/xrealloc.c
index 7840bc3fc17..0bafda049c7 100644
--- a/Build/source/texk/kpathsea/xrealloc.c
+++ b/Build/source/texk/kpathsea/xrealloc.c
@@ -18,10 +18,10 @@
#include <kpathsea/config.h>
-extern void *xmalloc P1H(unsigned);
+extern void *xmalloc (unsigned);
void *
-xrealloc P2C(void *, old_ptr, unsigned, size)
+xrealloc (void *old_ptr, unsigned size)
{
void *new_mem;
diff --git a/Build/source/texk/kpathsea/xstat.c b/Build/source/texk/kpathsea/xstat.c
index 678e2fe411e..17a3992c0dd 100644
--- a/Build/source/texk/kpathsea/xstat.c
+++ b/Build/source/texk/kpathsea/xstat.c
@@ -22,7 +22,7 @@
struct stat
-xstat P1C(const_string, path)
+xstat (const_string path)
{
struct stat s;
@@ -43,13 +43,12 @@ xstat P1C(const_string, path)
// extern int lstat ();
*/
struct stat
-xlstat P1C(const_string, path)
+xlstat (const_string path)
{
struct stat s;
if (lstat(path, &s) != 0)
- FATAL_PERROR(path);
-
+ FATAL_PERROR(path);
return s;
}
#endif
diff --git a/Build/source/texk/kpathsea/xstat.h b/Build/source/texk/kpathsea/xstat.h
index fcebb4f0e14..c256687b4ba 100644
--- a/Build/source/texk/kpathsea/xstat.h
+++ b/Build/source/texk/kpathsea/xstat.h
@@ -29,11 +29,11 @@
((s1).st_ino == (s2).st_ino && (s1).st_dev == (s2).st_dev)
/* Does stat(2) on PATH, and aborts if the stat fails. */
-extern struct stat xstat P1H(const_string path);
+extern struct stat xstat (const_string path);
/* Ditto, for lstat(2) (except that lstat might not exist). */
#ifdef S_ISLNK
-extern struct stat xlstat P1H(const_string path);
+extern struct stat xlstat (const_string path);
#else
#define xlstat xstat
#endif
diff --git a/Build/source/texk/kpathsea/xstrdup.c b/Build/source/texk/kpathsea/xstrdup.c
index 6afe72f5efa..738421874e8 100644
--- a/Build/source/texk/kpathsea/xstrdup.c
+++ b/Build/source/texk/kpathsea/xstrdup.c
@@ -22,7 +22,7 @@
/* Return a copy of S in new storage. */
string
-xstrdup P1C(const_string, s)
+xstrdup (const_string s)
{
string new_string = (string)xmalloc(strlen (s) + 1);
return strcpy(new_string, s);
diff --git a/Build/source/texk/xdvipdfmx/ChangeLog.TL b/Build/source/texk/xdvipdfmx/ChangeLog.TL
index 03ae52d8f15..157c1f6e854 100644
--- a/Build/source/texk/xdvipdfmx/ChangeLog.TL
+++ b/Build/source/texk/xdvipdfmx/ChangeLog.TL
@@ -1,11 +1,14 @@
-ChangeLog.TL: Changes for xdvipdfmx (teTeX / TeX live)
-======================================================
+ChangeLog.TL: Changes for dvipdfmx (teTeX / TeX live)
+=====================================================
+
+2009-03-16 Peter Breitenlohner <peb@mppmu.mpg.de>
+ * src/cff.c, src/dpxutil.c, src/mem.c, src/pdfencoding.c,
+ src/pdfencrypt.c: Must include Kpathsea headers (via `system.h')
+ before including `mem.h'.
2008-04-06 Peter Breitenlohner <peb@mppmu.mpg.de>
- * configure.in: respect library dependencies.
-2008-03-31 Peter Breitenlohner <peb@mppmu.mpg.de>
- * Makefile.in, data/Makefile.in, src/Makefile.in: regenerated.
+ * configure.in: respect library dependencies.
2008-03-04 Peter Breitenlohner <peb@mppmu.mpg.de>
@@ -13,13 +16,5 @@ ChangeLog.TL: Changes for xdvipdfmx (teTeX / TeX live)
* configure.in: moved macro definitions ...
* m4/maw-time.m4 (new): ... to here
* acinclude.m4 (removed): moved macro definitions ...
- * m4/maw-kpse.m4, maw-libs.m4, maw-macos.m4 (all new): ... to
- here; these files are the same as in ../dvipdfmx.
-
-2008-02-21 Peter Breitenlohner <peb@mppmu.mpg.de>
-
- Allow maintainer mode to regenerate files.
- * configure.in, acinclude.m4: added AC_DEFINES's third arg to
- provide autoheader templates.
- * configure.in: use AC_DEFINES for XETEX and XETEX_MAC.
-
+ * m4/maw-kpse.m4, maw-libs.m4 (both new): ... to here; these
+ files are the same as in ../xdvipdfmx.
diff --git a/Build/source/texk/xdvipdfmx/src/cff.c b/Build/source/texk/xdvipdfmx/src/cff.c
index 51d33633f9d..70adb996fcd 100644
--- a/Build/source/texk/xdvipdfmx/src/cff.c
+++ b/Build/source/texk/xdvipdfmx/src/cff.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
@@ -37,24 +38,24 @@
#define CFF_DEBUG 5
#define CFF_DEBUG_STR "CFF"
-static unsigned long get_unsigned (sfnt *sfont, int n)
+static unsigned long get_unsigned (FILE *stream, int n)
{
unsigned long v = 0;
while (n-- > 0)
- v = v*0x100u + sfnt_get_byte(sfont);
+ v = v*0x100u + get_unsigned_byte(stream);
return v;
}
#define get_offset(s, n) get_unsigned((s), (n))
-#define get_card8(s) sfnt_get_byte((s))
-#define get_card16(s) sfnt_get_ushort((s))
+#define get_card8(s) get_unsigned_byte((s))
+#define get_card16(s) get_unsigned_pair((s))
/*
* Read Header, Name INDEX, Top DICT INDEX, and String INDEX.
*/
-cff_font *cff_open(sfnt *sfont, long offset, int n)
+cff_font *cff_open(FILE *stream, long offset, int n)
{
cff_font *cff;
cff_index *idx;
@@ -63,7 +64,7 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
cff->fontname = NULL;
cff->index = n;
- cff->sfont = sfont;
+ cff->stream = stream;
cff->offset = offset;
cff->filter = 0; /* not used */
cff->flag = 0;
@@ -83,10 +84,10 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
cff->_string = NULL;
cff_seek_set(cff, 0);
- cff->header.major = get_card8(cff->sfont);
- cff->header.minor = get_card8(cff->sfont);
- cff->header.hdr_size = get_card8(cff->sfont);
- cff->header.offsize = get_card8(cff->sfont);
+ cff->header.major = get_card8(cff->stream);
+ cff->header.minor = get_card8(cff->stream);
+ cff->header.hdr_size = get_card8(cff->stream);
+ cff->header.offsize = get_card8(cff->stream);
if (cff->header.offsize < 1 ||
cff->header.offsize > 4)
ERROR("invalid offsize data");
@@ -140,12 +141,12 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
cff->string = cff_get_index(cff);
/* offset to GSubr */
- cff->gsubr_offset = cff->sfont->loc - offset;
+ cff->gsubr_offset = tell_position(cff->stream) - offset;
/* Number of glyphs */
offset = (long) cff_dict_get(cff->topdict, "CharStrings", 0);
cff_seek_set(cff, offset);
- cff->num_glyphs = get_card16(cff->sfont);
+ cff->num_glyphs = get_card16(cff->stream);
/* Check for font type */
if (cff_dict_known(cff->topdict, "ROS")) {
@@ -292,15 +293,15 @@ cff_get_index_header (cff_font *cff)
idx = NEW(1, cff_index);
- idx->count = count = get_card16(cff->sfont);
+ idx->count = count = get_card16(cff->stream);
if (count > 0) {
- idx->offsize = get_card8(cff->sfont);
+ idx->offsize = get_card8(cff->stream);
if (idx->offsize < 1 || idx->offsize > 4)
ERROR("invalid offsize data");
idx->offset = NEW(count+1, l_offset);
for (i=0;i<count+1;i++) {
- (idx->offset)[i] = get_offset(cff->sfont, idx->offsize);
+ (idx->offset)[i] = get_offset(cff->stream, idx->offsize);
}
if (idx->offset[0] != 1)
@@ -325,15 +326,15 @@ cff_get_index (cff_font *cff)
idx = NEW(1, cff_index);
- idx->count = count = get_card16(cff->sfont);
+ idx->count = count = get_card16(cff->stream);
if (count > 0) {
- idx->offsize = get_card8(cff->sfont);
+ idx->offsize = get_card8(cff->stream);
if (idx->offsize < 1 || idx->offsize > 4)
ERROR("invalid offsize data");
idx->offset = NEW(count + 1, l_offset);
for (i = 0 ; i < count + 1; i++) {
- idx->offset[i] = get_offset(cff->sfont, idx->offsize);
+ idx->offset[i] = get_offset(cff->stream, idx->offsize);
}
if (idx->offset[0] != 1)
@@ -344,7 +345,7 @@ cff_get_index (cff_font *cff)
idx->data = NEW(length, card8);
offset = 0;
while (length > 0) {
- nb_read = sfnt_read(idx->data + offset, length, cff->sfont);
+ nb_read = fread(idx->data + offset, 1, length, cff->stream);
offset += nb_read;
length -= nb_read;
}
@@ -625,27 +626,27 @@ long cff_read_encoding (cff_font *cff)
cff_seek_set(cff, offset);
cff->encoding = encoding = NEW(1, cff_encoding);
- encoding->format = get_card8(cff->sfont);
+ encoding->format = get_card8(cff->stream);
length = 1;
switch (encoding->format & (~0x80)) {
case 0:
- encoding->num_entries = get_card8(cff->sfont);
+ encoding->num_entries = get_card8(cff->stream);
(encoding->data).codes = NEW(encoding->num_entries, card8);
for (i=0;i<(encoding->num_entries);i++) {
- (encoding->data).codes[i] = get_card8(cff->sfont);
+ (encoding->data).codes[i] = get_card8(cff->stream);
}
length += encoding->num_entries + 1;
break;
case 1:
{
cff_range1 *ranges;
- encoding->num_entries = get_card8(cff->sfont);
+ encoding->num_entries = get_card8(cff->stream);
encoding->data.range1 = ranges
= NEW(encoding->num_entries, cff_range1);
for (i=0;i<(encoding->num_entries);i++) {
- ranges[i].first = get_card8(cff->sfont);
- ranges[i].n_left = get_card8(cff->sfont);
+ ranges[i].first = get_card8(cff->stream);
+ ranges[i].n_left = get_card8(cff->stream);
}
length += (encoding->num_entries) * 2 + 1;
}
@@ -659,11 +660,11 @@ long cff_read_encoding (cff_font *cff)
/* Supplementary data */
if ((encoding->format) & 0x80) {
cff_map *map;
- encoding->num_supps = get_card8(cff->sfont);
+ encoding->num_supps = get_card8(cff->stream);
encoding->supp = map = NEW(encoding->num_supps, cff_map);
for (i=0;i<(encoding->num_supps);i++) {
- map[i].code = get_card8(cff->sfont);
- map[i].glyph = get_card16(cff->sfont); /* SID */
+ map[i].code = get_card8(cff->stream);
+ map[i].glyph = get_card16(cff->stream); /* SID */
}
length += (encoding->num_supps) * 3 + 1;
} else {
@@ -841,7 +842,7 @@ long cff_read_charsets (cff_font *cff)
cff_seek_set(cff, offset);
cff->charsets = charset = NEW(1, cff_charsets);
- charset->format = get_card8(cff->sfont);
+ charset->format = get_card8(cff->stream);
charset->num_entries = 0;
count = cff->num_glyphs - 1;
@@ -854,7 +855,7 @@ long cff_read_charsets (cff_font *cff)
charset->data.glyphs = NEW(charset->num_entries, s_SID);
length += (charset->num_entries) * 2;
for (i=0;i<(charset->num_entries);i++) {
- charset->data.glyphs[i] = get_card16(cff->sfont);
+ charset->data.glyphs[i] = get_card16(cff->stream);
}
count = 0;
break;
@@ -863,8 +864,8 @@ long cff_read_charsets (cff_font *cff)
cff_range1 *ranges = NULL;
while (count > 0 && charset->num_entries < cff->num_glyphs) {
ranges = RENEW(ranges, charset->num_entries + 1, cff_range1);
- ranges[charset->num_entries].first = get_card16(cff->sfont);
- ranges[charset->num_entries].n_left = get_card8(cff->sfont);
+ ranges[charset->num_entries].first = get_card16(cff->stream);
+ ranges[charset->num_entries].n_left = get_card8(cff->stream);
count -= ranges[charset->num_entries].n_left + 1; /* no-overrap */
charset->num_entries += 1;
charset->data.range1 = ranges;
@@ -877,8 +878,8 @@ long cff_read_charsets (cff_font *cff)
cff_range2 *ranges = NULL;
while (count > 0 && charset->num_entries < cff->num_glyphs) {
ranges = RENEW(ranges, charset->num_entries + 1, cff_range2);
- ranges[charset->num_entries].first = get_card16(cff->sfont);
- ranges[charset->num_entries].n_left = get_card16(cff->sfont);
+ ranges[charset->num_entries].first = get_card16(cff->stream);
+ ranges[charset->num_entries].n_left = get_card16(cff->stream);
count -= ranges[charset->num_entries].n_left + 1; /* non-overrapping */
charset->num_entries += 1;
}
@@ -1171,7 +1172,7 @@ long cff_read_fdselect (cff_font *cff)
offset = (long) cff_dict_get(cff->topdict, "FDSelect", 0);
cff_seek_set(cff, offset);
cff->fdselect = fdsel = NEW(1, cff_fdselect);
- fdsel->format = get_card8(cff->sfont);
+ fdsel->format = get_card8(cff->stream);
length = 1;
@@ -1180,22 +1181,22 @@ long cff_read_fdselect (cff_font *cff)
fdsel->num_entries = cff->num_glyphs;
(fdsel->data).fds = NEW(fdsel->num_entries, card8);
for (i=0;i<(fdsel->num_entries);i++) {
- (fdsel->data).fds[i] = get_card8(cff->sfont);
+ (fdsel->data).fds[i] = get_card8(cff->stream);
}
length += fdsel->num_entries;
break;
case 3:
{
cff_range3 *ranges;
- fdsel->num_entries = get_card16(cff->sfont);
+ fdsel->num_entries = get_card16(cff->stream);
fdsel->data.ranges = ranges = NEW(fdsel->num_entries, cff_range3);
for (i=0;i<(fdsel->num_entries);i++) {
- ranges[i].first = get_card16(cff->sfont);
- ranges[i].fd = get_card8(cff->sfont);
+ ranges[i].first = get_card16(cff->stream);
+ ranges[i].fd = get_card8(cff->stream);
}
if (ranges[0].first != 0)
ERROR("Range not starting with 0.");
- if (cff->num_glyphs != get_card16(cff->sfont))
+ if (cff->num_glyphs != get_card16(cff->stream))
ERROR("Sentinel value mismatched with number of glyphs.");
length += (fdsel->num_entries) * 3 + 4;
}
@@ -1419,7 +1420,7 @@ long cff_read_private (cff_font *cff)
offset = (long) cff_dict_get(cff->fdarray[i], "Private", 1);
cff_seek_set(cff, offset);
data = NEW(size, card8);
- if (sfnt_read(data, size, cff->sfont) != size)
+ if (fread(data, 1, size, cff->stream) != size)
ERROR("reading file failed");
(cff->private)[i] = cff_dict_unpack(data, data+size);
RELEASE(data);
@@ -1436,7 +1437,7 @@ long cff_read_private (cff_font *cff)
offset = (long) cff_dict_get(cff->topdict, "Private", 1);
cff_seek_set(cff, offset);
data = NEW(size, card8);
- if (sfnt_read(data, size, cff->sfont) != size)
+ if (fread(data, 1, size, cff->stream) != size)
ERROR("reading file failed");
cff->private[0] = cff_dict_unpack(data, data+size);
RELEASE(data);
@@ -1449,10 +1450,3 @@ long cff_read_private (cff_font *cff)
return len;
}
-
-#ifdef XETEX
-unsigned short* cff_get_ft_to_gid(cff_font *cff)
-{
- return cff->ft_to_gid;
-}
-#endif
diff --git a/Build/source/texk/xdvipdfmx/src/dpxutil.c b/Build/source/texk/xdvipdfmx/src/dpxutil.c
index c87568b96a5..a30a3269dfa 100644
--- a/Build/source/texk/xdvipdfmx/src/dpxutil.c
+++ b/Build/source/texk/xdvipdfmx/src/dpxutil.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <time.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
diff --git a/Build/source/texk/xdvipdfmx/src/mem.c b/Build/source/texk/xdvipdfmx/src/mem.c
index e474f407e6d..97e46cdd0d9 100644
--- a/Build/source/texk/xdvipdfmx/src/mem.c
+++ b/Build/source/texk/xdvipdfmx/src/mem.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
diff --git a/Build/source/texk/xdvipdfmx/src/pdfencoding.c b/Build/source/texk/xdvipdfmx/src/pdfencoding.c
index 4f50b312372..296674d9880 100644
--- a/Build/source/texk/xdvipdfmx/src/pdfencoding.c
+++ b/Build/source/texk/xdvipdfmx/src/pdfencoding.c
@@ -28,6 +28,7 @@
#include <string.h>
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "dpxutil.h"
diff --git a/Build/source/texk/xdvipdfmx/src/pdfencrypt.c b/Build/source/texk/xdvipdfmx/src/pdfencrypt.c
index fd43569dd1c..e76f18eedaa 100644
--- a/Build/source/texk/xdvipdfmx/src/pdfencrypt.c
+++ b/Build/source/texk/xdvipdfmx/src/pdfencrypt.c
@@ -2,7 +2,7 @@
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
This program is free software; you can redistribute it and/or modify
@@ -36,6 +36,7 @@
#include <unistd.h>
#endif /* WIN32 */
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "pdfobj.h"