Mercurial > octave
changeset 19727:3c3b9fce7d2b
improve compatibility of sprintf function.
* file-io.cc (Fsprintf): Return 1x0 empty string if no conversion
occurs.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Feb 2015 00:42:25 -0500 |
parents | 94cc1bdaf884 |
children | 928ecc95f395 |
files | libinterp/corefcn/file-io.cc |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Mon Feb 16 18:42:00 2015 -0800 +++ b/libinterp/corefcn/file-io.cc Tue Feb 17 00:42:25 2015 -0500 @@ -1096,8 +1096,13 @@ retval(2) = os.printf (fmt_arg, tmp_args, who); retval(1) = os.error (); - retval(0) = octave_value (ostr->str (), - fmt_arg.is_sq_string () ? '\'' : '"'); + + std::string result = ostr->str (); + char type = fmt_arg.is_sq_string () ? '\'' : '"'; + + retval(0) = (result.empty () + ? octave_value (charMatrix (1, 0), type) + : octave_value (result, type)); } else ::error ("%s: format TEMPLATE must be a string", who.c_str ());