help-octave
[Top][All Lists]
Advanced

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

Re: empty matrix problem with 2.1.32 (cvs)


From: John W. Eaton
Subject: Re: empty matrix problem with 2.1.32 (cvs)
Date: Fri, 5 Jan 2001 10:37:14 -0600

On  4-Jan-2001, address@hidden <address@hidden> wrote:

| I've found the problem with octave 2.1.32 and Yellow Dog Linux (YDL).  
| The problem only occurs (in practice) under Yellow Dog Linux
| on a powerpc computer, although the patch below should be applied in order
| to meet va_start, va_end specifications.  The issue is the use of 
| multiple va_list functions between va_start() and va_end() calls, e.g.,
| 
|   va_start(args, fmt);
|   vfprintf(fp, fmt, args);
|   vprintf( fmt, args);
|   va_end(args);
| 
| I ran into this problem earlier this year porting another package to YDL.
| I  put together a simple example like the one above and submitted it to
| the YDL support mailing list and to the comp.os.linux.ppc newsgroup.  The
| responses I got back said
| 
|       - yup, this works on any other Unix I have as well, but ...
|       - it doesn't follow the va_start, va_end specifications, and so
|         it's not a bug with YDL.  The code should be rewritten as:
| 
|   va_start(args, fmt);
|   vfprintf(fp, fmt, args);
|   va_end(args);
| 
|   va_start(args, fmt);
|   vprintf( fmt, args);
|   va_end(args);
| 
| This means that the call to vwarning in src/error.cc needs to be rewritten.
| In particular, vwarning cannot make two back-to-back calls to octave-vformat
| as is currently done.  The diff below fixes the problem:
| 
| Index: error.cc
| ===================================================================
| RCS file: /cvs/octave/src/error.cc,v
| retrieving revision 1.78
| diff -c -r1.78 error.cc
| *** error.cc    2000/10/10 21:42:21     1.78
| --- error.cc    2001/01/05 01:45:24
| ***************
| *** 75,97 ****
|   // XXX FIXME XXX -- we should provide another way to turn them off...
| 
|   static void
| ! vwarning (const char *name, const char *fmt, va_list args)
|   {
|     flush_octave_stdout ();
| 
|     std::ostrstream output_buf;
| 
|     if (name)
| !     {
| !       octave_diary << name << ": ";
| !       std::cerr << name << ": ";
| !     }
| 
| !   octave_vformat (octave_diary, fmt, args);
| !   octave_vformat (std::cerr, fmt, args);
| 
| !   octave_diary << std::endl;
| !   std::cerr << std::endl;
|   }
| 
|   static void
| --- 75,92 ----
|   // XXX FIXME XXX -- we should provide another way to turn them off...
| 
|   static void
| ! vwarning (std::ostream& os, const char *name, const char *fmt, va_list args)
|   {
|     flush_octave_stdout ();
| 
|     std::ostrstream output_buf;
| 
|     if (name)
| !     os << name << ": ";
| 
| !   octave_vformat (os, fmt, args);
| 
| !   os << endl;
|   }
| 
|   static void
| ***************
| *** 296,304 ****
|   warning (const char *fmt, ...)
|   {
|     va_list args;
| -   va_start (args, fmt);
|     warning_state = 1;
| !   vwarning ("warning", fmt, args);
|     va_end (args);
| 
|     pr_where ("warning");
| --- 291,304 ----
|   warning (const char *fmt, ...)
|   {
|     va_list args;
|     warning_state = 1;
| !
| !   va_start (args, fmt);
| !   vwarning (octave_diary,"warning", fmt, args);
| !   va_end (args);
| !
| !   va_start (args, fmt);
| !   vwarning (std::cerr,"warning", fmt, args);
|     va_end (args);
| 
|     pr_where ("warning");

Thanks for debugging this problem.  Does the following patch also
work?  It makes vwarning similar to verror.  It seems that this change
was started but not finished at some time in the past (note the unused
variable output_buf in the original).

Thanks,

jwe


2001-01-05  John W. Eaton  <address@hidden>

        * error.cc (vwarning): Write to output_buf, then send formatted
        message to diary and error streams.


Index: error.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/error.cc,v
retrieving revision 1.78
diff -c -r1.78 error.cc
*** error.cc    2000/10/10 21:42:21     1.78
--- error.cc    2001/01/05 16:32:44
***************
*** 82,97 ****
    std::ostrstream output_buf;
  
    if (name)
!     {
!       octave_diary << name << ": ";
!       std::cerr << name << ": ";
!     }
  
!   octave_vformat (octave_diary, fmt, args);
!   octave_vformat (std::cerr, fmt, args);
  
!   octave_diary << std::endl;
!   std::cerr << std::endl;
  }
  
  static void
--- 82,99 ----
    std::ostrstream output_buf;
  
    if (name)
!     output_buf << name << ": ";
  
!   octave_vformat (output_buf, fmt, args);
  
!   output_buf << std::endl << std::ends;
! 
!   char *msg = output_buf.str ();
! 
!   octave_diary << msg;
!   std::cerr << msg;
! 
!   delete [] msg;
  }
  
  static void



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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