changeset 29695:dcb8f78d0f6b

print: Fix error when "px" word is present in a figure (bug #60641) * gl2ps-print.cc (gl2ps_renderer::draw): Only try to replace "px" at the same line as the "svg" element.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Fri, 21 May 2021 09:08:48 +0200
parents f625b7670c0e
children cc9bda97ac3f
files libinterp/corefcn/gl2ps-print.cc
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc	Tue May 18 09:08:45 2021 -0400
+++ b/libinterp/corefcn/gl2ps-print.cc	Fri May 21 09:08:48 2021 +0200
@@ -499,15 +499,19 @@
                     //        Remove this "else if" block, and
                     //        make header_found true for SVG if gl2ps is fixed.
                     std::string srchstr (str);
-                    std::size_t pos = srchstr.find ("px");
+                    std::size_t pos = srchstr.find ("<svg ");
                     if (! header_found && pos != std::string::npos)
                       {
                         header_found = true;
-                        srchstr[pos+1] = 't';  // "px" -> "pt"
-                        // Assume the second occurrence is at the same line
-                        pos = srchstr.find ("px", pos);
-                        srchstr[pos+1] = 't';  // "px" -> "pt"
-                        std::strcpy (str, srchstr.c_str ());
+                        pos = srchstr.find ("px");
+                        if (pos != std::string::npos)
+                          {
+                            srchstr[pos+1] = 't';  // "px" -> "pt"
+                            // Assume the second occurrence is at the same line
+                            pos = srchstr.find ("px", pos);
+                            srchstr[pos+1] = 't';  // "px" -> "pt"
+                            std::strcpy (str, srchstr.c_str ());
+                          }
                       }
                   }