From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 17 17:53:14 2002 Subject: Unidentified subject! From: "John W. Eaton" To: Johannes Martin Cc: bug-octave at bevo dot che dot wisc dot edu, jmartin@notamusica.com Date: Tue, 17 Dec 2002 17:52:51 -0600 On 17-Dec-2002, Johannes Martin wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: jmartin at notamusica dot com | Subject: switch statement with expression labels in Octave 2.1.36 | | Bug report for Octave 2.1.36 configured for i686-pc-linux-gnu | | Description: | ----------- | | using an expression in a case label does not seem to work any more | in Octave 2.1.36. It works fine for me in Octave 2.0.16.92 on | Debian/GNU Linux 3.0. | | Repeat-By: | --------- | | switch 1 case 1==1 1 otherwise 0 end | expected result: ans=1 (works in 2.0.16.92) | 2.1.36 result: ans=0 | | switch 1 case 1==0 1 otherwise 0 end | expected result: ans=0 | 2.1.36 result: ans=0 | | It seems like in Octave 2.1.36 a case label with an expression | always fails. Please try the following patch. Thanks, jwe 2002-12-17 John W. Eaton * pt-select.cc (equal): Don't look up == op, just try it and see whether it works. Index: pt-select.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/pt-select.cc,v retrieving revision 1.10 diff -c -r1.10 pt-select.cc *** pt-select.cc 6 Dec 2002 21:29:18 -0000 1.10 --- pt-select.cc 17 Dec 2002 23:52:11 -0000 *************** *** 135,146 **** int t1 = val.type_id (); int t2 = test.type_id (); - binary_op_fcn f - = octave_value_typeinfo::lookup_binary_op (octave_value::op_eq, t1, t2); - // If there is no op_eq for these types, we can't compare values. ! if (f && val.rows () == test.rows () && val.columns () == test.columns ()) { octave_value tmp = do_binary_op (octave_value::op_eq, val, test); --- 135,143 ---- int t1 = val.type_id (); int t2 = test.type_id (); // If there is no op_eq for these types, we can't compare values. ! if (val.rows () == test.rows () && val.columns () == test.columns ()) { octave_value tmp = do_binary_op (octave_value::op_eq, val, test); ------------------------------------------------------------- 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 -------------------------------------------------------------