Filenames with spaces; output beside the input file; warning fixes (from dev c08eb1bbfa4c)

- Filenames may contain spaces: quote on the command line; filename
  lists use a standalone "/" separator; unseparated names that do not
  exist are rejoined into names that do (announced); leading ~ expands.
- Without -o, output is written to the input file's directory; -o fully
  specifies the output directory and basename.
- "Word not parsed" warnings now appear without -v, only for text that
  survives removal, with correct line numbers.
- New tst/filename_test.sh regression suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 23:22:59 +02:00
parent d9c98ac86d
commit fd9a370af7
21 changed files with 430 additions and 34 deletions

View File

@@ -78,7 +78,12 @@ std::string tex_to_pdf(Machine& machine)
for (auto ext : {"aux", "log", "out", "toc"}) {
fs::remove(outbase + "." + ext);
}
std::string command = "xelatex -interaction=batchmode -halt-on-error " + tex_filename;
// xelatex writes .pdf/.log/.aux/.toc into its cwd unless told otherwise;
// K_output_dir need not be cwd (it follows the input file, or -o).
// The embedded paths are quoted defensively: they derive from user
// filenames, which may contain spaces.
std::string command = "xelatex -interaction=batchmode -halt-on-error -output-directory=\""
+ machine.m_state.value("K_output_dir") + "\" \"" + tex_filename + "\"";
string_to_file(tex_filename, machine.m_result);
std::string xelatex_output = exec(command.c_str());
std::string xelatex_log = string_from_file(outbase + ".log");