diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-09 08:04:20 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-09 08:04:20 +0000 |
commit | 2e4d12f4ceeaf451fa4ff0666a4c50b33f1826b2 (patch) | |
tree | 82985be2f5edd0565f5cea5983320666fff937e7 /Build/source | |
parent | 1913b736d7e8d17206f1afa59cae982b6639fd2a (diff) |
WIN32: more C program replacements for Unix shell scripts (from Akira's W32TeX)
git-svn-id: svn://tug.org/texlive/trunk@23469 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/dviljk/win32/ChangeLog | 2 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/Makefile.am | 1 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/Makefile.in | 5 | ||||
-rwxr-xr-x | Build/source/texk/kpathsea/configure | 3 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/configure.ac | 2 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/ChangeLog | 20 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/Makefile.am | 47 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/Makefile.in | 587 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/getdestdir.c | 329 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/getdestdir.h | 3 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktexmf.c | 360 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktexpk.c | 1263 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktextfm.c | 410 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktexupd.c | 122 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktexupd.h | 1 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/win32/mktexupdmain.c | 34 |
17 files changed, 3190 insertions, 7 deletions
diff --git a/Build/source/texk/dviljk/win32/ChangeLog b/Build/source/texk/dviljk/win32/ChangeLog index daaa579f6d0..f3a3da3e9b6 100644 --- a/Build/source/texk/dviljk/win32/ChangeLog +++ b/Build/source/texk/dviljk/win32/ChangeLog @@ -13,4 +13,4 @@ * dvihp.c (main): Drop use of getlongname() for 8+3 names. Remove unused variables `dvicopy_log' and `dvilj_log'. Declare almost all strings as const. - * mktexlib.h, stackenv.c: Declare mktex_version_string as const.
\ No newline at end of file + * mktexlib.h, stackenv.c: Declare mktex_version_string as const. diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 68f900f6734..e5478fa7a67 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,4 +1,9 @@ -2011-08-06 Peter Breitenlohner <peb@mppmu.mpg.de> +2011-08-09 Peter Breitenlohner <peb@mppmu.mpg.de> + + * Makefile.am (SUBDIRS): Add win32 to build C programs from + Akira's W32TeX as WIN32 replacements for the shell scripts. + +2011-08-08 Peter Breitenlohner <peb@mppmu.mpg.de> * progname.c (fix_selfdir): Simplified to not modify arg. (remove_dots): Somewhat clarify the code (suggested by Karl). @@ -223,7 +228,6 @@ 2011-06-18 Peter Breitenlohner <peb@mppmu.mpg.de> * progname.c (remove_dots): Correctly handle dir="/foo/../bar". - FIXME: What about dir="c:foo/../bar" and dir="c:../bar"? 2011-06-17 Peter Breitenlohner <peb@mppmu.mpg.de> diff --git a/Build/source/texk/kpathsea/Makefile.am b/Build/source/texk/kpathsea/Makefile.am index 9257bec27c8..495ed284f7f 100644 --- a/Build/source/texk/kpathsea/Makefile.am +++ b/Build/source/texk/kpathsea/Makefile.am @@ -93,6 +93,7 @@ else !MINGW32 libkpathsea_la_SOURCES += win32lib.c endif !MINGW32 libkpathsea_la_SOURCES += knj.c +SUBDIRS += win32 endif WIN32 $(libkpathsea_la_OBJECTS): paths.h kpathsea.h diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in index b1fe69aa7ee..bfc065cedef 100644 --- a/Build/source/texk/kpathsea/Makefile.in +++ b/Build/source/texk/kpathsea/Makefile.in @@ -41,6 +41,7 @@ host_triplet = @host@ @MINGW32_TRUE@@WIN32_TRUE@am__append_1 = mingw32.c @MINGW32_FALSE@@WIN32_TRUE@am__append_2 = win32lib.c @WIN32_TRUE@am__append_3 = knj.c +@WIN32_TRUE@am__append_4 = win32 bin_PROGRAMS = kpseaccess$(EXEEXT) kpsereadlink$(EXEEXT) \ kpsestat$(EXEEXT) kpsewhich$(EXEEXT) EXTRA_PROGRAMS = progname-test$(EXEEXT) xdirtest$(EXEEXT) @@ -213,7 +214,7 @@ ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= -DIST_SUBDIRS = $(SUBDIRS) +DIST_SUBDIRS = . doc man win32 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -370,7 +371,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I ../../m4 -SUBDIRS = . doc man +SUBDIRS = . doc man $(am__append_4) EXTRA_DIST = BUGS PROJECTS putenv.c strcasecmp.c strtol.c strstr.c \ bsnl.awk cnf-to-paths.awk $(TESTS) mktex.cnf win32lib.h.mugica INCLUDES = -I$(top_builddir)/.. -I$(top_srcdir)/.. diff --git a/Build/source/texk/kpathsea/configure b/Build/source/texk/kpathsea/configure index 07e7a6a6db0..20fac4388ee 100755 --- a/Build/source/texk/kpathsea/configure +++ b/Build/source/texk/kpathsea/configure @@ -12936,7 +12936,7 @@ ac_config_headers="$ac_config_headers c-auto.h:c-auto.in" -ac_config_files="$ac_config_files Makefile doc/Makefile man/Makefile" +ac_config_files="$ac_config_files Makefile doc/Makefile man/Makefile win32/Makefile" cat >confcache <<\_ACEOF @@ -13965,6 +13965,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; + "win32/Makefile") CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/Build/source/texk/kpathsea/configure.ac b/Build/source/texk/kpathsea/configure.ac index 85d150031fa..2688cb01130 100644 --- a/Build/source/texk/kpathsea/configure.ac +++ b/Build/source/texk/kpathsea/configure.ac @@ -92,6 +92,6 @@ AH_TOP([/* c-auto.h: defines for kpathsea, as determined by configure. #define KPSEVERSION "REPLACE-WITH-KPSEVERSION"]) AH_BOTTOM([#endif /* !KPATHSEA_C_AUTO_H */]) -AC_CONFIG_FILES([Makefile doc/Makefile man/Makefile]) +AC_CONFIG_FILES([Makefile doc/Makefile man/Makefile win32/Makefile]) AC_OUTPUT diff --git a/Build/source/texk/kpathsea/win32/ChangeLog b/Build/source/texk/kpathsea/win32/ChangeLog new file mode 100644 index 00000000000..6fc667428c5 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/ChangeLog @@ -0,0 +1,20 @@ +2011-08-09 Peter Breitenlohner <peb@mppmu.mpg.de> + + * getdestdir.c, mktexmf.c, mktexpk.c, mktextfm.c, mktexupd.c, + mktexupdmain.c: New files from Akira's W32TeX. + + * getdestdir.c (getdestdir): Replace kstrrchr() by strrchr(). + + * mktexmf.c (main), mktexpk.c (main), mktextfm.c (main), + mktexupdmain.c (main): Drop use of getlongname() for 8+3 names. + + * mktexpk.c (main): Replace win32_popen() and win32_pclose() by + popen() and pclose(). + + * getdestdir.h, mktexupd.h: New headers with function prototypes. + + * *.c: Drop extern declarations and #include these headers. + Declare functions as static. Drop unused variables. + Add parentheses around assignment used as truth value. + Add 'return 0' at end of non-void function. Constify strings. + * getdestdir.c (getdestdir): Initialize `Num' to avoid warning. diff --git a/Build/source/texk/kpathsea/win32/Makefile.am b/Build/source/texk/kpathsea/win32/Makefile.am new file mode 100644 index 00000000000..2842eeec972 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/Makefile.am @@ -0,0 +1,47 @@ +## Makefile.am for the TeX Live subdirectory texk/dviljk/win32/ +## +## Copyright (C) 2011 Peter Breitenlohner <tex-live@tug.org> +## You may freely use, modify and/or distribute this file. +## +AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. +AM_CFLAGS = $(WARNING_CFLAGS) + +# Build WIN32 replacements for Unix shell scripts. +bin_PROGRAMS = mktexmf mktexpk mktextfm mktexupd + +mktexmf_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktexmf.c \ + mktexupd.c \ + mktexupd.h + +mktexpk_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktexpk.c \ + mktexupd.c \ + mktexupd.h + +mktextfm_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktextfm.c \ + mktexupd.c \ + mktexupd.h + +mktexupd_SOURCES = \ + mktexupdmain.c \ + mktexupd.c \ + mktexupd.h + +LDADD = ../libkpathsea.la + +## Rebuild libkpathsea +../libkpathsea.la: ${top_srcdir}/../kpathsea/*.[ch] ../paths.h + cd .. && $(MAKE) $(AM_MAKEFLAGS) rebuild +../paths.h: + cd .. && $(MAKE) $(AM_MAKEFLAGS) rebuild + +EXTRA_DIST = ChangeLog + diff --git a/Build/source/texk/kpathsea/win32/Makefile.in b/Build/source/texk/kpathsea/win32/Makefile.in new file mode 100644 index 00000000000..708fe567375 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/Makefile.in @@ -0,0 +1,587 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = mktexmf$(EXEEXT) mktexpk$(EXEEXT) mktextfm$(EXEEXT) \ + mktexupd$(EXEEXT) +subdir = win32 +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ + $(top_srcdir)/../../m4/kpse-lib-version.m4 \ + $(top_srcdir)/../../m4/kpse-mktex.m4 \ + $(top_srcdir)/../../m4/kpse-warnings.m4 \ + $(top_srcdir)/../../m4/kpse-win32.m4 \ + $(top_srcdir)/../../m4/libtool.m4 \ + $(top_srcdir)/../../m4/ltoptions.m4 \ + $(top_srcdir)/../../m4/ltsugar.m4 \ + $(top_srcdir)/../../m4/ltversion.m4 \ + $(top_srcdir)/../../m4/lt~obsolete.m4 $(top_srcdir)/version.ac \ + $(top_srcdir)/ac/mktex.ac $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/c-auto.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_mktexmf_OBJECTS = getdestdir.$(OBJEXT) mktexmf.$(OBJEXT) \ + mktexupd.$(OBJEXT) +mktexmf_OBJECTS = $(am_mktexmf_OBJECTS) +mktexmf_LDADD = $(LDADD) +mktexmf_DEPENDENCIES = ../libkpathsea.la +am_mktexpk_OBJECTS = getdestdir.$(OBJEXT) mktexpk.$(OBJEXT) \ + mktexupd.$(OBJEXT) +mktexpk_OBJECTS = $(am_mktexpk_OBJECTS) +mktexpk_LDADD = $(LDADD) +mktexpk_DEPENDENCIES = ../libkpathsea.la +am_mktextfm_OBJECTS = getdestdir.$(OBJEXT) mktextfm.$(OBJEXT) \ + mktexupd.$(OBJEXT) +mktextfm_OBJECTS = $(am_mktextfm_OBJECTS) +mktextfm_LDADD = $(LDADD) +mktextfm_DEPENDENCIES = ../libkpathsea.la +am_mktexupd_OBJECTS = mktexupdmain.$(OBJEXT) mktexupd.$(OBJEXT) +mktexupd_OBJECTS = $(am_mktexupd_OBJECTS) +mktexupd_LDADD = $(LDADD) +mktexupd_DEPENDENCIES = ../libkpathsea.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/../../build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(mktexmf_SOURCES) $(mktexpk_SOURCES) $(mktextfm_SOURCES) \ + $(mktexupd_SOURCES) +DIST_SOURCES = $(mktexmf_SOURCES) $(mktexpk_SOURCES) \ + $(mktextfm_SOURCES) $(mktexupd_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KPSEVERSION = @KPSEVERSION@ +KPSE_LT_VERSINFO = @KPSE_LT_VERSINFO@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_OBJDIR = @LT_OBJDIR@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. +AM_CFLAGS = $(WARNING_CFLAGS) +mktexmf_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktexmf.c \ + mktexupd.c \ + mktexupd.h + +mktexpk_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktexpk.c \ + mktexupd.c \ + mktexupd.h + +mktextfm_SOURCES = \ + getdestdir.c \ + getdestdir.h \ + mktextfm.c \ + mktexupd.c \ + mktexupd.h + +mktexupd_SOURCES = \ + mktexupdmain.c \ + mktexupd.c \ + mktexupd.h + +LDADD = ../libkpathsea.la +EXTRA_DIST = ChangeLog +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign win32/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign win32/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +mktexmf$(EXEEXT): $(mktexmf_OBJECTS) $(mktexmf_DEPENDENCIES) + @rm -f mktexmf$(EXEEXT) + $(LINK) $(mktexmf_OBJECTS) $(mktexmf_LDADD) $(LIBS) +mktexpk$(EXEEXT): $(mktexpk_OBJECTS) $(mktexpk_DEPENDENCIES) + @rm -f mktexpk$(EXEEXT) + $(LINK) $(mktexpk_OBJECTS) $(mktexpk_LDADD) $(LIBS) +mktextfm$(EXEEXT): $(mktextfm_OBJECTS) $(mktextfm_DEPENDENCIES) + @rm -f mktextfm$(EXEEXT) + $(LINK) $(mktextfm_OBJECTS) $(mktextfm_LDADD) $(LIBS) +mktexupd$(EXEEXT): $(mktexupd_OBJECTS) $(mktexupd_DEPENDENCIES) + @rm -f mktexupd$(EXEEXT) + $(LINK) $(mktexupd_OBJECTS) $(mktexupd_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdestdir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexmf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexpk.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktextfm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexupd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexupdmain.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +../libkpathsea.la: ${top_srcdir}/../kpathsea/*.[ch] ../paths.h + cd .. && $(MAKE) $(AM_MAKEFLAGS) rebuild +../paths.h: + cd .. && $(MAKE) $(AM_MAKEFLAGS) rebuild + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Build/source/texk/kpathsea/win32/getdestdir.c b/Build/source/texk/kpathsea/win32/getdestdir.c new file mode 100644 index 00000000000..63ecdb8a7a7 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/getdestdir.c @@ -0,0 +1,329 @@ +/* +getdestdir.c +from mktexpk: + argv[0] = "Dummy", argv[1] = "pk", argv[2] = path, argv[3] = mode +from mktextfm: + argv[0] = "Dummy", argv[1] = "tfm", argv[2] = path +*/ + +#include <kpathsea/kpathsea.h> +#include <stdio.h> +#include <stdlib.h> +#include <process.h> +#include <string.h> +#include <malloc.h> +#include <direct.h> +#include <io.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "getdestdir.h" + +#define NUMBUF 32 +#define LENBUF 128 +#define MPATH 256 +#define FTOP "fonts" + +/* error message */ +static void +fatal (const char *s) +{ + fprintf (stderr, "%s\n", s); +} + +/* check a directory */ +int +is_dir (char *buff) +{ + HANDLE h; + WIN32_FIND_DATA w32fd; + + if (((h = FindFirstFile (buff, &w32fd)) + != INVALID_HANDLE_VALUE) && + (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + FindClose (h); + return (1); + } else { + FindClose (h); + return (0); + } +} + +/* make a directory */ +int +make_dir (char *buff) +{ + if (_mkdir (buff)) { + fprintf(stderr, "mkdir %s error.\n", buff); + return (1); + } + if (_chmod (buff, _S_IREAD | _S_IWRITE)) { + fprintf(stderr, "chmod %s failed.\n", buff); + return (1); + } + return (0); +} + +static int +make_dir_p(char *buff) +{ + int ret = 0; + int i = 0; + char *p = buff; + + while (1) { + if(*p == '\0') { + ret = 0; + if(!is_dir(buff)) { + if(make_dir(buff)) { + ret = 1; + } + } + break; + } + if(*p == '/' && (i > 0 && *(p-1) != ':')) { + *p = '\0'; + if(!is_dir(buff)) { + if(make_dir(buff)) { + ret = 1; + *p = '/'; + break; + } + } + *p = '/'; + } + p++; + i++; + } + return ret; +} + +char * +getdestdir (int ac, char **av) +{ + static char buff[MPATH]; + char *pb[NUMBUF]; + char *p, *q; + char spec[32]; + int i, Num = 0, ispk, k; + char *topdir; + + ispk = 0; + + for (i = 0; i < NUMBUF; i++) { + if (!(pb[i] = (char *) malloc (LENBUF))) { + fatal ("Memory allocation error."); + return (NULL); + } + } + + if (ac != 3 && ac != 4) { + fatal ("Argument error."); + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + + strcpy (spec, av[1]); + + for (p = av[2]; *p; p++) { /* path */ + if (isknj (*p)) { + if(*(p+1)) p++; + continue; + } + if (*p == '\\') + *p = '/'; + } + + p = av[2]; + q = buff; + +/* UNC name support */ + + if (p[0] == '/' && p[1] == '/') { + *q++ = *p++; + *q++ = *p++; + } + + while (*p) { + if (*p == '/') { + *q = *p; + while (*p == '/') + p++; + p--; + } else { + *q = *p; + } + p++; + q++; + } + *q = '\0'; /* now path name of ${name}.mf is in buff. */ +/* +#ifdef TEST + return buff; +#endif +*/ + if (ac == 4) + ispk = 1; /* called from mktexpk */ + + if (!(p = strrchr (buff, '/'))) { + fatal ("Invalid path name."); + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + + *p = '\0'; /* get directory name */ + + for (i = 0; i < NUMBUF; i++) { + if (!(p = strrchr (buff, '/'))) { + fatal ("Invalid path name."); + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + *p = '\0'; + p++; + strcpy (pb[i], p); + if (!stricmp (pb[i], FTOP)) { + Num = i; + break; + } + } + + Num -= 2; + if (Num < 0) { + fprintf (stderr, "Font resources should be under a directory "); + fprintf (stderr, "with the name \"fonts\".\n"); + fprintf (stderr, "Furthermore, there must be at least two directories "); + fprintf (stderr, "under the directory \"fonts\".\n"); + fatal ("Invalid path name."); + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + + topdir = kpse_var_value ("MAKETEXPK_TOP_DIR"); + if (topdir && *topdir && ispk) { + for (i = 0; topdir[i]; i++) { + if (isknj (topdir[i])) { + if(topdir[i+1]) i++; + continue; + } + if (topdir[i] == '\\') + topdir[i] = '/'; + } + i = strlen (topdir); + while(topdir[i - 1] == '/') + i--; + topdir[i] = '\0'; + + if(!is_dir(topdir)) { + if(make_dir_p(topdir)) { + fprintf(stderr, "Failed to access %s.\n", topdir); + return NULL; + } + } +#ifdef TEST + printf ("%s\n", topdir); +#endif + if (strnicmp (&topdir[i - 3], "/pk", 3) != 0) { + strcat (topdir, "/pk"); + if (!is_dir(topdir)) { + if (make_dir(topdir)) { + fprintf(stderr, "Faild to access %s.\n", topdir); + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + } + } + strcpy (buff, topdir); + free(topdir); + } else { + if((topdir = kpse_var_value("TEXMFVAR")) != NULL) { + for (i = 0; topdir[i]; i++) { + if (isknj (topdir[i])) { + if(topdir[i+1]) i++; + continue; + } + if (topdir[i] == '\\') + topdir[i] = '/'; + } + i = strlen (topdir); + while(topdir[i - 1] == '/') + i--; + topdir[i] = '\0'; + + if(!is_dir(topdir)) { + if(make_dir_p(topdir)) { + fprintf(stderr, "Failed to access %s.\n", topdir); + return NULL; + } + } + + strcpy(buff, topdir); + free(topdir); + } + + strcat (buff, "/fonts"); + if (!is_dir (buff)) { + if (make_dir (buff)) { + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + } + strcat (buff, "/"); + strcat (buff, spec); + if (!is_dir (buff)) { + if (make_dir (buff)) { + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + } + } + + if (ispk) { + strcat (buff, "/"); + strcat (buff, av[3]); + if (!is_dir (buff)) { + if (make_dir (buff)) { + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + } + } + + for (i = Num; i > -1; i--) { + strcat (buff, "/"); + strcat (buff, pb[i]); + if (is_dir (buff)) + continue; + else { + if (make_dir (buff)) { + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + return (NULL); + } + } + } + + for (k = 0; k < NUMBUF; k++) + free (pb[k]); + + p = buff; + return p; +} + +#ifdef TEST +int +main (int ac, char *av[]) +{ + kpse_set_program_name (av[0], "getdestdir"); + printf ("%s", getdestdir (ac, av)); + return 0; +} +#endif diff --git a/Build/source/texk/kpathsea/win32/getdestdir.h b/Build/source/texk/kpathsea/win32/getdestdir.h new file mode 100644 index 00000000000..e60dc86f5b8 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/getdestdir.h @@ -0,0 +1,3 @@ +extern int is_dir (char *buff); +extern int make_dir (char *buff); +extern char *getdestdir (int ac, char **av); diff --git a/Build/source/texk/kpathsea/win32/mktexmf.c b/Build/source/texk/kpathsea/win32/mktexmf.c new file mode 100644 index 00000000000..df7f6f28c59 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktexmf.c @@ -0,0 +1,360 @@ +/* + * mktexmf.c (Borrowed from Fabrice) + * (2006 --ak) + * +*/ + +#include <kpathsea/kpathsea.h> +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <fcntl.h> +#include <io.h> +#include <string.h> +#include <ctype.h> + +#include "getdestdir.h" +#include "mktexupd.h" + +#define SBUF 256 + +char *progname; + +static int +test_file(char c, char * name) +{ +/* + * c= 'z', 'f', 'd', 'r' + * +*/ + FILE *fp; + + if (c == 'z') { + if (name == NULL) return 1; + else if (*name == '\0') return 1; + else if (_access(name, 0) != 0) return 1; + else if ((fp = (FILE *)fopen(name, "r")) == NULL) return 1; + else if (_filelength(_fileno(fp)) == 0L) { + fclose(fp); + return 1; + } + else { + fclose(fp); + return 0; + } + } + else if (c == 'f') { + if (name == NULL) return 0; + else if (*name == '\0') return 0; + else if (_access(name, 0) != 0) return 0; + else return 1; + } + else if (c == 'd') { + if (is_dir(name)) return 1; + else return 0; + } + else if (c == 'r') { + if (_access(name, 4) == 0) return 1; + else return 0; + } + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "Usage : mktexmf FONT.\n\n"); + fprintf(stderr, "Makes the Metafont source file for FONT," + " if possible. For example,\n"); + fprintf(stderr, "`ecr12' or `cmr11'.\n"); +} + +/* + * Split a .mf name into root part and point size part. + * Root and point size are optional (may be NULL). + */ + +static void +split_mf_name(string name, string *base, string *root, string *ptsize) +{ + string p, q; + /* name = basename $1 .mf */ + p = strrchr (name, '.'); + if (p) { + if (stricmp (p, ".mf") == 0) *p = '\0'; + } + p = name; + + if (base) + *base = xstrdup(p); + /* rootname = `echo $name | sed 's/[0-9]*$//'` */ + for (q = p + strlen(p); q > p && isdigit(q[-1]); q--); + /* ptsize = `echo $name | sed 's/^$rootname//'` */ + if (ptsize) + *ptsize = xstrdup(q); + *q = '\0'; + if (root) + *root = p; + else + free(p); +} + +static void +relmem (char **v) +{ + int j; + for (j = 0; j < 4; j++) + free (v[j]); + return; +} + +int +main (int argc, char **argv) +{ + string rootname, pointsize; + const_string realsize; + string name; + string sauterroot, rootfile; + string destdir = NULL; + FILE *f; + size_t ptsz_len; + char font[SBUF]; + char mfname[SBUF]; + char *arg[4]; + int i; + char *ptr; + + progname = argv[0]; + kpse_set_program_name (progname, NULL); + if (argc != 2) { + usage(); + return 0; + } + + for (i=0; i < 4; i++) { + arg[i] = (char *)malloc(SBUF); + } + + if(strlen(argv[1]) > SBUF - 1) { + fprintf(stderr, "\nToo long a font name.\n"); + return 100; + } + + strcpy (font, argv[1]); + + split_mf_name(font, &name, &rootname, &pointsize); + + + fprintf(stderr, "name = %s, rootname = %s, pointsize = %s\n", + name, rootname, pointsize); + + + sauterroot = kpse_find_file(concat3("b-", rootname, ".mf"), + kpse_mf_format, false); + + if (sauterroot && *sauterroot) { + rootfile = sauterroot; + rootname = concat("b-", rootname); + strcpy (arg[0], "Dummy"); + strcpy (arg[1], "source"); + strcpy (arg[2], sauterroot); + if (!(ptr = getdestdir (3, arg))) { + fprintf(stderr, "Cannot get destination directory name.\n"); + relmem (arg); + return 100; + } + destdir = ptr; + } + else if (strlen(name) == 8 + && FILESTRNCASEEQ(name, "csso12", 6) + && (name[6] >= '0' && name[6] <= '5') + && isdigit(name[7])) { + rootfile = xstrdup(""); + } + else if (FILESTRNCASEEQ(rootname, "cs", 2) + || FILESTRNCASEEQ(rootname, "lcsss", 5) + || FILESTRNCASEEQ(rootname, "icscsc", 6) + || FILESTRNCASEEQ(rootname, "icstt", 5) + || FILESTRNCASEEQ(rootname, "ilcsss", 6) + ) { + rootfile = kpse_find_file("cscode.mf", + kpse_mf_format, false); + } + else if (strlen(rootname) >= 3 + && ((FILESTRNCASEEQ(rootname, "wn", 2) + && strchr("bBcCdDfFiIrRsStTuUvV", rootname[2])) + || (FILESTRNCASEEQ(rootname, "rx", 2) + && strchr("bBcCdDfFiIoOrRsStTuUvVxX", rootname[2]) + && strlen(rootname) >= 4 + && strchr("bBcCfFhHiIlLmMoOsStTxX", rootname[3])) + || ((rootname[0] == 'l' || rootname[0] == 'L') + && strchr("aAbBcCdDhHlL", rootname[1]) + && strchr("bBcCdDfFiIoOrRsStTuUvVxX", rootname[2])))) { + char lhprefix[64]; + strncpy(lhprefix, name, 2); + lhprefix[2] = '\0'; + strcat(lhprefix, "codes.mf"); + rootfile = kpse_find_file(lhprefix, kpse_mf_format, false); + } + else { + string tem; + rootfile = kpse_find_file(tem = concat(rootname, ".mf"), + kpse_mf_format, false); + free(tem); + } + + if (test_file('z', rootfile)) { + fprintf (stderr, "%s: empty or non-existent rootfile!\n", progname); + relmem (arg); + return 1; + } + if (!test_file('f', rootfile)) { + fprintf (stderr, "%s: rootfile %s does not exist!\n", progname, rootfile); + relmem (arg); + return 1; + } + + if (!destdir) { + if (rootfile && *rootfile) { + strcpy (arg[0], "Dummy"); + strcpy (arg[1], "source"); + strcpy (arg[2], rootfile); + if (!(ptr = getdestdir (3, arg))) { + fprintf(stderr, "Cannot get destination directory name.\n"); + relmem (arg); + return 1; + } + destdir = ptr; + } + } + + if (!test_file('d', destdir)) { + relmem (arg); + return 1; + } + + ptsz_len = strlen(pointsize); + if (ptsz_len == 0) { + fprintf(stderr, "%s: no pointsize.\n", progname); + relmem (arg); + return 1; + } else if (ptsz_len == 2) { + if (pointsize[0] == '1' && pointsize[1] == '1') + realsize = "10.95"; /* \magstephalf */ + else if (pointsize[0] == '1' && pointsize[1] == '4') + realsize = "14.4"; /* \magstep2 */ + else if (pointsize[0] == '1' && pointsize[1] == '7') + realsize = "17.28"; /* \magstep3 */ + else if (pointsize[0] == '2' && pointsize[1] == '0') + realsize = "20.74"; /* \magstep4 */ + else if (pointsize[0] == '2' && pointsize[1] == '5') + realsize = "24.88"; /* \magstep5 */ + else if (pointsize[0] == '3' && pointsize[1] == '0') + realsize = "29.86"; /* \magstep6 */ + else if (pointsize[0] == '3' && pointsize[1] == '6') + realsize = "35.83"; /* \magstep7 */ + else + realsize = pointsize; + } + /* The new convention is to have three or four letters for the + font name and four digits for the pointsize. The number is + pointsize * 100. We effectively divide by 100 by inserting a + dot before the last two digits. */ + else if (ptsz_len == 4 || ptsz_len == 5) { + /* realsize=`echo "$pointsize" | sed 's/\(..\)$/.\1/'` */ + string tempsize = (string)xmalloc(ptsz_len + 2); + strcpy(tempsize, pointsize); + /* The script doesn't check for last chars being digits, but we do! */ + if (isdigit(tempsize[ptsz_len-1]) + && isdigit(tempsize[ptsz_len-2])) { + tempsize[ptsz_len+1] = '\0'; + tempsize[ptsz_len] = tempsize[ptsz_len-1]; + tempsize[ptsz_len-1] = tempsize[ptsz_len-2]; + tempsize[ptsz_len-2] = '.'; + free(pointsize); + } + realsize = tempsize; + } else realsize = pointsize; + +/* mfname is the full name */ + strcpy (mfname, destdir); + i = strlen (mfname); + if (mfname[i-1] != '/') { + mfname[i] = '/'; + mfname[i+1] = '\0'; + } + + strcat (mfname, name); + strcat (mfname, ".mf"); + + if (test_file('r', mfname)) { + fprintf(stderr, "%s: %s already exists.\n", progname, mfname); + fprintf(stdout, "%s\n", mfname); + if (destdir) free (destdir); + relmem (arg); + return 0; + } + + if ((f = fopen(mfname, "wb")) == NULL) { + fprintf(stderr, "%s: can't write into the file %s/%s.\n", + progname, destdir, name); + if (destdir) free (destdir); + relmem (arg); + return 1; + } + + if (FILESTRNCASEEQ(name, "ec", 2) + || FILESTRNCASEEQ(name, "tc", 2)) { + fprintf(f, "if unknown exbase: input exbase fi;\n"); + fprintf(f, "gensize:=%s;\ngenerate %s;\n", realsize, rootname); + } + else if (FILESTRNCASEEQ(name, "dc", 2)) { + fprintf(f, "if unknown dxbase: input dxbase fi;\n"); + fprintf(f, "gensize:=%s;\ngenerate %s;\n", realsize, rootname); + + } + else if (FILESTRNCASEEQ(name, "cs", 2) + || FILESTRNCASEEQ(name, "lcsss", 5) + || FILESTRNCASEEQ(name, "icscsc", 6) + || FILESTRNCASEEQ(name, "icstt", 5) + || FILESTRNCASEEQ(name, "ilcsss", 6) + ) { + fprintf(f, "input cscode\nuse_driver;\n"); + } + else if (strlen(name) >= 3 + && ((FILESTRNCASEEQ(name, "wn", 2) + && strchr("bBcCdDfFiIrRsStTuUvV", name[2])) + || (FILESTRNCASEEQ(name, "rx", 2) + && strchr("bBcCdDfFiIoOrRsStTuUvVxX", name[2]) + && strlen(name) >= 4 + && strchr("bBcCfFhHiIlLmMoOsStTxX", name[3])) + || ((name[0] == 'l' || name[0] == 'L') + && strchr("aAbBcCdDhHlL", name[1]) + && strchr("bBcCdDfFiIoOrRsStTuUvVxX", name[2])))) { + fprintf(f, "input fikparm;\n"); + } + else if (strlen(name) >= 4 && strchr("gG", name[0]) + && strchr("lLmMoOrRsStT", name[1]) + && strchr("bBiIjJmMtTwWxX", name[2]) + && strchr("cCiIlLnNoOrRuU", name[3])) { + /* A small superset of the names of the cbgreek fonts: + pattern `g[lmorst][bijmtwx][cilnou]*'. + This is only slightly more general than the exact set of patterns. + */ + fprintf(f, "gensize:=%s;\ninput %s;\n", realsize, rootname); + } + else { + /* FIXME: this was in the previous versions */ + /* fprintf(f, "if unknown %s: input %s fi;\n", base, base); */ + fprintf(f, "design_size := %s;\ninput %s;\n", + realsize, rootname); + } + + fclose(f); + fprintf(stdout, "%s\n", mfname); + fprintf(stderr, "%s: %s: successfully generated.\n", progname, mfname); + mktexupd (mfname); + if (destdir) free (destdir); + relmem (arg); + return 0; +} diff --git a/Build/source/texk/kpathsea/win32/mktexpk.c b/Build/source/texk/kpathsea/win32/mktexpk.c new file mode 100644 index 00000000000..5445dfb4eac --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktexpk.c @@ -0,0 +1,1263 @@ +/* mktexpk.c (Web2C-7.5.5 --ak 2006) + * %%---------------------------------------- + * % Special variables for mktexpk ( W32TeX ) + * % ---------------------------------------- + * % MAKETEXPK_STYLE = dosnames + * % ----------------------------------------- + * % MAKETEXPK_TOP_DIR = $VARTEXFONTS + * % ----------------------------------------- + * % MAKETEXPK_MODE = canonex + * % ----------------------------------------- + * % MAKETEXPK_MODE_300 = cx + * % MAKETEXPK_MODE_400 = nexthi + * % MAKETEXPK_MODE_600 = canonex + * % etc. + * %%----------------------------------------- + * + * Usage: mktexpk [OPTIONS] name, + * Create a PK font. + * + * --dpi DPI use resolution DPI. + * --bdpi BDPI use base resolution BDPI. + * --mag MAG use magnificiation MAG. + * --mfmode MODE use MODE as the METAFONT mode. + * --destdir DESTDIR write fonts in DESTDIR (absolute path). + * + * The following old form is also supported: + * Usage: mktexmk name dpi bdpi mag [mode] + */ + +#include <kpathsea/kpathsea.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <fcntl.h> +#include <direct.h> +#include <io.h> +#include <malloc.h> +#include <process.h> +#include <direct.h> + +#include "getdestdir.h" +#include "mktexupd.h" + +#define WINWEB2CVERSION "Web2C-2011" +#define WINKPSEVERSION " Kpathsea-6.0.1" + +#define LLBUF 1024 +#define LBUF 512 +#define SBUF 256 +#define TBUF 256 + +/* +Global variables +*/ + +char *progname; +int UseAspectRatio = 0; +int FileName = 0; +double AspectRatio = 1.0; + +#define BBUFF_FUL 253 +#define FFILE_END 254 +#define LLINE_END 255 + +static int +ffgets(char *buf, int size, FILE *fi) +{ + char *p; + int c; + int n; + + n = 0; + p = buf; + *p = '\0'; + + while(1) { + c = getc(fi); + if(c == 26) + continue; + n++; + if(c == EOF) { + n++; + *p++ = '\n'; + *p = '\0'; + return FFILE_END; + } + else if(c == 0x0d || c == 0x0a) { + n++; + *p++ = '\n'; + *p = '\0'; + if(c == 0x0d) { + c = getc(fi); + if(c != 0x0a) + ungetc(c, fi); + } + return LLINE_END; + } + else if(n == (size - 3)) { + *p++ = c; *p = '\0'; + return BBUFF_FUL; + } + else *p++ = c; + } +} + +static int +isskip(char c) +{ + if((c == ' ') || (c == '\t')) + return 1; + else if((c == '<') || (c == '[')) { + FileName = 1; + return 1; + } + else + return 0; +} + +static void +skipchar(char **p) +{ + while(isskip(**p)) + (*p)++; +} + +static void +version (void) +{ + fprintf (stderr, "%s, (C version 1.5 --ak 2006-2011)\n", progname); + fprintf (stderr, WINWEB2CVERSION WINKPSEVERSION "\n"); +} + +static void +usage (void) +{ + fprintf (stderr, "Usage: %s [OPTIONS] NAME,\n\ + Create a PK font.\n\n\ +--dpi DPI use resolution DPI.\n\ +--bdpi BDPI use base resolution BDPI.\n\ +--mag MAG use magnificiation MAG.\n\ +--mfmode MODE use MODE as the METAFONT mode.\n\ +--destdir DESTDIR write fonts in DESTDIR.\n", progname); +} + +static void +help (void) +{ + fprintf (stderr, "Usage: %s [OPTIONS] NAME,\n\ + Create a PK font.\n\n\ +--dpi DPI use resolution DPI.\n\ +--bdpi BDPI use base resolution BDPI.\n\ +--mag MAG use magnificiation MAG.\n\ +--mfmode MODE use MODE as the METAFONT mode.\n\ +--destdir DESTDIR write fonts in DESTDIR.\n\n\ +Try to create a PK file for NAME at resolution DPI, with an assumed\n\ +device base resolution of BDPI, and a Metafont `mag' of MAG. Use MODE\n\ +for the METAFONT mode. Use DESTDIR for the root of where to install\n\ +into. DESTDIR must be an absolute directory name. If DESTDIR is not given,\n\ +suitable directory is determined according to the TDS.\n\n\ +Old form:\n\ +Usage: %s name dpi bdpi mag [mode]\n\ +is also supported.", progname, progname); +} + + +static void +tpkerr (const char *s) +{ + fprintf (stderr, "%s\n", s); +} + + +static void +relmem (char **v) +{ + int j; + for (j = 0; j < 4; j++) + free (v[j]); + return; +} + + +int +main (int ac, char **av) +{ + static char execfile[SBUF]; + char rbuff[LBUF]; + char buff[LBUF]; + char cmd[LBUF]; + char mfname[TBUF]; + char tfname[TBUF]; + char pkname[TBUF]; + + char name[TBUF]; + char dpi[TBUF]; + char ydpi[TBUF]; + char bdpi[TBUF]; + char mag[TBUF]; + char mode[TBUF]; + char destdir[SBUF]; + + char *arg[4]; + + char currdir[SBUF]; + char kpsedot[SBUF]; + char *tmp; + int cdrive, tdrive; + + FILE *fr, *fw, *fnul, *tfmfileptr; + + int i, savo, savi, ret; + int style; + int issetdest; + int app; + int oldform; + int ps2pkok; + char *env; + char *p, *fpp; + + double Xdpi, Ydpi; + + char texname[TBUF], pfbname[TBUF], slant[TBUF], extend[TBUF], encname[TBUF]; + + char texbindir[256]; + char fullbin[512]; + +/* + * style = 0 : MAKETEXPK_STYLE undefined or other than dosnames + * style = 1 : MAKETEXPK_STYLE = dosnames + */ + +/* + * issetdest = 0 : no destdir + * issetdest = 1 : destdir + * issetdest = 2 : current working dir + */ + +/* + * app = 0 : mf + * app = 1 : ps2pk + * app = 2 : gsftopk + * app = 3 : ttf2pk + * app = 4 : hbf2gf + */ + +/* + * oldform = 0 : newform of the command line + * oldform = 1 : oldform of the command line + */ + +/* + * TEMP | TMP | TMPDIR (necessary) + * + */ + + tmp = getenv ("TEMP"); + if (!tmp) + getenv ("TMP"); + if (!tmp) + getenv ("TMPDIR"); + if (!tmp) { + tpkerr ("Please define TEMP | TMP | TMPDIR."); + return (100); + } + tmp = xstrdup(tmp); +/* + * normalize directory separators + */ + + for (fpp = tmp; *fpp; fpp++) { + if (isknj (*fpp)) { + if(*(fpp+1)) fpp++; + continue; + } + if (*fpp == '\\') + *fpp = '/'; + } + + for (i = 0; i < 4; i++) + arg[i] = (char *) malloc (SBUF); + + progname = av[0]; + kpse_set_program_name (progname, NULL); + +/* + * get tex binary dir + * + */ + p = kpse_var_value("SELFAUTOLOC"); + if(p == 0) { + fprintf(stderr, "I cannot get SELFAUTOLOC\n"); + exit(100); + } + strcpy(texbindir, p); + free(p); + for(p=texbindir; *p; p++) { + if(*p == '/') *p = '\\'; + } + *p = '\\'; + *(p+1) = '\0'; + + if (ac < 2) { + usage (); + relmem (arg); + return (100); + } + + issetdest = 0; + ps2pkok = 0; + +/* + * oldform or newform ? + * + */ + + if (av[1][0] == '-') + oldform = 0; + else + oldform = 1; + + +/* + * Old form of the command line + */ + + if (oldform == 1) { + if (ac < 5) { + usage (); + relmem (arg); + return (100); + } + if((strlen(av[1]) > TBUF -1 ) || + (strlen(av[2]) > TBUF -1 ) || + (strlen(av[3]) > TBUF -1 ) || + (strlen(av[4]) > TBUF -1 )) { + fprintf(stderr, "\nToo long a string.\n"); + return 100; + } + + strcpy (name, av[1]); + strcpy (dpi, av[2]); + strcpy (bdpi, av[3]); + strcpy (mag, av[4]); + if (ac > 5) { + if(strlen(av[5]) > TBUF -1) { + fprintf(stderr, "\nToo long a string.\n"); + return 100; + } + strcpy (mode, av[5]); + } + else + mode[0] = '\0'; + } else { +/* + * New form of the command line + */ + name[0] = dpi[0] = bdpi[0] = mag[0] = mode[0] = destdir[0] = '\0'; + i = 1; + while (i < ac) { + if(strlen(av[i]) > TBUF - 1) { + fprintf(stderr, "\nToo long a string.\n"); + return 100; + } + if (av[i][0] != '-') { + strcpy (name, av[i]); + break; + } + if (!strcmp (av[i], "--dpi") || !strcmp (av[i], "-dpi")) { + i++; + if (i >= ac) { + tpkerr ("Invarid arguments."); + relmem (arg); + return (100); + } + strcpy (dpi, av[i]); + i++; + } else if (!strcmp (av[i], "--bdpi") || !strcmp (av[i], "-bdpi")) { + i++; + if (i >= ac) { + tpkerr ("Invarid arguments."); + relmem (arg); + return (100); + } + strcpy (bdpi, av[i]); + i++; + } else if (!strcmp (av[i], "--mag") || !strcmp (av[i], "-mag")) { + i++; + if (i >= ac) { + tpkerr ("Invarid arguments."); + relmem (arg); + return (100); + } + strcpy (mag, av[i]); + i++; + } else if (!strcmp (av[i], "--mfmode") || !strcmp (av[i], "-mfmode")) { + i++; + if (i >= ac) { + tpkerr ("Invarid arguments."); + relmem (arg); + return (100); + } + strcpy (mode, av[i]); + i++; + } else if (!strcmp (av[i], "--destdir") || !strcmp (av[i], "-destdir")) { + i++; + if (i >= ac) { + tpkerr ("Invarid arguments."); + relmem (arg); + return (100); + } + strcpy (destdir, av[i]); + issetdest = 1; + i++; + } else if (!strcmp (av[i], "--version") || !strcmp (av[i], "-version")) { + version (); + relmem (arg); + return (0); + } else if (!strcmp (av[i], "--help") || !strcmp (av[i], "-help")) { + help (); + relmem (arg); + return (0); + } else { + tpkerr ("Argument error."); + relmem (arg); + return (100); + } + } + } /* End of command line analysis */ + + env = kpse_var_value ("MAKETEXPK_STYLE"); + + if ((env == NULL) || !(*env) || (env && strcmp (env, "dosnames"))) { + style = 0; + } else + style = 1; + +/* + * Default program is mf + */ + + app = 0; + +/* + * check if mfmode and bdpi are consistent or not + */ + + if (bdpi[0] && mode[0] && mode[0] != '/') { + FILE *frd; + char buff[128]; + int len; + + strcpy (fullbin, texbindir); + strcat (fullbin, "mf-nowin.exe \"\\mode:="); + strcat (fullbin, mode); + strcat (fullbin, ";mode_setup;message"); + strcat (fullbin, "(decimal round pixels_per_inch);"); + strcat (fullbin, "end. <nul\""); + + frd = popen (fullbin, "r"); + if (!frd) { + tpkerr ("I cannot find METAFONT.\n"); + relmem (arg); + return (100); + } + (void) fgets (buff, 126, frd); + (void) fgets (buff, 126, frd); + pclose (frd); + remove ("mfput.log"); + remove ("mfput.tfm"); + + len = strlen (buff); + if (buff[len - 1] == '\n') + buff[len - 1] = '\0'; + if (strcmp (bdpi, buff)) { + fprintf(stderr, "mode_dpi %s and bdpi %s are inconsistent.\n", buff, bdpi); + fprintf(stderr, "therefore I reset mfmode.\n"); + mode[0] = '\0'; + } + } + +/* + * determine mfmode if not given + */ + + if (mode[0] == 0 || mode[0] == '/') { + if (bdpi[0] == 0) { + tpkerr ("Cannot determine the mode."); + tpkerr ("I will try other possibilities."); + app = 1; + } else { + strcpy (rbuff, "MAKETEXPK_MODE_"); + strcat (rbuff, bdpi); + if ((env = kpse_var_value ("MAKETEXPK_MODE")) && *env) + strcpy (mode, env); + else if ((env = kpse_var_value (rbuff))) + strcpy (mode, env); + else if (!strcmp (bdpi, "85")) + strcpy (mode, "sun"); + else if (!strcmp (bdpi, "100")) + strcpy (mode, "nextscrn"); + else if (!strcmp (bdpi, "118")) + strcpy (mode, "pcprevw"); + else if (!strcmp (bdpi, "160")) + strcpy (mode, "nectzo"); + else if (!strcmp (bdpi, "180")) + strcpy (mode, "toshiba"); + else if (!strcmp (bdpi, "200")) + strcpy (mode, "highfax"); + else if (!strcmp (bdpi, "240")) + strcpy (mode, "canonlbp"); + else if (!strcmp (bdpi, "300")) + strcpy (mode, "cx"); + else if (!strcmp (bdpi, "320")) + strcpy (mode, "neclm"); + else if (!strcmp (bdpi, "360")) + strcpy (mode, "epstylus"); + else if (!strcmp (bdpi, "400")) + strcpy (mode, "nexthi"); + else if (!strcmp (bdpi, "600")) + strcpy (mode, "ljfour"); + else if (!strcmp (bdpi, "720")) + strcpy (mode, "epscszz"); + else if (!strcmp (bdpi, "800")) + strcpy (mode, "lwpro"); + else if (!strcmp (bdpi, "1000")) + strcpy (mode, "lmaster"); + else if (!strcmp (bdpi, "1200")) + strcpy (mode, "ultre"); + else if (!strcmp (bdpi, "1270")) + strcpy (mode, "linoone"); + else if (!strcmp (bdpi, "1800")) + strcpy (mode, "vtftzz"); + else if (!strcmp (bdpi, "2400")) + strcpy (mode, "supre"); + else if (!strcmp (bdpi, "2540")) + strcpy (mode, "linotzzh"); + else if (!strcmp (bdpi, "3386")) + strcpy (mode, "linolttz"); + else if (!strcmp (bdpi, "8000")) + strcpy (mode, "dpdfezzz"); + else if (!strcmp (bdpi, "9600")) + strcpy (mode, "ibx"); + else { + tpkerr ("Cannot determine the mode."); + tpkerr ("I will try other possibilities."); + app = 1; + } + } + } + + if (env) free (env); + + if (name[0] == 0) { + tpkerr ("Font name is not given."); + relmem (arg); + return (100); + } + + if ((p = strrchr (name, '.'))) + *p = '\0'; + + strcpy (mfname, name); + strcat (mfname, ".mf"); + + if (app == 0) { + if (!(p = kpse_var_value ("MFINPUTS"))) { + tpkerr ("Cannot get value of MFINPUTS."); + relmem (arg); + return (100); + } + free (p); + xputenv("MKTEXMF", "1"); + if (!(p = kpse_find_file (mfname, kpse_mf_format, 1))) { + fprintf (stderr, "Cannot find %s .\n", mfname); + tpkerr ("I try ps2pk --> gsftopk --> ttf2pk --> hbf2gf."); + app = 1; + } + } + + if (app != 0) { + strcpy (mode, "modeless"); + strcpy (tfname, name); + strcat (tfname, ".tfm"); + if (!(p = kpse_var_value ("TFMFONTS"))) { + tpkerr ("Cannot get value of TFMFONTS."); + relmem (arg); + return (100); + } + free (p); +/* + I don't try to create nonexisting tfm here. +*/ + if (!(p = kpse_find_file (tfname, kpse_tfm_format, 0))) { + fprintf (stderr, "Cannot find %s .\n", tfname); + relmem (arg); + return 100; + } + tfmfileptr = fopen (p, "rb"); + if (!tfmfileptr) { + fprintf (stderr, "I cannot open %s.\n", p); + relmem (arg); + return 100; + } + i = 256 * getc (tfmfileptr); + i += getc (tfmfileptr); + fclose (tfmfileptr); + if ((i == 9) || (i == 11)) { + fprintf (stderr, "Current font seems to be a Japanese one.\n"); + fprintf (stderr, "I give up to create a PK font.\n"); + relmem (arg); + return 100; + } + } + + if ((p[0] == '.') && (p[1] == '/') && (issetdest != 1)) + issetdest = 2; + + fpp = _getcwd (currdir, SBUF); + if (!fpp) { + fprintf (stderr, "Failed to get current working directory.\n"); + relmem (arg); + return (100); + } + for (fpp = currdir; *fpp; fpp++) { + if (isknj (*fpp)) { + if(*(fpp+1)) fpp++; + continue; + } + if (*fpp == '\\') + *fpp = '/'; + } + + i = strlen (currdir); + if (currdir[i - 1] == '/') + currdir[i - 1] = '\0'; + + strcpy (kpsedot, "KPSE_DOT=.;"); + strcat (kpsedot, currdir); + _putenv (kpsedot); + + if (issetdest == 2) { + strcpy (destdir, currdir); + } + + if (issetdest == 0) { + strcpy (arg[0], "Dummy"); + strcpy (arg[1], "pk"); + strcpy (arg[2], p); + strcpy (arg[3], mode); + + if (!(p = getdestdir (4, arg))) { + tpkerr ("Cannot get destination directory name."); + relmem (arg); + return (100); + } + strcpy (rbuff, p); + } else + strcpy (rbuff, destdir); + +/* + * Change backslash into slash + */ + + for (p = rbuff; *p; p++) { + if (isknj (*p)) { + if(*(p+1)) p++; + continue; + } + if (*p == '\\') + *p = '/'; + } + + p = rbuff; + i = strlen (p); + if (p[i - 1] == '/') + p[i - 1] = '\0'; + + if (issetdest) { + if (!is_dir (p)) { + fprintf (stderr, "Destination %s is not found.\n", p); + relmem (arg); + return (100); + } + } else if (!is_dir (p)) { + if (make_dir (p)) { + tpkerr ("Error in make_dir."); + relmem (arg); + return (100); + } + } + + strcpy (buff, p); + p = buff; + + i = strlen (p); + + if (p[i - 1] != '/') + strcat (p, "/"); + + if (dpi[0] == 0) { + tpkerr ("Cannot determine DPI."); + relmem (arg); + return (100); + } + + if (style == 1 && issetdest != 2) { /* dosnames */ + strcat (p, "dpi"); + strcat (p, dpi); + if (!is_dir (p)) { + if (make_dir (p)) { + tpkerr ("Error in make_dir."); + relmem (arg); + return (100); + } + } + strcat (p, "/"); + } + + strcat (p, name); + strcat (p, "."); + + if (style != 1 || issetdest == 2) + strcat (p, dpi); /* long suffix */ + strcat (p, "pk"); + +/* Now buff and p is the full path name of pk file */ +/* check the existence of pk file */ + + if (_access (p, 0) == 0) { + fprintf (stderr, "%s exists.\n", p); + relmem (arg); + printf ("%s\n", p); + return (0); + } + +/* + * Go to the temporary directory + */ + + cdrive = _getdrive (); + if (tmp[1] == ':') { + tdrive = tolower (*tmp) - 'a' + 1; + _chdrive (tdrive); + } + _chdir (tmp); + +/* + * save stdout and stdin + */ + savo = _dup (fileno (stdout)); + savi = _dup (fileno (stdin)); + +/* + * connect stdout to stderr +*/ + _dup2 (fileno (stderr), fileno (stdout)); + +/* + * connect stdin to nul + */ + if (!(fnul = fopen ("nul", "rb"))) { + fprintf (stderr, "Cannot open nul device to read.\n"); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + _dup2 (fileno (fnul), fileno (stdin)); + +/* + * pkname is the filename of PK font + */ + sprintf (pkname, "%s.%spk", name, dpi); + + if (app == 0) { +/* + * METAFONT command line + */ + if (mag[0] == 0) { + tpkerr ("Cannot determine MAG."); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + sprintf (cmd, + "--progname=mf --base=mf \\mode:=%s; \\mag:=%s; nonstopmode; input %s;", + mode, mag, name); + + strcpy (execfile, "mf-nowin.exe"); + fprintf (stderr, "%s %s\n", execfile, cmd); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, cmd, NULL); + + sprintf (cmd, "%s.%sgf", name, dpi); + +/* + * check the consistency + */ + if (_access (cmd, 0) != 0) { + tpkerr ("Failed to make gf font by METAFONT."); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + +/* + * Change gf into pk + */ + strcpy (execfile, "gftopk.exe"); + fprintf (stderr, "%s %s %s\n", execfile, cmd, pkname); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, cmd, pkname, NULL); + + if (_access (pkname, 0) != 0) { + tpkerr ("Failed to make pk from gf."); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + +/* + * erase gf file + */ + remove (cmd); + +/* + * erase log file + */ + sprintf (cmd, "%s.log", name); + remove (cmd); +/* + * erase tfm file + */ + sprintf (cmd, "%s.tfm", name); + remove (cmd); + + goto finale; + } + +/* + * app = 1 : ps2pk --> gsftopk --> ttf2pk --> hbf2gf + */ + + p = kpse_find_file ("pspksupp.map", kpse_fontmap_format, 0); + if(p) { + fr = fopen (p, "r"); /* Read pspksupp.map */ + free (p); + + if (!fr) { + tpkerr ("Cannot open pspksupp.map to read."); + ps2pkok = 0; + goto do_ps2pk; + } + + while (fgets (rbuff, SBUF, fr)) { + if (rbuff[0] == '%' || rbuff[0] == '#' || rbuff[0] == '\n') + continue; + texname[0] = pfbname[0] = slant[0] = extend[0] = encname[0] = '\0'; + i = sscanf (rbuff, "%s %s %s %s %s", texname, pfbname, slant, extend, + encname); + if (i == 2 && !strncmp (texname, "AspectRatio", 11)) { + if (!sscanf (pfbname, "%lf", &AspectRatio)) { + tpkerr ("File format of pspksupp.map is wrong."); + fclose (fr); + ps2pkok = 0; + goto do_ps2pk; + } + UseAspectRatio = 1; + continue; + } else if (i > 0 && !stricmp (texname, name)) { + p = kpse_var_value ("T1FONTS"); + if (!p) { + tpkerr ("T1FONTS is not defined."); + ps2pkok = 0; + break; + } + free (p); + p = kpse_find_file (pfbname, kpse_type1_format, 0); + if (!p) { + fprintf (stderr, "%s is not found.\n", pfbname); + ps2pkok = 0; + break; + } + free (p); + ps2pkok = 1; + if(bdpi[0] == 0) + i--; + break; + } + } + fclose (fr); + goto do_ps2pk; + } else { + char *q; + char a[SBUF]; + char b[SBUF]; + char psname[SBUF]; + char pscommand[SBUF]; + double slantval, extendval; + + texname[0] = pfbname[0] = encname[0] = '\0'; + a[0] = b[0] = psname[0] = pscommand[0] = '\0'; + FileName = 0; + strcpy(slant, "0"); + strcpy(extend, "1"); + + ps2pkok = 0; + + p = kpse_find_file ("ps2pk.map", kpse_fontmap_format, 0); + if(!p) { + tpkerr("Necessary map file for ps2pk is not found."); + goto do_ps2pk; + } + fr = fopen(p,"rb"); + free(p); + if (!fr) { + tpkerr ("Cannot open ps2pk.map to read."); + goto do_ps2pk; + } + while ((ret=ffgets (rbuff, LBUF, fr)) != FFILE_END) { + if(ret == BBUFF_FUL) { + fprintf(stderr, "A line in ps2pk.map seems to be too long.\n"); + fprintf(stderr, "I try to continue. But something may be wrong.\n"); + } + p = rbuff; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + continue; + q = texname; + while(!isskip(*p) && (*p != '\n')) + *q++ = *p++; + *q = '\0'; + if(stricmp(texname, name)) + continue; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) { + fprintf(stderr, "Incorrect line in \"ps2pk.map\".\n"); + break; + } + if(FileName) + q = a; + else + q = psname; + while(!isskip(*p) && (*p != '\n')) + *q++ = *p++; + *q = '\0'; + skipchar(&p); +/* +skip flag +*/ + if(!FileName) { + while(isdigit(*p)) + p++; + skipchar(&p); + } + if((*p == '%') || (*p == '#') || (*p == '\n')) { + tpkerr("I cannot use ps2pk due to lack of data."); + break; + } + if(*p == '\"') { + q = pscommand; + *q++ = *p++; + while(*p != '\"') + *q++ = *p++; + *q++ = *p++; + *q = '\0'; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + } + if(FileName && a[0] == '\0') + q = a; + else if(FileName && b[0] == '\0') + q = b; + else { + tpkerr("Incorrect line in ps2pk.map."); + break; + } + while(!isskip(*p) && (*p != '\n')) + *q++ = *p++; + *q = '\0'; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + if(*p == '\"') { + q = pscommand; + *q++ = *p++; + while(*p != '\"') + *q++ = *p++; + *q++ = *p++; + *q = '\0'; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + } + if (FileName && a[0] == '\0') + q = a; + else if (FileName && b[0] == '\0') + q = b; + else { + fprintf(stderr, "Incorrect line in \"ps2pk.map\".\n"); + break; + } + while(!isskip(*p) && (*p != '\n')) + *q++ = *p++; + *q = '\0'; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + if(*p == '\"') { + q = pscommand; + *q++ = *p++; + while(*p != '\"') + *q++ = *p++; + *q++ = *p++; + *q = '\0'; + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + } + skipchar(&p); + if((*p == '%') || (*p == '#') || (*p == '\n')) + break; + else { + fprintf(stderr, "Incorrect line in \"ps2pk.map\".\n"); + break; + } + } + fclose(fr); + + if(pscommand[0]) { + p = strstr(pscommand, "SlantFont"); + if(p) { + p--; + while(*p == ' ' || *p == '\t') p--; + while(*p != ' ' && *p != '\t' && *p != '\"') p--; + p++; + sscanf(p, "%lf SlantFont", &slantval); + sprintf(slant, "%lf", slantval); + p = slant + strlen(slant) - 1; + while(*p == '0') { + *p = '\0'; + p--; + } + } + p = strstr(pscommand, "ExtendFont"); + if(p) { + p--; + while(*p == ' ' || *p == '\t') p--; + while(*p != ' ' && *p != '\t' && *p != '\"') p--; + p++; + sscanf(p, "%lf ExtendFont", &extendval); + sprintf(extend, "%lf", extendval); + p = extend + strlen(extend) - 1; + while(*p == '0') { + *p = '\0'; + p--; + } + } + } + if(a[0]) { + p = strrchr(a, '.'); + if(p && !stricmp(p, ".enc")) { + *p = '\0'; + strcpy(encname, a); + } + else if(p && !stricmp(p, ".pfb")) { + *p = '\0'; + strcpy(pfbname, a); + } + } + if(b[0]) { + p = strrchr(b, '.'); + if(p && !stricmp(p, ".enc")) { + *p = '\0'; + strcpy(encname, b); + } + else if(p && !stricmp(p, ".pfb")) { + *p = '\0'; + strcpy(pfbname, b); + } + } + if(pfbname[0] == '\0') + goto do_ps2pk; + p = kpse_find_file (pfbname, kpse_type1_format, 0); + if(!p) + goto do_ps2pk; + free(p); + ps2pkok = 1; + if(encname[0] && bdpi[0]) { + i = 5; + } else if(!encname[0] && !bdpi[0]) { + i = 3; + } else { + i = 4; + } + } + + do_ps2pk: + + if (ps2pkok) { + if (UseAspectRatio) { + sscanf (dpi, "%lf", &Xdpi); + Ydpi = Xdpi * AspectRatio; + sprintf (ydpi, "%d", (int) Ydpi); + } else + strcpy (ydpi, dpi); + + if (i == 3) { + sprintf (cmd, "-X%s -Y%s -S%s -E%s %s %s", + dpi, ydpi, slant, extend, pfbname, pkname); + } else if (i == 4 && bdpi[0]) { + sprintf (cmd, "-X%s -Y%s -R%s -S%s -E%s %s %s", + dpi, ydpi, bdpi, slant, extend, pfbname, pkname); + } else if (i == 4 && encname[0]) { + sprintf (cmd, "-e%s -X%s -Y%s -S%s -E%s %s %s", + encname, dpi, ydpi, slant, extend, pfbname, pkname); + } else if (i == 5) { + sprintf (cmd, "-e%s -X%s -Y%s -R%s -S%s -E%s %s %s", + encname, dpi, ydpi, bdpi, slant, extend, pfbname, pkname); + } else { + tpkerr ("File format of pspksupp.map is wrong."); + goto do_gsftopk; + } + + strcpy (execfile, "ps2pk.exe"); + fprintf (stderr, "%s %s\n", execfile, cmd); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, cmd, NULL); + + if (_access (pkname, 0) != 0) { + tpkerr ("ps2pk failed to make pk font."); + goto do_gsftopk; + } + goto finale; + } + +/* + * ps2pk is impossible to use + */ + + do_gsftopk: + + tpkerr ("ps2pk cannot be used."); + tpkerr ("I try gsftopk."); + app = 2; + + strcpy (execfile, "gsftopk.exe"); + fprintf (stderr, "%s %s %s\n", execfile, name, dpi); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, name, dpi, NULL); + + if (_access (pkname, 0) != 0) { + tpkerr ("gsftopk cannot be used."); + tpkerr ("Next I try ttf2pk."); + app = 3; + strcpy (execfile, "ttf2pk.exe"); + fprintf (stderr, "%s -q %s %s\n", execfile, name, dpi); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, "-q", name, dpi, NULL); + + if (_access (pkname, 0) != 0) { + tpkerr ("ttf2pk failed."); + tpkerr ("Finally I try hbf2gf."); + app = 4; + strcpy (execfile, "hbf2gf.exe"); + fprintf (stderr, "%s -q -p %s %s\n", execfile, name, dpi); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, "-q -p", name, dpi, NULL); + + sprintf (cmd, "%s.%sgf", name, dpi); + if (_access (cmd, 0) != 0) { + tpkerr ("All trials failed."); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + strcpy (execfile, "gftopk.exe"); + fprintf (stderr, "%s %s %s\n", execfile, cmd, pkname); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, cmd, pkname, NULL); + + if (_access (pkname, 0) != 0) { + tpkerr ("All trials failed."); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + remove (cmd); + } + } + + finale: + +/* + * return to original stdout and stdin + */ + _dup2 (savo, fileno (stdout)); + close (savo); + _dup2 (savi, fileno (stdin)); + close (savi); + +/* + * close nul device + */ + fclose (fnul); + +/* + * copy the pk file + */ + if (!(fr = fopen (pkname, "rb"))) { + fprintf (stderr, "Cannot open %s to read.\n", pkname); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + + if (!(fw = fopen (buff, "wb"))) { + fprintf (stderr, "Cannot open %s to write.\n", buff); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + + while ((i = fread (rbuff, 1, LBUF, fr))) + fwrite (rbuff, 1, i, fw); + + fclose (fr); + fclose (fw); + remove (pkname); + + relmem (arg); + +/* + * update ls-R if it exists + */ + mktexupd (buff); + +/* + * tell kpathsea + */ + + printf ("%s\n", buff); + _chdrive (cdrive); + _chdir (currdir); + + return (0); +} diff --git a/Build/source/texk/kpathsea/win32/mktextfm.c b/Build/source/texk/kpathsea/win32/mktextfm.c new file mode 100644 index 00000000000..4dfbac8123c --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktextfm.c @@ -0,0 +1,410 @@ +/* mktextfm.c + * Assumes the cx mode in mf.base . + * Usage: mktextfm [--destdir DESTDIR] name + * Web2C 7.3.7 (2001/12/29 --ak) + * not change current dir to tmp (2002/10/05 --ak) + * Web2C 7.5.2 (2003/02/20 --ak) + * change current dir to tmp. + */ + +#define WINWEB2CVERSION "Web2C-2011" +#define WINKPSEVERSION " Kpathsea-6.0.1" + +#include <kpathsea/kpathsea.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <fcntl.h> +#include <direct.h> +#include <io.h> +#include <malloc.h> +#include <process.h> + +#include "getdestdir.h" +#include "mktexupd.h" + +#define LBUF 512 +#define SBUF 256 +#define TBUF 256 + +char *progname; + +static void +usage (void) +{ + fprintf (stderr, "Usage: %s [--destdir destdir] name\n", progname); + return; +} + +static void +version (void) +{ + fprintf (stderr, "%s, (C version 1.4 --ak 2009-2011)\n", progname); + fprintf (stderr, WINWEB2CVERSION WINKPSEVERSION "\n"); + return; +} + +static void +help (void) +{ + fprintf (stderr, "Usage (1): %s name\n", progname); + fprintf (stderr, " tfm is saved following TDS\n"); + fprintf (stderr, "Usage (2): %s --destdir destdir name\n", progname); + fprintf (stderr, " destdir must be an absolute path of dir\n"); + fprintf (stderr, "Usage (3): %s --version\n", progname); + fprintf (stderr, "Usage (4): %s --help\n", progname); + + return; +} + +static void +relmem (char **v) +{ + int j; + for (j = 0; j < 4; j++) + free (v[j]); + return; +} + +int +main (int ac, char **av) +{ + char rbuff[LBUF]; + char buff[SBUF]; + char savebuff[SBUF]; + char cmd[LBUF]; + char mffile[TBUF]; + char *arg[4]; + static char execfile[SBUF]; + + char kpsedot[SBUF]; + char currdir[SBUF]; + char *tmp; + int cdrive, tdrive; + + FILE *fr, *fw, *fnul; + + int i, savo, savi; + char *p, *fp, *fpp; + int issetdest; + char fontname[SBUF]; + + char texbindir[256]; + char fullbin[512]; + + progname = av[0]; + kpse_set_program_name (av[0], NULL); + +/* + * get tex binary dir + * + */ + p = kpse_var_value("SELFAUTOLOC"); + if(p == 0) { + fprintf(stderr, "I cannot get SELFAUTOLOC\n"); + exit(100); + } + strcpy(texbindir, p); + free(p); + for(p=texbindir; *p; p++) { + if(*p == '/') *p = '\\'; + } + *p = '\\'; + *(p+1) = '\0'; + + tmp = getenv ("TEMP"); + if (!tmp) + getenv ("TMP"); + if (!tmp) + getenv ("TMPDIR"); + if (!tmp) { + fprintf (stderr, "Please define TEMP | TMP | TMPDIR.\n"); + return (100); + } + + tmp = xstrdup(tmp); + + for (fpp = tmp; *fpp; fpp++) { + if (isknj (*fpp)) { + if(*(fpp+1)) fpp++; + continue; + } + if (*fpp == '\\') + *fpp = '/'; + } +/* +issetdest = 0 : TDS +issetdest = 1 : user setting +issetdest = 2 : current directory +*/ + + issetdest = 0; + + if (ac < 2) { + usage (); + return (100); + } + + if ((!strcmp (av[1], "--version")) || (!strcmp (av[1], "-version"))) { + version (); + return (100); + } + + if ((!strcmp (av[1], "--help")) || (!strcmp (av[1], "-help"))) { + help (); + return (100); + } + + for (i = 0; i < 4; i++) + arg[i] = (char *) malloc (SBUF); + + if ((!strcmp (av[1], "--destdir")) || (!strcmp (av[1], "-destdir"))) { + if (ac != 4) { + usage (); + relmem (arg); + return (100); + } + issetdest = 1; + strcpy (buff, av[2]); + strcpy (fontname, av[3]); + for (p = buff; *p; p++) { + if (isknj (*p)) { + if(*(p+1)) p++; + continue; + } + if (*p == '\\') + *p = '/'; + } + } else { + strcpy (fontname, av[1]); + } + + + /* fontname = font name + */ + if ((p = strrchr (fontname, '.'))) + *p = '\0'; + + /* mffile is METAFONT file name + */ + strcpy (mffile, fontname); + strcat (mffile, ".mf"); + + if (!(fp = kpse_var_value ("MFINPUTS"))) { + fprintf (stderr, "Cannot get value of MFINPUTS\n"); + relmem (arg); + return (100); + } + + free (fp); + + xputenv("MKTEXMF", "1"); + if (!(p = kpse_find_file (mffile, kpse_mf_format, 1))) { + fprintf (stderr, "Cannot find %s.\n", mffile); + relmem (arg); + return (100); + } + + fpp = _getcwd (currdir, SBUF); + if (!fpp) { + fprintf (stderr, "Failed to get current working directory.\n"); + relmem (arg); + return (100); + } + for (fpp = currdir; *fpp; fpp++) { + if (isknj (*fpp)) { + if(*(fpp+1)) fpp++; + continue; + } + if (*fpp == '\\') + *fpp = '/'; + } + + i = strlen (currdir); + if (currdir[i - 1] == '/') + currdir[i - 1] = '\0'; + strcpy (kpsedot, "KPSE_DOT=.;"); + strcat (kpsedot, currdir); + _putenv (kpsedot); + + if ((p[0] == '.') && (p[1] == '/') && (issetdest != 1)) { + issetdest = 2; + strcpy (buff, currdir); + } + + if (issetdest == 0) { + /* now path of ${name}.mf is in p */ + strcpy (arg[0], "Dummy"); + strcpy (arg[1], "tfm"); + strcpy (arg[2], p); + + if (!(p = getdestdir (3, arg))) { + fprintf (stderr, "Cannot get destination directory name.\n"); + relmem (arg); + return (100); + } + strcpy (buff, p); + } + +/* Now buff is the destdir */ + p = buff; + + i = strlen (p); + + if (p[i - 1] != '/') + strcat (p, "/"); + strcat (p, fontname); + strcat (p, ".tfm"); + +/* now p (or buff) is the full path name of the tfm font */ +/* check if it exists */ + if (_access (p, 0) == 0) { + fprintf (stderr, "%s exists\n", p); + printf ("%s\n", p); + relmem (arg); + return (0); + } + + cdrive = _getdrive (); + if (tmp[1] == ':') { + tdrive = tolower (*tmp) - 'a' + 1; + _chdrive (tdrive); + } + _chdir (tmp); + +/* save stdout and stdin */ + savo = _dup (fileno (stdout)); + savi = _dup (fileno (stdin)); + +/* connect stdout to stderr */ + _dup2 (fileno (stderr), fileno (stdout)); + +/* connect stdin to nul device */ + if (!(fnul = fopen ("nul", "r"))) { + fprintf (stderr, "Cannot open nul device to read\n"); + relmem (arg); + _chdrive (cdrive); + _chdir (currdir); + return (100); + } + _dup2 (fileno (fnul), fileno (stdin)); + +/* METAFONT command line */ + strcpy (cmd, "--progname=mf --base=mf "); + strcat (cmd, "\\mode:=ljfour; \\mag:=1; nonstopmode; input "); + strcat (cmd, fontname); + strcat (cmd, ";"); + + strcpy (execfile, "mf-nowin.exe"); + fprintf (stderr, "%s %s\n", execfile, cmd); + strcpy(fullbin, texbindir); + strcat(fullbin, execfile); + (void) spawnlp (P_WAIT, fullbin, execfile, cmd, NULL); + +/* return to original stdout and stdin */ + _dup2 (savo, fileno (stdout)); + close (savo); + _dup2 (savi, fileno (stdin)); + close (savi); + +/* close nul device */ + fclose (fnul); + +/* check consistency */ + strcpy (cmd, fontname); + strcat (cmd, ".600gf"); + + if (_access (cmd, 0) == -1) { + fprintf (stderr, "METAFONT failed to make gf font.\n"); + relmem (arg); + _chdrive (cdrive); + _chdir (currdir); + return (100); + } + + remove (cmd); + + strcpy (cmd, fontname); + strcat (cmd, ".tfm"); + +/* copy the tfm file */ + if (!(fr = fopen (cmd, "rb"))) { + fprintf (stderr, "Cannot open %s to read\n", cmd); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + if (!(fw = fopen (buff, "wb"))) { + fprintf (stderr, "Cannot open %s to write\n", buff); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + + while ((i = fread (rbuff, 1, LBUF, fr))) + fwrite (rbuff, 1, i, fw); + fclose (fr); + fclose (fw); + + strcpy(savebuff, buff); + +/* + copy log file into the current directory + in the case that issetdest == 2, + because feynmf package requires the + log file. +*/ + + if(issetdest == 2) { + i = strlen(buff); + if(i > 3) { + i -= 4; + buff[i] = '\0'; + strcat(buff, ".log"); + strcpy(cmd, fontname); + strcat(cmd, ".log"); + if (!(fr = fopen (cmd, "rb"))) { + fprintf (stderr, "Cannot open %s to read\n", cmd); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + if (!(fw = fopen (buff, "wb"))) { + fprintf (stderr, "Cannot open %s to write\n", buff); + _chdrive (cdrive); + _chdir (currdir); + relmem (arg); + return (100); + } + while ((i = fread (rbuff, 1, LBUF, fr))) + fwrite (rbuff, 1, i, fw); + fclose (fr); + fclose (fw); + } + } + + relmem (arg); + if(issetdest != 2) + mktexupd (savebuff); + +/* erase files */ + strcpy (cmd, fontname); + strcat (cmd, ".log"); + remove (cmd); + + strcpy (cmd, fontname); + strcat (cmd, ".tfm"); + remove (cmd); + + _chdrive (cdrive); + _chdir (currdir); + +/* send message to Kpathsea */ + printf ("%s\n", savebuff); + + return (0); +} diff --git a/Build/source/texk/kpathsea/win32/mktexupd.c b/Build/source/texk/kpathsea/win32/mktexupd.c new file mode 100644 index 00000000000..5e58a8618df --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktexupd.c @@ -0,0 +1,122 @@ +#include <kpathsea/kpathsea.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <fcntl.h> +#include <direct.h> +#include <io.h> +#include <malloc.h> +#include <process.h> +#include <direct.h> + +#include "mktexupd.h" + +#define MBUF 128 +#define SBUF 256 +#define LBUF 512 +#define DBS "TEXMFDBS" +#define MAXTREE 16 + +void +mktexupd (char *s) +{ + char fname[MBUF]; + char lsrname[SBUF]; + char path[LBUF]; + char *rootdir[MAXTREE]; + int i, j, treenum; + char *pa, *pb, *pc; + int existflag = 0; + FILE *f; + + pa = kpse_var_value (DBS); + if (pa == NULL) { + fprintf (stderr, "No definition of TEXMFDBS.\n"); + fprintf (stderr, "Maybe you are not using ls-R.\n"); + return; + } + + pb = kpse_brace_expand (pa); + free (pa); + if (pb == NULL) { + fprintf (stderr, "I cannot expand braces in TEXMFDBS.\n"); + fprintf (stderr, "Maybe you are not using ls-R.\n"); + return; + } + + for (i = 0; i < MAXTREE; i++) + rootdir[i] = (char *) malloc (MBUF); + + pa = pb; + i = 0; + + while (*pa && i < MAXTREE) { + if (*pa == '!' && *(pa + 1) == '!') { + pa++; + pa++; + } + pc = rootdir[i]; + while (*pa != ';' && *pa) + *pc++ = *pa++; + *pc = '\0'; + if (*pa == ';') { + pa++; + i++; + } + } + + i++; + treenum = i; + free (pb); + + for (i = 0; i < treenum; i++) { + j = strlen (rootdir[i]); + if (rootdir[i][j - 1] == '/') + rootdir[i][j - 1] = '\0'; + } + + strcpy (path, s); + pa = strrchr (path, '/'); + if (pa == NULL) { + fprintf (stderr, "Path name of the file may be incorrect.\n"); + for (i = 0; i < MAXTREE; i++) + free (rootdir[i]); + return; + } + + *pa = '\0'; + pa++; + strcpy (fname, pa); + + for (i = 0; i < treenum; i++) { + j = strlen (rootdir[i]); + if (j && strnicmp (path, rootdir[i], j) == 0) { + existflag = 1; + break; + } + } + + if (existflag) { + strcpy (lsrname, rootdir[i]); + strcat (lsrname, "/ls-R"); + if (_access (lsrname, 0) != 0) { + for (j = 0; j < MAXTREE; j++) + free (rootdir[j]); + return; + } + pa = path; + pb = rootdir[i]; + while (tolower (*pa) == tolower (*pb) && *pb) { + pa++; + pb++; + } + f = fopen (lsrname, "ab"); + fprintf (f, "\n.%s:\n%s\n", pa, fname); + fclose (f); + } else { + fprintf(stderr, "mktexupd failed\n"); + } + for (i = 0; i < MAXTREE; i++) + free (rootdir[i]); +} diff --git a/Build/source/texk/kpathsea/win32/mktexupd.h b/Build/source/texk/kpathsea/win32/mktexupd.h new file mode 100644 index 00000000000..76bd89da92f --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktexupd.h @@ -0,0 +1 @@ +extern void mktexupd (char *s); diff --git a/Build/source/texk/kpathsea/win32/mktexupdmain.c b/Build/source/texk/kpathsea/win32/mktexupdmain.c new file mode 100644 index 00000000000..393020e7ae0 --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mktexupdmain.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <kpathsea/kpathsea.h> + +#include "mktexupd.h" + +int main(int argc, char **argv) +{ + char dir[256]; + char file[256]; + char path[256]; + char *p; + int i; + + kpse_set_program_name (argv[0], NULL); + if(argc != 3) { + fprintf(stderr, "%s:: usage: %s DIR FILE\n", argv[0], argv[0]); + return 1; + } + strcpy(dir, argv[1]); + strcpy(file, argv[2]); + for(p = dir; *p; ++p) { + if(*p == '\\') *p = '/'; + else if (IS_KANJI(p)) p++; + } + i = strlen(dir); + while(dir[i-1] == '/') + i--; + dir[i] = '\0'; + strcpy(path, dir); + strcat(path, "/"); + strcat(path, file); + mktexupd(path); + return 0; +} |