[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn()
From: |
Arun Giridhar |
Subject: |
[Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure |
Date: |
Fri, 24 Mar 2023 09:55:52 -0400 (EDT) |
Follow-up Comment #35, bug #63415 (project octave):
I have a patch for this. Please test this:
diff -r c735cce18c7a libinterp/corefcn/oct-stream.h
--- a/libinterp/corefcn/oct-stream.h Thu Mar 23 16:22:59 2023 -0400
+++ b/libinterp/corefcn/oct-stream.h Fri Mar 24 09:34:34 2023 -0400
@@ -119,7 +119,7 @@ public:
std::ostream * preferred_output_stream ()
{
- if (! m_encoding.compare ("utf-8"))
+ if (! m_encoding.compare ("utf-8") || (m_mode & std::ios::binary))
return output_stream ();
if (m_conv_ostream)
Explanation: The previous code was skipping conversion to/from UTF-8 when the
encoding was already UTF-8. The patched code adds another criterion to skip
conversion: the stream was opened in binary mode.
Unpatched:
octave:1> cd /tmp/
octave:2> __mfile_encoding__ ("latin1")
octave:3> __mfile_encoding__
ans = latin1
octave:4> fwritetest
error: assert (stat ("m_rand.bin").size == numel (matB) * sizeof (double (1)))
failed
error: called from
assert at line 107 column 11
fwritetest at line 21 column 1
octave:5> ver
----------------------------------------------------------------------
GNU Octave Version: 9.0.0 (hg id: c735cce18c7a)
Patched:
octave:1> cd /tmp/
octave:2> __mfile_encoding__ ("latin1")
octave:3> __mfile_encoding__
ans = latin1
octave:4> fwritetest
Variables visible from the current scope:
variables in scope: top scope
Attr Name Size Bytes Class
==== ==== ==== ===== =====
matA 100x150 120000 double
matB 100x150 120000 double
matC 15000x1 120000 double
matD 15000x1 120000 double
n 1x1 8 double
Total is 60001 elements using 480008 bytes
Elapsed time is 0.00793386 seconds.
octave:5> ver
----------------------------------------------------------------------
GNU Octave Version: 9.0.0 (hg id: c735cce18c7a+)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63415>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, (continued)
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Arun Giridhar, 2023/03/15
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, José Luis García Pallero, 2023/03/16
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Nicholas Jankowski, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Nicholas Jankowski, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Arun Giridhar, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Nicholas Jankowski, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Dmitri A. Sergatskov, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, José Luis García Pallero, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Dmitri A. Sergatskov, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Dmitri A. Sergatskov, 2023/03/20
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure,
Arun Giridhar <=
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Arun Giridhar, 2023/03/24
- [Octave-bug-tracker] [bug #63415] Error in fwrite() or rand() or randn(), I'm not sure, Arun Giridhar, 2023/03/31