Uwe Stöhr wrote: > The print dialog is currently unusable on Windows due to bug 3915: > http://bugzilla.lyx.org/show_bug.cgi?id=3915
Rather: printing to a file is completely broken when a path contains spaces (not only on Windows). I guess this went unnoticed since nobody actually uses this (but export->PostScript instead). However, the attached patch should fix it (the fix for the crash is not included). If someone has a more elegant idea to strip out the target_name argument, please let me know. Please test. Jürgen
Index: src/frontends/controllers/ControlPrint.cpp =================================================================== --- src/frontends/controllers/ControlPrint.cpp (Revision 18879) +++ src/frontends/controllers/ControlPrint.cpp (Arbeitskopie) @@ -31,6 +31,7 @@ using support::changeExtension; using support::FileFilterList; +using support::quoteName; namespace frontend { @@ -136,7 +137,7 @@ string const target_name = (pp.target == PrinterParams::PRINTER) ? (pp.printer_name.empty() ? "default" : pp.printer_name) : - pp.file_name; + quoteName(pp.file_name); string const data = target + " " + target_name + " " + command; kernel().dispatch(FuncRequest(getLfun(), data)); Index: src/LyXFunc.cpp =================================================================== --- src/LyXFunc.cpp (Revision 18879) +++ src/LyXFunc.cpp (Arbeitskopie) @@ -128,6 +128,7 @@ using support::package; using support::quoteName; using support::rtrim; +using support::rsplit; using support::split; using support::subst; using support::Systemcall; @@ -990,20 +991,29 @@ case LFUN_BUFFER_PRINT: { BOOST_ASSERT(lyx_view_ && lyx_view_->buffer()); string target; + string tmp = split(argument, target, ' '); string target_name; - string command = split(split(argument, target, ' '), - target_name, ' '); + // target_name might be quoted and contain spaces! + char const quote = + (support::os::shell() == support::os::UNIX) ? '\'': '"'; + if (contains(tmp, quote)) { + tmp = rsplit(tmp, target_name, quote); + // remove quote, will be readded later + target_name = token(target_name, quote, 1); + } else + tmp = split(tmp, target_name, ' '); + string command = tmp; if (target.empty() || target_name.empty() || command.empty()) { lyxerr << "Unable to parse \"" - << argument << '"' << std::endl; + << argument << '"' << endl; break; } if (target != "printer" && target != "file") { lyxerr << "Unrecognized target \"" - << target << '"' << std::endl; + << target << '"' << endl; break; } @@ -1069,7 +1079,9 @@ } else { // case 1: print to a file - FileName const filename(makeAbsPath(target_name, path)); + FileName const filename(makeAbsPath(target_name, + lyx_view_->buffer()->filePath())); + FileName const dvifile(makeAbsPath(dviname, path)); if (fs::exists(filename.toFilesystemEncoding())) { docstring text = bformat( _("The file %1$s already exists.\n\n" @@ -1082,7 +1094,7 @@ command += lyxrc.print_to_file + quoteName(filename.toFilesystemEncoding()) + ' ' - + quoteName(dviname); + + quoteName(dvifile.toFilesystemEncoding()); res = one.startscript(Systemcall::DontWait, command); }