summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/win32/mktextfm.c
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2015-06-18 10:49:17 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2015-06-18 10:49:17 +0000
commit973cc50127fd0835fbbd57bbb9dd8885c60e154d (patch)
treec14d3476c68fd27c7e3382b9e5089e410ac9a6de /Build/source/texk/kpathsea/win32/mktextfm.c
parentbae57b6f7ea0c81be60f4c73814128c4c91a84ee (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/kpathsea/win32/mktextfm.c')
-rw-r--r--Build/source/texk/kpathsea/win32/mktextfm.c89
1 files changed, 60 insertions, 29 deletions
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);
}