Skip to content

Commit c546af1

Browse files
Only quote filenames if they have spaces
- This fixes the tests again - Spaces are still handled correctly, to fix #36
1 parent 76f56bc commit c546af1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tectonic/xetexini.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,7 @@ init_io(string input_file_name)
28512851
int k;
28522852
unsigned char *ptr = (unsigned char *) input_file_name;
28532853
UInt32 rval;
2854+
bool name_needs_quotes;
28542855

28552856
stdin_ufile.handle = NULL;
28562857
stdin_ufile.savedChar = -1;
@@ -2862,10 +2863,18 @@ init_io(string input_file_name)
28622863
/* Hacky stuff that sets us up to process the input file, including UTF8
28632864
* interpretation. */
28642865

2866+
/* Check if there is a space in the input_file_name. If so, quote it,
2867+
* because xetex interprets space as the end of the filename. Otherwise, we
2868+
* leave it unquoted, to maintain backwards compatibility. */
2869+
name_needs_quotes = (strchr(input_file_name, ' ') != NULL);
2870+
28652871
buffer[first] = 0;
28662872
k = first;
28672873

2868-
buffer[k++] = '"'; /* Quote filename so xetex accepts spaces */
2874+
/* If the name needs quotes, start them here. */
2875+
if(name_needs_quotes) {
2876+
buffer[k++] = '"';
2877+
}
28692878

28702879
while ((rval = *(ptr++)) != 0) {
28712880
UInt16 extraBytes = bytesFromUTF8[rval];
@@ -2883,8 +2892,11 @@ init_io(string input_file_name)
28832892
buffer[k++] = rval;
28842893
}
28852894

2886-
buffer[k++] = '"'; /* Quote filename so xetex accepts spaces */
2887-
buffer[k] = ' '; /* Unquoted space terminates filename for xetex engine */
2895+
/* If we quoted earlier, end them here. */
2896+
if(name_needs_quotes) {
2897+
buffer[k++] = '"';
2898+
}
2899+
buffer[k] = ' '; /* Unquoted space terminates filename for xetex engine */
28882900
last = k;
28892901
cur_input.loc = first;
28902902
cur_input.limit = last;

0 commit comments

Comments
 (0)