octave-maintainers
[Top][All Lists]
Advanced

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

Re: 2.9.18 --> 3.0


From: John W. Eaton
Subject: Re: 2.9.18 --> 3.0
Date: Tue, 04 Dec 2007 14:02:35 -0500

On  3-Dec-2007, John W. Eaton wrote:

| On  1-Dec-2007, Thomas Treichl wrote:
| 
| | John W. Eaton schrieb:
| | > On  1-Dec-2007, Thomas Treichl wrote:
| | > 
| | > | Oooops, I would have better had a look at the codes before I wrote
| | > | that email. I found the FIXME in the error.cc file.
| | > 
| | > I remember this problem being discussed before, but I'm not sure I see
| | > a FIXME note in error.cc that is specifically about it.
| | > 
| | > jwe
| | 
| | In current CVS file error.cc "DEFUN (error, args, ," line 1019:
| | 
| |    // FIXME -- need to extract and pass message id to
| |    // handle_message.
| | 
| | The mwarnerr.m output from the example I sent looks somehow like that fixme 
for 
| | me, ie. the error ID is passed to the output instead of the error message 
and so 
| | the error id is not extracted but taken as the output string? My example 
looks like
| | 
| |    octave-2.9.17:1> mwarnerr
| |    warning: This is a warning with ID
| |    error: mwarnerr:ErrID
| |    error: called from `mwarnerr' in file `/Users/Me/tmp/mwarnerr.m'
| | 
| | I'm not sure that I have had a look at the right place?
| 
| Sorry, I misunderstood what the problem was (it might have helped if
| in your original message you had shown the output you see and the
| output you expect).
| 
| As you've noted, there is a FIXME about this problem.
| 
| I guess I'm waiting for a patch.

OK, I tired of waiting and decided to make the following change.

Now I see this behavior:

  octave:1> mwarnerr
  warning: This is a warning with ID
  error: This is an error with ID
  error: called from `mwarnerr' in file `/export/home/jwe/mwarnerr.m'
  octave:1> lasterror
  ans =
  {
    message = error: This is an error with ID

    identifier = mwarnerr:ErrID
    stack =
    {
      file = /export/home/jwe/mwarnerr.m
      name = mwarnerr
      line =  3
      column =  3
    }

  }


jwe


src/ChangeLog:

2007-12-04  John W. Eaton  <address@hidden>

        * error.cc (Ferror): Handle error id.


Index: src/error.cc
===================================================================
RCS file: /cvs/octave/src/error.cc,v
retrieving revision 1.128
diff -u -u -r1.128 error.cc
--- src/error.cc        27 Nov 2007 22:40:20 -0000      1.128
+++ src/error.cc        4 Dec 2007 18:58:06 -0000
@@ -963,6 +963,7 @@
 DEFUN (error, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\
address@hidden {Built-in Function} {} error (@var{id}, @var{template}, 
@dots{})\n\
 Format the optional arguments under the control of the template string\n\
 @var{template} using the same rules as the @code{printf} family of\n\
 functions (@pxref{Formatted Output}) and print the resulting message\n\
@@ -1016,11 +1017,36 @@
 @end example\n\
 @end deftypefn")
 {
-  // FIXME -- need to extract and pass message id to
-  // handle_message.
+  octave_value retval;
+
+  int nargin = args.length ();
+
+  octave_value_list nargs = args;
+
+  std::string id;
+
+  if (nargin > 1)
+    {
+      std::string arg1 = args(0).string_value ();
+
+      if (! error_state)
+       {
+         if (arg1.find ('%') == NPOS)
+           {
+             id = arg1;
+
+             nargs.resize (nargin-1);
+
+             for (int i = 1; i < nargin; i++)
+               nargs(i-1) = args(i);
+           }
+       }
+      else
+       return retval;
+    }
+
+  handle_message (error_with_id, id.c_str (), "unspecified error", nargs);
 
-  octave_value_list retval;
-  handle_message (error_with_id, "", "unspecified error", args);
   return retval;
 }
 

reply via email to

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