Mercurial > hg > octave-lyh
changeset 5409:fda074a55b5c
[project @ 2005-07-11 08:41:16 by dbateman]
author | dbateman |
---|---|
date | Mon, 11 Jul 2005 08:41:16 +0000 (2005-07-11) |
parents | 9461ff9278fb |
children | 56e066f5efc1 |
files | src/ChangeLog src/ov-fcn-inline.cc |
diffstat | 2 files changed, 26 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-07-11 David Bateman <dbateman@free.fr> + + * ov-fc-inline.cc (Fvectorize): Allow string arguments + 2005-07-08 John W. Eaton <jwe@octave.org> * DLD-FUNCTIONS/gplot.l (Fhold, Fishold): Delete.
--- 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");