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

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

[Octave-bug-tracker] [bug #58055] ftell() incorrect on MS Windows platfo


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #58055] ftell() incorrect on MS Windows platforms if file is not encoded with CRLF line endings
Date: Mon, 13 Apr 2020 15:14:49 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #19, bug #58055 (project octave):

Markus: thanks for finding the visual studio bug info.

Until the problem is fixed, I think a reasonable solution for us is to call
"setvbuf (FID, _IONBF, 0, 0)" on Windows systems when opening files in text
mode.  Maybe we could also create a simple test to run when Octave first needs
to do this that could determine whether the workaround is needed.  Then we
would only do this when we detect the problem.  But for now, I propose the
following simpler change:


diff --git a/libinterp/corefcn/file-io.cc b/libinterp/corefcn/file-io.cc
--- a/libinterp/corefcn/file-io.cc
+++ b/libinterp/corefcn/file-io.cc
@@ -449,6 +449,15 @@ do_stream_open (const std::string& name,
         {
           FILE *fptr = octave::sys::fopen (fname.c_str (), mode.c_str ());
 
+#if defined (__WIN32__)
+          // FIXME: Work around fseek/ftell bug on Windows systems.  See
+          // Octave bug #58055.  This should really be enabled only if
+          // fseek/ftell require setting _IONBF to work properly.
+
+          if (mode.find ('t') != std::string::npos)
+            ::setvbuf (fptr, NULL, _IONBF, 0);
+#endif
+
           retval = octave_stdiostream::create (fname, fptr, md, flt_fmt,
                                                encoding);



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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