diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-08-13 07:48:23 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-08-13 07:48:23 +0000 |
commit | d2fbaf4a407cac794e13fdb9d5d032b0aa16b8e6 (patch) | |
tree | 78c4c2b5da2a15b611b1d5fb4fb5bbed1ef75e0f /Build/source | |
parent | 48f3c5e8221e66fda48a8b93457b71ce99356a25 (diff) |
lcdf-typetools: Reduce TL vs W32TeX diffs (from Akira)
git-svn-id: svn://tug.org/texlive/trunk@27382 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
11 files changed, 303 insertions, 16 deletions
diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/ChangeLog b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/ChangeLog index c6648877f5a..915f9243c02 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/ChangeLog +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/ChangeLog @@ -1,3 +1,9 @@ +2012-08-11 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-02-WIN32 (new): Adapt for WIN32. + * patch-20-TL-binary (new): Use binary mode for output files. + From Akira Kakuto <kakuto@fuk.kindai.ac.jp> (W32TeX). + 2012-08-05 Peter Breitenlohner <peb@mppmu.mpg.de> Import lcdf-typetools-2.94. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-02-WIN32 b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-02-WIN32 new file mode 100644 index 00000000000..5905e60855f --- /dev/null +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-02-WIN32 @@ -0,0 +1,130 @@ +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/automatic.cc lcdf-typetools-2.94/otftotfm/automatic.cc +--- lcdf-typetools-2.94.orig/otftotfm/automatic.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/otftotfm/automatic.cc 2012-08-11 17:49:05.000000000 +0200 +@@ -40,6 +40,18 @@ + + #ifdef WIN32 + # define mkdir(dir, access) mkdir(dir) ++# define COPY_CMD "copy" ++#else ++# define COPY_CMD "cp" ++#endif ++ ++/* kpathsea may already have defined this */ ++#ifndef DEV_NULL ++# ifdef WIN32 ++# define DEV_NULL "NUL" ++# else ++# define DEV_NULL "/dev/null" ++# endif + #endif + + #if HAVE_AUTO_T1DOTLESSJ +@@ -307,7 +319,11 @@ + if (!success && writable_texdir.find_left('\'') < 0 && directory.find_left('\'') < 0 && file.find_left('\'') < 0) { + // look for mktexupd script + if (!mktexupd_tried) { ++#ifdef WIN32 ++ mktexupd = strdup("mktexupd"); ++#else + mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C)); ++#endif + mktexupd_tried = true; + } + +@@ -482,7 +498,7 @@ + + int retval; + if (!same_filename(ttf_filename, installed_ttf_filename)) { +- String command = "cp " + shell_quote(ttf_filename) + " " + shell_quote(installed_ttf_filename); ++ String command = COPY_CMD " " + shell_quote(ttf_filename) + " " + shell_quote(installed_ttf_filename); + retval = mysystem(command.c_str(), errh); + if (retval == 127) + errh->error("could not run %<%s%>", command.c_str()); +@@ -731,7 +747,7 @@ + if (verbose) + command += " 1>&2"; + else +- command += " >/dev/null 2>&1"; ++ command += " >" DEV_NULL " 2>&1"; + int retval = mysystem(command.c_str(), errh); + if (retval == 127) + errh->warning("could not run %<%s%>", command.c_str()); +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc lcdf-typetools-2.94/otftotfm/otftotfm.cc +--- lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/otftotfm/otftotfm.cc 2012-08-11 17:14:49.000000000 +0200 +@@ -50,6 +50,10 @@ + #include <signal.h> + #include <algorithm> + #include <math.h> ++/* apparently M_PI isn't defined by <math.h> under VC++ */ ++#ifndef M_PI ++#define M_PI 3.14159265358979323846 ++#endif + #ifdef HAVE_CTIME + # include <time.h> + #endif +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/util.cc lcdf-typetools-2.94/otftotfm/util.cc +--- lcdf-typetools-2.94.orig/otftotfm/util.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/otftotfm/util.cc 2012-08-11 17:42:50.000000000 +0200 +@@ -103,14 +103,29 @@ + String + shell_quote(const String &str) + { ++ const char *begin = str.begin(); ++ const char *end = str.end(); + #if defined(_MSDOS) || defined(_WIN32) +- return str; // XXX ++ if (!str) ++ return String::make_stable("\"\""); ++ ++ for (const char *s = begin; s < end; s++) ++ if (isalnum((unsigned char) *s) || *s == '_' || *s == '-' || *s == '+' || *s == '/' || *s == ':' || *s == '.') ++ /* do nothing */; ++ else { ++ StringAccum sa; ++ ++ sa.append('"'); ++ sa.append(begin, end); ++ sa.append('"'); ++ return sa.take_string(); ++ } ++ ++ return str; + #else + if (!str) + return String::make_stable("''"); + +- const char *begin = str.begin(); +- const char *end = str.end(); + StringAccum sa; + for (const char *s = begin; s < end; s++) + if (isalnum((unsigned char) *s) || *s == '_' || *s == '-' || *s == '+' || *s == '/' || *s == ':' || *s == '.') +@@ -165,9 +180,27 @@ + errh->error("temporary file %<%s%>: %s", filename.c_str(), strerror(errno)); + return fd; + #else // !HAVE_MKSTEMP ++#if defined(WIN32) ++ char *tmpdir = getenv("TEMP"); ++ if (!tmpdir) ++ tmpdir = getenv("TMP"); ++ if (!tmpdir) ++ tmpdir = getenv("TMPDIR"); ++ if (tmpdir) { ++ int len; ++ tmpdir = strdup(tmpdir); ++ len = strlen(tmpdir); ++ if(tmpdir[len-1] == '/' || tmpdir[len-1] == '\\') tmpdir[len-1] = '\0'; ++ } else ++ tmpdir = strdup("."); ++ for (int tries = 0; tries < 5; tries++) { ++ if (!(filename = tempnam(tmpdir, "otf."))) ++ return errh->error("cannot create temporary file"); ++#else + for (int tries = 0; tries < 5; tries++) { + if (!(filename = tmpnam(0))) + return errh->error("cannot create temporary file"); ++#endif + # ifdef O_EXCL + int fd = ::open(filename.c_str(), O_RDWR | O_CREAT | O_EXCL | O_TRUNC, 0600); + # else diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-20-TL-binary b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-20-TL-binary new file mode 100644 index 00000000000..b921936e5d3 --- /dev/null +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-20-TL-binary @@ -0,0 +1,96 @@ + In TeX Live we treat all output files as binary. + +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/liblcdf/filename.cc lcdf-typetools-2.94/liblcdf/filename.cc +--- lcdf-typetools-2.94.orig/liblcdf/filename.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/liblcdf/filename.cc 2012-08-11 18:30:06.000000000 +0200 +@@ -126,5 +126,5 @@ + if (_actual || !_path) + return _actual; + else +- return fopen(_path.c_str(), binary ? "wb" : "w"); ++ return fopen(_path.c_str(), "wb"); + } +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/automatic.cc lcdf-typetools-2.94/otftotfm/automatic.cc +--- lcdf-typetools-2.94.orig/otftotfm/automatic.cc 2012-08-11 17:49:05.000000000 +0200 ++++ lcdf-typetools-2.94/otftotfm/automatic.cc 2012-08-11 17:57:54.000000000 +0200 +@@ -309,7 +309,7 @@ + String ls_r = writable_texdir + "ls-R"; + bool success = false; + if (access(ls_r.c_str(), R_OK) >= 0) // make sure it already exists +- if (FILE *f = fopen(ls_r.c_str(), "a")) { ++ if (FILE *f = fopen(ls_r.c_str(), "ab")) { + fprintf(f, "./%s:\n%s\n", directory.c_str(), file.c_str()); + success = true; + fclose(f); +@@ -680,7 +680,7 @@ + #endif + { + fclose(f); +- f = fopen(map_file.c_str(), "w"); ++ f = fopen(map_file.c_str(), "wb"); + fd = fileno(f); + } + +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc lcdf-typetools-2.94/otftotfm/otftotfm.cc +--- lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc 2012-08-11 17:14:49.000000000 +0200 ++++ lcdf-typetools-2.94/otftotfm/otftotfm.cc 2012-08-11 18:07:57.000000000 +0200 +@@ -555,7 +555,7 @@ + + if (verbose) + errh->message("creating %s", filename.c_str()); +- FILE *f = fopen(filename.c_str(), "w"); ++ FILE *f = fopen(filename.c_str(), "wb"); + if (!f) { + errh->error("%s: %s", filename.c_str(), strerror(errno)); + return; +@@ -997,7 +997,7 @@ + #endif + { + fclose(f); +- f = fopen(filename.c_str(), "w"); ++ f = fopen(filename.c_str(), "wb"); + fd = fileno(f); + } + +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/t1rawafm/t1rawafm.cc lcdf-typetools-2.94/t1rawafm/t1rawafm.cc +--- lcdf-typetools-2.94.orig/t1rawafm/t1rawafm.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/t1rawafm/t1rawafm.cc 2012-08-11 16:01:57.000000000 +0200 +@@ -350,6 +350,9 @@ + if (!outf) + errh->fatal("%s: %s", output_file, strerror(errno)); + } ++#if defined(_MSDOS) || defined(_WIN32) ++ _setmode(_fileno(outf), _O_BINARY); ++#endif + + write_afm(outf, font); + +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/t1reencode/t1reencode.cc lcdf-typetools-2.94/t1reencode/t1reencode.cc +--- lcdf-typetools-2.94.orig/t1reencode/t1reencode.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/t1reencode/t1reencode.cc 2012-08-11 15:58:50.000000000 +0200 +@@ -1094,10 +1094,10 @@ + if (!outf) + errh->fatal("%s: %s", output_file, strerror(errno)); + } +- if (binary) { + #if defined(_MSDOS) || defined(_WIN32) +- _setmode(_fileno(outf), _O_BINARY); ++ _setmode(_fileno(outf), _O_BINARY); + #endif ++ if (binary) { + Type1PFBWriter w(outf); + font->write(w); + } else { +diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/t1testpage/t1testpage.cc lcdf-typetools-2.94/t1testpage/t1testpage.cc +--- lcdf-typetools-2.94.orig/t1testpage/t1testpage.cc 2011-11-03 17:51:58.000000000 +0100 ++++ lcdf-typetools-2.94/t1testpage/t1testpage.cc 2012-08-11 16:02:02.000000000 +0200 +@@ -665,6 +665,9 @@ + if (!outf) + errh->fatal("%s: %s", output_file, strerror(errno)); + } ++#if defined(_MSDOS) || defined(_WIN32) ++ _setmode(_fileno(outf), _O_BINARY); ++#endif + + //font->undo_synthetic(); + diff --git a/Build/source/texk/lcdf-typetools/liblcdf/filename.cc b/Build/source/texk/lcdf-typetools/liblcdf/filename.cc index 6fb0f3079d9..8136c626666 100644 --- a/Build/source/texk/lcdf-typetools/liblcdf/filename.cc +++ b/Build/source/texk/lcdf-typetools/liblcdf/filename.cc @@ -126,5 +126,5 @@ Filename::open_write(bool binary) const if (_actual || !_path) return _actual; else - return fopen(_path.c_str(), binary ? "wb" : "w"); + return fopen(_path.c_str(), "wb"); } diff --git a/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc b/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc index 9c503e072d4..585dc69ec70 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc @@ -40,6 +40,18 @@ #ifdef WIN32 # define mkdir(dir, access) mkdir(dir) +# define COPY_CMD "copy" +#else +# define COPY_CMD "cp" +#endif + +/* kpathsea may already have defined this */ +#ifndef DEV_NULL +# ifdef WIN32 +# define DEV_NULL "NUL" +# else +# define DEV_NULL "/dev/null" +# endif #endif #if HAVE_AUTO_T1DOTLESSJ @@ -297,7 +309,7 @@ update_odir(int o, String file, ErrorHandler *errh) String ls_r = writable_texdir + "ls-R"; bool success = false; if (access(ls_r.c_str(), R_OK) >= 0) // make sure it already exists - if (FILE *f = fopen(ls_r.c_str(), "a")) { + if (FILE *f = fopen(ls_r.c_str(), "ab")) { fprintf(f, "./%s:\n%s\n", directory.c_str(), file.c_str()); success = true; fclose(f); @@ -307,7 +319,11 @@ update_odir(int o, String file, ErrorHandler *errh) if (!success && writable_texdir.find_left('\'') < 0 && directory.find_left('\'') < 0 && file.find_left('\'') < 0) { // look for mktexupd script if (!mktexupd_tried) { +#ifdef WIN32 + mktexupd = strdup("mktexupd"); +#else mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C)); +#endif mktexupd_tried = true; } @@ -482,7 +498,7 @@ installed_truetype(const String &ttf_filename, bool allow_generate, ErrorHandler int retval; if (!same_filename(ttf_filename, installed_ttf_filename)) { - String command = "cp " + shell_quote(ttf_filename) + " " + shell_quote(installed_ttf_filename); + String command = COPY_CMD " " + shell_quote(ttf_filename) + " " + shell_quote(installed_ttf_filename); retval = mysystem(command.c_str(), errh); if (retval == 127) errh->error("could not run %<%s%>", command.c_str()); @@ -664,7 +680,7 @@ update_autofont_map(const String &fontname, String mapline, ErrorHandler *errh) #endif { fclose(f); - f = fopen(map_file.c_str(), "w"); + f = fopen(map_file.c_str(), "wb"); fd = fileno(f); } @@ -731,7 +747,7 @@ update_autofont_map(const String &fontname, String mapline, ErrorHandler *errh) if (verbose) command += " 1>&2"; else - command += " >/dev/null 2>&1"; + command += " >" DEV_NULL " 2>&1"; int retval = mysystem(command.c_str(), errh); if (retval == 127) errh->warning("could not run %<%s%>", command.c_str()); diff --git a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc index 84becc2c692..e2eb62f1f71 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc @@ -50,6 +50,10 @@ #include <signal.h> #include <algorithm> #include <math.h> +/* apparently M_PI isn't defined by <math.h> under VC++ */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif #ifdef HAVE_CTIME # include <time.h> #endif @@ -551,7 +555,7 @@ output_pl(Metrics &metrics, const String &ps_name, int boundary_char, if (verbose) errh->message("creating %s", filename.c_str()); - FILE *f = fopen(filename.c_str(), "w"); + FILE *f = fopen(filename.c_str(), "wb"); if (!f) { errh->error("%s: %s", filename.c_str(), strerror(errno)); return; @@ -993,7 +997,7 @@ write_encoding_file(String &filename, const String &encoding_name, #endif { fclose(f); - f = fopen(filename.c_str(), "w"); + f = fopen(filename.c_str(), "wb"); fd = fileno(f); } diff --git a/Build/source/texk/lcdf-typetools/otftotfm/util.cc b/Build/source/texk/lcdf-typetools/otftotfm/util.cc index 58095b48050..e60953446fd 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/util.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/util.cc @@ -103,14 +103,29 @@ same_filename(const String &a, const String &b) String shell_quote(const String &str) { + const char *begin = str.begin(); + const char *end = str.end(); #if defined(_MSDOS) || defined(_WIN32) - return str; // XXX + if (!str) + return String::make_stable("\"\""); + + for (const char *s = begin; s < end; s++) + if (isalnum((unsigned char) *s) || *s == '_' || *s == '-' || *s == '+' || *s == '/' || *s == ':' || *s == '.') + /* do nothing */; + else { + StringAccum sa; + + sa.append('"'); + sa.append(begin, end); + sa.append('"'); + return sa.take_string(); + } + + return str; #else if (!str) return String::make_stable("''"); - const char *begin = str.begin(); - const char *end = str.end(); StringAccum sa; for (const char *s = begin; s < end; s++) if (isalnum((unsigned char) *s) || *s == '_' || *s == '-' || *s == '+' || *s == '/' || *s == ':' || *s == '.') @@ -165,9 +180,27 @@ temporary_file(String &filename, ErrorHandler *errh) errh->error("temporary file %<%s%>: %s", filename.c_str(), strerror(errno)); return fd; #else // !HAVE_MKSTEMP +#if defined(WIN32) + char *tmpdir = getenv("TEMP"); + if (!tmpdir) + tmpdir = getenv("TMP"); + if (!tmpdir) + tmpdir = getenv("TMPDIR"); + if (tmpdir) { + int len; + tmpdir = strdup(tmpdir); + len = strlen(tmpdir); + if(tmpdir[len-1] == '/' || tmpdir[len-1] == '\\') tmpdir[len-1] = '\0'; + } else + tmpdir = strdup("."); + for (int tries = 0; tries < 5; tries++) { + if (!(filename = tempnam(tmpdir, "otf."))) + return errh->error("cannot create temporary file"); +#else for (int tries = 0; tries < 5; tries++) { if (!(filename = tmpnam(0))) return errh->error("cannot create temporary file"); +#endif # ifdef O_EXCL int fd = ::open(filename.c_str(), O_RDWR | O_CREAT | O_EXCL | O_TRUNC, 0600); # else diff --git a/Build/source/texk/lcdf-typetools/t1rawafm/t1rawafm.cc b/Build/source/texk/lcdf-typetools/t1rawafm/t1rawafm.cc index e9176663bbf..22246daca99 100644 --- a/Build/source/texk/lcdf-typetools/t1rawafm/t1rawafm.cc +++ b/Build/source/texk/lcdf-typetools/t1rawafm/t1rawafm.cc @@ -350,6 +350,9 @@ particular purpose.\n"); if (!outf) errh->fatal("%s: %s", output_file, strerror(errno)); } +#if defined(_MSDOS) || defined(_WIN32) + _setmode(_fileno(outf), _O_BINARY); +#endif write_afm(outf, font); diff --git a/Build/source/texk/lcdf-typetools/t1reencode/t1reencode.cc b/Build/source/texk/lcdf-typetools/t1reencode/t1reencode.cc index b07857e1632..5885917d21c 100644 --- a/Build/source/texk/lcdf-typetools/t1reencode/t1reencode.cc +++ b/Build/source/texk/lcdf-typetools/t1reencode/t1reencode.cc @@ -1094,10 +1094,10 @@ particular purpose.\n"); if (!outf) errh->fatal("%s: %s", output_file, strerror(errno)); } - if (binary) { #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(outf), _O_BINARY); + _setmode(_fileno(outf), _O_BINARY); #endif + if (binary) { Type1PFBWriter w(outf); font->write(w); } else { diff --git a/Build/source/texk/lcdf-typetools/t1testpage/t1testpage.cc b/Build/source/texk/lcdf-typetools/t1testpage/t1testpage.cc index 81948e8bfd5..a7bea659d8e 100644 --- a/Build/source/texk/lcdf-typetools/t1testpage/t1testpage.cc +++ b/Build/source/texk/lcdf-typetools/t1testpage/t1testpage.cc @@ -665,6 +665,9 @@ particular purpose.\n"); if (!outf) errh->fatal("%s: %s", output_file, strerror(errno)); } +#if defined(_MSDOS) || defined(_WIN32) + _setmode(_fileno(outf), _O_BINARY); +#endif //font->undo_synthetic(); diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index 77081e16499..2471866718e 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,7 +1,3 @@ -2012-08-13 TANAKA Takuji <KXD02663@nifty.ne.jp> - - * Makefile.in: upTeX u1.11. - 2012-08-01 Peter Breitenlohner <peb@mppmu.mpg.de> * configure.ac (AC_CHECK_FUNCS): Remove test for snprintf. |