changeset 10889:1d7a7fb5074b

__print_parse_opts__.m: Double quote paths with spaces.
author Ben Abbott <bpabbott@mac.com>
date Fri, 13 Aug 2010 19:16:47 -0400
parents f4fdd8637762
children 51b64b7229e5
files scripts/ChangeLog scripts/plot/__print_parse_opts__.m
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-13  Ben Abbott <bpabbott@mac.com>
+
+	* plot/__print_parse_opts__.m: Double quote paths with spaces.
+
 2010-08-11  Rik <octave@nomad.inbox5.com>
 
 	* set/unique.m: Handle corner case where sparse matrix is actually full.
--- a/scripts/plot/__print_parse_opts__.m
+++ b/scripts/plot/__print_parse_opts__.m
@@ -32,11 +32,11 @@
   arg_st.debug_file = "octave-print-commands.log";
   arg_st.devopt = "";
   arg_st.figure = get (0, "currentfigure");
-  arg_st.fig2dev_binary = __find_binary__ ("fig2dev");
+  arg_st.fig2dev_binary = __quote_path__ (__find_binary__ ("fig2dev"));
   arg_st.fontsize = "";
   arg_st.font = "";
   arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid
-  arg_st.ghostscript.binary = __ghostscript_binary__ ();
+  arg_st.ghostscript.binary = __quote_path__ (__ghostscript_binary__ ());
   arg_st.ghostscript.device = "";
   arg_st.ghostscript.output = "";
   arg_st.ghostscript.papersize = "";
@@ -45,7 +45,7 @@
   arg_st.ghostscript.epscrop = false;
   arg_st.ghostscript.resolution = 150;
   arg_st.orientation = "";
-  arg_st.pstoedit_binary = __find_binary__ ("pstoedit");
+  arg_st.pstoedit_binary = __quote_path__ (__find_binary__ ("pstoedit"));
   arg_st.name = "";
   arg_st.printer = "";
   arg_st.special_flag = "textnormal";
@@ -95,12 +95,11 @@
       elseif (length (arg) > 2 && arg(1:2) == "-P")
         arg_st.printer = arg;
       elseif ((length (arg) > 2) && arg(1:2) == "-G")
-        arg_st.ghostscript.binary = arg(3:end);
-        if (exist (arg_st.ghostscript.binary, "file") != 2)
-          arg_st.ghostscript.binary = file_in_path (EXEC_PATH, arg_st.ghostscript.binary);
-        endif
+        arg_st.ghostscript.binary = file_in_path (EXEC_PATH, arg(3:end));
         if (isempty (arg_st.ghostscript.binary))
           error ("print: Ghostscript binary ""%s"" could not be located", arg(3:end))
+        else
+          arg_st.ghostscript_binary = __quote_path__ (arg_st.ghostscript_binary);
         endif
       elseif (length (arg) > 2 && arg(1:2) == "-F")
         idx = rindex (arg, ":");
@@ -339,6 +338,12 @@
 %!   unlink (opts.unlink{n});
 %! endfor
 
+function cmd = __quote_path__ (cmd)
+  if (any (cmd == " ") && ! (cmd(1) == """" && cmd(end) == """"))
+    cmd = strcat ("""", strrep (cmd, """", """"""), """");
+  endif
+endfunction
+
 function gs = __ghostscript_binary__ ()
 
   persistent ghostscript_binary = ""