changeset 31961:c1fc1e821381 stable

Don't use encoding facet when writing bytes to stream (bug #63931). * libinterp/corefcn/oct-stream.h (octave::stream::output_stream): Do not return output stream with encoding facet. (octave::stream::preferred_output_stream): Add new function that returns output stream with encoding facet if applicable. * libinterp/corefcn/pr-output.cc (Ffdisp): Use new function `preferred_output_stream` instead of `output_stream`.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 01 Apr 2023 18:34:27 +0200
parents ce64ec8fe929
children 476c84c4f201 622985ce895b
files libinterp/corefcn/oct-stream.h libinterp/corefcn/pr-output.cc
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.h	Sat Apr 01 11:47:51 2023 -0400
+++ b/libinterp/corefcn/oct-stream.h	Sat Apr 01 18:34:27 2023 +0200
@@ -456,6 +456,12 @@
 
   std::ostream * output_stream (void)
   {
+    return (m_rep ? m_rep->output_stream () : nullptr);
+  }
+
+  std::ostream * preferred_output_stream ()
+  {
+    // return output stream with encoding facet if applicable
     return (m_rep ? m_rep->preferred_output_stream () : nullptr);
   }
 
--- a/libinterp/corefcn/pr-output.cc	Sat Apr 01 11:47:51 2023 -0400
+++ b/libinterp/corefcn/pr-output.cc	Sat Apr 01 18:34:27 2023 +0200
@@ -3397,7 +3397,7 @@
 
   stream os = streams.lookup (fid, "fdisp");
 
-  std::ostream *osp = os.output_stream ();
+  std::ostream *osp = os.preferred_output_stream ();
 
   if (! osp)
     error ("fdisp: stream FID not open for writing");