octave-maintainers
[Top][All Lists]
Advanced

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

compatibility patch of isfield


From: John W. Eaton
Subject: compatibility patch of isfield
Date: Tue, 27 Jul 2004 11:00:50 -0400

On 25-Jul-2004, Andy Adler <address@hidden> wrote:

| In Matlab, isfield gives output 0 for all
| unreasonable inputs, rather than showing an error.
| 
| Examples:
|     >> a.b=1;
|     >> x=0;
|     >> isfield(x,0)
|     ans =
|          0
|     >> isfield(a,0)
|     ans =
|          0
|     >> isfield(a,'b')
|     ans =
|          1
|     >> isfield(a)
|     ??? Input argument 'f' is undefined.
| 
|     Error in ==> C:\Program Files\MATLAB6p5\toolbox\matlab\datatypes\isfield.m
|     On line 12  ==>   tf = any(strcmp(fieldnames(s),f));
| 
| --
| Andy Adler
| 
| Here is a patch:
| 
| $ cvs diff -u src/ov-struct.cc
| RCS file: /cvs/octave/src/ov-struct.cc,v
| retrieving revision 1.48
| diff -u -r1.48 ov-struct.cc
| --- a/src/ov-struct.cc  12 Mar 2004 19:13:02 -0000      1.48
| +++ b/src/ov-struct.cc  25 Jul 2004 14:02:14 -0000
| @@ -679,7 +679,7 @@
|           retval = m.contains (key) != 0;
|         }
|        else
| -       print_usage ("isfield");
| +       retval= 0;
|      }
|    else
|      print_usage ("isfield");

I made this change, but by removing the else clause entirely, since
retval was already initialized to false.

Thanks,

jwe



reply via email to

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