bug in printf in 2.1.31?

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

bug in printf in 2.1.31?

Joao Cardoso-3

Hi,

I'm not sure if this is 2.1.31 bug...

octave:1> printf("--%d--\n",[]);
--0--
octave:2> printf("%d\n");
0
octave:3> printf("%d")
0ans = 1

is it? humm, I think it is.

Joao


Reply | Threaded
Open this post in threaded view
|

bug in printf in 2.1.31?

John W. Eaton-6
On  3-Aug-2000, Joao Cardoso <[hidden email]> wrote:

| I'm not sure if this is 2.1.31 bug...
|
| octave:1> printf("--%d--\n",[]);
| --0--
| octave:2> printf("%d\n");
| 0
| octave:3> printf("%d")
| 0ans = 1
|
| is it? humm, I think it is.

I think it's a bug.  Please try the following patch (also checked in
to the CVS archive now, so it should show up in the anonymous CVS
archive shortly).

Thanks,

jwe

2000-08-03  John W. Eaton  <[hidden email]>

        * oct-stream.cc (printf_value_cache::double_value): Also set
        curr_stat to conversion_error if there are no values at all.


Index: oct-stream.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/oct-stream.cc,v
retrieving revision 1.66
diff -u -r1.66 oct-stream.cc
--- oct-stream.cc 2000/07/20 19:21:24 1.66
+++ oct-stream.cc 2000/08/03 05:08:37
@@ -2037,7 +2037,10 @@
 {
   double retval = 0.0;
 
-  while (val_idx < n_vals)
+  if (exhausted ())
+    curr_state = conversion_error;
+
+  while (! exhausted ())
     {
       if (! data)
  {