diff libinterp/interp-core/oct-stream.cc @ 16011:8122286c69a9

initial large file support for 32-bit systems * bootstrap.conf (gnulib_modules): Explicitly list largefile. * c-file-ptr-stream.cc, c-file-ptr-stream.h, oct-fstrm.cc, oct-fstrm.h, oct-iostrm.cc, oct-iostrm.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, file-io.cc: Use off_t instead of long for seek and tell file position values.
author John W. Eaton <jwe@octave.org>
date Thu, 07 Feb 2013 11:58:46 -0500
parents 049e8bbff782
children
line wrap: on
line diff
--- a/libinterp/interp-core/oct-stream.cc	Thu Feb 07 11:58:40 2013 -0500
+++ b/libinterp/interp-core/oct-stream.cc	Thu Feb 07 11:58:46 2013 -0500
@@ -1028,10 +1028,10 @@
   return do_gets (max_len, err, false, who);
 }
 
-long
-octave_base_stream::skipl (long num, bool& err, const std::string& who)
+off_t
+octave_base_stream::skipl (off_t num, bool& err, const std::string& who)
 {
-  long cnt = -1;
+  off_t cnt = -1;
 
   if ((interactive || forced_interactive) && file_number () == 0)
     {
@@ -2816,10 +2816,10 @@
   return retval;
 }
 
-long
-octave_stream::skipl (long count, bool& err, const std::string& who)
+off_t
+octave_stream::skipl (off_t count, bool& err, const std::string& who)
 {
-  long retval = -1;
+  off_t retval = -1;
 
   if (stream_ok ())
     retval = rep->skipl (count, err, who);
@@ -2827,10 +2827,10 @@
   return retval;
 }
 
-long
+off_t
 octave_stream::skipl (const octave_value& tc_count, bool& err, const std::string& who)
 {
-  long retval = -1;
+  off_t retval = -1;
 
   err = false;
 
@@ -2861,7 +2861,7 @@
 }
 
 int
-octave_stream::seek (long offset, int origin)
+octave_stream::seek (off_t offset, int origin)
 {
   int status = -1;
 
@@ -2871,7 +2871,7 @@
 
       // Find current position so we can return to it if needed.
 
-      long orig_pos = rep->tell ();
+      off_t orig_pos = rep->tell ();
 
       // Move to end of file.  If successful, find the offset of the end.
 
@@ -2879,7 +2879,7 @@
 
       if (status == 0)
         {
-          long eof_pos = rep->tell ();
+          off_t eof_pos = rep->tell ();
 
           if (origin == SEEK_CUR)
             {
@@ -2899,7 +2899,7 @@
             {
               // Where are we after moving to desired position?
 
-              long desired_pos = rep->tell ();
+              off_t desired_pos = rep->tell ();
 
               // I don't think save_pos can be less than zero, but we'll
               // check anyway...
@@ -2935,7 +2935,10 @@
 {
   int retval = -1;
 
-  long xoffset = tc_offset.long_value (true);
+  // FIXME -- should we have octave_value methods that handle off_t
+  // explicitly?
+  octave_int64 val = tc_offset.int64_scalar_value ();
+  off_t xoffset = val.value ();
 
   if (! error_state)
     {
@@ -2989,10 +2992,10 @@
   return retval;
 }
 
-long
+off_t
 octave_stream::tell (void)
 {
-  long retval = -1;
+  off_t retval = -1;
 
   if (stream_ok ())
     retval = rep->tell ();
@@ -3561,17 +3564,17 @@
               // Seek to skip when inside bounds of existing file.
               // Otherwise, write NUL to skip.
 
-              long orig_pos = tell ();
+              off_t orig_pos = tell ();
 
               seek (0, SEEK_END);
 
-              long eof_pos = tell ();
+              off_t eof_pos = tell ();
 
               // Is it possible for this to fail to return us to the
               // original position?
               seek (orig_pos, SEEK_SET);
 
-              long remaining = eof_pos - orig_pos;
+              off_t remaining = eof_pos - orig_pos;
 
               if (remaining < skip)
                 {