Merge pull request #20 from DavidKinder/master

For Windows, replace backslashes with forward slashes for pdftex
This commit is contained in:
David Kinder 2022-08-14 15:37:42 +01:00 committed by GitHub
commit 6872eab1d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,14 +123,30 @@ int Platform::system(const char *cmd) {
or a Unix-like shell. */
int unix = Platform::Win32_is_unix_cmd(cmd);
if (unix) {
/* Some Cygwin commands cannot handle backslashes in paths. */
int forward_slash = 0;
if (strncmp(cmd,"pdftex ",7) == 0)
forward_slash = 1;
/* For a Unix shell command, escape any double quotes and backslashes. */
char *pcl;
const char *pc;
strcpy(cmd_line, "sh -c \"");
for (pc = cmd, pcl = cmd_line+strlen(cmd_line); *pc != 0; ++pc, ++pcl) {
if ((*pc == '\\') || (*pc == '\"'))
if (*pc == '\"') {
*(pcl++) = '\\';
*pcl = *pc;
*pcl = *pc;
}
else if (*pc == '\\') {
if (forward_slash)
*pcl = '/';
else {
*(pcl++) = '\\';
*pcl = *pc;
}
}
else
*pcl = *pc;
}
*(pcl++) = '\"';
*(pcl++) = 0;
@ -209,13 +225,13 @@ void Platform::closedir(void *D) {
=
void Platform::path_add(const char* base, const char* add, char* path) {
char last;
char last;
strcpy(path, base);
last = path[strlen(path) - 1];
if ((last != '/') && (last != '\\'))
strcat(path, "\\");
strcat(path, add);
strcpy(path, base);
last = path[strlen(path) - 1];
if ((last != '/') && (last != '\\'))
strcat(path, "\\");
strcat(path, add);
}
void Platform::rsync(char *transcoded_source, char *transcoded_dest) {