summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/TLpatches/patch-03-w32
blob: 4511911edda37f119cd25706432487f0aa5e7aa3 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
diff -ur lcdf-typetools-2.108/liblcdf/filename.cc lcdf-typetools-src/liblcdf/filename.cc
--- lcdf-typetools-2.108/liblcdf/filename.cc	Mon Jan 28 03:39:19 2019
+++ lcdf-typetools-src/liblcdf/filename.cc	Mon Jan 28 08:02:02 2019
@@ -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 lcdf-typetools-2.108/otftotfm/automatic.cc lcdf-typetools-src/otftotfm/automatic.cc
--- lcdf-typetools-2.108/otftotfm/automatic.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/otftotfm/automatic.cc	Mon Jan 28 08:19:16 2019
@@ -39,7 +39,9 @@
 #include <algorithm>
 
 #ifdef WIN32
-# define mkdir(dir, access) mkdir(dir)
+# include <io.h>
+# include <direct.h>
+# define mkdir(dir, access) _mkdir(dir)
 # define COPY_CMD "copy"
 # define CMD_SEP "&"
 #else
@@ -124,7 +126,18 @@
 static void
 find_writable_texdir(ErrorHandler *errh, const char *)
 {
+#if defined(W32TEX)
+// W32TeX does not have TEXMFVAR
+    char *p = kpsei_var_value("TEXMFVAR");
+    if (p == NULL) // W32TeX
+        look_for_writable_texdir("$TEXMFLOCAL", true);
+    else { // TeXLive
+        free (p);
+        look_for_writable_texdir("$TEXMFVAR", true);
+    }
+#else
     look_for_writable_texdir("$TEXMFVAR", true);
+#endif
     if (!writable_texdir)
         look_for_writable_texdir("$VARTEXMF", false);
     if (!writable_texdir)
@@ -313,7 +326,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);
@@ -323,7 +336,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 = "mktexupd";
+#else
             mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C));
+#endif
             mktexupd_tried = true;
         }
 
@@ -677,7 +694,7 @@
 #endif
             {
                 fclose(f);
-                f = fopen(map_file.c_str(), "w");
+                f = fopen(map_file.c_str(), "wb");
                 fd = fileno(f);
             }
 
@@ -746,7 +763,16 @@
             if (slash >= 0)
                 filename = filename.substring(slash + 1);
             String redirect = verbose ? " 1>&2" : " >" DEV_NULL " 2>&1";
-            String command = updmap_prog + " --nomkmap --enable Map " + shell_quote(filename) + redirect
+#if defined(W32TEX)
+// jtex_filetype is defined only in W32TeX
+            char *p = kpsei_var_value("jtex_filetype");
+            if (p != NULL) { // W32TeX
+                free(p);
+                String option = "--add ";
+            } else // TeXLive
+#endif
+            String option = "--enable Map ";
+            String command = "updmap --nomkmap " + option  + shell_quote(filename) + redirect
                 + CMD_SEP " " + updmap_prog + redirect;
             int retval = mysystem(command.c_str(), errh);
             if (retval == 127)
diff -ur lcdf-typetools-2.108/otftotfm/kpseinterface.c lcdf-typetools-src/otftotfm/kpseinterface.c
--- lcdf-typetools-2.108/otftotfm/kpseinterface.c	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/otftotfm/kpseinterface.c	Mon Jan 28 08:21:16 2019
@@ -21,6 +21,9 @@
 #include <kpathsea/expand.h>
 #include <kpathsea/c-pathch.h>
 #include <kpathsea/tex-file.h>
+#ifdef W32TEX
+#include <kpathsea/variable.h>
+#endif
 #include "kpseinterface.h"
 
 int kpsei_env_sep_char = ENV_SEP;
@@ -86,3 +89,11 @@
 {
     kpathsea_debug = flags;
 }
+
+#ifdef W32TEX
+char*
+kpsei_var_value(const char *name)
+{
+    return kpse_var_value(name);
+}
+#endif
diff -ur lcdf-typetools-2.108/otftotfm/kpseinterface.h lcdf-typetools-src/otftotfm/kpseinterface.h
--- lcdf-typetools-2.108/otftotfm/kpseinterface.h	Thu Jun 23 21:25:52 2016
+++ lcdf-typetools-src/otftotfm/kpseinterface.h	Mon Jan 28 08:22:18 2019
@@ -13,6 +13,10 @@
 char* kpsei_find_file(const char* name, int format);
 void kpsei_set_debug_flags(unsigned flags);
 
+#ifdef W32TEX
+char* kpsei_var_value(const char *name);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff -ur lcdf-typetools-2.108/otftotfm/otftotfm.cc lcdf-typetools-src/otftotfm/otftotfm.cc
--- lcdf-typetools-2.108/otftotfm/otftotfm.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/otftotfm/otftotfm.cc	Mon Jan 28 08:25:14 2019
@@ -63,6 +63,9 @@
 #ifdef HAVE_FCNTL_H
 # include <fcntl.h>
 #endif
+#ifdef _MSC_VER
+# include <io.h>
+#endif
 
 using namespace Efont;
 
@@ -590,7 +593,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;
@@ -1048,7 +1051,7 @@
 #endif
     {
         fclose(f);
-        f = fopen(filename.c_str(), "w");
+        f = fopen(filename.c_str(), "wb");
         fd = fileno(f);
     }
 
diff -ur lcdf-typetools-2.108/t1dotlessj/t1dotlessj.cc lcdf-typetools-src/t1dotlessj/t1dotlessj.cc
--- lcdf-typetools-2.108/t1dotlessj/t1dotlessj.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/t1dotlessj/t1dotlessj.cc	Mon Jan 28 08:29:20 2019
@@ -410,10 +410,10 @@
     // write it to output
     if (!outputf)
 	outputf = stdout;
-    if (binary) {
 #if defined(_MSDOS) || defined(_WIN32)
-	_setmode(_fileno(outputf), _O_BINARY);
+    _setmode(_fileno(outputf), _O_BINARY);
 #endif
+    if (binary) {
 	Type1PFBWriter w(outputf);
 	dotless_font->write(w);
     } else {
diff -ur lcdf-typetools-2.108/t1rawafm/t1rawafm.cc lcdf-typetools-src/t1rawafm/t1rawafm.cc
--- lcdf-typetools-2.108/t1rawafm/t1rawafm.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/t1rawafm/t1rawafm.cc	Mon Jan 28 08:30:38 2019
@@ -359,6 +359,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 lcdf-typetools-2.108/t1reencode/t1reencode.cc lcdf-typetools-src/t1reencode/t1reencode.cc
--- lcdf-typetools-2.108/t1reencode/t1reencode.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/t1reencode/t1reencode.cc	Mon Jan 28 08:32:09 2019
@@ -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 lcdf-typetools-2.108/t1testpage/t1testpage.cc lcdf-typetools-src/t1testpage/t1testpage.cc
--- lcdf-typetools-2.108/t1testpage/t1testpage.cc	Mon Jan 28 03:39:20 2019
+++ lcdf-typetools-src/t1testpage/t1testpage.cc	Mon Jan 28 08:33:12 2019
@@ -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();