# HG changeset patch # User dbateman # Date 1121071276 0 # Node ID fda074a55b5c4eb3706b963f8d9657a2e55838fe # Parent 9461ff9278fb27cbb1d92fe4b4daa9720b5fec8e [project @ 2005-07-11 08:41:16 by dbateman] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-07-11 David Bateman + + * ov-fc-inline.cc (Fvectorize): Allow string arguments + 2005-07-08 John W. Eaton * DLD-FUNCTIONS/gplot.l (Fhold, Fishold): Delete. diff --git a/src/ov-fcn-inline.cc b/src/ov-fcn-inline.cc --- a/src/ov-fcn-inline.cc +++ b/src/ov-fcn-inline.cc @@ -810,13 +810,26 @@ if (nargin == 1) { - octave_fcn_inline* old = args(0).fcn_inline_value (true); + std::string old_func; + octave_fcn_inline* old = 0; + bool func_is_string = true; - if (old) + if (args(0).is_string ()) + old_func = args(0).string_value (); + else { - std::string old_func = old->fcn_text (); + old = args(0).fcn_inline_value (true); + func_is_string = false; + + if (old) + old_func = old->fcn_text (); + else + error ("vectorize: must be a string or inline function"); + } + + if (! error_state) + { std::string new_func; - size_t i = 0; while (i < old_func.length ()) @@ -840,10 +853,12 @@ i++; } - retval = octave_value (new octave_fcn_inline (new_func, old->fcn_arg_names ())); + if (func_is_string) + retval = octave_value (new_func); + else + retval = octave_value (new octave_fcn_inline + (new_func, old->fcn_arg_names ())); } - else - error ("vectorize: must be an inline function"); } else print_usage ("vectorize");