changeset 24418:c23b9af6a664

Remove warnings about 'W', 'A', and 'R' modes in fopen (bug #52644). * file-io.cc (normalize_fopen_mode): Add comment about why warnings not necessary here. Just translate 'W', 'A', 'R' to lowercase.
author Rik <rik@octave.org>
date Fri, 15 Dec 2017 12:51:20 -0800
parents c341ebb40ede
children e1390a99a993
files libinterp/corefcn/file-io.cc
diffstat 1 files changed, 9 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc	Fri Dec 15 12:01:17 2017 -0800
+++ b/libinterp/corefcn/file-io.cc	Fri Dec 15 12:51:20 2017 -0800
@@ -110,38 +110,27 @@
 
   if (! mode.empty ())
     {
-      // Could probably be faster, but does it really matter?
-
-      // Accept 'W', 'R', and 'A' as 'w', 'r', and 'a' but we warn about
-      // them because Matlab says they don't perform "automatic
-      // flushing" but we don't know precisely what action that implies.
+      // Matlab uses 'A' and 'W' to indicate that buffered writing should
+      // take place.  Octave already does that.  Theoretically, we should
+      // warn about using 'a', 'r', or 'w' because Octave does not enable
+      // automatic flushing with these modes.  The performance hit is ~4X
+      // when using automatic flushing and seems completely unnecessary.
+      // See bug #52644.
 
       size_t pos = mode.find ('W');
 
       if (pos != std::string::npos)
-        {
-          warning_with_id ("Octave:fopen-mode",
-                           R"(fopen: treating mode "W" as equivalent to "w")");
-          mode[pos] = 'w';
-        }
+        mode[pos] = 'w';
 
       pos = mode.find ('R');
 
       if (pos != std::string::npos)
-        {
-          warning_with_id ("Octave:fopen-mode",
-                           R"(fopen: treating mode "R" as equivalent to "r")");
-          mode[pos] = 'r';
-        }
+        mode[pos] = 'r';
 
       pos = mode.find ('A');
 
       if (pos != std::string::npos)
-        {
-          warning_with_id ("Octave:fopen-mode",
-                           R"(fopen: treating mode "A" as equivalent to "a")");
-          mode[pos] = 'a';
-        }
+        mode[pos] = 'a';
 
       pos = mode.find ('z');