summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/kpathsea/win32/ChangeLog23
-rw-r--r--Build/source/texk/kpathsea/win32/Makefile.am30
-rw-r--r--Build/source/texk/kpathsea/win32/Makefile.in66
-rw-r--r--Build/source/texk/kpathsea/win32/dirutil.c71
-rw-r--r--Build/source/texk/kpathsea/win32/dirutil.h3
-rw-r--r--Build/source/texk/kpathsea/win32/fmtutil.c960
-rw-r--r--Build/source/texk/kpathsea/win32/getdestdir.c95
-rw-r--r--Build/source/texk/kpathsea/win32/getdestdir.h2
-rw-r--r--Build/source/texk/kpathsea/win32/mktexfmt.c95
-rw-r--r--Build/source/texk/kpathsea/win32/mktexlsr.c225
-rw-r--r--Build/source/texk/kpathsea/win32/mktexmf.c8
-rw-r--r--Build/source/texk/kpathsea/win32/mktexpk.c29
-rw-r--r--Build/source/texk/kpathsea/win32/mktextfm.c28
-rw-r--r--Build/source/texk/kpathsea/win32/mktexupd.c10
-rw-r--r--Build/source/texk/kpathsea/win32/mktexupdmain.c1
15 files changed, 1486 insertions, 160 deletions
diff --git a/Build/source/texk/kpathsea/win32/ChangeLog b/Build/source/texk/kpathsea/win32/ChangeLog
index 6fc667428c5..ccd19f9b8d5 100644
--- a/Build/source/texk/kpathsea/win32/ChangeLog
+++ b/Build/source/texk/kpathsea/win32/ChangeLog
@@ -1,3 +1,26 @@
+2011-08-10 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * getdestdir.c, mktexmf.c, mktexpk.c, mktextfm.c, mktexupd.c,
+ mktexupdmain.c: No need to #include any standard headers, they
+ all come through <kpathsea/kpathsea.h>.
+ * getdestdir.c, mktexpk.c, mktextfm.c: Use IS_KANJI().
+
+ * dirutil.[ch]: New files extracted ...
+ * getdestdir.[ch]: ... from here.
+
+ * fmtutil.c, mktexfmt.c, mktexlsr.c: More new files from W32TeX.
+ Drop use of getlongname() for 8+3 names. Constify strings.
+ No need to #include any standard headers.
+ Declare functions as static. Drop unused variables.
+ Add parentheses around assignment used as truth value.
+
+ * fmtutil.c: Declare the array index Exenum as unsigned char.
+ (is_dir, make_dir, make_dir_p): Removed, use dirutil.c.
+
+ * mktexlsr.c: For MinGW #include "dirutil.h" and use is_dir(),
+ for native WIN32 #include <kpathsea/dirent.h> and use d_isdir.
+ (search): No need to slashify name. Remove return at end.
+
2011-08-09 Peter Breitenlohner <peb@mppmu.mpg.de>
* getdestdir.c, mktexmf.c, mktexpk.c, mktextfm.c, mktexupd.c,
diff --git a/Build/source/texk/kpathsea/win32/Makefile.am b/Build/source/texk/kpathsea/win32/Makefile.am
index 2842eeec972..3f5cfc9d35c 100644
--- a/Build/source/texk/kpathsea/win32/Makefile.am
+++ b/Build/source/texk/kpathsea/win32/Makefile.am
@@ -7,9 +7,33 @@ 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
+bin_PROGRAMS = \
+ fmtutil \
+ mktexfmt \
+ mktexlsr \
+ mktexmf \
+ mktexpk \
+ mktextfm \
+ mktexupd
+
+fmtutil_SOURCES = \
+ dirutil.c \
+ dirutil.h \
+ fmtutil.c \
+ mktexupd.c \
+ mktexupd.h
+
+mktexfmt_SOURCES = \
+ mktexfmt.c
+
+mktexlsr_SOURCES = \
+ dirutil.c \
+ dirutil.h \
+ mktexlsr.c
mktexmf_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktexmf.c \
@@ -17,6 +41,8 @@ mktexmf_SOURCES = \
mktexupd.h
mktexpk_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktexpk.c \
@@ -24,6 +50,8 @@ mktexpk_SOURCES = \
mktexupd.h
mktextfm_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktextfm.c \
diff --git a/Build/source/texk/kpathsea/win32/Makefile.in b/Build/source/texk/kpathsea/win32/Makefile.in
index 708fe567375..85a3064c93b 100644
--- a/Build/source/texk/kpathsea/win32/Makefile.in
+++ b/Build/source/texk/kpathsea/win32/Makefile.in
@@ -34,7 +34,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-bin_PROGRAMS = mktexmf$(EXEEXT) mktexpk$(EXEEXT) mktextfm$(EXEEXT) \
+bin_PROGRAMS = fmtutil$(EXEEXT) mktexfmt$(EXEEXT) mktexlsr$(EXEEXT) \
+ mktexmf$(EXEEXT) mktexpk$(EXEEXT) mktextfm$(EXEEXT) \
mktexupd$(EXEEXT)
subdir = win32
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
@@ -58,18 +59,31 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
-am_mktexmf_OBJECTS = getdestdir.$(OBJEXT) mktexmf.$(OBJEXT) \
+am_fmtutil_OBJECTS = dirutil.$(OBJEXT) fmtutil.$(OBJEXT) \
mktexupd.$(OBJEXT)
+fmtutil_OBJECTS = $(am_fmtutil_OBJECTS)
+fmtutil_LDADD = $(LDADD)
+fmtutil_DEPENDENCIES = ../libkpathsea.la
+am_mktexfmt_OBJECTS = mktexfmt.$(OBJEXT)
+mktexfmt_OBJECTS = $(am_mktexfmt_OBJECTS)
+mktexfmt_LDADD = $(LDADD)
+mktexfmt_DEPENDENCIES = ../libkpathsea.la
+am_mktexlsr_OBJECTS = dirutil.$(OBJEXT) mktexlsr.$(OBJEXT)
+mktexlsr_OBJECTS = $(am_mktexlsr_OBJECTS)
+mktexlsr_LDADD = $(LDADD)
+mktexlsr_DEPENDENCIES = ../libkpathsea.la
+am_mktexmf_OBJECTS = dirutil.$(OBJEXT) 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)
+am_mktexpk_OBJECTS = dirutil.$(OBJEXT) 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)
+am_mktextfm_OBJECTS = dirutil.$(OBJEXT) getdestdir.$(OBJEXT) \
+ mktextfm.$(OBJEXT) mktexupd.$(OBJEXT)
mktextfm_OBJECTS = $(am_mktextfm_OBJECTS)
mktextfm_LDADD = $(LDADD)
mktextfm_DEPENDENCIES = ../libkpathsea.la
@@ -90,9 +104,11 @@ 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) \
+SOURCES = $(fmtutil_SOURCES) $(mktexfmt_SOURCES) $(mktexlsr_SOURCES) \
+ $(mktexmf_SOURCES) $(mktexpk_SOURCES) $(mktextfm_SOURCES) \
$(mktexupd_SOURCES)
-DIST_SOURCES = $(mktexmf_SOURCES) $(mktexpk_SOURCES) \
+DIST_SOURCES = $(fmtutil_SOURCES) $(mktexfmt_SOURCES) \
+ $(mktexlsr_SOURCES) $(mktexmf_SOURCES) $(mktexpk_SOURCES) \
$(mktextfm_SOURCES) $(mktexupd_SOURCES)
ETAGS = etags
CTAGS = ctags
@@ -218,7 +234,24 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/..
AM_CFLAGS = $(WARNING_CFLAGS)
+fmtutil_SOURCES = \
+ dirutil.c \
+ dirutil.h \
+ fmtutil.c \
+ mktexupd.c \
+ mktexupd.h
+
+mktexfmt_SOURCES = \
+ mktexfmt.c
+
+mktexlsr_SOURCES = \
+ dirutil.c \
+ dirutil.h \
+ mktexlsr.c
+
mktexmf_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktexmf.c \
@@ -226,6 +259,8 @@ mktexmf_SOURCES = \
mktexupd.h
mktexpk_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktexpk.c \
@@ -233,6 +268,8 @@ mktexpk_SOURCES = \
mktexupd.h
mktextfm_SOURCES = \
+ dirutil.c \
+ dirutil.h \
getdestdir.c \
getdestdir.h \
mktextfm.c \
@@ -323,6 +360,15 @@ clean-binPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
+fmtutil$(EXEEXT): $(fmtutil_OBJECTS) $(fmtutil_DEPENDENCIES)
+ @rm -f fmtutil$(EXEEXT)
+ $(LINK) $(fmtutil_OBJECTS) $(fmtutil_LDADD) $(LIBS)
+mktexfmt$(EXEEXT): $(mktexfmt_OBJECTS) $(mktexfmt_DEPENDENCIES)
+ @rm -f mktexfmt$(EXEEXT)
+ $(LINK) $(mktexfmt_OBJECTS) $(mktexfmt_LDADD) $(LIBS)
+mktexlsr$(EXEEXT): $(mktexlsr_OBJECTS) $(mktexlsr_DEPENDENCIES)
+ @rm -f mktexlsr$(EXEEXT)
+ $(LINK) $(mktexlsr_OBJECTS) $(mktexlsr_LDADD) $(LIBS)
mktexmf$(EXEEXT): $(mktexmf_OBJECTS) $(mktexmf_DEPENDENCIES)
@rm -f mktexmf$(EXEEXT)
$(LINK) $(mktexmf_OBJECTS) $(mktexmf_LDADD) $(LIBS)
@@ -342,7 +388,11 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirutil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmtutil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdestdir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexfmt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktexlsr.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@
diff --git a/Build/source/texk/kpathsea/win32/dirutil.c b/Build/source/texk/kpathsea/win32/dirutil.c
new file mode 100644
index 00000000000..fbedd4c9b8b
--- /dev/null
+++ b/Build/source/texk/kpathsea/win32/dirutil.c
@@ -0,0 +1,71 @@
+
+#include <kpathsea/kpathsea.h>
+
+#include "dirutil.h"
+
+/* 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);
+}
+
+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;
+}
diff --git a/Build/source/texk/kpathsea/win32/dirutil.h b/Build/source/texk/kpathsea/win32/dirutil.h
new file mode 100644
index 00000000000..c260ff37921
--- /dev/null
+++ b/Build/source/texk/kpathsea/win32/dirutil.h
@@ -0,0 +1,3 @@
+extern int is_dir (char *buff);
+extern int make_dir (char *buff);
+extern int make_dir_p (char *buff);
diff --git a/Build/source/texk/kpathsea/win32/fmtutil.c b/Build/source/texk/kpathsea/win32/fmtutil.c
new file mode 100644
index 00000000000..6a9252f8110
--- /dev/null
+++ b/Build/source/texk/kpathsea/win32/fmtutil.c
@@ -0,0 +1,960 @@
+/*
+
+Try TEXMFVAR as a head directory, if not defined try TEXMFMAIN next.
+
+
+fmtutil.c (2002/10/06 --ak)
+Web2C-7.3.9 (2002/10/25 --ak)
+Web2C-7.4.2 (2002/12/27 --ak)
+Web2C-7.4.3 (2003/01/12 --ak)
+Web2C-7.5.2 (2003/11/09 --ak)
+Web2C-7.5.3 (2004/05/09 --ak)
+Web2C-7.5.3 (2004/06/11 --ak)
+Web2C-7.5.5 (2005/12/23 --ak)
+Web2C-7.5.5 (2006/11/25 --ak)
+Web2C-7.5.6 (2007/06/01 --ak) save log files.
+Web2C-7.5.6 (2008/01/20 --ak) Create necessary directories.
+Web2C-2009 (2009/06/11 --ak) error handling.
+Web2C-2009 (2009/08/13 Nobert) new option --byengine
+Web2C-2009 (2009/10/10 --ak) creates mplib-luatex.mem.
+Web2C-2010 (2010/05/31 --ak) multiple language files.
+Web2C-2010 (2010/07/03 --ak) new options.
+*/
+
+#include <kpathsea/kpathsea.h>
+
+#include "dirutil.h"
+#include "mktexupd.h"
+
+#ifndef __MINGW32__
+#undef system
+#define system win32_system
+#endif
+
+#define BLEN 512
+#define SLEN 256
+#define MAXFMT 128
+#define SIXTY4 64
+#define SIXTEEN 16
+#define DEFAULTCNF "fmtutil.cnf"
+#define REVISION "fmtutil (C version 0.7) 2002-2010 --ak"
+
+typedef struct {
+char *format;
+char *engine;
+char *hyphen;
+char *args;
+} cmd_t;
+
+/*
+Global variables
+*/
+cmd_t K[MAXFMT];
+int Fmtnum = 0;
+char Buff[BLEN];
+char Programname[BLEN];
+char Enginename[BLEN];
+char Realenginename[BLEN];
+char Destdir[BLEN];
+char Currdir[BLEN];
+char *Exefile[MAXFMT];
+unsigned char Exenum = 0;
+int Errorcnt = 0;
+int UserDestdir = 0;
+int QQQ = 0; /* quiet */
+
+static void
+revision(void)
+{
+ printf(REVISION "\n");
+}
+
+static void
+usage(void)
+{
+ printf(
+"Commands:\n"
+" --all recreate all format, base, mem files\n"
+" --missing create all missing format, base, mem files\n"
+" --refresh recreate existing format, base, mem files\n"
+" --byfmt FORMATNAME (re)create format for `FORMATNAME'\n"
+" `base' and `mem' files can also be created\n"
+" --byhyphen HYPHENFILE (re)create formats that depend on `HYPHENFILE'\n"
+" --byengine ENGINENAME (re)create formats that depend on `ENGINENAME'\n"
+" --showhyphen FORMATNAME print name of hyphenfile for format `FORMATNAME'\n"
+" --version show revision number\n"
+" --help show this message\n"
+" --enablefmt FORMATNAME (not implemented)\n"
+" --disablefmt FORMATNAME (not implemented)\n"
+" --listcfg (not implemented)\n"
+" --catcfg (not implemented)\n"
+" --edit (not implemented)\n"
+"\n"
+"Options:\n"
+" --cnffile FILE set configfile for fmtutil\n"
+" default is `fmtutil.cnf'\n"
+" --fmtdir DIRECTORY set destination directory for format files\n"
+" `DIRECTORY' must be an absolute path\n"
+" default is $TEXMFVAR/web2c/$engine\n"
+" or $TEXMFMAIN/web2c/$engine if TEXMFVAR is undefined\n"
+" --engine TEXENGINE specify the TeX engine (with --byfmt fmtname)\n"
+" --quiet be silent\n"
+" --no-error-if-no-format (just for compatibility)\n"
+" --no-engine-subdir (not implemented)\n"
+" --test (not implemented)\n"
+" --dolinks (not implemented)\n"
+" --force (not implemented)\n");
+}
+
+static void
+freeK(void)
+{
+ int i;
+ for(i=0; i < MAXFMT; i++) {
+ free(K[i].format);
+ free(K[i].engine);
+ free(K[i].hyphen);
+ free(K[i].args);
+ free(Exefile[i]);
+ }
+}
+
+static int
+do_initex(char *fm, char *en, char *args)
+{
+ int ret, lsrflag;
+ char fmt[BLEN];
+ char ext[SIXTEEN];
+ char cmd[BLEN];
+ char progn[BLEN];
+ char progn2[BLEN];
+ char enginesubdir[BLEN];
+ char src[BLEN];
+ char dst[BLEN];
+ char logdst[BLEN];
+ char log[BLEN];
+ char fullbin[256], *pp;
+
+ if(!strnicmp(fm, "cont", 4)) strcpy(progn, "context");
+ else if(!strnicmp(fm, "ptex-", 5)) strcpy(progn, "ptex");
+ else if(!strnicmp(fm, "platex-", 7)) strcpy(progn, "platex");
+ else strcpy(progn, fm);
+
+ strcpy(enginesubdir, en);
+
+ if(!stricmp(enginesubdir, "mf-nowin"))
+ strcpy(enginesubdir, "metafont");
+ if(!stricmp(enginesubdir, "mf"))
+ strcpy(enginesubdir, "metafont");
+ if(!stricmp(enginesubdir, "mpost"))
+ strcpy(enginesubdir, "metapost");
+
+ if(!stricmp(en, "mf-nowin")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".base");
+ }
+ else if(!stricmp(en, "mf")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".base");
+ }
+ else if(!stricmp(en, "mpost")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".mem");
+ }
+ else if(!stricmp(en, "pmpost")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".mem");
+ }
+ else if(!stricmp(en, "upmpost")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".mem");
+ }
+ else if(!stricmp(en, "mp641")) {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".mem");
+ }
+ else if(!stricmp(en, "nts")) {
+ strcpy(fmt, "--fmt=");
+ strcpy(ext, ".nfmt");
+ }
+ else {
+ strcpy(fmt, "--jobname=");
+ strcpy(ext, ".fmt");
+ }
+
+ if(!stricmp(en, "pmpost") || !stricmp(en, "mpost")
+ || !stricmp(en, "upmpost") || !stricmp(en, "mp641"))
+ strcpy(progn2, "mpost");
+ else if(!stricmp(en, "mf-nowin"))
+ strcpy(progn2, "mf");
+ else if(!stricmp(en, "nts"))
+ strcpy(progn2, "tex");
+ else strcpy(progn2, progn);
+
+ pp = kpse_var_value("SELFAUTOLOC");
+ if(pp == NULL) {
+ fprintf(stderr, "I cannot get SELFAUTOLOC\n");
+ exit(100);
+ }
+ fullbin[0] = '\"';
+ fullbin[1] = '\0';
+ strcat(fullbin, pp);
+ free(pp);
+ for(pp=fullbin; *pp; pp++) {
+ if(*pp == '/') *pp = '\\';
+ }
+ strcat(fullbin, "\\");
+ strcat(fullbin, en);
+ strcat(fullbin, "\"");
+
+ if(!stricmp(en, "nts"))
+ sprintf(cmd, "%s --ini --progname=%s %s <nul",
+ fullbin, progn2, args);
+ else
+ sprintf(cmd, "%s --ini %s%s --progname=%s %s <nul",
+ fullbin, fmt, fm, progn2, args);
+
+ if(QQQ == 0)
+ fprintf(stderr, "Running: %s\n", cmd);
+ ret = system(cmd);
+ strcpy(src, fm);
+ strcpy(log, fm);
+ strcat(log, ".log");
+ strcat(src, ext);
+ strcpy(dst, Destdir);
+
+ if((UserDestdir == 0) && stricmp(enginesubdir, "nts")) {
+ strcat(dst, enginesubdir);
+ if(!is_dir(dst)) {
+ if(make_dir(dst)) {
+ fprintf(stderr, "Failed to make format in %s.\n", dst);
+ return (-100);
+ }
+ }
+ strcat(dst, "/");
+ }
+
+ strcpy(logdst, dst);
+ strcat(logdst, log);
+ strcat(dst, src);
+ if(_access(dst, 0) == 0)
+ lsrflag = 0;
+ else
+ lsrflag = 1;
+
+ if((_access(src, 0) == 0) && ret == 0) {
+ CopyFile(src, dst, FALSE);
+ if(lsrflag) mktexupd(dst);
+ if(stricmp(src, "mpost.mem") == 0) {
+ int len;
+ char *tmpstr;
+ len = strlen(dst);
+ tmpstr = (char *)malloc(len + 10);
+ strcpy(tmpstr, dst);
+ tmpstr[len-9] = '\0';
+ strcat(tmpstr, "mplib-luatex.mem");
+ if(_access(tmpstr, 0) == 0)
+ free(tmpstr);
+ else {
+ CopyFile(src, tmpstr, FALSE);
+ mktexupd(tmpstr);
+ free(tmpstr);
+ }
+ }
+ remove(src);
+ if(_access(logdst, 0) == 0)
+ lsrflag = 0;
+ else
+ lsrflag = 1;
+ if(_access(log, 0) == 0) {
+ CopyFile(log, logdst, FALSE);
+ if(lsrflag) mktexupd(logdst);
+ remove(log);
+ }
+ if(QQQ == 0)
+ fprintf(stderr, "The file %s%s was created.\n", fm, ext);
+ if(!strcmp(progn, "context"))
+ strcpy(Exefile[Exenum], "texexec");
+ else if(!strcmp(en, "nts"))
+ strcpy(Exefile[Exenum], "nts");
+ else
+ strcpy(Exefile[Exenum], fm);
+
+ Exenum++;
+ } else {
+ if(_access(src, 0) == 0)
+ remove(src);
+ if(_access(logdst, 0) == 0)
+ lsrflag = 0;
+ else
+ lsrflag = 1;
+ if(_access(log, 0) == 0) {
+ CopyFile(log, logdst, FALSE);
+ if(lsrflag) mktexupd(logdst);
+ remove(log);
+ }
+ if(QQQ == 0) {
+ fprintf(stderr, "\nThe file %s%s was not created due to some errors.\n",
+ fm, ext);
+ fprintf(stderr, "See the log file %s for details.\n", logdst);
+ }
+ Errorcnt++;
+ ret = -100;
+ }
+ return ret;
+}
+
+static void
+do_all(void)
+{
+ int i;
+
+ for(i = 0; i < Fmtnum; i++)
+ do_initex(K[i].format, K[i].engine, K[i].args);
+}
+
+static void
+show_hyphen(char *fm, char *hfile)
+{
+ char *p, *q, *r;
+ int cont;
+ char progn[BLEN];
+
+ if(!strcmp(hfile, "-")) {
+ printf("%s\n", hfile);
+ return;
+ }
+
+ if(!strnicmp(fm, "cont", 4)) strcpy(progn, "context");
+ else strcpy(progn, fm);
+ if(QQQ == 0)
+ fprintf(stderr, "Searching ... \n");
+ kpse_reset_program_name(progn);
+ q = hfile;
+ cont = 1;
+ while(cont) {
+ for(r=q; *r && *r != ','; r++)
+ ;
+ if(*r == '\0') cont = 0;
+ *r = '\0';
+ r++;
+ p = kpse_find_file(q, kpse_tex_format, 0);
+ if(!p) {
+ if(QQQ == 0)
+ fprintf(stderr, "%s not found.\n", q);
+ q = r;
+ continue;
+ }
+ printf("%s\n", p);
+ free(p);
+ q = r;
+ }
+ kpse_reset_program_name(Programname);
+ return;
+}
+
+static int
+testexe(char *name, const char *suffix)
+{
+ char buffer[BLEN];
+ char *p;
+
+ if(SearchPath(NULL, name, suffix, BLEN, buffer, &p))
+ return 1;
+ else
+ return 0;
+}
+
+int
+main(int ac, char **av)
+{
+ FILE *in;
+
+ int i, j, k;
+ char *cnfname;
+ char *p;
+ char cnffile[BLEN];
+ char fmtname[BLEN];
+ char hyphenfile[BLEN];
+ char byenginename[BLEN];
+ char kpsedot[BLEN];
+ char enginesubdir[BLEN];
+ char *tmp;
+ int cdrive, tdrive;
+
+ int flag;
+
+/*
+flag = 1 : --all
+ 2 : --missing
+ 3 : --byfmt formatname
+ 4 : --byhyphen hyphenfile
+ 5 : --showhyphen formatname
+ 6 : --refresh
+ 7 : --byengine engine
+*/
+
+ flag = 0;
+ cnffile[0] = '\0';
+ fmtname[0] = '\0';
+ hyphenfile[0] = '\0';
+ byenginename[0] = '\0';
+ Destdir[0] = '\0';
+ Currdir[0] = '\0';
+ Enginename[0] = '\0';
+ Realenginename[0] = '\0';
+
+ kpse_set_program_name(av[0], NULL);
+ strcpy(Programname, av[0]);
+
+ tmp = getenv("TEMP");
+ if(!tmp) tmp = getenv("TMP");
+ if(!tmp) tmp = getenv("TMPDIR");
+ if(!tmp) {
+ fprintf(stderr, "Please define TEMP | TMP | TMPDIR.\n");
+ return (100);
+ }
+
+ tmp = xstrdup(tmp);
+ for(p = tmp; *p; p++) {
+ if(*p == '\\')
+ *p = '/';
+ else if (IS_KANJI(p))
+ p++;
+ }
+
+ i = strlen(tmp);
+ if(tmp[i-1] == '/') tmp[i-1] = '\0';
+
+ for(i = 1; i < ac; i++) {
+ if(strlen(av[i]) > BLEN-1) {
+ fprintf(stderr, "\nToo long a string.\n");
+ return 100;
+ }
+ /* --cnffile FILE */
+
+ if(!strncmp(av[i],"--cn", 4) || !strncmp(av[i], "-cn", 3)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ strcpy(cnffile, av[i]);
+ continue;
+ }
+ /* --engine TEXENGINE */
+
+ else if(!strncmp(av[i],"--eng", 5) || !strncmp(av[i], "-eng", 4)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ strcpy(Enginename, av[i]);
+ continue;
+ }
+ /* --fmtdir DIRCTORY */
+
+ else if(!strncmp(av[i],"--fm", 4) || !strncmp(av[i], "-fm", 3)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ strcpy(Destdir, av[i]);
+ UserDestdir = 1;
+ continue;
+ }
+ /* --all */
+
+ else if(!strncmp(av[i],"--a", 3) || !strncmp(av[i], "-a", 2)) {
+ flag = 1;
+ continue;
+ }
+ /* --missing */
+
+ else if(!strncmp(av[i],"--m", 3) || !strncmp(av[i], "-m", 2)) {
+ flag = 2;
+ continue;
+ }
+ /* --refresh */
+
+ else if(!strncmp(av[i],"--r", 3) || !strncmp(av[i], "-r", 2)) {
+ flag = 6;
+ continue;
+ }
+ /* --byfmt FORMATNAME */
+
+ else if(!strncmp(av[i],"--byf", 5) || !strncmp(av[i], "-byf", 4)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ flag = 3;
+ strcpy(fmtname, av[i]);
+ continue;
+ }
+ /* --byhyphen HYPHENFILE */
+
+ else if(!strncmp(av[i],"--byh", 5) || !strncmp(av[i], "-byh", 4)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ flag = 4;
+ strcpy(hyphenfile, av[i]);
+ for(p=hyphenfile; *p; p++) {
+ if(*p == '\\')
+ *p = '/';
+ else if (IS_KANJI(p))
+ p++;
+ }
+ p = strrchr(hyphenfile, '/');
+ if(p) {
+ p++;
+ strcpy(hyphenfile, p);
+ }
+ continue;
+ }
+ /* --byengine ENGINENAME */
+
+ else if(!strncmp(av[i],"--bye", 5) || !strncmp(av[i], "-bye", 4)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ flag = 7;
+ strcpy(byenginename, av[i]);
+ continue;
+ }
+ /* --showhyphen FORMATNAME */
+
+ else if(!strncmp(av[i],"--s", 3) || !strncmp(av[i], "-s", 2)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ flag = 5;
+ strcpy(fmtname, av[i]);
+ continue;
+ }
+ /* --version */
+
+ else if(!strncmp(av[i],"--v", 3) || !strncmp(av[i], "-v", 2)) {
+ revision();
+ return 0;
+ }
+ /* --help */
+
+ else if(!strncmp(av[i],"--h", 3) || !strncmp(av[i], "-h", 2)) {
+ usage();
+ return 0;
+ }
+ /* --enablefmt FORMATNAME */
+
+ else if(!strncmp(av[i],"--ena", 5) || !strncmp(av[i], "-ena", 4)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ fprintf(stderr, "`--enablefmt FORMATNAME' is not implemented.\n");
+ continue;
+ }
+ /* --disablefmt FORMATNAME */
+
+ else if(!strncmp(av[i],"--di", 4) || !strncmp(av[i], "-di", 3)) {
+ i++;
+ if(i >= ac) {
+ fprintf(stderr, "Invalid argument.\n");
+ exit (100);
+ }
+ fprintf(stderr, "`--disablefmt FORMATNAME' is not implemented.\n");
+ continue;
+ }
+ /* --listcfg */
+
+ else if(!strncmp(av[i],"--l", 3) || !strncmp(av[i], "-l", 2)) {
+ fprintf(stderr, "`--listcfg' is not implemented.\n");
+ continue;
+ }
+ /* --catcfg */
+
+ else if(!strncmp(av[i],"--ca", 4) || !strncmp(av[i], "-ca", 3)) {
+ fprintf(stderr, "`--catcfg' is not implemented.\n");
+ continue;
+ }
+ /* --edit */
+
+ else if(!strncmp(av[i],"--ed", 4) || !strncmp(av[i], "-ed", 3)) {
+ fprintf(stderr, "`--edit' is not implemented.\n");
+ continue;
+ }
+ /* --test */
+
+ else if(!strncmp(av[i],"--t", 3) || !strncmp(av[i], "-t", 2)) {
+ fprintf(stderr, "`--test' is not implemented.\n");
+ continue;
+ }
+ /* --dolinks */
+
+ else if(!strncmp(av[i],"--do", 4) || !strncmp(av[i], "-do", 3)) {
+ fprintf(stderr, "`--dolinks' is not implemented.\n");
+ continue;
+ }
+ /* --force */
+
+ else if(!strncmp(av[i],"--fo", 4) || !strncmp(av[i], "-fo", 3)) {
+ fprintf(stderr, "`--force' is not implemented.\n");
+ continue;
+ }
+ /* --no-engine-subdir */
+
+ else if(!strncmp(av[i],"--no-en", 7) || !strncmp(av[i], "-no-en", 6)) {
+ fprintf(stderr, "`--no-engine-subdir' is not implemented.\n");
+ continue;
+ }
+ /* --no-error-if-no-format */
+
+ else if(!strncmp(av[i],"--no-er", 7) || !strncmp(av[i], "-no-er", 6)) {
+ continue;
+ }
+ /* --quiet */
+
+ else if(!strncmp(av[i],"--q", 3) || !strncmp(av[i], "-q", 2)) {
+ QQQ = 1;
+ continue;
+ }
+ else {
+ fprintf(stderr, "%s: Invalid argument.\n\n", av[0]);
+ usage();
+ return 100;
+ }
+ }
+
+ if(flag == 0) {
+ usage();
+ return 100;
+ }
+
+
+ if(!cnffile[0]) strcpy(cnffile, DEFAULTCNF);
+ cnfname = kpse_find_file(cnffile, kpse_web2c_format, 0);
+ if(!cnfname) {
+ fprintf(stderr, "Failed to find cnffile %s.\n", cnffile);
+ exit (100);
+ }
+
+ in = fopen(cnfname, "r");
+ free(cnfname);
+ if(!in) {
+ fprintf(stderr, "Failed to open %s.\n", cnffile);
+ exit (100);
+ }
+
+ for(i=0; i < MAXFMT; i++) {
+ K[i].format = (char *)malloc(BLEN);
+ K[i].engine = (char *)malloc(BLEN);
+ K[i].hyphen = (char *)malloc(BLEN);
+ K[i].args = (char *)malloc(BLEN);
+ Exefile[i] = (char *)malloc(BLEN);
+ }
+
+ i = 0;
+ while(fgets(Buff, BLEN, in)) {
+ if(Buff[0] == '#' ||
+ Buff[0] == '\n' ||
+ Buff[0] == 0x25)
+ continue;
+ p = strtok(Buff, " \t");
+ if(p)
+ strcpy(K[i].format, p);
+ else
+ K[i].format[0] = '\0';
+ p = strtok(NULL, " \t");
+ if(p)
+ strcpy(K[i].engine, p);
+ else
+ K[i].engine[0] = '\0';
+ p = strtok(NULL, " \t");
+ if(p)
+ strcpy(K[i].hyphen, p);
+ else
+ K[i].hyphen[0] = '\0';
+ p = strtok(NULL, "\n");
+ if(p) {
+ while(*p == ' ' || *p == '\t')
+ p++;
+ j = strlen(p);
+ if(*(p+j-1) == '\n')
+ *(p+j-1) = '\0';
+ strcpy(K[i].args, p);
+ }
+ else
+ K[i].args[0] = '\0';
+
+ if(!K[i].format[0] ||
+ !K[i].engine[0] ||
+ !K[i].hyphen[0] ||
+ !K[i].args) {
+ fprintf(stderr, "Invalid line in %s.\n", cnffile);
+ freeK();
+ return (100);
+ }
+ i++;
+ if(i > MAXFMT) {
+ fprintf(stderr, "Too many lines in %s.\n", cnffile);
+ freeK();
+ return (100);
+ }
+ }
+
+ Fmtnum = i;
+ fclose(in);
+
+ j = 0;
+ if(flag == 5) {
+ for(i = 0; i < Fmtnum; i++) {
+ if(!stricmp(K[i].format, fmtname)) {
+ show_hyphen(K[i].format, K[i].hyphen);
+ j++;
+ }
+ }
+ if(j == 0)
+ fprintf(stderr, "argument of --showhyphen must be a format name.\n");
+ freeK();
+ return 1;
+ }
+
+ if(stricmp(Programname, "fmtutil-sys") == 0) {
+ char *px = kpse_var_value("TEXMFSYSVAR");
+ if(px) {
+ xputenv("TEXMFVAR", px);
+ }
+ }
+
+ if(UserDestdir == 0) {
+ p = kpse_var_value("TEXMFVAR");
+ if(!p)
+ p = kpse_var_value("TEXMFMAIN");
+ if(!p) {
+ fprintf(stderr, "TEXMFMAIN not defined.\n");
+ freeK();
+ return 100;
+ }
+ strcpy(Destdir, p);
+ free(p);
+ for(p = Destdir; *p ; p++) {
+ if(*p == '\\')
+ *p = '/';
+ else if (IS_KANJI(p))
+ p++;
+ }
+
+ i = strlen(Destdir);
+ while (Destdir[i-1] == '/')
+ i--;
+ Destdir[i] = '\0';
+ strcat(Destdir, "/web2c");
+ }
+
+ if(!is_dir(Destdir)) {
+ if(make_dir_p(Destdir)) {
+ fprintf(stderr, "Failed to make a format under %s.\n", Destdir);
+ return (-100);
+ }
+ }
+
+ strcat(Destdir, "/");
+ p = _getcwd(Currdir, BLEN);
+ if(p) {
+ for(p = Currdir; *p ; p++) {
+ if(*p == '\\')
+ *p = '/';
+ else if (IS_KANJI(p))
+ p++;
+ }
+ i = strlen(Currdir);
+ if(Currdir[i-1] == '/') Currdir[i-1] = '\0';
+ strcpy(kpsedot, "KPSE_DOT=.;");
+ strcat(kpsedot, Currdir);
+ _putenv(kpsedot);
+ }
+
+ cdrive = _getdrive();
+ if(tmp[1] == ':') {
+ tdrive = tolower(*tmp) -'a' + 1;
+ _chdrive(tdrive);
+ }
+ _chdir(tmp);
+
+ j = 0;
+
+ if(flag == 4) {
+ char *p, *q;
+ int cont;
+ for(i = 0; i < Fmtnum; i++) {
+ p = K[i].hyphen;
+ cont = 1;
+ while(cont) {
+ for(q = p; *q && *q != ','; q++)
+ ;
+ if(*q == '\0') cont = 0;
+ *q = '\0';
+ q++;
+ if(!stricmp(p, hyphenfile)) {
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ j++;
+ cont = 0;
+ }
+ p = q;
+ }
+ }
+ if(j == 0)
+ fprintf(stderr, "hyphen pattern %s not written in %s.\n",hyphenfile,cnffile);
+ }
+
+ else if(flag == 7) {
+ if(stricmp(byenginename, "metafont") == 0)
+ strcpy(byenginename, "mf-nowin");
+ if(stricmp(byenginename, "metapost") == 0)
+ strcpy(byenginename, "mpost");
+ for(i = 0; i < Fmtnum; i++) {
+ if(!stricmp(K[i].engine, byenginename)) {
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ j++;
+ }
+ }
+ if(j == 0) {
+ fprintf(stderr, "engine name %s not written in %s.\n", byenginename, cnffile);
+ }
+ }
+
+ else if(flag == 3) {
+ for(i = 0; i < Fmtnum; i++) {
+ if(Enginename[0]) {
+ if(!stricmp(Enginename, "metafont"))
+ strcpy(Realenginename, "mf-nowin");
+ else if(!stricmp(Enginename, "metapost"))
+ strcpy(Realenginename, "mpost");
+ else
+ strcpy(Realenginename, Enginename);
+ if(!stricmp(K[i].format, fmtname) &&
+ !stricmp(K[i].engine, Realenginename)) {
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ j++;
+ }
+ }
+ else {
+ if(!stricmp(K[i].format, fmtname)) {
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ j++;
+ }
+ }
+ }
+ if(j == 0) {
+ if(Enginename[0])
+ fprintf(stderr, "format name %s with engine %s not written in %s.\n",
+ fmtname, Realenginename, cnffile);
+ else
+ fprintf(stderr, "format name %s not written in %s.\n", fmtname, cnffile);
+ }
+ }
+
+ else if((flag == 2) || (flag == 6)) {
+ for(i = 0; i < Fmtnum; i++) {
+ strcpy(Buff, Destdir);
+
+ strcpy(enginesubdir, K[i].engine);
+ if(!stricmp(enginesubdir, "mf-nowin"))
+ strcpy(enginesubdir, "metafont");
+ if(!stricmp(enginesubdir, "mf"))
+ strcpy(enginesubdir, "metafont");
+ if(!stricmp(enginesubdir, "mpost"))
+ strcpy(enginesubdir, "metapost");
+ if(stricmp(enginesubdir, "nts"))
+ strcat(Buff, enginesubdir);
+ strcat(Buff, "/");
+
+ strcat(Buff, K[i].format);
+ if(!stricmp(K[i].engine, "nts"))
+ strcat(Buff, ".nfmt");
+ else if(!stricmp(K[i].engine, "mf"))
+ strcat(Buff, ".base");
+ else if(!stricmp(K[i].engine, "mf-nowin"))
+ strcat(Buff, ".base");
+ else if(!stricmp(K[i].engine, "mpost"))
+ strcat(Buff, ".mem");
+ else if(!stricmp(K[i].engine, "pmpost"))
+ strcat(Buff, ".mem");
+ else if(!stricmp(K[i].engine, "upmpost"))
+ strcat(Buff, ".mem");
+ else
+ strcat(Buff, ".fmt");
+ if(flag == 2) {
+ if(_access(Buff, 0) != 0)
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ else if(QQQ == 0)
+ fprintf(stderr, "%s exists.\n", Buff);
+ } else if(flag == 6) {
+ if(_access(Buff, 0) == 0)
+ do_initex(K[i].format, K[i].engine, K[i].args);
+ else if(QQQ == 0)
+ fprintf(stderr, "%s does not exist.\n", Buff);
+ }
+ }
+ }
+
+ else if(flag == 1)
+ do_all();
+
+ _chdrive(cdrive);
+ _chdir(Currdir);
+
+/*
+Check executable files. (ignore "Batch" or "Script" files (case 'x'))
+*/
+ if(Exenum && QQQ == 0) {
+ fprintf(stderr, "\n\nNow I check executable files...\n");
+ fprintf(stderr, "If some executable files do not exist, you must make them\n");
+ fprintf(stderr, "by hard link (Windows NT/2000/XP/Vista/7),"
+ " symbolic link (Vista/7)\n"
+ "or copying (Windows 95/98/Me).\n\n");
+
+ for(i = 0; i < Exenum; i++) {
+ if(testexe(Exefile[i], ".exe"))
+ sprintf(Buff, "OK. %s.exe exists.", Exefile[i]);
+ else if(testexe(Exefile[i], ".bat"))
+ sprintf(Buff, "OK. %s.bat exists.", Exefile[i]);
+ else if(testexe(Exefile[i], ".sh"))
+ sprintf(Buff, "OK. %s.sh exists.", Exefile[i]);
+ else
+ sprintf(Buff, "I cannot find %s.", Exefile[i]);
+ j = strlen(Buff);
+
+ if((i+1) % 2) {
+ for(k = j; k < 36; k++)
+ Buff[k] = ' ';
+ Buff[k] = '\0';
+ fprintf(stderr, "%s", Buff);
+ }
+ else {
+ fprintf(stderr, "%s", Buff);
+ fprintf(stderr, "\n");
+ }
+ }
+ fprintf(stderr, "\n");
+ }
+
+ freeK();
+ if(Errorcnt && QQQ == 0) {
+ fprintf(stderr, "\n\nI could not create %d of format (base/mem) file(s).\n",
+ Errorcnt);
+ fprintf(stderr, "For details, see log file(s) in the (fmt/base/mem) dir(s).\n");
+ }
+ return 0;
+}
diff --git a/Build/source/texk/kpathsea/win32/getdestdir.c b/Build/source/texk/kpathsea/win32/getdestdir.c
index 63ecdb8a7a7..0d77f320d2a 100644
--- a/Build/source/texk/kpathsea/win32/getdestdir.c
+++ b/Build/source/texk/kpathsea/win32/getdestdir.c
@@ -7,16 +7,8 @@ from mktextfm:
*/
#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 "dirutil.h"
#include "getdestdir.h"
#define NUMBUF 32
@@ -31,73 +23,6 @@ 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)
{
@@ -127,12 +52,10 @@ getdestdir (int ac, char **av)
strcpy (spec, av[1]);
for (p = av[2]; *p; p++) { /* path */
- if (isknj (*p)) {
- if(*(p+1)) p++;
- continue;
- }
if (*p == '\\')
*p = '/';
+ else if (IS_KANJI(p))
+ p++;
}
p = av[2];
@@ -206,12 +129,10 @@ getdestdir (int ac, char **av)
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] = '/';
+ else if (IS_KANJI(topdir+i))
+ i++;
}
i = strlen (topdir);
while(topdir[i - 1] == '/')
@@ -243,12 +164,10 @@ getdestdir (int ac, char **av)
} 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] = '/';
+ else if (IS_KANJI(topdir+i))
+ i++;
}
i = strlen (topdir);
while(topdir[i - 1] == '/')
diff --git a/Build/source/texk/kpathsea/win32/getdestdir.h b/Build/source/texk/kpathsea/win32/getdestdir.h
index e60dc86f5b8..743db043675 100644
--- a/Build/source/texk/kpathsea/win32/getdestdir.h
+++ b/Build/source/texk/kpathsea/win32/getdestdir.h
@@ -1,3 +1 @@
-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/mktexfmt.c b/Build/source/texk/kpathsea/win32/mktexfmt.c
new file mode 100644
index 00000000000..3b38aa038b7
--- /dev/null
+++ b/Build/source/texk/kpathsea/win32/mktexfmt.c
@@ -0,0 +1,95 @@
+/* mktexfmt.c
+ */
+
+#include <kpathsea/kpathsea.h>
+
+int main(int ac, char **av)
+{
+ int savo, savi;
+ FILE *fnul;
+ char *fmtname;
+ char *p;
+ char orgname[256];
+
+ char texbindir[256];
+ char fullbin[256];
+
+ kpse_set_program_name(av[0], NULL);
+
+ if(ac != 2) {
+ fprintf(stderr,"%s : Usage %s formatname\n", av[0], av[0]);
+ fprintf(stderr,"formatname : (foo.fmt, foo.nfmt, foo.mem, foo.base)\n");
+ return 1;
+ }
+
+ if(strlen(av[1]) > 127) {
+ fprintf(stderr, "\nToo long a format name.\n");
+ return 100;
+ }
+
+ p = kpse_var_value("SELFAUTOLOC");
+ if(p == 0) {
+ fprintf(stderr, "I cannot get SELFAUTOLOC\n");
+ exit(1);
+ }
+ strcpy(texbindir, p);
+ free(p);
+ for(p=texbindir; *p; p++) {
+ if(*p == '/') *p = '\\';
+ }
+ strcat(texbindir, "\\");
+
+ strcpy(orgname, av[1]);
+
+ p = strrchr(av[1], '.');
+ if(!p) {
+ fprintf(stderr, "formatname needs a suffix.\n");
+ return 1;
+ }
+
+ if(stricmp(p, ".fmt") && stricmp(p, ".nfmt") &&
+ stricmp(p, ".base") && stricmp(p, ".mem")) {
+ fprintf(stderr, "%s : unknown format type.\n", av[1]);
+ return 1;
+ }
+
+ *p = '\0';
+
+/* 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");
+ exit(100);
+ }
+ _dup2(fileno(fnul), fileno(stdin));
+
+/* COMMAND */
+ strcpy(fullbin, texbindir);
+ strcat(fullbin, "fmtutil.exe");
+ fprintf(stderr, "Running the command %s\n", fullbin);
+ spawnlp(P_WAIT, fullbin, "fmtutil", "--byfmt", av[1], NULL);
+
+/* END COMMAND */
+
+/* return to original stdout and stdin */
+ _dup2(savo, fileno(stdout));
+ close(savo);
+ _dup2(savi, fileno(stdin));
+ close(savi);
+
+/* close nul device */
+ fclose(fnul);
+
+ fmtname = kpse_find_file(orgname , kpse_fmt_format, 0);
+ if(fmtname) {
+ printf("%s\n", fmtname);
+ free(fmtname);
+ }
+ return 0;
+}
diff --git a/Build/source/texk/kpathsea/win32/mktexlsr.c b/Build/source/texk/kpathsea/win32/mktexlsr.c
new file mode 100644
index 00000000000..80e283faf1e
--- /dev/null
+++ b/Build/source/texk/kpathsea/win32/mktexlsr.c
@@ -0,0 +1,225 @@
+/*
+mktexlsr
+Web2C 2010 (2010/08/22 --ak)
+*/
+
+#include <kpathsea/kpathsea.h>
+
+#ifdef __MINGW32__
+#include "dirutil.h"
+#else
+#include <kpathsea/dirent.h>
+#endif
+
+#define MAXTREE 32 /* Max number of texmf trees */
+
+/* magic header */
+#define HDL "%% ls-R -- filename database for kpathsea; do not change this line.\n"
+
+#define VARTEXFONTS "c:/var/tex/fonts/ls-R"
+
+FILE *ls_R;
+
+static void
+search(const char *name)
+{
+ DIR *dp;
+ struct dirent *de;
+ char buff[256];
+ int len;
+
+ if ((dp = opendir(name))) {
+ fprintf(ls_R, "\n%s:\n", name);
+ while ((de = readdir(dp))) {
+ if(stricmp(de->d_name, ".") &&
+ stricmp(de->d_name, "..") &&
+ stricmp(de->d_name, ".bzr") &&
+ stricmp(de->d_name, ".git") &&
+ stricmp(de->d_name, ".hg") &&
+ stricmp(de->d_name, ".svn") &&
+ stricmp(de->d_name, "_bzr") &&
+ stricmp(de->d_name, "_git") &&
+ stricmp(de->d_name, "_hg") &&
+ stricmp(de->d_name, "_svn") &&
+ stricmp(de->d_name, "_darcs")) {
+ fprintf(ls_R, "%s\n", de->d_name);
+ }
+ }
+ closedir(dp);
+
+ len = strlen (name);
+ strcpy (buff, name);
+ if (name[len-1] != '/')
+ buff[len++] = '/';
+
+ dp = opendir(name);
+ while ((de = readdir(dp))) {
+ if(stricmp(de->d_name, ".") &&
+ stricmp(de->d_name, "..") &&
+ stricmp(de->d_name, ".bzr") &&
+ stricmp(de->d_name, ".git") &&
+ stricmp(de->d_name, ".hg") &&
+ stricmp(de->d_name, ".svn") &&
+ stricmp(de->d_name, "_bzr") &&
+ stricmp(de->d_name, "_git") &&
+ stricmp(de->d_name, "_hg") &&
+ stricmp(de->d_name, "_svn") &&
+ stricmp(de->d_name, "_darcs")) {
+#ifdef __MINGW32__
+ strcpy(buff + len, de->d_name);
+ if (is_dir (buff)) {
+ search (buff);
+ }
+#else
+ if (de->d_isdir) {
+ strcpy (buff + len, de->d_name);
+ search (buff);
+ }
+#endif
+ }
+ }
+ closedir(dp);
+ }
+}
+
+int Quiet = 0;
+
+int main(int ac, char **av)
+{
+ char *texmfdbs ;
+ int cdrive, tdrive;
+ char ls_R_name[256];
+ int len, i, numtree;
+ char *progname;
+ char *pathbuff[MAXTREE];
+ char *p, *q;
+
+ progname = av[0];
+ kpse_set_program_name(progname, NULL);
+
+ for(i = 0; i < MAXTREE; i++) {
+ pathbuff[i] = (char *)malloc(384);
+ if(!pathbuff[i]) {
+ fprintf(stderr, "Memory allocation error.\n");
+ exit(100);
+ }
+ }
+
+ if(ac > 1 && (!strncmp(av[1], "-v", 2) || !strncmp(av[1], "--v", 3))) {
+ puts (kpathsea_version_string);
+ puts ("Copyright 2010 Karl Berry & Olaf Weber.\n\
+There is NO warranty. You may redistribute this software\n\
+under the terms of the GNU General Public License.\n\
+For more information about these matters, see the files named GPL and LGPL.");
+ exit (0);
+ }
+
+ if(ac > 1 && (!strncmp(av[1], "-h", 2) || !strncmp(av[1], "--h", 3))) {
+ printf("Usage: %s [--quiet|--silent] [DIRS ...]\n\n"
+"Rebuild all necessary ls-R filename databases completely. If one or\n"
+"more arguments DIRS are given, these are used as texmf directories to\n"
+"build ls-R for. Else all directories in the search path for ls-R files\n"
+"($TEXMFDBS) are used.", av[0]);
+ exit (0);
+ }
+
+ if(ac > 1) {
+ if(!strncmp(av[1], "-q", 2) || !strncmp(av[1], "--q", 3) ||
+ !strncmp(av[1], "-s", 2) || !strncmp(av[1], "--s", 3)) {
+ Quiet = 1;
+ ac--;
+ av++;
+ }
+ }
+ if(ac > 1) {
+ if(ac > MAXTREE + 1) {
+ fprintf(stderr, "Number of trees must be less than %d.\n"
+ "Some trees are discarded.\n", MAXTREE);
+ numtree = MAXTREE;
+ } else {
+ numtree = ac - 1;
+ }
+ for(i=0; i < numtree; i++) {
+ strcpy(pathbuff[i], av[i+1]);
+ for(p=pathbuff[i]; *p; p++) {
+ if(*p == '\\')
+ *p = '/';
+ else if (IS_KANJI(p))
+ p++;
+ }
+ }
+ } else {
+ if(!(p = kpse_var_value("TEXMFDBS"))) {
+ fprintf(stderr, "TEXMFDBS is not defined in texmf.cnf.\n");
+ exit (100);
+ }
+
+ texmfdbs = kpse_brace_expand(p);
+ free(p);
+
+ for(i=0 ; (i < MAXTREE) && *texmfdbs ; i++) {
+ p = strchr(texmfdbs, ';');
+ if(!p) {
+ strcpy(pathbuff[i], texmfdbs);
+ q = pathbuff[i];
+ if(*q == '!' && *(q+1) == '!')
+ q += 2;
+ strcpy(pathbuff[i], q);
+ i++;
+ break;
+ }
+ *p = '\0';
+ strcpy(pathbuff[i], texmfdbs);
+ q = pathbuff[i];
+ if(*q == '!' && *(q+1) == '!')
+ q += 2;
+ strcpy(pathbuff[i], q);
+ p++;
+ texmfdbs = p;
+ }
+
+ numtree = i;
+ }
+
+ for(i = 0; i < numtree; i++) {
+ strcpy(ls_R_name, pathbuff[i]);
+ len = strlen(ls_R_name);
+ if(ls_R_name[len-1] != '/') strcat(ls_R_name, "/");
+ strcat(ls_R_name, "ls-R");
+
+ ls_R = fopen(ls_R_name, "wb");
+ if(!ls_R) {
+ fprintf(stderr, "Cannot open %s to write.\n", ls_R_name);
+ if(!stricmp(ls_R_name, VARTEXFONTS))
+ fprintf(stderr, " (Don't mind this message.)\n");
+ continue;
+ }
+
+ cdrive = _getdrive();
+
+ if(ls_R_name[1] == ':') {
+ tdrive = tolower(ls_R_name[0]) - 'a' + 1;
+ _chdrive(tdrive);
+ }
+
+ _chdir(pathbuff[i]);
+ if(!Quiet)
+ fprintf(stderr, "%s: Updating %s...\n", progname, ls_R_name);
+ fprintf(ls_R, HDL);
+ search("./");
+
+ fclose(ls_R);
+ if(!Quiet)
+ fprintf(stderr, "%s: Updated %s.\n", progname, ls_R_name);
+ _chdrive(cdrive);
+ }
+
+ if(!Quiet)
+ fprintf(stderr, "%s: Done.\n", progname);
+
+ for(i = 0; i < MAXTREE; i++) {
+ free(pathbuff[i]);
+ }
+
+ return 0;
+}
diff --git a/Build/source/texk/kpathsea/win32/mktexmf.c b/Build/source/texk/kpathsea/win32/mktexmf.c
index df7f6f28c59..a1ff80b87f0 100644
--- a/Build/source/texk/kpathsea/win32/mktexmf.c
+++ b/Build/source/texk/kpathsea/win32/mktexmf.c
@@ -5,14 +5,8 @@
*/
#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 "dirutil.h"
#include "getdestdir.h"
#include "mktexupd.h"
diff --git a/Build/source/texk/kpathsea/win32/mktexpk.c b/Build/source/texk/kpathsea/win32/mktexpk.c
index 5445dfb4eac..e4f23087644 100644
--- a/Build/source/texk/kpathsea/win32/mktexpk.c
+++ b/Build/source/texk/kpathsea/win32/mktexpk.c
@@ -28,17 +28,8 @@
*/
#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 "dirutil.h"
#include "getdestdir.h"
#include "mktexupd.h"
@@ -269,12 +260,10 @@ main (int ac, char **av)
*/
for (fpp = tmp; *fpp; fpp++) {
- if (isknj (*fpp)) {
- if(*(fpp+1)) fpp++;
- continue;
- }
if (*fpp == '\\')
*fpp = '/';
+ else if (IS_KANJI(fpp))
+ fpp++;
}
for (i = 0; i < 4; i++)
@@ -623,12 +612,10 @@ main (int ac, char **av)
return (100);
}
for (fpp = currdir; *fpp; fpp++) {
- if (isknj (*fpp)) {
- if(*(fpp+1)) fpp++;
- continue;
- }
if (*fpp == '\\')
*fpp = '/';
+ else if (IS_KANJI(fpp))
+ fpp++;
}
i = strlen (currdir);
@@ -663,12 +650,10 @@ main (int ac, char **av)
*/
for (p = rbuff; *p; p++) {
- if (isknj (*p)) {
- if(*(p+1)) p++;
- continue;
- }
if (*p == '\\')
*p = '/';
+ else if (IS_KANJI(p))
+ p++;
}
p = rbuff;
diff --git a/Build/source/texk/kpathsea/win32/mktextfm.c b/Build/source/texk/kpathsea/win32/mktextfm.c
index 4dfbac8123c..14ef9526b85 100644
--- a/Build/source/texk/kpathsea/win32/mktextfm.c
+++ b/Build/source/texk/kpathsea/win32/mktextfm.c
@@ -11,16 +11,8 @@
#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 "dirutil.h"
#include "getdestdir.h"
#include "mktexupd.h"
@@ -126,12 +118,10 @@ main (int ac, char **av)
tmp = xstrdup(tmp);
for (fpp = tmp; *fpp; fpp++) {
- if (isknj (*fpp)) {
- if(*(fpp+1)) fpp++;
- continue;
- }
if (*fpp == '\\')
*fpp = '/';
+ else if (IS_KANJI(fpp))
+ fpp++;
}
/*
issetdest = 0 : TDS
@@ -169,12 +159,10 @@ issetdest = 2 : current directory
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 if (IS_KANJI(p))
+ p++;
}
} else {
strcpy (fontname, av[1]);
@@ -213,12 +201,10 @@ issetdest = 2 : current directory
return (100);
}
for (fpp = currdir; *fpp; fpp++) {
- if (isknj (*fpp)) {
- if(*(fpp+1)) fpp++;
- continue;
- }
if (*fpp == '\\')
*fpp = '/';
+ else if (IS_KANJI(fpp))
+ fpp++;
}
i = strlen (currdir);
diff --git a/Build/source/texk/kpathsea/win32/mktexupd.c b/Build/source/texk/kpathsea/win32/mktexupd.c
index 5e58a8618df..ffe5fb338d7 100644
--- a/Build/source/texk/kpathsea/win32/mktexupd.c
+++ b/Build/source/texk/kpathsea/win32/mktexupd.c
@@ -1,14 +1,4 @@
#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"
diff --git a/Build/source/texk/kpathsea/win32/mktexupdmain.c b/Build/source/texk/kpathsea/win32/mktexupdmain.c
index 393020e7ae0..a1484faa9f7 100644
--- a/Build/source/texk/kpathsea/win32/mktexupdmain.c
+++ b/Build/source/texk/kpathsea/win32/mktexupdmain.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <kpathsea/kpathsea.h>
#include "mktexupd.h"