# HG changeset patch # User Pantxo Diribarne # Date 1621580928 -7200 # Node ID dcb8f78d0f6bb8358e21858e847da3ed1af35adf # Parent f625b7670c0e3649efef2bface6d1b780309488d 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. diff -r f625b7670c0e -r dcb8f78d0f6b libinterp/corefcn/gl2ps-print.cc --- 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 (" "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 ()); + } } }