Mercurial > octave-nkf
diff libinterp/corefcn/oct-stream.cc @ 17292:c5073ed27cdc
Handle '+' format modifier in sprintf (bug #39773)
* libinterp/corefcn/oct-stream.cc: Print '+' character even for
Inf and NaN when '+' format specified.
* scripts/general/num2str.m: Handle Inf values correctly when
generating format for sprintf. Add new %!tests.
* test/io.tst: Add %! tests for sprintf behavior. Use Octave coding
conventions on rest of file.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 20 Aug 2013 11:06:20 -0700 |
parents | 68fc671a9339 |
children | 3856298f1ff8 |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Tue Aug 20 19:11:17 2013 +0200 +++ b/libinterp/corefcn/oct-stream.cc Tue Aug 20 11:06:20 2013 -0700 @@ -2544,9 +2544,17 @@ nsa--; } - const char *tval = xisinf (val) - ? (val < 0 ? "-Inf" : "Inf") - : (lo_ieee_is_NA (val) ? "NA" : "NaN"); + const char *tval; + if (xisinf (val)) + if (elt->flags.find ('+') != std::string::npos) + tval = (val < 0 ? "-Inf" : "+Inf"); + else + tval = (val < 0 ? "-Inf" : "Inf"); + else + if (elt->flags.find ('+') != std::string::npos) + tval = (lo_ieee_is_NA (val) ? "+NA" : "+NaN"); + else + tval = (lo_ieee_is_NA (val) ? "NA" : "NaN"); retval += do_printf_conv (os, tfmt.c_str (), nsa, sa_1, sa_2,