Jean-Marc Lasgouttes wrote: > I would quote it too. Excellent idea, as always.
OK for the attached? Jürgen
Index: src/LyXFunc.cpp =================================================================== --- src/LyXFunc.cpp (Revision 18888) +++ src/LyXFunc.cpp (Arbeitskopie) @@ -989,21 +989,20 @@ case LFUN_BUFFER_PRINT: { BOOST_ASSERT(lyx_view_ && lyx_view_->buffer()); - string target; - string target_name; - string command = split(split(argument, target, ' '), - target_name, ' '); + string target = cmd.getArg(0); + string target_name = cmd.getArg(1); + string command = cmd.getArg(2); 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; } @@ -1035,13 +1034,13 @@ // case 3: print using a spool string const psname = changeExtension(dviname,".ps"); - command += lyxrc.print_to_file + command += ' ' + lyxrc.print_to_file + quoteName(psname) + ' ' + quoteName(dviname); string command2 = - lyxrc.print_spool_command +' '; + lyxrc.print_spool_command + ' '; if (target_name != "default") { command2 += lyxrc.print_spool_printerprefix + target_name @@ -1061,7 +1060,7 @@ } else { // case 2: print directly to a printer if (target_name != "default") - command += lyxrc.print_to_printer + target_name + ' '; + command += ' ' + lyxrc.print_to_printer + target_name + ' '; res = one.startscript( Systemcall::DontWait, command + quoteName(dviname)); @@ -1069,7 +1068,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" @@ -1079,10 +1080,10 @@ text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0) break; } - command += lyxrc.print_to_file + command += ' ' + lyxrc.print_to_file + quoteName(filename.toFilesystemEncoding()) + ' ' - + quoteName(dviname); + + quoteName(dvifile.toFilesystemEncoding()); res = one.startscript(Systemcall::DontWait, command); } Index: src/frontends/controllers/ControlPrint.cpp =================================================================== --- src/frontends/controllers/ControlPrint.cpp (Revision 18888) +++ src/frontends/controllers/ControlPrint.cpp (Arbeitskopie) @@ -129,7 +129,7 @@ command += lyxrc.print_extra_options + ' '; } - command += kernel().buffer().params().dvips_options() + ' '; + command += kernel().buffer().params().dvips_options(); string const target = (pp.target == PrinterParams::PRINTER) ? "printer" : "file"; @@ -138,7 +138,7 @@ (pp.printer_name.empty() ? "default" : pp.printer_name) : pp.file_name; - string const data = target + " " + target_name + " " + command; + string const data = target + " \"" + target_name + "\" \"" + command + '"'; kernel().dispatch(FuncRequest(getLfun(), data)); }