Skip to content

Commit cc78267

Browse files
authored
Merge pull request #21 from mojca/TL-patches
[WIP] TeX Live patches for Windows
2 parents 9b2257f + 7cc3b38 commit cc78267

File tree

9 files changed

+41
-10
lines changed

9 files changed

+41
-10
lines changed

include/config.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifdef WIN32
88
# ifdef __MINGW32__
99
# include <winsock2.h>
10+
# include <windows.h>
1011
# else
1112
# include <win32lib.h>
1213
# endif

otftotfm/automatic.cc

+19-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
#include <algorithm>
4040

4141
#ifdef WIN32
42-
# define mkdir(dir, access) mkdir(dir)
42+
# include <io.h>
43+
# include <direct.h>
44+
# define mkdir(dir, access) _mkdir(dir)
4345
# define COPY_CMD "copy"
4446
# define CMD_SEP "&"
4547
#else
@@ -124,7 +126,16 @@ look_for_writable_texdir(const char *path_variable, bool create)
124126
static void
125127
find_writable_texdir(ErrorHandler *errh, const char *)
126128
{
127-
look_for_writable_texdir("$TEXMFVAR", true);
129+
// Check if TEXMFVAR is writable.
130+
// Some distributions like W32TeX do not have TEXMFVAR defined,
131+
// in which case we check TEXMFLOCAL.
132+
char *p = kpsei_var_value("TEXMFVAR");
133+
if (p == NULL)
134+
look_for_writable_texdir("$TEXMFLOCAL", true);
135+
else {
136+
free (p);
137+
look_for_writable_texdir("$TEXMFVAR", true);
138+
}
128139
if (!writable_texdir)
129140
look_for_writable_texdir("$VARTEXMF", false);
130141
if (!writable_texdir)
@@ -313,7 +324,7 @@ update_odir(int o, String file, ErrorHandler *errh)
313324
String ls_r = writable_texdir + "ls-R";
314325
bool success = false;
315326
if (access(ls_r.c_str(), R_OK) >= 0) // make sure it already exists
316-
if (FILE *f = fopen(ls_r.c_str(), "a")) {
327+
if (FILE *f = fopen(ls_r.c_str(), "ab")) {
317328
fprintf(f, "./%s:\n%s\n", directory.c_str(), file.c_str());
318329
success = true;
319330
fclose(f);
@@ -323,7 +334,11 @@ update_odir(int o, String file, ErrorHandler *errh)
323334
if (!success && writable_texdir.find_left('\'') < 0 && directory.find_left('\'') < 0 && file.find_left('\'') < 0) {
324335
// look for mktexupd script
325336
if (!mktexupd_tried) {
337+
#ifdef _WIN32
338+
mktexupd = "mktexupd.exe";
339+
#else
326340
mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C));
341+
#endif
327342
mktexupd_tried = true;
328343
}
329344

@@ -677,7 +692,7 @@ update_autofont_map(const String &fontname, String mapline, ErrorHandler *errh)
677692
#endif
678693
{
679694
fclose(f);
680-
f = fopen(map_file.c_str(), "w");
695+
f = fopen(map_file.c_str(), "wb");
681696
fd = fileno(f);
682697
}
683698

otftotfm/kpseinterface.c

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <kpathsea/expand.h>
2222
#include <kpathsea/c-pathch.h>
2323
#include <kpathsea/tex-file.h>
24+
#include <kpathsea/variable.h>
2425
#include "kpseinterface.h"
2526

2627
int kpsei_env_sep_char = ENV_SEP;
@@ -49,6 +50,12 @@ kpsei_path_expand(const char* path)
4950
return kpse_path_expand(path);
5051
}
5152

53+
char*
54+
kpsei_var_value(const char *name)
55+
{
56+
return kpse_var_value(name);
57+
}
58+
5259
char*
5360
kpsei_find_file(const char* name, int format)
5461
{

otftotfm/kpseinterface.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern "C" {
77
void kpsei_init(const char* argv0, const char* progname);
88
extern int kpsei_env_sep_char;
99
char* kpsei_path_expand(const char* path); /* free() result */
10+
char* kpsei_var_value(const char *name);
1011
enum { KPSEI_FMT_WEB2C, KPSEI_FMT_ENCODING, KPSEI_FMT_TYPE1,
1112
KPSEI_FMT_OTHER_TEXT, KPSEI_FMT_MAP, KPSEI_FMT_TRUETYPE,
1213
KPSEI_FMT_OPENTYPE, KPSEI_FMT_TYPE42 };

otftotfm/otftotfm.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#endif
1717
#ifdef WIN32
1818
# define _USE_MATH_DEFINES
19+
# include <io.h>
1920
#endif
2021
#include <efont/psres.hh>
2122
#include <efont/t1rw.hh>
@@ -590,7 +591,7 @@ output_pl(Metrics &metrics, const String &ps_name, int boundary_char,
590591

591592
if (verbose)
592593
errh->message("creating %s", filename.c_str());
593-
FILE *f = fopen(filename.c_str(), "w");
594+
FILE *f = fopen(filename.c_str(), "wb");
594595
if (!f) {
595596
errh->error("%s: %s", filename.c_str(), strerror(errno));
596597
return;
@@ -1048,7 +1049,7 @@ write_encoding_file(String &filename, const String &encoding_name,
10481049
#endif
10491050
{
10501051
fclose(f);
1051-
f = fopen(filename.c_str(), "w");
1052+
f = fopen(filename.c_str(), "wb");
10521053
fd = fileno(f);
10531054
}
10541055

t1dotlessj/t1dotlessj.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ particular purpose.\n");
410410
// write it to output
411411
if (!outputf)
412412
outputf = stdout;
413-
if (binary) {
414413
#if defined(_MSDOS) || defined(_WIN32)
415-
_setmode(_fileno(outputf), _O_BINARY);
414+
_setmode(_fileno(outputf), _O_BINARY);
416415
#endif
416+
if (binary) {
417417
Type1PFBWriter w(outputf);
418418
dotless_font->write(w);
419419
} else {

t1rawafm/t1rawafm.cc

+3
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ particular purpose.\n");
359359
if (!outf)
360360
errh->fatal("%s: %s", output_file, strerror(errno));
361361
}
362+
#if defined(_MSDOS) || defined(_WIN32)
363+
_setmode(_fileno(outf), _O_BINARY);
364+
#endif
362365

363366
write_afm(outf, font);
364367

t1reencode/t1reencode.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1094,10 +1094,10 @@ particular purpose.\n");
10941094
if (!outf)
10951095
errh->fatal("%s: %s", output_file, strerror(errno));
10961096
}
1097-
if (binary) {
10981097
#if defined(_MSDOS) || defined(_WIN32)
1099-
_setmode(_fileno(outf), _O_BINARY);
1098+
_setmode(_fileno(outf), _O_BINARY);
11001099
#endif
1100+
if (binary) {
11011101
Type1PFBWriter w(outf);
11021102
font->write(w);
11031103
} else {

t1testpage/t1testpage.cc

+3
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ particular purpose.\n");
665665
if (!outf)
666666
errh->fatal("%s: %s", output_file, strerror(errno));
667667
}
668+
#if defined(_MSDOS) || defined(_WIN32)
669+
_setmode(_fileno(outf), _O_BINARY);
670+
#endif
668671

669672
//font->undo_synthetic();
670673

0 commit comments

Comments
 (0)