Mercurial > hg > octave-terminal
changeset 13135:af36cdb552a6
char: return empty string if called with no arguments
* strfns.cc (Fchar): return empty string if called with no arguments.
Update tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 14 Sep 2011 13:50:33 -0400 |
parents | e255f8c3c2ff |
children | 79b9a7669bb8 |
files | src/strfns.cc |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -80,10 +80,12 @@ int nargin = args.length (); - if (nargin == 1) + if (nargin == 0) + retval = ""; + else if (nargin == 1) retval = args(0).convert_to_str (true, true, args(0).is_dq_string () ? '"' : '\''); - else if (nargin > 1) + else { int n_elts = 0; @@ -144,14 +146,12 @@ retval = octave_value (result, '\''); } - else - print_usage (); return retval; } /* -%!error <Invalid call to char> char() +%!assert (char (), ''); %!assert (char (100) == "d"); %!assert (all(char (100,100) == ["d";"d"])); %!assert (all(char ({100,100}) == ["d";"d"]));