From e729c5ffeefcbf72ec319c18ccebfad66712df57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Thu, 28 Jun 2007 21:21:05 +0000 Subject: [PATCH] =?utf8?q?ControlPrint.cpp=20LyXFunc.cpp=20=20=20Quote=20f?= =?utf8?q?ile=20paths=20in=20printer=20dialog=20=20=20Fix=20bug=203915:=20?= =?utf8?q?http://bugzilla.lyx.org/show=5Fbug.cgi=3Fid=3D3915=20=20=20(patc?= =?utf8?q?h=20from=20J=C3=BCrgen=20and=20JMarc)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18934 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 27 ++++++++++++---------- src/frontends/controllers/ControlPrint.cpp | 4 ++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 27f558a5fb..01b6984eff 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -989,21 +989,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_BUFFER_PRINT: { BOOST_ASSERT(lyx_view_ && lyx_view_->buffer()); - string target; - string target_name; - string command = split(split(argument, target, ' '), - target_name, ' '); + // FIXME: cmd.getArg() might fail if one of the arguments + // contains double quotes + 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 +1036,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // 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 +1062,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } 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 +1070,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } 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 +1082,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd) 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); } diff --git a/src/frontends/controllers/ControlPrint.cpp b/src/frontends/controllers/ControlPrint.cpp index 2f42527935..bcb0df017b 100644 --- a/src/frontends/controllers/ControlPrint.cpp +++ b/src/frontends/controllers/ControlPrint.cpp @@ -129,7 +129,7 @@ void ControlPrint::dispatchParams() 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 @@ void ControlPrint::dispatchParams() (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)); } -- 2.39.2