changeset 28994:c3970f97f9b8

maint: merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 25 Oct 2020 09:41:51 +0100
parents 48122a60d99b (current diff) cc287e633588 (diff)
children 0e86e50bebeb
files libinterp/corefcn/load-save.cc
diffstat 2 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/load-save.cc	Sat Oct 24 11:18:14 2020 -0400
+++ b/libinterp/corefcn/load-save.cc	Sun Oct 25 09:41:51 2020 +0100
@@ -1469,14 +1469,8 @@
         std::ios::openmode mode
           = (append ? (std::ios::app | std::ios::ate) : std::ios::out);
 
-        if (format.type () == BINARY
-#if defined (HAVE_HDF5)
-            || format.type () == HDF5
-#endif
-            || format.type () == MAT_BINARY
-            || format.type () == MAT5_BINARY
-            || format.type () == MAT7_BINARY)
-          mode |= std::ios::binary;
+        // Always open in binary mode to save line endings as is.
+        mode |= std::ios::binary;
 
 #if defined (HAVE_HDF5)
         if (format.type () == HDF5)
--- a/libinterp/corefcn/ls-ascii-helper.cc	Sat Oct 24 11:18:14 2020 -0400
+++ b/libinterp/corefcn/ls-ascii-helper.cc	Sun Oct 25 09:41:51 2020 +0100
@@ -34,8 +34,11 @@
 
 // Helper functions when reading from ascii files.
 
-// These function take care of CR/LF issues when files are opened in
-// text-mode for reading.
+// These functions take care of different line endings (LF, CR, CRLF)
+// when files were opened in text mode for writing and are now opened in
+// binary mode for reading.
+// Even though we no longer store files in text mode, keep this logic
+// to allow loading older files that might have CRLF or CR line endings.
 
 // Skip characters from stream IS until a newline is reached.
 // Depending on KEEP_NEWLINE, either eat newline from stream or