# HG changeset patch # User jwe # Date 1115829251 0 # Node ID 679cc8fec4086647c07bf8aef5c9086f611ec0eb # Parent a103c41e68b20c2797255f0768748a7b6e7ad6f0 [project @ 2005-05-11 16:34:11 by jwe] diff -r a103c41e68b2 -r 679cc8fec408 liboctave/Range.h --- a/liboctave/Range.h Tue May 10 09:41:38 2005 +0000 +++ b/liboctave/Range.h Wed May 11 16:34:11 2005 +0000 @@ -33,7 +33,7 @@ public: Range (void) - : rng_base (-1), rng_limit (-1), rng_inc (-1), rng_nelem (-1), cache () { } + : rng_base (0), rng_limit (0), rng_inc (0), rng_nelem (0), cache (1, 0) { } Range (const Range& r) : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc), diff -r a103c41e68b2 -r 679cc8fec408 scripts/ChangeLog --- a/scripts/ChangeLog Tue May 10 09:41:38 2005 +0000 +++ b/scripts/ChangeLog Wed May 11 16:34:11 2005 +0000 @@ -1,3 +1,7 @@ +2005-05-11 John W. Eaton + + * plot/polar.m: Don't call __pltopt__ here. + 2005-05-02 John W. Eaton * mkdoc: Print header message. diff -r a103c41e68b2 -r 679cc8fec408 scripts/plot/polar.m --- a/scripts/plot/polar.m Tue May 10 09:41:38 2005 +0000 +++ b/scripts/plot/polar.m Wed May 11 16:34:11 2005 +0000 @@ -40,16 +40,13 @@ __gnuplot_raw__ ("set nopolar;\n"); if (nargin == 3) - if (isstr (fmt)) - fmt = __pltopt__ ("polar", fmt); - else + if (! isstr (fmt)) error ("polar: third argument must be a string"); endif __plr2__ (x1, x2, fmt); elseif (nargin == 2) if (isstr (x2)) - fmt = __pltopt__ ("polar", x2); - __plr1__ (x1, fmt); + __plr1__ (x1, x2); else fmt = ""; __plr2__ (x1, x2, fmt); diff -r a103c41e68b2 -r 679cc8fec408 src/pt-colon.cc --- a/src/pt-colon.cc Tue May 10 09:41:38 2005 +0000 +++ b/src/pt-colon.cc Wed May 11 16:34:11 2005 +0000 @@ -82,6 +82,73 @@ } octave_value +tree_colon_expression::make_range (const Matrix& m_base, + const Matrix& m_limit, + const Matrix& m_increment, + bool result_is_str, bool dq_str) const +{ + octave_value retval; + + bool base_empty = m_base.is_empty (); + bool limit_empty = m_limit.is_empty (); + bool increment_empty = m_increment.is_empty (); + + if ((base_empty || m_base.numel () == 1) + && (limit_empty || m_limit.numel () == 1) + && (increment_empty || m_increment.numel () == 1)) + { + if (base_empty || limit_empty || increment_empty) + retval = Range (); + else + { + retval = Range (m_base(0), m_limit(0), m_increment(0)); + + if (result_is_str) + retval = retval.convert_to_str (false, true, dq_str ? '"' : '\''); + } + } + else + eval_error ("colon expression values must be scalars or empty matrices"); + + return retval; +} + +octave_value +tree_colon_expression::make_range (const octave_value& ov_base, + const octave_value& ov_limit, + const octave_value& ov_increment) const +{ + octave_value retval; + + bool result_is_str = (ov_base.is_string () && ov_limit.is_string ()); + bool dq_str = (ov_base.is_dq_string () || ov_limit.is_dq_string ()); + + Matrix m_base = ov_base.matrix_value (true); + + if (error_state) + eval_error ("invalid base value in colon expression"); + else + { + Matrix m_limit = ov_limit.matrix_value (true); + + if (error_state) + eval_error ("invalid limit value in colon expression"); + else + { + Matrix m_increment = ov_increment.matrix_value (true); + + if (error_state) + eval_error ("invalid increment value in colon expression"); + else + retval = make_range (m_base, m_limit, m_increment, + result_is_str, dq_str); + } + } + + return retval; +} + +octave_value tree_colon_expression::rvalue (void) { octave_value retval; @@ -91,72 +158,38 @@ if (error_state || ! op_base || ! op_limit) return retval; - octave_value tmp = op_base->rvalue (); - - if (error_state || tmp.is_undefined ()) - { - eval_error ("invalid value in colon expression"); - return retval; - } - - double xbase = tmp.double_value (); + octave_value ov_base = op_base->rvalue (); - if (error_state) - { - eval_error ("colon expression elements must be scalars"); - return retval; - } - - tmp = op_limit->rvalue (); - - if (error_state || tmp.is_undefined ()) - { - eval_error ("invalid value in colon expression"); - return retval; - } - - double xlimit = tmp.double_value (); - - if (error_state) + if (error_state || ov_base.is_undefined ()) + eval_error ("invalid base value in colon expression"); + else { - eval_error ("colon expression elements must be scalars"); - return retval; - } - - double xinc = 1.0; + octave_value ov_limit = op_limit->rvalue (); - if (op_increment) - { - tmp = op_increment->rvalue (); - - if (error_state || tmp.is_undefined ()) + if (error_state || ov_limit.is_undefined ()) + eval_error ("invalid limit value in colon expression"); + else { - eval_error ("invalid value in colon expression"); - return retval; - } + octave_value ov_increment = 1.0; - xinc = tmp.double_value (); + if (op_increment) + { + ov_increment = op_increment->rvalue (); - if (error_state) - { - eval_error ("colon expression elements must be scalars"); - return retval; + if (error_state || ov_increment.is_undefined ()) + eval_error ("invalid increment value in colon expression"); + } + + if (! error_state) + retval = make_range (ov_base, ov_limit, ov_increment); } } - retval = octave_value (xbase, xlimit, xinc); - - if (error_state) - { - retval = octave_value (); - eval_error (); - } - return retval; } void -tree_colon_expression::eval_error (const std::string& s) +tree_colon_expression::eval_error (const std::string& s) const { if (! s.empty ()) ::error ("%s", s.c_str ()); diff -r a103c41e68b2 -r 679cc8fec408 src/pt-colon.h --- a/src/pt-colon.h Tue May 10 09:41:38 2005 +0000 +++ b/src/pt-colon.h Wed May 11 16:34:11 2005 +0000 @@ -75,7 +75,7 @@ octave_value_list rvalue (int nargout); - void eval_error (const std::string& s = std::string ()); + void eval_error (const std::string& s = std::string ()) const; tree_expression *base (void) { return op_base; } @@ -97,6 +97,14 @@ bool save_base; + octave_value + make_range (const Matrix& m_base, const Matrix& m_limit, + const Matrix& m_increment, bool result_is_str) const; + + octave_value + make_range (const octave_value& ov_base, const octave_value& ov_limit, + const octave_value& ov_increment) const; + // No copying! tree_colon_expression (const tree_colon_expression&); diff -r a103c41e68b2 -r 679cc8fec408 test/ChangeLog --- a/test/ChangeLog Tue May 10 09:41:38 2005 +0000 +++ b/test/ChangeLog Wed May 11 16:34:11 2005 +0000 @@ -1,3 +1,7 @@ +2005-05-11 John W. Eaton + + * config/unix.exp: Start Octave with -H. + 2002-10-31 John W. Eaton * octave.test/arith/prod-4.m, octave.test/arith/sum-4.m: diff -r a103c41e68b2 -r 679cc8fec408 test/config/unix.exp --- a/test/config/unix.exp Tue May 10 09:41:38 2005 +0000 +++ b/test/config/unix.exp Wed May 11 16:34:11 2005 +0000 @@ -81,7 +81,7 @@ # the timeout period at a minute for the real tests. set timeout 60 - spawn $OCTAVE -f -q $OSPATH + spawn $OCTAVE -f -q -H $OSPATH set timeout 5 expect { @@ -132,8 +132,8 @@ # Can't seem to get 2>&1 to work without using /bin/sh -c ""... - send_log "EXEC: $OCTAVE -f -q $OSPATH $src_file\n" - catch "exec /bin/sh -c \"$OCTAVE -f -q $OSPATH $src_file 2>&1\"" oct_output + send_log "EXEC: $OCTAVE -f -q -H $OSPATH $src_file\n" + catch "exec /bin/sh -c \"$OCTAVE -f -q -H $OSPATH $src_file 2>&1\"" oct_output } # do_test -- run a test given by the file $src_code.