Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] TeX Live patches for Windows #21

Merged
merged 5 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifdef WIN32
# ifdef __MINGW32__
# include <winsock2.h>
# include <windows.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this would not hurt even if defined immediately under WIN32. It's just that under VS it isn't really needed.

# else
# include <win32lib.h>
# endif
Expand Down
23 changes: 19 additions & 4 deletions otftotfm/automatic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't object to this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kakuto:

Thanks a lot.

# define COPY_CMD "copy"
# define CMD_SEP "&"
#else
Expand Down Expand Up @@ -124,7 +126,16 @@ look_for_writable_texdir(const char *path_variable, bool create)
static void
find_writable_texdir(ErrorHandler *errh, const char *)
{
look_for_writable_texdir("$TEXMFVAR", true);
// Check if TEXMFVAR is writable.
// Some distributions like W32TeX do not have TEXMFVAR defined,
// in which case we check TEXMFLOCAL.
char *p = kpsei_var_value("TEXMFVAR");
if (p == NULL)
look_for_writable_texdir("$TEXMFLOCAL", true);
else {
free (p);
look_for_writable_texdir("$TEXMFVAR", true);
}
if (!writable_texdir)
look_for_writable_texdir("$VARTEXMF", false);
if (!writable_texdir)
Expand Down Expand Up @@ -313,7 +324,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")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all files being made binary? Is there an actual concrete reason? Because this is just a text file. But maybe on Windows all kpathsea files such as ls-R should use Unix lineendings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kakuto:

In the TeX Live, ls-R files on w32 use Unix style lineendings.

fprintf(f, "./%s:\n%s\n", directory.c_str(), file.c_str());
success = true;
fclose(f);
Expand All @@ -323,7 +334,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 = "mktexupd.exe";
#else
mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C));
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK (shrug)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kakuto:

Thanks a lot.

mktexupd_tried = true;
}

Expand Down Expand Up @@ -677,7 +692,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");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kakuto:

See above

fd = fileno(f);
}

Expand Down
7 changes: 7 additions & 0 deletions otftotfm/kpseinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <kpathsea/expand.h>
#include <kpathsea/c-pathch.h>
#include <kpathsea/tex-file.h>
#include <kpathsea/variable.h>
#include "kpseinterface.h"

int kpsei_env_sep_char = ENV_SEP;
Expand Down Expand Up @@ -49,6 +50,12 @@ kpsei_path_expand(const char* path)
return kpse_path_expand(path);
}

char*
kpsei_var_value(const char *name)
{
return kpse_var_value(name);
}

char*
kpsei_find_file(const char* name, int format)
{
Expand Down
1 change: 1 addition & 0 deletions otftotfm/kpseinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
void kpsei_init(const char* argv0, const char* progname);
extern int kpsei_env_sep_char;
char* kpsei_path_expand(const char* path); /* free() result */
char* kpsei_var_value(const char *name);
enum { KPSEI_FMT_WEB2C, KPSEI_FMT_ENCODING, KPSEI_FMT_TYPE1,
KPSEI_FMT_OTHER_TEXT, KPSEI_FMT_MAP, KPSEI_FMT_TRUETYPE,
KPSEI_FMT_OPENTYPE, KPSEI_FMT_TYPE42 };
Expand Down
5 changes: 3 additions & 2 deletions otftotfm/otftotfm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif
#ifdef WIN32
# define _USE_MATH_DEFINES
# include <io.h>
#endif
#include <efont/psres.hh>
#include <efont/t1rw.hh>
Expand Down Expand Up @@ -590,7 +591,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;
Expand Down Expand Up @@ -1048,7 +1049,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);
}

Expand Down
4 changes: 2 additions & 2 deletions t1dotlessj/t1dotlessj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ particular purpose.\n");
// 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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kakuto:

See above...

Type1PFBWriter w(outputf);
dotless_font->write(w);
} else {
Expand Down
3 changes: 3 additions & 0 deletions t1rawafm/t1rawafm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,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);

Expand Down
4 changes: 2 additions & 2 deletions t1reencode/t1reencode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions t1testpage/t1testpage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down