changeset 28337:8d2f9cfc16bc

Use relative filename in .tex file when printing using -dXXXlatex devices (bug #58374). * gl2ps-print.cc (gl2ps_renderer::draw): Strip path and pass basename of file to gl2ps for inclusion in the latex directive \\includegraphics. * print.m (latex_standalone): Remove code that was correcting absolute filenames since they no longer occur.
author Rik <rik@octave.org>
date Wed, 20 May 2020 13:17:00 -0700
parents 391a9d85e59d
children 70908e5d8865
files libinterp/corefcn/gl2ps-print.cc scripts/plot/util/print.m
diffstat 2 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc	Wed May 20 08:26:47 2020 -0700
+++ b/libinterp/corefcn/gl2ps-print.cc	Wed May 20 13:17:00 2020 -0700
@@ -39,6 +39,7 @@
 
 #include <gl2ps.h>
 
+#include "file-ops.h"
 #include "lo-mappers.h"
 #include "oct-locbuf.h"
 #include "tmpfile-wrapper.h"
@@ -417,9 +418,13 @@
 
             if (n_begin != std::string::npos)
               {
+                // Strip any quote characters characters around filename
                 size_t n_end = include_graph.find_last_not_of (" \"'");
                 include_graph = include_graph.substr (n_begin,
                                                       n_end - n_begin + 1);
+                // Strip path from filename
+                n_begin = include_graph.find_last_of (octave::sys::file_ops::dir_sep_chars ());
+                include_graph = include_graph.substr (n_begin + 1);
               }
             else
               include_graph = "foobar-inc";
--- a/scripts/plot/util/print.m	Wed May 20 08:26:47 2020 -0700
+++ b/scripts/plot/util/print.m	Wed May 20 13:17:00 2020 -0700
@@ -1006,13 +1006,10 @@
   switch (opts.devopt)
     case {"pdflatexstandalone"}
       packages = "\\usepackage{graphicx,color}";
-      graphicsfile = [opts.name "-inc.pdf"];
     case {"pslatexstandalone"}
       packages = "\\usepackage{epsfig,color}";
-      graphicsfile = [opts.name "-inc.ps"];
     otherwise
       packages = "\\usepackage{epsfig,color}";
-      graphicsfile = [opts.name "-inc.eps"];
   endswitch
 
   packages = {packages "\\usepackage[utf8]{inputenc}"};
@@ -1035,9 +1032,6 @@
     error ("Octave:print:errorclosingfile",
            "print: error closing file '%s'", latexfile);
   endif
-  ## FIXME: should this be fixed in GL2PS?
-  latex = strrep (latex, "\\includegraphics{}",
-                  sprintf ("\\includegraphics{%s}", graphicsfile));
 
   fid = fopen (latexfile, "w");
   if (fid >= 0)