changeset 5065:1312d3af9eb0

[project @ 2004-11-04 20:12:00 by jwe]
author jwe
date Thu, 04 Nov 2004 20:12:11 +0000
parents a6755bc45f15
children 05e4d8c0a840
files scripts/ChangeLog scripts/plot/hist.m src/ChangeLog src/oct-stream.cc
diffstat 4 files changed, 53 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Nov 04 16:34:57 2004 +0000
+++ b/scripts/ChangeLog	Thu Nov 04 20:12:11 2004 +0000
@@ -1,3 +1,7 @@
+2004-11-04  John W. Eaton  <jwe@octave.org>
+
+	* plot/hist.m: Always return row vectors for vector args.
+
 2004-09-23  John W. Eaton  <jwe@octave.org>
 
 	* strings/strcmp.m: If args are not strings or cell arrays of
--- a/scripts/plot/hist.m	Thu Nov 04 16:34:57 2004 +0000
+++ b/scripts/plot/hist.m	Thu Nov 04 20:12:11 2004 +0000
@@ -50,8 +50,9 @@
     usage ("[nn, xx] = hist (y, x, norm)");
   endif
 
-  transpose = rows (y) == 1;
-  if (transpose)
+  arg_is_vector = is_vector (y);
+
+  if (rows (y) == 1)
     y = y(:);
   endif
 
@@ -119,7 +120,7 @@
   endif
 
   if (nargout > 0)
-    if (transpose)
+    if (arg_is_vector)
       nn = freq';
       xx = x';
     else
--- a/src/ChangeLog	Thu Nov 04 16:34:57 2004 +0000
+++ b/src/ChangeLog	Thu Nov 04 20:12:11 2004 +0000
@@ -1,5 +1,9 @@
 2004-11-04  John W. Eaton  <jwe@octave.org>
 
+	* oct-stream.cc (octave_stream::seek (long, int)): Return error
+	(but leave file position unchanged) for attempt to seek beyond end
+	of file.
+
 	* DLD-FUNCTIONS/inv.cc (Finv): Check rcond value returned from
 	LAPACK routines, and be careful to avoid optimizing away the
 	1+rcond == 1.0 check.
--- a/src/oct-stream.cc	Thu Nov 04 16:34:57 2004 +0000
+++ b/src/oct-stream.cc	Thu Nov 04 20:12:11 2004 +0000
@@ -2663,16 +2663,48 @@
 int
 octave_stream::seek (long offset, int origin)
 {
-  int retval = -1;
+  int status = -1;
 
   if (stream_ok ("fseek"))
     {
       clearerr ();
 
-      retval = rep->seek (offset, origin);
+      long orig_pos = rep->tell ();
+
+      status = rep->seek (offset, origin);
+
+      if (status == 0)
+	{
+	  long save_pos = rep->tell ();
+
+	  rep->seek (0, SEEK_END);
+
+	  long pos_eof = rep->tell ();
+
+	  // I don't think save_pos can be less than zero, but we'll
+	  // check anyway...
+
+	  if (save_pos > pos_eof || save_pos < 0)
+	    {
+	      // Seek outside bounds of file.  Failure should leave
+	      // position unchanged.
+
+	      rep->seek (orig_pos, SEEK_SET);
+
+	      status = -1;
+	    }
+	  else
+	    {
+	      // Is it possible for this to fail?  We are just
+	      // returning to a position after the first successful
+	      // seek.
+
+	      rep->seek (save_pos, SEEK_SET);
+	    }
+	}
     }
 
-  return retval;
+  return status;
 }
 
 int
@@ -2720,7 +2752,12 @@
 	}
 
       if (! conv_err)
-	retval = seek (xoffset, origin);
+	{
+	  retval = seek (xoffset, origin);
+
+	  if (retval != 0)
+	    error ("fseek: failed to seek to requested position");
+	}
       else
 	error ("fseek: invalid value for origin");
     }