octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59238] load variables from file: the next sav


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #59238] load variables from file: the next saving operation produces a faulty file
Date: Tue, 20 Oct 2020 06:12:28 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43

Follow-up Comment #9, bug #59238 (project octave):

Sorry, I misunderstood what I was supposed to test.
Saving a double variable with the following commands, also leads to a file
with CRLF line endings on Windows:

A = rand(4);
save A_text.txt A -text


Loading that file (again on Windows) successfully restores all matrix elements
of A.

The issue seems to be with saving and loading cell strings in "-text" format
if the line ending is CRLF.

An example that reproduces the issue for me on Windows is:

cell_str = {"This\nis\na\ntest."};
save cell_str_text.txt cell_str -text
cell_str2 = cell_str;
load cell_str_text.txt


The length of the string as marked in `cell_str_text.txt` is 15. But because
the string was saved with CRLF line endings, 18 bytes have to be read from the
file.

I see the following possible solutions:
- When saving, write the string literal in the file with LF line endings. This
might be awkward when displaying the file in editors that have issues with
mixed line endings in the same file.
- When saving, increase "length" by the number of additional bytes for the CR
characters.
- When loading, count CRLF as one byte only.

Afaict, this is an issue in core Octave. There's not much the "symbolic"
package can do about it.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59238>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]