Mercurial > octave
comparison scripts/plot/util/print.m @ 27622:df8942d19b7b
Allow printing with Octave installed in path with parenthesis (bug #49718)
* print.m (pstoedit, svgconvert, fig2dev, epstool), __ghostscript__.m: Quote
file names and escape strings that will be used as format strings.
* __opengl_print__.m: Ditto. On Windows, quote the complete string for the pipe
because it has a strange logic that sometimes removes the outer quotes.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 02 Sep 2019 21:21:58 +0200 |
parents | 1807acfe2150 |
children | 45ad2127582b |
comparison
equal
deleted
inserted
replaced
27621:39fac14ab25a | 27622:df8942d19b7b |
---|---|
822 | 822 |
823 if (nargin < 2 || strcmp (filein, "-") || isempty (filein)) | 823 if (nargin < 2 || strcmp (filein, "-") || isempty (filein)) |
824 pipein = true; | 824 pipein = true; |
825 filein = [tempname() ".eps"]; | 825 filein = [tempname() ".eps"]; |
826 if (dos_shell) | 826 if (dos_shell) |
827 cleanup = sprintf ("& del %s ", strrep (filein, '/', '\')); | 827 cleanup = sprintf ('& del "%s" ', strrep (filein, '/', '\')); |
828 else | 828 else |
829 cleanup = sprintf ("; rm %s ", filein); | 829 cleanup = sprintf ('; rm "%s" ', filein); |
830 endif | 830 endif |
831 else | 831 else |
832 pipein = false; | 832 pipein = false; |
833 filein = ["'" strtrim(filein) "'"]; | 833 filein = ["'" strtrim(filein) "'"]; |
834 endif | 834 endif |
835 if (strcmp (fileout, "-")) | 835 if (strcmp (fileout, "-")) |
836 pipeout = true; | 836 pipeout = true; |
837 fileout = [tempname() ".eps"]; | 837 fileout = [tempname() ".eps"]; |
838 if (dos_shell) | 838 if (dos_shell) |
839 cleanup = [cleanup, sprintf("& del %s ", strrep (fileout, '/', '\'))]; | 839 cleanup = [cleanup, sprintf('& del "%s" ', strrep (fileout, '/', '\'))]; |
840 else | 840 else |
841 cleanup = [cleanup, sprintf("; rm %s ", fileout)]; | 841 cleanup = [cleanup, sprintf('; rm "%s" ', fileout)]; |
842 endif | 842 endif |
843 else | 843 else |
844 pipeout = false; | 844 pipeout = false; |
845 fileout = ["'" strtrim(fileout) "'"]; | 845 fileout = ["'" strtrim(fileout) "'"]; |
846 endif | 846 endif |
1076 if (! do_svg) | 1076 if (! do_svg) |
1077 if (dos_shell) | 1077 if (dos_shell) |
1078 cmd = sprintf ("%s -f %s 2> NUL", opts.pstoedit_binary, devopt); | 1078 cmd = sprintf ("%s -f %s 2> NUL", opts.pstoedit_binary, devopt); |
1079 else | 1079 else |
1080 cmd = sprintf ("%s -f %s 2> /dev/null", opts.pstoedit_binary, devopt); | 1080 cmd = sprintf ("%s -f %s 2> /dev/null", opts.pstoedit_binary, devopt); |
1081 endi;f | |
1082 endif | 1081 endif |
1083 else | 1082 else |
1084 cmd = svgconvert (opts, devopt); | 1083 cmd = svgconvert (opts, devopt); |
1085 if (dos_shell) | 1084 if (dos_shell) |
1086 cmd = sprintf ("%s & %s -ssp -f %s %%s 2> NUL", cmd, ... | 1085 cmd = sprintf ('%s & %s -ssp -f %s "%%s" 2> NUL', cmd, ... |
1087 opts.pstoedit_binary, devopt); | 1086 undo_string_escapes (opts.pstoedit_binary), ... |
1087 undo_string_escapes (devopt)); | |
1088 else | 1088 else |
1089 cmd = sprintf ("%s ; %s -ssp -f %s %%s 2> /dev/null", cmd, ... | 1089 cmd = sprintf ('%s ; %s -ssp -f %s "%%s" 2> /dev/null', cmd, ... |
1090 opts.pstoedit_binary, devopt); | 1090 opts.pstoedit_binary, devopt); |
1091 endif | 1091 endif |
1092 endif | 1092 endif |
1093 | 1093 |
1094 if (opts.debug) | 1094 if (opts.debug) |
1114 | 1114 |
1115 if (isempty (fontdir)) | 1115 if (isempty (fontdir)) |
1116 fontdir = __octave_config_info__ ("octfontsdir"); | 1116 fontdir = __octave_config_info__ ("octfontsdir"); |
1117 endif | 1117 endif |
1118 | 1118 |
1119 cmd = sprintf ("%s - %%s %3.2f %s %d \"%%s\"", opts.svgconvert_binary, ... | 1119 cmd = sprintf ('%s - %%s %3.2f "%s" %d "%%s"', ... |
1120 undo_string_escapes (opts.svgconvert_binary), ... | |
1120 get (0, "screenpixelsperinch"), ... | 1121 get (0, "screenpixelsperinch"), ... |
1121 fullfile (fontdir, "FreeSans.otf"), 1); | 1122 undo_string_escapes (fullfile (fontdir, "FreeSans.otf")), 1); |
1122 | 1123 |
1123 if (opts.debug) | 1124 if (opts.debug) |
1124 fprintf ("svgconvert command: '%s'\n", cmd); | 1125 fprintf ("svgconvert command: '%s'\n", cmd); |
1125 endif | 1126 endif |
1126 endif | 1127 endif |