|
From: | Markus Mützel |
Subject: | [Octave-bug-tracker] [bug #59238] load variables from file: the next saving operation produces a faulty file |
Date: | Wed, 21 Oct 2020 15:27:45 -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.48 |
Follow-up Comment #22, bug #59238 (project octave): The correct number of characters is stored in the file. The issue here is for strings that contain line feed characters "\n". When those are written to a file that is opened in text mode on an OS that has CRLF default line endings (like Windows) those "\n" characters expand to "\r\n". When we are loading strings from files, we are reading the number of bytes marked in the file. If some of those bytes expanded to two bytes, we are going to miss some bytes from the end. If a tool would replace the "\r\n" with "\n" the byte count would be correct again. If we can't open the files in text mode for reading, that leaves us with options 1.b) (write in binary mode). Or option 2 (adapt the number of read bytes on platforms with CRLF line ending according to how many line endings have been read in the string). I still prefer option 1.b). _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?59238> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |