Octave 2.1.55 available for ftp

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Octave 2.1.55 available for ftp

John W. Eaton-6
Octave 2.1.55 is now available for ftp from ftp.octave.org in the
directory /pub/octave/bleeding-edge:

  -rw-r--r--  1 103  5323000 Feb 20 21:21 octave-2.1.55.tar.gz
  -rw-r--r--  1 103  4197965 Feb 20 21:21 octave-2.1.55.tar.bz2
  -rw-r--r--  1 103    23802 Feb 20 21:43 octave-2.1.54-2.1.55.patch.gz
  -rw-r--r--  1 103    22930 Feb 20 21:43 octave-2.1.54-2.1.55.patch.bz2

This version should fix most of the bugs reported since 2.1.54.

There are still some significant features related to N-d arrays that
need to be implemented, but this version does provide a cat function
and also allows you to use the [] to concatenate N-d numeric arrays.
This still needs to be extended to handle cell and structure arrays
and user-defined types.  We hope to fix this for 2.1.56.  Indexing and
indexed assignment for N-d arrays should also be much better in
2.1.55.  If you find that another of your favorite N-d array
operations doesn't work, please mention it so we can have some idea of
what features are missed the most.  Patches are also welcome.

As always, if your favorite bug is still not fixed, please report it.

Also, 2.1.50 is still the recommended version, but 2.1.55 should be an
improvement over 2.1.54.  If there are no serious problems reported
during the next few weeks for for anything that should have worked
with 2.1.50, then 2.1.55 will probably be promoted to the recommended
version.

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Octave 2.1.55 available for ftp

Alois Schlögl-2


John W. Eaton wrote:

>Octave 2.1.55 is now available for ftp from ftp.octave.org in the
>directory /pub/octave/bleeding-edge:
>
>  -rw-r--r--  1 103  5323000 Feb 20 21:21 octave-2.1.55.tar.gz
>  -rw-r--r--  1 103  4197965 Feb 20 21:21 octave-2.1.55.tar.bz2
>  -rw-r--r--  1 103    23802 Feb 20 21:43 octave-2.1.54-2.1.55.patch.gz
>  -rw-r--r--  1 103    22930 Feb 20 21:43 octave-2.1.54-2.1.55.patch.bz2
>
>This version should fix most of the bugs reported since 2.1.54.
>
>There are still some significant features related to N-d arrays that
>need to be implemented, but this version does provide a cat function
>and also allows you to use the [] to concatenate N-d numeric arrays.
>This still needs to be extended to handle cell and structure arrays
>and user-defined types.  We hope to fix this for 2.1.56.  Indexing and
>indexed assignment for N-d arrays should also be much better in
>2.1.55.  If you find that another of your favorite N-d array
>operations doesn't work, please mention it so we can have some idea of
>what features are missed the most.  Patches are also welcome.
>
>As always, if your favorite bug is still not fixed, please report it.
>
>Also, 2.1.50 is still the recommended version, but 2.1.55 should be an
>improvement over 2.1.54.  If there are no serious problems reported
>during the next few weeks for for anything that should have worked
>with 2.1.50, then 2.1.55 will probably be promoted to the recommended
>version.
>
>Thanks,
>
>jwe
>  
>


In 2.1.50 it was possible to do something like the following

fid = fopen(filename);
hdr = fread(fid, ...);       % reading header information, header might
contain complicated constructs.
hdr.Blocksize=fread(fid, 1, 'int32'); % one field in the header contains
e.g. the Blocksize, or the Number_of_blocks
HeaderLength = ftell(fid);
fseek(fid,0,'eof');
FileSize = ftell(fid);
hdr.Blocksize = (FileSize-HeaderLength)/hdr.number_of_blocks;
fseek(fid,HeaderLen,'bof');
for k = 1:hdr.Blocksize,
    d = fread(fid,hdr.number_of_blocks,'int16');
        % do something with d
end;
fclose;

This is not possible in 2.1.55, because ftell return value is not numeric.

A possible hack (i.e. workaround) for this problem is the patch in
http://www.octave.org/octave-lists/archive/bug-octave.2004/msg00002.html.
At least this seems to do the job.

I was thinking about an alternative solution, too. A possible solution
could also be separating the internal file-io from the file-io for the
users. The user file-io could be mapped to the file-io of stdio; the
internal file-io of Octave could still use the c++ streams. Presumably,
you know much better than me, if this makes sense.


Alois




Reply | Threaded
Open this post in threaded view
|

Re: Octave 2.1.55 available for ftp

John W. Eaton-6
On 23-Feb-2004, Alois Schloegl <[hidden email]> wrote:

| In 2.1.50 it was possible to do something like the following
|
| fid = fopen(filename);
| hdr = fread(fid, ...);       % reading header information, header might
| contain complicated constructs.
| hdr.Blocksize=fread(fid, 1, 'int32'); % one field in the header contains
| e.g. the Blocksize, or the Number_of_blocks
| HeaderLength = ftell(fid);
| fseek(fid,0,'eof');
| FileSize = ftell(fid);
| hdr.Blocksize = (FileSize-HeaderLength)/hdr.number_of_blocks;
| fseek(fid,HeaderLen,'bof');
| for k = 1:hdr.Blocksize,
|     d = fread(fid,hdr.number_of_blocks,'int16');
| % do something with d
| end;
| fclose;
|
| This is not possible in 2.1.55, because ftell return value is not numeric.

Ah yes, your favorite bug.  :-)

| A possible hack (i.e. workaround) for this problem is the patch in
| http://www.octave.org/octave-lists/archive/bug-octave.2004/msg00002.html.
| At least this seems to do the job.

The patch you proposed can't work in general, because there is no
guarantee that a cast from std::streamoff to a "long long" is
meaningful.

| I was thinking about an alternative solution, too. A possible solution
| could also be separating the internal file-io from the file-io for the
| users. The user file-io could be mapped to the file-io of stdio; the
| internal file-io of Octave could still use the c++ streams. Presumably,
| you know much better than me, if this makes sense.

Yes, it does make sense, and it turns out to not be all that hard to
implement.  So maybe the following patch will do?  It should allow us
to preserve backward compatibility.

We will still need some way of handling large files inserting C++
streams into octave_stream objects.  It seems likely that ftell and
fseek will not work for those objects.

Thanks,

jwe


src/ChangeLog:

2004-02-23  John W. Eaton  <[hidden email]>

        * file-io.cc (Fftell): Return long integer instead of streamoff_array.
        (do_stream_open): Create octave_stdiostream instead of octave_fstream.

        * oct-fstrm.cc (octave_fstream::seek, octave_fstream::tell):
        Always fail.  Signatures now match C library functionsb.
        * oct-iostrm.cc (octave_base_iostream::seek,
        octave_base_iostream::tell): Likewise.
        * oct-strstrm.cc (octave_base_strstream::seek,
        octave_base_strstream::tell): Likewise.

        * oct-stream.cc (octave_stream::seek, octave_stream::tell):
        Signatures now match C-library functions.

        * oct-stdstrm.cc (octave_stdiostream::seek, octave_stdiostream::tell):
        Call io_c_file_ptr_stream::seek and tell.  Signatures now match
        C-library functions.

        * c-file-ptr-stream.h (c_file_ptr_buf::seek, c_file_ptr_buf::tell):
        New functions.
        (i_c_file_ptr_stream::seek, i_c_file_ptr_stream::tell): Likewise.
        (o_c_file_ptr_stream::seek, o_c_file_ptr_stream::tell): Likewise.
        (io_c_file_ptr_stream::seek, io_c_file_ptr_stream::tell): Likewise.
 

Index: c-file-ptr-stream.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/c-file-ptr-stream.h,v
retrieving revision 1.15
diff -u -r1.15 c-file-ptr-stream.h
--- c-file-ptr-stream.h 15 Feb 2003 23:14:47 -0000 1.15
+++ c-file-ptr-stream.h 23 Feb 2004 22:03:03 -0000
@@ -43,7 +43,7 @@
 
   typedef int (*close_fcn) (FILE *);
 
-  FILE* stdiofile (void) const { return f; }
+  FILE* stdiofile (void) { return f; }
 
   c_file_ptr_buf (FILE *f_arg, close_fcn cf_arg = fclose)
     : std::streambuf (), f (f_arg), cf (cf_arg)
@@ -77,6 +77,11 @@
 
   int file_number () const { return f ? fileno (f) : -1; }
 
+  int seek (long offset, int origin)
+    { return f ? fseek (f, offset, origin) : -1; }
+
+  long tell (void) { return f ? ftell (f) : -1; }
+
   static int fclose (FILE *f) { return ::fclose (f); }
 
 protected:
@@ -105,6 +110,11 @@
 
   void close (void) { if (buf) buf->close (); }
 
+  int seek (long offset, int origin)
+    { return buf ? buf->seek (offset, origin) : -1; }
+
+  long tell (void) { return buf ? buf->tell () : -1; }
+
 private:
 
   c_file_ptr_buf *buf;
@@ -125,6 +135,11 @@
 
   void close (void) { if (buf) buf->close (); }
 
+  int seek (long offset, int origin)
+    { return buf ? buf->seek (offset, origin) : -1; }
+
+  long tell (void) { return buf ? buf->tell () : -1; }
+
 private:
 
   c_file_ptr_buf *buf;
@@ -145,6 +160,11 @@
 
   void close (void) { if (buf) buf->close (); }
 
+  int seek (long offset, int origin)
+    { return buf ? buf->seek (offset, origin) : -1; }
+
+  long tell (void) { return buf ? buf->tell () : -1; }
+
 private:
 
   c_file_ptr_buf *buf;
Index: file-io.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/file-io.cc,v
retrieving revision 1.150
diff -u -r1.150 file-io.cc
--- file-io.cc 23 Jan 2004 20:04:36 -0000 1.150
+++ file-io.cc 23 Feb 2004 22:03:03 -0000
@@ -38,8 +38,9 @@
 #include <config.h>
 #endif
 
-#include <climits>
 #include <cerrno>
+#include <climits>
+#include <cstdio>
 
 #include <iostream>
 #include <vector>
@@ -337,8 +338,15 @@
       oct_mach_info::float_format flt_fmt =
  oct_mach_info::string_to_float_format (arch);
 
-      if (! error_state)
- retval = octave_fstream::create (name, md, flt_fmt);
+      FILE *fptr = ::fopen (name.c_str (), mode.c_str ());
+
+      if (fptr)
+ {
+  if (! error_state)
+    retval = octave_stdiostream::create (name, fptr, md, flt_fmt);
+ }
+      else
+ error ("fopen: failed to open file %s", name.c_str ());
     }
 
   return retval;
@@ -638,7 +646,7 @@
 from the beginning of the file @var{fid}.\n\
 @end deftypefn")
 {
-  octave_value retval = streamoff_array (dim_vector (1, 1), -1);
+  octave_value retval = -1;
 
   int nargin = args.length ();
 
@@ -647,7 +655,7 @@
       octave_stream os = octave_stream_list::lookup (args(0), "ftell");
 
       if (! error_state)
- retval = streamoff_array (dim_vector (1, 1), os.tell ());
+ retval = os.tell ();
     }
   else
     print_usage ("ftell");
Index: oct-fstrm.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-fstrm.cc,v
retrieving revision 1.17
diff -u -r1.17 oct-fstrm.cc
--- oct-fstrm.cc 22 Nov 2003 12:25:44 -0000 1.17
+++ oct-fstrm.cc 23 Feb 2004 22:03:03 -0000
@@ -66,41 +66,19 @@
 // Position a stream at OFFSET relative to ORIGIN.
 
 int
-octave_fstream::seek (std::streamoff offset, std::ios::seekdir origin)
+octave_fstream::seek (long, int)
 {
-  int retval = -1;
-
-  if (! fs.bad ())
-    {
-      fs.clear ();
-
-      std::filebuf *fb = fs.rdbuf ();
-
-      if (fb)
- {
-  fb->pubseekoff (offset, origin);
-  retval = fs.bad () ? -1 : 0;
- }
-    }
-
-  return retval;
+  error ("fseek: invalid_operation");
+  return -1;
 }
 
 // Return current stream position.
 
-std::streamoff
-octave_fstream::tell (void) const
+long
+octave_fstream::tell (void)
 {
-  std::streamoff retval = -1;
-
-  if (fs)
-    {
-      std::filebuf *fb = fs.rdbuf ();
-
-      retval = std::streamoff (fb->pubseekoff (0, std::ios::cur));
-    }
-
-  return retval;
+  error ("ftell: invalid_operation");
+  return -1;
 }
 
 // Return non-zero if EOF has been reached on this stream.
Index: oct-fstrm.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-fstrm.h,v
retrieving revision 1.16
diff -u -r1.16 oct-fstrm.h
--- oct-fstrm.h 22 Nov 2003 12:25:44 -0000 1.16
+++ oct-fstrm.h 23 Feb 2004 22:03:03 -0000
@@ -45,11 +45,11 @@
 
   // Position a stream at OFFSET relative to ORIGIN.
 
-  int seek (std::streamoff offset, std::ios::seekdir origin);
+  int seek (long offset, int origin);
 
   // Return current stream position.
 
-  std::streamoff tell (void) const;
+  long tell (void);
 
   // Return non-zero if EOF has been reached on this stream.
 
Index: oct-iostrm.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-iostrm.cc,v
retrieving revision 1.10
diff -u -r1.10 oct-iostrm.cc
--- oct-iostrm.cc 22 Nov 2003 12:25:44 -0000 1.10
+++ oct-iostrm.cc 23 Feb 2004 22:03:03 -0000
@@ -30,7 +30,7 @@
 // Position a stream at OFFSET relative to ORIGIN.
 
 int
-octave_base_iostream::seek (std::streamoff, std::ios::seekdir)
+octave_base_iostream::seek (long, int)
 {
   invalid_operation ();
   return -1;
@@ -38,8 +38,8 @@
 
 // Return current stream position.
 
-std::streamoff
-octave_base_iostream::tell (void) const
+long
+octave_base_iostream::tell (void)
 {
   invalid_operation ();
   return -1;
Index: oct-iostrm.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-iostrm.h,v
retrieving revision 1.16
diff -u -r1.16 oct-iostrm.h
--- oct-iostrm.h 22 Nov 2003 12:25:44 -0000 1.16
+++ oct-iostrm.h 23 Feb 2004 22:03:03 -0000
@@ -40,11 +40,11 @@
 
   // Position a stream at OFFSET relative to ORIGIN.
 
-  int seek (std::streamoff offset, std::ios::seekdir origin);
+  int seek (long offset, int origin);
 
   // Return current stream position.
 
-  std::streamoff tell (void) const;
+  long tell (void);
 
   // Return non-zero if EOF has been reached on this stream.
 
Index: oct-stdstrm.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-stdstrm.cc,v
retrieving revision 1.17
diff -u -r1.17 oct-stdstrm.cc
--- oct-stdstrm.cc 22 Nov 2003 12:25:44 -0000 1.17
+++ oct-stdstrm.cc 23 Feb 2004 22:03:03 -0000
@@ -31,45 +31,25 @@
 // Position a stream at OFFSET relative to ORIGIN.
 
 int
-octave_stdiostream::seek (std::streamoff offset, std::ios::seekdir origin)
+octave_stdiostream::seek (long offset, int origin)
 {
   int retval = -1;
 
-  if (! bad ())
-    {
-      c_file_ptr_buf *sb = rdbuf ();
-
-      if (sb)
- {
-  clear ();
-
-  sb->pubseekoff (offset, origin);
-  retval = bad () ? -1 : 0;
- }
-    }
+  if (s)
+    retval = s->seek (offset, origin);
 
   return retval;
 }
 
 // Return current stream position.
 
-std::streamoff
-octave_stdiostream::tell (void) const
+long
+octave_stdiostream::tell (void)
 {
-  std::streamoff retval = -1;
+  long retval = -1;
 
-  if (! bad ())
-    {
-      c_file_ptr_buf *sb = rdbuf ();
-
-      if (sb)
- {
-  retval = std::streamoff (sb->pubseekoff (0, std::ios::cur));
-
-  if (bad ())
-    retval = -1;
- }
-    }
+  if (s)
+    retval = s->tell ();
 
   return retval;
 }
Index: oct-stdstrm.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-stdstrm.h,v
retrieving revision 1.22
diff -u -r1.22 oct-stdstrm.h
--- oct-stdstrm.h 22 Nov 2003 12:25:44 -0000 1.22
+++ oct-stdstrm.h 23 Feb 2004 22:03:03 -0000
@@ -53,11 +53,11 @@
 
   // Position a stream at OFFSET relative to ORIGIN.
 
-  int seek (std::streamoff offset, std::ios::seekdir origin);
+  int seek (long offset, int origin);
 
   // Return current stream position.
 
-  std::streamoff tell (void) const;
+  long tell (void);
 
   // Return non-zero if EOF has been reached on this stream.
 
Index: oct-stream.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-stream.cc,v
retrieving revision 1.99
diff -u -r1.99 oct-stream.cc
--- oct-stream.cc 10 Jan 2004 22:49:19 -0000 1.99
+++ oct-stream.cc 23 Feb 2004 22:03:04 -0000
@@ -2692,7 +2692,7 @@
 }
 
 int
-octave_stream::seek (std::streamoff offset, std::ios::seekdir origin)
+octave_stream::seek (long offset, int origin)
 {
   int retval = -1;
 
@@ -2708,24 +2708,24 @@
 {
   int retval = -1;
 
-  std::streamoff xoffset = tc_offset.streamoff_value ();
+  long xoffset = tc_offset.long_value (true);
 
   if (! error_state)
     {
       int conv_err = 0;
 
-      std::ios::seekdir origin = std::ios::beg;
+      int origin = SEEK_SET;
 
       if (tc_origin.is_string ())
  {
   std::string xorigin = tc_origin.string_value ();
 
   if (xorigin == "bof")
-    origin = std::ios::beg;
+    origin = SEEK_SET;
   else if (xorigin == "cof")
-    origin = std::ios::cur;
+    origin = SEEK_CUR;
   else if (xorigin == "eof")
-    origin = std::ios::end;
+    origin = SEEK_END;
   else
     conv_err = -1;
  }
@@ -2736,11 +2736,11 @@
   if (! conv_err)
     {
       if (xorigin == -1)
- origin = std::ios::beg;
+ origin = SEEK_SET;
       else if (xorigin == 0)
- origin = std::ios::cur;
+ origin = SEEK_CUR;
       else if (xorigin == 1)
- origin = std::ios::end;
+ origin = SEEK_END;
       else
  conv_err = -1;
     }
@@ -2757,10 +2757,10 @@
   return retval;
 }
 
-std::streamoff
-octave_stream::tell (void) const
+long
+octave_stream::tell (void)
 {
-  std::streamoff retval = -1;
+  long retval = -1;
 
   if (stream_ok ("tell"))
     retval = rep->tell ();
Index: oct-stream.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-stream.h,v
retrieving revision 1.33
diff -u -r1.33 oct-stream.h
--- oct-stream.h 22 Nov 2003 12:25:44 -0000 1.33
+++ oct-stream.h 23 Feb 2004 22:03:04 -0000
@@ -334,11 +334,11 @@
 
   // Position a stream at OFFSET relative to ORIGIN.
 
-  virtual int seek (std::streamoff offset, std::ios::seekdir origin) = 0;
+  virtual int seek (long offset, int origin) = 0;
 
   // Return current stream position.
 
-  virtual std::streamoff tell (void) const = 0;
+  virtual long tell (void) = 0;
 
   // Return TRUE if EOF has been reached on this stream.
 
@@ -502,10 +502,10 @@
   std::string gets (const octave_value& max_len, bool& err,
     const std::string& who /* = "gets" */);
 
-  int seek (std::streamoff offset, std::ios::seekdir origin);
+  int seek (long offset, int origin);
   int seek (const octave_value& offset, const octave_value& origin);
 
-  std::streamoff tell (void) const;
+  long tell (void);
 
   int rewind (void);
 
Index: oct-strstrm.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-strstrm.cc,v
retrieving revision 1.12
diff -u -r1.12 oct-strstrm.cc
--- oct-strstrm.cc 22 Nov 2003 12:25:44 -0000 1.12
+++ oct-strstrm.cc 23 Feb 2004 22:03:04 -0000
@@ -29,49 +29,19 @@
 // Position a stream at OFFSET relative to ORIGIN.
 
 int
-octave_base_strstream::seek (std::streamoff offset, std::ios::seekdir origin)
+octave_base_strstream::seek (long offset, int origin)
 {
-  int retval = -1;
-
-  if (! bad ())
-    {
-      std::streambuf *sb = rdbuf ();
-
-      if (sb)
- {
-  clear ();
-
-  sb->pubseekoff (offset, origin);
-  retval = bad () ? -1 : 0;
- }
-    }
-
-  return retval;
+  error ("fseek: invalid operation");
+  return -1;
 }
 
 // Return current stream position.
 
-std::streamoff
-octave_base_strstream::tell (void) const
+long
+octave_base_strstream::tell (void)
 {
-  std::streamoff retval = -1;
-
-  if (! bad ())
-    {
-      // XXX FIXME XXX -- shouldn't have to do this!
-
-      std::streambuf *sb = (const_cast<octave_base_strstream *>(this))->rdbuf ();
-
-      if (sb)
- {
-  retval = std::streamoff (sb->pubseekoff (0, std::ios::cur));
-
-  if (bad ())
-    retval = -1;
- }
-    }
-
-  return retval;
+  error ("ftell: invalid operation");
+  return -1;
 }
 
 octave_stream
Index: oct-strstrm.h
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-strstrm.h,v
retrieving revision 1.16
diff -u -r1.16 oct-strstrm.h
--- oct-strstrm.h 22 Nov 2003 12:25:44 -0000 1.16
+++ oct-strstrm.h 23 Feb 2004 22:03:04 -0000
@@ -41,11 +41,11 @@
 
   // Position a stream at OFFSET relative to ORIGIN.
 
-  int seek (std::streamoff offset, std::ios::seekdir origin);
+  int seek (long offset, int origin);
 
   // Return current stream position.
 
-  std::streamoff tell (void) const;
+  long tell (void);
 
   // The name of the file.