diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-06-18 10:49:17 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-06-18 10:49:17 +0000 |
commit | 973cc50127fd0835fbbd57bbb9dd8885c60e154d (patch) | |
tree | c14d3476c68fd27c7e3382b9e5089e410ac9a6de /Build/source/texk | |
parent | bae57b6f7ea0c81be60f4c73814128c4c91a84ee (diff) |
Sync WIN32 versions of mktex* with W32TeX
git-svn-id: svn://tug.org/texlive/trunk@37597 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
22 files changed, 694 insertions, 303 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index d7b0f1b8110..06125ce725b 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,7 @@ +2015-06-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + * configure.ac: Define WEB2CVERSION for WIN32 programs. + 2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> * version.ac: Update version number 6.2.1 => 6.2.2dev. diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in index 24556754826..c971f22503c 100644 --- a/Build/source/texk/kpathsea/Makefile.in +++ b/Build/source/texk/kpathsea/Makefile.in @@ -639,7 +639,6 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ WARNING_CFLAGS = @WARNING_CFLAGS@ -WEB2CVERSION = @WEB2CVERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ diff --git a/Build/source/texk/kpathsea/c-auto.in b/Build/source/texk/kpathsea/c-auto.in index 8029626515c..a8dfb4aefdc 100644 --- a/Build/source/texk/kpathsea/c-auto.in +++ b/Build/source/texk/kpathsea/c-auto.in @@ -194,6 +194,9 @@ /* Version number of package */ #undef VERSION +/* Define to the current TeX Live version string. */ +#undef WEB2CVERSION + /* Define to 1 if we need (v)snprintf wrapper functions. */ #undef WRAP_SNPRINTF diff --git a/Build/source/texk/kpathsea/configure b/Build/source/texk/kpathsea/configure index d0f4dc5809d..1e0cfa0d320 100755 --- a/Build/source/texk/kpathsea/configure +++ b/Build/source/texk/kpathsea/configure @@ -723,7 +723,6 @@ am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -WEB2CVERSION KPSE_LT_VERSINFO KPSEVERSION target_alias @@ -2764,7 +2763,8 @@ KPSE_LT_VERSINFO=8:2:2 - WEB2CVERSION=2016/dev + +$as_echo "#define WEB2CVERSION \" (TeX Live 2016/dev)\"" >>confdefs.h am__api_version='1.15' diff --git a/Build/source/texk/kpathsea/configure.ac b/Build/source/texk/kpathsea/configure.ac index 84d0d89e4e9..28ed24d85f4 100644 --- a/Build/source/texk/kpathsea/configure.ac +++ b/Build/source/texk/kpathsea/configure.ac @@ -17,7 +17,8 @@ AC_SUBST([KPSEVERSION], [kpse_version]) KPSE_LT_VERSION([kpse]) m4_include([../../version.ac])[] dnl define tex_live_version -AC_SUBST([WEB2CVERSION], [tex_live_version]) +AC_DEFINE([WEB2CVERSION], [" (TeX Live tex_live_version)"], + [Define to the current TeX Live version string.]) dnl Common code for all programs using libkpathsea. KPSE_COMMON([kpathsea]) diff --git a/Build/source/texk/kpathsea/doc/Makefile.in b/Build/source/texk/kpathsea/doc/Makefile.in index dfe9f58d02d..4828ae2ae60 100644 --- a/Build/source/texk/kpathsea/doc/Makefile.in +++ b/Build/source/texk/kpathsea/doc/Makefile.in @@ -269,7 +269,6 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ WARNING_CFLAGS = @WARNING_CFLAGS@ -WEB2CVERSION = @WEB2CVERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ diff --git a/Build/source/texk/kpathsea/man/Makefile.in b/Build/source/texk/kpathsea/man/Makefile.in index f4e51cd29c1..d5be4eac784 100644 --- a/Build/source/texk/kpathsea/man/Makefile.in +++ b/Build/source/texk/kpathsea/man/Makefile.in @@ -231,7 +231,6 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ WARNING_CFLAGS = @WARNING_CFLAGS@ -WEB2CVERSION = @WEB2CVERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ diff --git a/Build/source/texk/kpathsea/win32/ChangeLog b/Build/source/texk/kpathsea/win32/ChangeLog index d0419ee6e9e..74b858b73ab 100644 --- a/Build/source/texk/kpathsea/win32/ChangeLog +++ b/Build/source/texk/kpathsea/win32/ChangeLog @@ -1,3 +1,12 @@ +2015-06-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + * Makefile.am (AM_CPPFLAGS): Drop WEB2C_KPSE_VERSION. + * dirutil.[ch], getdestdir.h, mktexupd.h: Add W32TeX Copyright. + * getdestdir.c, mktexfmt.c, mktexlsr.c, mktexmf.c, mktexupd.c, + mktexupdmain.c: Sync with W32TeX. + * mktexpk.c, mktextfm.c: Sync with W32TeX. + Use KPSEVERSION and WEB2CVERSION instead of WEB2C_KPSE_VERSION. + 2015-04-12 Peter Breitenlohner <peb@mppmu.mpg.de> * Makefile.am (bin_PROGRAMS): Drop fmtutil, now a perl script. diff --git a/Build/source/texk/kpathsea/win32/Makefile.am b/Build/source/texk/kpathsea/win32/Makefile.am index f8a8296baf3..875e2f61081 100644 --- a/Build/source/texk/kpathsea/win32/Makefile.am +++ b/Build/source/texk/kpathsea/win32/Makefile.am @@ -4,7 +4,6 @@ ## You may freely use, modify and/or distribute this file. ## AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. -AM_CPPFLAGS += -DWEB2C_KPSE_VERSION='"Web2C-$(WEB2CVERSION) Kpathsea-$(KPSEVERSION)"' AM_CFLAGS = $(WARNING_CFLAGS) # Build WIN32 replacements for Unix shell scripts. diff --git a/Build/source/texk/kpathsea/win32/Makefile.in b/Build/source/texk/kpathsea/win32/Makefile.in index bb10aee6f25..8b49202aa31 100644 --- a/Build/source/texk/kpathsea/win32/Makefile.in +++ b/Build/source/texk/kpathsea/win32/Makefile.in @@ -279,7 +279,6 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ WARNING_CFLAGS = @WARNING_CFLAGS@ -WEB2CVERSION = @WEB2CVERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -332,9 +331,7 @@ 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)/.. \ - -DWEB2C_KPSE_VERSION='"Web2C-$(WEB2CVERSION) \ - Kpathsea-$(KPSEVERSION)"' +AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. AM_CFLAGS = $(WARNING_CFLAGS) mktexfmt_SOURCES = \ mktexfmt.c diff --git a/Build/source/texk/kpathsea/win32/dirutil.c b/Build/source/texk/kpathsea/win32/dirutil.c index db0525f6529..4b471ad543d 100644 --- a/Build/source/texk/kpathsea/win32/dirutil.c +++ b/Build/source/texk/kpathsea/win32/dirutil.c @@ -1,3 +1,20 @@ +/* dirutil.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ #include <kpathsea/kpathsea.h> diff --git a/Build/source/texk/kpathsea/win32/dirutil.h b/Build/source/texk/kpathsea/win32/dirutil.h index c260ff37921..72fb1dc3da9 100644 --- a/Build/source/texk/kpathsea/win32/dirutil.h +++ b/Build/source/texk/kpathsea/win32/dirutil.h @@ -1,3 +1,21 @@ +/* dirutil.h + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + 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/getdestdir.c b/Build/source/texk/kpathsea/win32/getdestdir.c index 2dcafbd242f..136f6fab4c2 100644 --- a/Build/source/texk/kpathsea/win32/getdestdir.c +++ b/Build/source/texk/kpathsea/win32/getdestdir.c @@ -1,9 +1,24 @@ -/* -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 +/* getdestdir.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. + + 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> @@ -52,10 +67,10 @@ getdestdir (int ac, char **av) strcpy (spec, av[1]); for (p = av[2]; *p; p++) { /* path */ - if (*p == '\\') - *p = '/'; - else if (IS_KANJI(p)) + if (IS_KANJI(p)) p++; + else if (*p == '\\') + *p = '/'; } p = av[2]; @@ -129,12 +144,12 @@ getdestdir (int ac, char **av) topdir = kpse_var_value ("MAKETEXPK_TOP_DIR"); if (topdir && *topdir && ispk) { for (i = 0; topdir[i]; i++) { - if (topdir[i] == '\\') - topdir[i] = '/'; - else if (IS_KANJI(topdir+i)) + if (IS_KANJI(topdir+i)) i++; + else if (topdir[i] == '\\') + topdir[i] = '/'; } - i = strlen (topdir); + i = (int)strlen (topdir); while(topdir[i - 1] == '/') i--; topdir[i] = '\0'; @@ -164,12 +179,12 @@ getdestdir (int ac, char **av) } else { if((topdir = kpse_var_value("TEXMFVAR")) != NULL) { for (i = 0; topdir[i]; i++) { - if (topdir[i] == '\\') - topdir[i] = '/'; - else if (IS_KANJI(topdir+i)) + if (IS_KANJI(topdir+i)) i++; + else if (topdir[i] == '\\') + topdir[i] = '/'; } - i = strlen (topdir); + i = (int)strlen (topdir); while(topdir[i - 1] == '/') i--; topdir[i] = '\0'; diff --git a/Build/source/texk/kpathsea/win32/getdestdir.h b/Build/source/texk/kpathsea/win32/getdestdir.h index 743db043675..ab1f2d652f9 100644 --- a/Build/source/texk/kpathsea/win32/getdestdir.h +++ b/Build/source/texk/kpathsea/win32/getdestdir.h @@ -1 +1,24 @@ +/* getdestdir.h + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. + + 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 +*/ + 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 index e6b3e6ff32c..3171643d64f 100644 --- a/Build/source/texk/kpathsea/win32/mktexfmt.c +++ b/Build/source/texk/kpathsea/win32/mktexfmt.c @@ -1,8 +1,28 @@ /* mktexfmt.c - */ + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +/* + kpathsea functions +*/ #include <kpathsea/kpathsea.h> +#define VERSION "0.1" + int main(int ac, char **av) { int savo, savi; @@ -16,11 +36,21 @@ int main(int ac, char **av) kpse_set_program_name(av[0], NULL); + p = kpse_program_name; if(ac != 2) { - fprintf(stderr,"%s : Usage %s formatname\n", av[0], av[0]); + fprintf(stderr,"%s : Usage %s formatname\n", p, p); fprintf(stderr,"formatname : (foo.fmt, foo.nfmt, foo.mem, foo.base)\n"); return 1; } + if(!strncmp(av[1], "-h", 2) || !strncmp(av[1], "--h", 3)) { + fprintf(stderr,"%s : Usage %s formatname\n", p, p); + fprintf(stderr,"formatname : (foo.fmt, foo.nfmt, foo.mem, foo.base)\n"); + return 0; + } + if(!strncmp(av[1], "-v", 2) || !strncmp(av[1], "--v", 3)) { + fprintf(stderr,"%s : Version %s\n", p, VERSION); + return 0; + } if(strlen(av[1]) > 127) { fprintf(stderr, "\nToo long a format name.\n"); diff --git a/Build/source/texk/kpathsea/win32/mktexlsr.c b/Build/source/texk/kpathsea/win32/mktexlsr.c index 80e283faf1e..c2ddc81273f 100644 --- a/Build/source/texk/kpathsea/win32/mktexlsr.c +++ b/Build/source/texk/kpathsea/win32/mktexlsr.c @@ -1,6 +1,21 @@ -/* -mktexlsr -Web2C 2010 (2010/08/22 --ak) +/* mktexlsr.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. + + Web2C 2010 (2010/08/22 --ak) */ #include <kpathsea/kpathsea.h> @@ -11,8 +26,6 @@ Web2C 2010 (2010/08/22 --ak) #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" @@ -21,16 +34,24 @@ Web2C 2010 (2010/08/22 --ak) FILE *ls_R; static void -search(const char *name) +search(char *name) { DIR *dp; struct dirent *de; char buff[256]; + char *p; int len; - if ((dp = opendir(name))) { + for(p = name; *p; p++) { + if(IS_KANJI(p)) + p++; + else if (*p == '\\') + *p = '/'; + } + + if((dp = opendir(name))) { fprintf(ls_R, "\n%s:\n", name); - while ((de = readdir(dp))) { + while((de = readdir(dp))) { if(stricmp(de->d_name, ".") && stricmp(de->d_name, "..") && stricmp(de->d_name, ".bzr") && @@ -47,13 +68,15 @@ search(const char *name) } closedir(dp); - len = strlen (name); - strcpy (buff, name); - if (name[len-1] != '/') - buff[len++] = '/'; + len = (int)strlen(name); + strcpy(buff, name); + if(name[len-1] != '/') { + strcat(buff, "/"); + len++; + } dp = opendir(name); - while ((de = readdir(dp))) { + while((de = readdir(dp))) { if(stricmp(de->d_name, ".") && stricmp(de->d_name, "..") && stricmp(de->d_name, ".bzr") && @@ -67,15 +90,14 @@ search(const char *name) stricmp(de->d_name, "_darcs")) { #ifdef __MINGW32__ strcpy(buff + len, de->d_name); - if (is_dir (buff)) { - search (buff); - } + if(!is_dir(buff)) + continue; #else - if (de->d_isdir) { - strcpy (buff + len, de->d_name); - search (buff); - } -#endif + if(!de->d_isdir) + continue; + strcpy(buff + len, de->d_name); +#endif + search(buff); } } closedir(dp); @@ -84,33 +106,25 @@ search(const char *name) int Quiet = 0; +char first_name[] = "./"; + int main(int ac, char **av) { - char *texmfdbs ; + char *texmfdbs = NULL; int cdrive, tdrive; - char ls_R_name[256]; - int len, i, numtree; + char ls_R_name[512]; + int i, numtree; + size_t len; char *progname; - char *pathbuff[MAXTREE]; - char *p, *q; - - progname = av[0]; - kpse_set_program_name(progname, NULL); + char **pathbuff = NULL; + char *p, *pa, *pc; - for(i = 0; i < MAXTREE; i++) { - pathbuff[i] = (char *)malloc(384); - if(!pathbuff[i]) { - fprintf(stderr, "Memory allocation error.\n"); - exit(100); - } - } + kpse_set_program_name(av[0], NULL); + progname = kpse_program_name; 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."); + puts ("mktexlsr: (C version 1.1 --ak 2002-2015)"); exit (0); } @@ -131,21 +145,17 @@ For more information about these matters, see the files named GPL and LGPL."); 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; - } + numtree = ac - 1; + pathbuff = xmalloc(numtree * sizeof(char *)); 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++; + pathbuff[i] = xstrdup(av[i+1]); + for(p = pathbuff[i]; *p; p++) { + if(IS_KANJI(p)) + p++; + else if(*p == '\\') + *p = '/'; } } } else { @@ -157,30 +167,61 @@ For more information about these matters, see the files named GPL and LGPL."); 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 = texmfdbs; + i = 0; + + while(*p) { + if(*p == '!' && *(p+1) == '!') + p += 2; + if(*p == ';') + while(*p == ';') + p++; + if(*p && *p != '!') { + while(*p != ';' && *p) + p++; + if(*p == ';') { + i++; + while(*p == ';') + p++; + } else if(*p == '\0') { + 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; + + pathbuff = malloc(numtree * sizeof(char *)); + + i = 0; + pa = texmfdbs; + + while (*pa) { + if (*pa == '!' && *(pa + 1) == '!') + pa += 2; + if (*pa == ';') { + while (*pa == ';') + pa++; + } + if(*pa && *pa != '!') { + pathbuff[i] = malloc(strlen(pa) + 1); + pc = pathbuff[i]; + while (*pa != ';' && *pa) + *pc++ = *pa++; + *pc = '\0'; + if (*pa == ';') { + while (*pa == ';') + pa++; + i++; + } else if (*pa == '\0') { + i++; + break; + } + } + } } - + for(i = 0; i < numtree; i++) { strcpy(ls_R_name, pathbuff[i]); len = strlen(ls_R_name); @@ -189,9 +230,9 @@ For more information about these matters, see the files named GPL and LGPL."); ls_R = fopen(ls_R_name, "wb"); if(!ls_R) { - fprintf(stderr, "Cannot open %s to write.\n", ls_R_name); + fprintf(stdout, "Cannot open %s to write.\n", ls_R_name); if(!stricmp(ls_R_name, VARTEXFONTS)) - fprintf(stderr, " (Don't mind this message.)\n"); + fprintf(stdout, " (Don't mind this message.)\n"); continue; } @@ -204,22 +245,27 @@ For more information about these matters, see the files named GPL and LGPL."); _chdir(pathbuff[i]); if(!Quiet) - fprintf(stderr, "%s: Updating %s...\n", progname, ls_R_name); + fprintf(stdout, "%s: Updating %s...\n", progname, ls_R_name); fprintf(ls_R, HDL); - search("./"); + search(first_name); fclose(ls_R); if(!Quiet) - fprintf(stderr, "%s: Updated %s.\n", progname, ls_R_name); + fprintf(stdout, "%s: Updated %s.\n", progname, ls_R_name); _chdrive(cdrive); } if(!Quiet) - fprintf(stderr, "%s: Done.\n", progname); + fprintf(stdout, "%s: Done.\n", progname); - for(i = 0; i < MAXTREE; i++) { + for(i = 0; i < numtree; i++) { free(pathbuff[i]); } + free (pathbuff); + + if(texmfdbs) + free(texmfdbs); + return 0; } diff --git a/Build/source/texk/kpathsea/win32/mktexmf.c b/Build/source/texk/kpathsea/win32/mktexmf.c index a1ff80b87f0..876719d1c54 100644 --- a/Build/source/texk/kpathsea/win32/mktexmf.c +++ b/Build/source/texk/kpathsea/win32/mktexmf.c @@ -1,7 +1,19 @@ -/* - * mktexmf.c (Borrowed from Fabrice) - * (2006 --ak) - * +/* mktexmf.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. */ #include <kpathsea/kpathsea.h> @@ -10,9 +22,7 @@ #include "getdestdir.h" #include "mktexupd.h" -#define SBUF 256 - -char *progname; +#define SBUF 512 static int test_file(char c, char * name) @@ -51,6 +61,7 @@ test_file(char c, char * name) if (_access(name, 4) == 0) return 1; else return 0; } + /* never reaches here */ return 0; } @@ -59,7 +70,7 @@ usage(void) { fprintf(stderr, "Usage : mktexmf FONT.\n\n"); fprintf(stderr, "Makes the Metafont source file for FONT," - " if possible. For example,\n"); + " if possible. For example,\n"); fprintf(stderr, "`ecr12' or `cmr11'.\n"); } @@ -113,18 +124,30 @@ main (int argc, char **argv) FILE *f; size_t ptsz_len; char font[SBUF]; + char *progname; char mfname[SBUF]; char *arg[4]; int i; char *ptr; - progname = argv[0]; - kpse_set_program_name (progname, NULL); + kpse_set_program_name (argv[0], NULL); + progname = kpse_program_name; + if (argc != 2) { usage(); return 0; } + if (strncmp(argv[1], "-v",2) == 0 || strncmp(argv[1], "--v",3) == 0) { + fprintf ( stderr, "%s, (C version 1.1 --ak 2006-2015)\n", progname); + return 0; + } + + if (strncmp(argv[1], "-h",2) == 0 || strncmp(argv[1], "--h",3) == 0) { + fprintf ( stderr, "%s, Usage: %s FontBaseName\n", progname, progname); + return 0; + } + for (i=0; i < 4; i++) { arg[i] = (char *)malloc(SBUF); } @@ -140,11 +163,11 @@ main (int argc, char **argv) fprintf(stderr, "name = %s, rootname = %s, pointsize = %s\n", - name, rootname, pointsize); + name, rootname, pointsize); sauterroot = kpse_find_file(concat3("b-", rootname, ".mf"), - kpse_mf_format, false); + kpse_mf_format, false); if (sauterroot && *sauterroot) { rootfile = sauterroot; @@ -160,30 +183,30 @@ main (int argc, char **argv) destdir = ptr; } else if (strlen(name) == 8 - && FILESTRNCASEEQ(name, "csso12", 6) - && (name[6] >= '0' && name[6] <= '5') - && isdigit(name[7])) { + && 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) - ) { + || 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); + 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])))) { + && ((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'; @@ -193,7 +216,7 @@ main (int argc, char **argv) else { string tem; rootfile = kpse_find_file(tem = concat(rootname, ".mf"), - kpse_mf_format, false); + kpse_mf_format, false); free(tem); } @@ -214,9 +237,9 @@ main (int argc, char **argv) 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; + fprintf(stderr, "Cannot get destination directory name.\n"); + relmem (arg); + return 1; } destdir = ptr; } @@ -234,19 +257,19 @@ main (int argc, char **argv) return 1; } else if (ptsz_len == 2) { if (pointsize[0] == '1' && pointsize[1] == '1') - realsize = "10.95"; /* \magstephalf */ + realsize = "10.95"; /* \magstephalf */ else if (pointsize[0] == '1' && pointsize[1] == '4') - realsize = "14.4"; /* \magstep2 */ + realsize = "14.4"; /* \magstep2 */ else if (pointsize[0] == '1' && pointsize[1] == '7') - realsize = "17.28"; /* \magstep3 */ + realsize = "17.28"; /* \magstep3 */ else if (pointsize[0] == '2' && pointsize[1] == '0') - realsize = "20.74"; /* \magstep4 */ + realsize = "20.74"; /* \magstep4 */ else if (pointsize[0] == '2' && pointsize[1] == '5') - realsize = "24.88"; /* \magstep5 */ + realsize = "24.88"; /* \magstep5 */ else if (pointsize[0] == '3' && pointsize[1] == '0') - realsize = "29.86"; /* \magstep6 */ + realsize = "29.86"; /* \magstep6 */ else if (pointsize[0] == '3' && pointsize[1] == '6') - realsize = "35.83"; /* \magstep7 */ + realsize = "35.83"; /* \magstep7 */ else realsize = pointsize; } @@ -260,7 +283,7 @@ main (int argc, char **argv) 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])) { + && 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]; @@ -272,7 +295,7 @@ main (int argc, char **argv) /* mfname is the full name */ strcpy (mfname, destdir); - i = strlen (mfname); + i = (int)strlen (mfname); if (mfname[i-1] != '/') { mfname[i] = '/'; mfname[i+1] = '\0'; @@ -291,7 +314,7 @@ main (int argc, char **argv) if ((f = fopen(mfname, "wb")) == NULL) { fprintf(stderr, "%s: can't write into the file %s/%s.\n", - progname, destdir, name); + progname, destdir, name); if (destdir) free (destdir); relmem (arg); return 1; @@ -308,29 +331,29 @@ main (int argc, char **argv) } else if (FILESTRNCASEEQ(name, "cs", 2) - || FILESTRNCASEEQ(name, "lcsss", 5) - || FILESTRNCASEEQ(name, "icscsc", 6) - || FILESTRNCASEEQ(name, "icstt", 5) - || FILESTRNCASEEQ(name, "ilcsss", 6) - ) { + || 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])))) { + && ((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])) { + && 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. @@ -341,7 +364,7 @@ main (int argc, char **argv) /* 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); + realsize, rootname); } fclose(f); diff --git a/Build/source/texk/kpathsea/win32/mktexpk.c b/Build/source/texk/kpathsea/win32/mktexpk.c index 2d562528495..ee716b8de76 100644 --- a/Build/source/texk/kpathsea/win32/mktexpk.c +++ b/Build/source/texk/kpathsea/win32/mktexpk.c @@ -1,33 +1,52 @@ -/* 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] - */ +/* mktexpk.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. + + %%---------------------------------------- + % 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> +#ifndef __MINGW32__ +#include <web2c/w2c/c-auto.h> +#endif #include "dirutil.h" #include "getdestdir.h" @@ -35,8 +54,8 @@ #define LLBUF 1024 #define LBUF 512 -#define SBUF 256 -#define TBUF 256 +#define SBUF 512 +#define TBUF 512 /* Global variables @@ -116,7 +135,7 @@ static void version (void) { fprintf (stderr, "%s, (C version 1.5 --ak 2006-2012)\n", progname); - fprintf (stderr, WEB2C_KPSE_VERSION "\n"); + fprintf (stderr, KPSEVERSION WEB2CVERSION "\n"); } static void @@ -168,6 +187,34 @@ relmem (char **v) return; } +static void +get_designsize(char *tfname, char *dsiz) +{ + FILE *f; + unsigned char a, b, c, d; + unsigned int n; + double x; + char *p; + + strcpy(dsiz, "10.0"); /* default */ + + p = kpse_find_file (tfname, kpse_tfm_format, 0); + if(p) { + f = fopen(p, "rb"); + free(p); + if(f) { + fseek(f, 28, SEEK_SET); + a = getc(f); + b = getc(f); + c = getc(f); + d = getc(f); + fclose(f); + n = (a << 24) + (b << 16) + (c << 8) + d; + x = n / 1048576.0; + sprintf(dsiz, "%.1lf", x); + } + } +} int main (int ac, char **av) @@ -187,6 +234,7 @@ main (int ac, char **av) char mag[TBUF]; char mode[TBUF]; char destdir[SBUF]; + char designsize[64]; char *arg[4]; @@ -244,9 +292,9 @@ main (int ac, char **av) tmp = getenv ("TEMP"); if (!tmp) - getenv ("TMP"); + tmp = getenv ("TMP"); if (!tmp) - getenv ("TMPDIR"); + tmp = getenv ("TMPDIR"); if (!tmp) { tpkerr ("Please define TEMP | TMP | TMPDIR."); return (100); @@ -257,17 +305,17 @@ main (int ac, char **av) */ for (fpp = tmp; *fpp; fpp++) { - if (*fpp == '\\') - *fpp = '/'; - else if (IS_KANJI(fpp)) + if (IS_KANJI(fpp)) fpp++; + else if (*fpp == '\\') + *fpp = '/'; } for (i = 0; i < 4; i++) arg[i] = (char *) malloc (SBUF); - progname = av[0]; - kpse_set_program_name (progname, NULL); + kpse_set_program_name (av[0], NULL); + progname = kpse_program_name; /* * get tex binary dir @@ -289,6 +337,7 @@ main (int ac, char **av) if (ac < 2) { usage (); relmem (arg); + free(tmp); return (100); } @@ -314,6 +363,7 @@ main (int ac, char **av) if (ac < 5) { usage (); relmem (arg); + free(tmp); return (100); } if((strlen(av[1]) > TBUF -1 ) || @@ -321,6 +371,7 @@ main (int ac, char **av) (strlen(av[3]) > TBUF -1 ) || (strlen(av[4]) > TBUF -1 )) { fprintf(stderr, "\nToo long a string.\n"); + free(tmp); return 100; } @@ -331,6 +382,7 @@ main (int ac, char **av) if (ac > 5) { if(strlen(av[5]) > TBUF -1) { fprintf(stderr, "\nToo long a string.\n"); + free(tmp); return 100; } strcpy (mode, av[5]); @@ -346,6 +398,7 @@ main (int ac, char **av) while (i < ac) { if(strlen(av[i]) > TBUF - 1) { fprintf(stderr, "\nToo long a string.\n"); + free(tmp); return 100; } if (av[i][0] != '-') { @@ -355,8 +408,9 @@ main (int ac, char **av) if (!strcmp (av[i], "--dpi") || !strcmp (av[i], "-dpi")) { i++; if (i >= ac) { - tpkerr ("Invarid arguments."); + tpkerr ("Invalid arguments."); relmem (arg); + free(tmp); return (100); } strcpy (dpi, av[i]); @@ -364,8 +418,9 @@ main (int ac, char **av) } else if (!strcmp (av[i], "--bdpi") || !strcmp (av[i], "-bdpi")) { i++; if (i >= ac) { - tpkerr ("Invarid arguments."); + tpkerr ("Invalid arguments."); relmem (arg); + free(tmp); return (100); } strcpy (bdpi, av[i]); @@ -373,8 +428,9 @@ main (int ac, char **av) } else if (!strcmp (av[i], "--mag") || !strcmp (av[i], "-mag")) { i++; if (i >= ac) { - tpkerr ("Invarid arguments."); + tpkerr ("Invalid arguments."); relmem (arg); + free(tmp); return (100); } strcpy (mag, av[i]); @@ -382,8 +438,9 @@ main (int ac, char **av) } else if (!strcmp (av[i], "--mfmode") || !strcmp (av[i], "-mfmode")) { i++; if (i >= ac) { - tpkerr ("Invarid arguments."); + tpkerr ("Invalid arguments."); relmem (arg); + free(tmp); return (100); } strcpy (mode, av[i]); @@ -391,8 +448,9 @@ main (int ac, char **av) } else if (!strcmp (av[i], "--destdir") || !strcmp (av[i], "-destdir")) { i++; if (i >= ac) { - tpkerr ("Invarid arguments."); + tpkerr ("Invalid arguments."); relmem (arg); + free(tmp); return (100); } strcpy (destdir, av[i]); @@ -401,14 +459,17 @@ main (int ac, char **av) } else if (!strcmp (av[i], "--version") || !strcmp (av[i], "-version")) { version (); relmem (arg); + free(tmp); return (0); } else if (!strcmp (av[i], "--help") || !strcmp (av[i], "-help")) { help (); relmem (arg); + free(tmp); return (0); } else { tpkerr ("Argument error."); relmem (arg); + free(tmp); return (100); } } @@ -447,17 +508,20 @@ main (int ac, char **av) if (!frd) { tpkerr ("I cannot find METAFONT.\n"); relmem (arg); + free(tmp); return (100); } (void) fgets (buff, 126, frd); (void) fgets (buff, 126, frd); pclose (frd); - remove ("mfput.log"); - remove ("mfput.tfm"); + system("del /Q mfput.*"); - len = strlen (buff); - if (buff[len - 1] == '\n') + len = (int)strlen (buff); + if (buff[len - 1] == '\n') { buff[len - 1] = '\0'; + if (buff[len - 2] == '\r') + buff[len - 2] = '\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"); @@ -540,6 +604,7 @@ main (int ac, char **av) if (name[0] == 0) { tpkerr ("Font name is not given."); relmem (arg); + free(tmp); return (100); } @@ -553,6 +618,7 @@ main (int ac, char **av) if (!(p = kpse_var_value ("MFINPUTS"))) { tpkerr ("Cannot get value of MFINPUTS."); relmem (arg); + free(tmp); return (100); } free (p); @@ -571,6 +637,7 @@ main (int ac, char **av) if (!(p = kpse_var_value ("TFMFONTS"))) { tpkerr ("Cannot get value of TFMFONTS."); relmem (arg); + free(tmp); return (100); } free (p); @@ -580,12 +647,14 @@ main (int ac, char **av) if (!(p = kpse_find_file (tfname, kpse_tfm_format, 0))) { fprintf (stderr, "Cannot find %s .\n", tfname); relmem (arg); + free(tmp); return 100; } tfmfileptr = fopen (p, "rb"); if (!tfmfileptr) { fprintf (stderr, "I cannot open %s.\n", p); relmem (arg); + free(tmp); return 100; } i = 256 * getc (tfmfileptr); @@ -595,6 +664,7 @@ main (int ac, char **av) fprintf (stderr, "Current font seems to be a Japanese one.\n"); fprintf (stderr, "I give up to create a PK font.\n"); relmem (arg); + free(tmp); return 100; } } @@ -606,16 +676,17 @@ main (int ac, char **av) if (!fpp) { fprintf (stderr, "Failed to get current working directory.\n"); relmem (arg); + free(tmp); return (100); } for (fpp = currdir; *fpp; fpp++) { - if (*fpp == '\\') - *fpp = '/'; - else if (IS_KANJI(fpp)) + if (IS_KANJI(fpp)) fpp++; + else if (*fpp == '\\') + *fpp = '/'; } - i = strlen (currdir); + i = (int)strlen (currdir); if (currdir[i - 1] == '/') currdir[i - 1] = '\0'; @@ -636,6 +707,7 @@ main (int ac, char **av) if (!(p = getdestdir (4, arg))) { tpkerr ("Cannot get destination directory name."); relmem (arg); + free(tmp); return (100); } strcpy (rbuff, p); @@ -647,14 +719,14 @@ main (int ac, char **av) */ for (p = rbuff; *p; p++) { - if (*p == '\\') - *p = '/'; - else if (IS_KANJI(p)) + if (IS_KANJI(p)) p++; + else if (*p == '\\') + *p = '/'; } p = rbuff; - i = strlen (p); + i = (int)strlen (p); if (p[i - 1] == '/') p[i - 1] = '\0'; @@ -662,12 +734,14 @@ main (int ac, char **av) if (!is_dir (p)) { fprintf (stderr, "Destination %s is not found.\n", p); relmem (arg); + free(tmp); return (100); } } else if (!is_dir (p)) { if (make_dir (p)) { tpkerr ("Error in make_dir."); relmem (arg); + free(tmp); return (100); } } @@ -675,7 +749,7 @@ main (int ac, char **av) strcpy (buff, p); p = buff; - i = strlen (p); + i = (int)strlen (p); if (p[i - 1] != '/') strcat (p, "/"); @@ -683,6 +757,7 @@ main (int ac, char **av) if (dpi[0] == 0) { tpkerr ("Cannot determine DPI."); relmem (arg); + free(tmp); return (100); } @@ -693,6 +768,7 @@ main (int ac, char **av) if (make_dir (p)) { tpkerr ("Error in make_dir."); relmem (arg); + free(tmp); return (100); } } @@ -713,6 +789,7 @@ main (int ac, char **av) fprintf (stderr, "%s exists.\n", p); relmem (arg); printf ("%s\n", p); + free(tmp); return (0); } @@ -746,6 +823,7 @@ main (int ac, char **av) _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } _dup2 (fileno (fnul), fileno (stdin)); @@ -764,6 +842,7 @@ main (int ac, char **av) _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } sprintf (cmd, @@ -786,6 +865,7 @@ main (int ac, char **av) _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } @@ -803,6 +883,7 @@ main (int ac, char **av) _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } @@ -1094,18 +1175,22 @@ skip flag } else strcpy (ydpi, dpi); + strcpy(tfname, name); + strcat(tfname, ".tfm"); + get_designsize(tfname, designsize); + if (i == 3) { - sprintf (cmd, "-X%s -Y%s -S%s -E%s %s %s", - dpi, ydpi, slant, extend, pfbname, pkname); + sprintf (cmd, "-X%s -Y%s -S%s -E%s -P%s %s %s", + dpi, ydpi, slant, extend, designsize, 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); + sprintf (cmd, "-X%s -Y%s -R%s -S%s -E%s -P%s %s %s", + dpi, ydpi, bdpi, slant, extend, designsize, 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); + sprintf (cmd, "-e%s -X%s -Y%s -S%s -E%s -P%s %s %s", + encname, dpi, ydpi, slant, extend, designsize, 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); + sprintf (cmd, "-e%s -X%s -Y%s -R%s -S%s -E%s -P%s %s %s", + encname, dpi, ydpi, bdpi, slant, extend, designsize, pfbname, pkname); } else { tpkerr ("File format of pspksupp.map is wrong."); goto do_gsftopk; @@ -1166,6 +1251,7 @@ skip flag _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } strcpy (execfile, "gftopk.exe"); @@ -1179,6 +1265,7 @@ skip flag _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } remove (cmd); @@ -1208,6 +1295,7 @@ skip flag _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } @@ -1216,10 +1304,11 @@ skip flag _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } - while ((i = fread (rbuff, 1, LBUF, fr))) + while ((i = (int)fread (rbuff, 1, LBUF, fr))) fwrite (rbuff, 1, i, fw); fclose (fr); @@ -1240,6 +1329,7 @@ skip flag printf ("%s\n", buff); _chdrive (cdrive); _chdir (currdir); + free(tmp); return (0); } diff --git a/Build/source/texk/kpathsea/win32/mktextfm.c b/Build/source/texk/kpathsea/win32/mktextfm.c index 7277d10af70..d9da4aeb5ab 100644 --- a/Build/source/texk/kpathsea/win32/mktextfm.c +++ b/Build/source/texk/kpathsea/win32/mktextfm.c @@ -1,21 +1,36 @@ /* 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. - */ + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. + + Assumes the cx mode in mf.base . + Usage: mktextfm [--destdir DESTDIR] name +*/ #include <kpathsea/kpathsea.h> +#ifndef __MINGW32__ +#include <web2c/w2c/c-auto.h> +#endif #include "dirutil.h" #include "getdestdir.h" #include "mktexupd.h" #define LBUF 512 -#define SBUF 256 -#define TBUF 256 +#define SBUF 512 +#define TBUF 512 char *progname; @@ -29,8 +44,8 @@ usage (void) static void version (void) { - fprintf (stderr, "%s, (C version 1.4 --ak 2009-2012)\n", progname); - fprintf (stderr, WEB2C_KPSE_VERSION "\n"); + fprintf (stderr, "%s, (C version 1.5 --ak 2009-2012)\n", progname); + fprintf (stderr, KPSEVERSION WEB2CVERSION "\n"); return; } @@ -79,11 +94,11 @@ main (int ac, char **av) int issetdest; char fontname[SBUF]; - char texbindir[256]; + char texbindir[512]; char fullbin[512]; - progname = av[0]; kpse_set_program_name (av[0], NULL); + progname = kpse_program_name; /* * get tex binary dir @@ -104,9 +119,9 @@ main (int ac, char **av) tmp = getenv ("TEMP"); if (!tmp) - getenv ("TMP"); + tmp = getenv ("TMP"); if (!tmp) - getenv ("TMPDIR"); + tmp = getenv ("TMPDIR"); if (!tmp) { fprintf (stderr, "Please define TEMP | TMP | TMPDIR.\n"); return (100); @@ -115,10 +130,10 @@ main (int ac, char **av) tmp = xstrdup(tmp); for (fpp = tmp; *fpp; fpp++) { - if (*fpp == '\\') - *fpp = '/'; - else if (IS_KANJI(fpp)) + if (IS_KANJI(fpp)) fpp++; + else if (*fpp == '\\') + *fpp = '/'; } /* issetdest = 0 : TDS @@ -130,16 +145,19 @@ issetdest = 2 : current directory if (ac < 2) { usage (); + free(tmp); return (100); } if ((!strcmp (av[1], "--version")) || (!strcmp (av[1], "-version"))) { version (); + free(tmp); return (100); } if ((!strcmp (av[1], "--help")) || (!strcmp (av[1], "-help"))) { help (); + free(tmp); return (100); } @@ -150,16 +168,17 @@ issetdest = 2 : current directory if (ac != 4) { usage (); relmem (arg); + free(tmp); return (100); } issetdest = 1; strcpy (buff, av[2]); strcpy (fontname, av[3]); for (p = buff; *p; p++) { - if (*p == '\\') - *p = '/'; - else if (IS_KANJI(p)) + if (IS_KANJI(p)) p++; + else if (*p == '\\') + *p = '/'; } } else { strcpy (fontname, av[1]); @@ -179,6 +198,7 @@ issetdest = 2 : current directory if (!(fp = kpse_var_value ("MFINPUTS"))) { fprintf (stderr, "Cannot get value of MFINPUTS\n"); relmem (arg); + free(tmp); return (100); } @@ -188,6 +208,7 @@ issetdest = 2 : current directory if (!(p = kpse_find_file (mffile, kpse_mf_format, 1))) { fprintf (stderr, "Cannot find %s.\n", mffile); relmem (arg); + free(tmp); return (100); } @@ -195,16 +216,17 @@ issetdest = 2 : current directory if (!fpp) { fprintf (stderr, "Failed to get current working directory.\n"); relmem (arg); + free(tmp); return (100); } for (fpp = currdir; *fpp; fpp++) { - if (*fpp == '\\') - *fpp = '/'; - else if (IS_KANJI(fpp)) + if (IS_KANJI(fpp)) fpp++; + else if (*fpp == '\\') + *fpp = '/'; } - i = strlen (currdir); + i = (int)strlen (currdir); if (currdir[i - 1] == '/') currdir[i - 1] = '\0'; strcpy (kpsedot, "KPSE_DOT=.;"); @@ -225,6 +247,7 @@ issetdest = 2 : current directory if (!(p = getdestdir (3, arg))) { fprintf (stderr, "Cannot get destination directory name.\n"); relmem (arg); + free(tmp); return (100); } strcpy (buff, p); @@ -233,7 +256,7 @@ issetdest = 2 : current directory /* Now buff is the destdir */ p = buff; - i = strlen (p); + i = (int)strlen (p); if (p[i - 1] != '/') strcat (p, "/"); @@ -246,6 +269,7 @@ issetdest = 2 : current directory fprintf (stderr, "%s exists\n", p); printf ("%s\n", p); relmem (arg); + free(tmp); return (0); } @@ -269,6 +293,7 @@ issetdest = 2 : current directory relmem (arg); _chdrive (cdrive); _chdir (currdir); + free(tmp); return (100); } _dup2 (fileno (fnul), fileno (stdin)); @@ -303,6 +328,7 @@ issetdest = 2 : current directory relmem (arg); _chdrive (cdrive); _chdir (currdir); + free(tmp); return (100); } @@ -317,6 +343,7 @@ issetdest = 2 : current directory _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } if (!(fw = fopen (buff, "wb"))) { @@ -324,10 +351,11 @@ issetdest = 2 : current directory _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } - while ((i = fread (rbuff, 1, LBUF, fr))) + while ((i = (int)fread (rbuff, 1, LBUF, fr))) fwrite (rbuff, 1, i, fw); fclose (fr); fclose (fw); @@ -342,7 +370,7 @@ issetdest = 2 : current directory */ if(issetdest == 2) { - i = strlen(buff); + i = (int)strlen(buff); if(i > 3) { i -= 4; buff[i] = '\0'; @@ -354,6 +382,7 @@ issetdest = 2 : current directory _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } if (!(fw = fopen (buff, "wb"))) { @@ -361,9 +390,10 @@ issetdest = 2 : current directory _chdrive (cdrive); _chdir (currdir); relmem (arg); + free(tmp); return (100); } - while ((i = fread (rbuff, 1, LBUF, fr))) + while ((i = (int)fread (rbuff, 1, LBUF, fr))) fwrite (rbuff, 1, i, fw); fclose (fr); fclose (fw); @@ -388,6 +418,7 @@ issetdest = 2 : current directory /* send message to Kpathsea */ printf ("%s\n", savebuff); + free(tmp); return (0); } diff --git a/Build/source/texk/kpathsea/win32/mktexupd.c b/Build/source/texk/kpathsea/win32/mktexupd.c index ffe5fb338d7..48a5de2b540 100644 --- a/Build/source/texk/kpathsea/win32/mktexupd.c +++ b/Build/source/texk/kpathsea/win32/mktexupd.c @@ -1,12 +1,29 @@ +/* mktexupd.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + #include <kpathsea/kpathsea.h> #include "mktexupd.h" -#define MBUF 128 -#define SBUF 256 +#define MBUF 512 +#define SBUF 512 #define LBUF 512 #define DBS "TEXMFDBS" -#define MAXTREE 16 void mktexupd (char *s) @@ -14,8 +31,8 @@ mktexupd (char *s) char fname[MBUF]; char lsrname[SBUF]; char path[LBUF]; - char *rootdir[MAXTREE]; - int i, j, treenum; + char **pathbuff = NULL; + int i, j, numtree; char *pa, *pb, *pc; int existflag = 0; FILE *f; @@ -35,43 +52,75 @@ mktexupd (char *s) 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++; + while(*pa) { + if(*pa == '!' && *(pa+1) == '!') + pa += 2; + if(*pa == ';') + while(*pa == ';') + pa++; + if(*pa && *pa != '!') { + while(*pa != ';' && *pa) + pa++; + if(*pa == ';') { + i++; + while(*pa == ';') + pa++; + } else if(*pa == '\0') { + i++; + break; + } } - pc = rootdir[i]; - while (*pa != ';' && *pa) - *pc++ = *pa++; - *pc = '\0'; + } + + numtree = i; + + pathbuff = xmalloc(numtree * sizeof(char *)); + + pa = pb; + i = 0; + + while (*pa) { + if (*pa == '!' && *(pa + 1) == '!') + pa += 2; if (*pa == ';') { - pa++; - i++; + while (*pa == ';') + pa++; + } + if(*pa && *pa != '!') { + pathbuff[i] = malloc(strlen(pa) + 1); + pc = pathbuff[i]; + while (*pa != ';' && *pa) + *pc++ = *pa++; + *pc = '\0'; + if (*pa == ';') { + while (*pa == ';') + pa++; + i++; + } else if (*pa == '\0') { + i++; + break; + } } } - 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'; + for (i = 0; i < numtree; i++) { + j = (int)strlen (pathbuff[i]); + if (pathbuff[i][j - 1] == '/') + pathbuff[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]); + for (i = 0; i < numtree; i++) + free (pathbuff[i]); + free (pathbuff); return; } @@ -79,24 +128,25 @@ mktexupd (char *s) pa++; strcpy (fname, pa); - for (i = 0; i < treenum; i++) { - j = strlen (rootdir[i]); - if (j && strnicmp (path, rootdir[i], j) == 0) { + for (i = 0; i < numtree; i++) { + j = (int)strlen (pathbuff[i]); + if (j && strnicmp (path, pathbuff[i], j) == 0) { existflag = 1; break; } } if (existflag) { - strcpy (lsrname, rootdir[i]); + strcpy (lsrname, pathbuff[i]); strcat (lsrname, "/ls-R"); if (_access (lsrname, 0) != 0) { - for (j = 0; j < MAXTREE; j++) - free (rootdir[j]); + for (j = 0; j < numtree; j++) + free (pathbuff[j]); + free (pathbuff); return; } pa = path; - pb = rootdir[i]; + pb = pathbuff[i]; while (tolower (*pa) == tolower (*pb) && *pb) { pa++; pb++; @@ -107,6 +157,7 @@ mktexupd (char *s) } else { fprintf(stderr, "mktexupd failed\n"); } - for (i = 0; i < MAXTREE; i++) - free (rootdir[i]); + for (i = 0; i < numtree; i++) + free (pathbuff[i]); + free (pathbuff); } diff --git a/Build/source/texk/kpathsea/win32/mktexupd.h b/Build/source/texk/kpathsea/win32/mktexupd.h index 76bd89da92f..2e0ea6277f8 100644 --- a/Build/source/texk/kpathsea/win32/mktexupd.h +++ b/Build/source/texk/kpathsea/win32/mktexupd.h @@ -1 +1,19 @@ +/* mktexupd.h + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + extern void mktexupd (char *s); diff --git a/Build/source/texk/kpathsea/win32/mktexupdmain.c b/Build/source/texk/kpathsea/win32/mktexupdmain.c index a1484faa9f7..1aa9e88e737 100644 --- a/Build/source/texk/kpathsea/win32/mktexupdmain.c +++ b/Build/source/texk/kpathsea/win32/mktexupdmain.c @@ -1,3 +1,21 @@ +/* mktexupdmain.c + + Copyright 2000, 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + #include <kpathsea/kpathsea.h> #include "mktexupd.h" @@ -8,7 +26,7 @@ int main(int argc, char **argv) char file[256]; char path[256]; char *p; - int i; + size_t i; kpse_set_program_name (argv[0], NULL); if(argc != 3) { @@ -18,8 +36,9 @@ int main(int argc, char **argv) strcpy(dir, argv[1]); strcpy(file, argv[2]); for(p = dir; *p; ++p) { - if(*p == '\\') *p = '/'; - else if (IS_KANJI(p)) p++; + if(IS_KANJI(p)) + p++; + else if(*p == '\\') *p = '/'; } i = strlen(dir); while(dir[i-1] == '/') |