summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-02-WIN32
blob: 5905e60855f5dd93275c56ddcbb9863d868934d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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