Mercurial > hg > octave-lyh
changeset 3611:b1ff6597576f
[project @ 2000-03-17 09:44:29 by jwe]
author | jwe |
---|---|
date | Fri, 17 Mar 2000 09:44:30 +0000 |
parents | 1222153daafb |
children | fcdf0897e705 |
files | src/ChangeLog src/Makefile.in src/oct-prcstrm.cc src/oct-stdstrm.cc src/oct-stdstrm.h src/pr-output.cc |
diffstat | 6 files changed, 59 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2000-03-17 John W. Eaton <jwe@bevo.che.wisc.edu> + + * c_file_ptr_stream.h, c_file_ptr_stream.cc: New files. + * oct-stdstrm.h, oct-stdstrm.cc, oct-prcstrm.cc: + Use c_file_ptr_buf, i_c_file_ptr_stream, and o_c_fie_ptr_stream + instead of stdiobuf, istdiostream, and ostdiostream. + + * pr-output.cc (set_real_format, set_real_matrix_format, + set_complex_format, set_complex_matrix_format, set_range_format): + Do the right thing again for int, NaN, and Inf values. + 2000-03-14 John W. Eaton <jwe@bevo.che.wisc.edu> * pr-output.cc (pr_plus_format): Rename from do_plus_format.
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -78,9 +78,9 @@ pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h INCLUDES := BaseSLList.h Cell.h DLList.h Map.h Pix.h SLList.h \ - SLStack.h Stack.h defun-dld.h defun-int.h defun.h \ - dirfns.h dynamic-ld.h error.h file-io.h fn-cache.h \ - gripes.h help.h input.h lex.h load-save.h \ + SLStack.h Stack.h c_file_ptr_stream.h defun-dld.h \ + defun-int.h defun.h dirfns.h dynamic-ld.h error.h file-io.h \ + fn-cache.h gripes.h help.h input.h lex.h load-save.h \ oct-fstrm.h oct-hist.h oct-iostrm.h oct-map.h oct-obj.h \ oct-prcstrm.h oct-procbuf.h oct-stdstrm.h oct-stream.h \ oct-strstrm.h oct-lvalue.h oct.h ops.h pager.h parse.h \ @@ -120,16 +120,16 @@ pt-select.cc pt-stmt.cc pt-unop.cc DIST_SRC := BaseSLList.cc Cell.cc DLList.cc Map.cc SLList.cc \ - SLStack.cc Stack.cc cutils.c data.cc defaults.cc defun.cc \ - dirfns.cc dynamic-ld.cc error.cc file-io.cc fn-cache.cc \ - gripes.cc help.cc input.cc lex.l load-save.cc mappers.cc \ - matherr.c oct-fstrm.cc oct-hist.cc oct-iostrm.cc oct-map.cc \ - oct-obj.cc oct-prcstrm.cc oct-procbuf.cc oct-stdstrm.cc \ - oct-stream.cc oct-strstrm.cc oct-lvalue.cc pager.cc parse.y \ - pr-output.cc procstream.cc sighandlers.cc siglist.c \ - strcasecmp.c strncase.c strfns.cc symtab.cc syscalls.cc \ - sysdep.cc system.c token.cc toplev.cc unwind-prot.cc \ - utils.cc variables.cc xdiv.cc xpow.cc \ + SLStack.cc Stack.cc c_file_ptr_stream.cc cutils.c data.cc \ + defaults.cc defun.cc dirfns.cc dynamic-ld.cc error.cc \ + file-io.cc fn-cache.cc gripes.cc help.cc input.cc lex.l \ + load-save.cc mappers.cc matherr.c oct-fstrm.cc oct-hist.cc \ + oct-iostrm.cc oct-map.cc oct-obj.cc oct-prcstrm.cc \ + oct-procbuf.cc oct-stdstrm.cc oct-stream.cc oct-strstrm.cc \ + oct-lvalue.cc pager.cc parse.y pr-output.cc procstream.cc \ + sighandlers.cc siglist.c strcasecmp.c strncase.c strfns.cc \ + symtab.cc syscalls.cc sysdep.cc system.c token.cc toplev.cc \ + unwind-prot.cc utils.cc variables.cc xdiv.cc xpow.cc \ $(OV_SRC) \ $(PT_SRC)
--- a/src/oct-prcstrm.cc +++ b/src/oct-prcstrm.cc @@ -45,7 +45,7 @@ if (fp) { delete is; - is = new std::istdiostream (fp); + is = new i_c_file_ptr_stream (fp); } } @@ -75,7 +75,7 @@ if (fp) { delete os; - os = new std::ostdiostream (fp); + os = new o_c_file_ptr_stream (fp); } }
--- a/src/oct-stdstrm.cc +++ b/src/oct-stdstrm.cc @@ -46,13 +46,13 @@ if (! bad ()) { - stdiobuf *sb = rdbuf (); + c_file_ptr_buf *sb = rdbuf (); if (sb) { clear (); - sb->seekoff (offset, origin); + sb->pubseekoff (offset, origin); retval = bad () ? -1 : 0; } } @@ -69,11 +69,11 @@ if (! bad ()) { - stdiobuf *sb = rdbuf (); + c_file_ptr_buf *sb = rdbuf (); if (sb) { - retval = static_cast<long> (sb->seekoff (0, ios::cur)); + retval = static_cast<long> (sb->pubseekoff (0, std::ios::cur)); if (bad ()) retval = -1; @@ -97,7 +97,7 @@ : octave_base_stdiostream (n, f, arg_md, flt_fmt), is (0) { if (f) - is = new std::istdiostream (f); + is = new i_c_file_ptr_stream (f); } octave_istdiostream::~octave_istdiostream (void) @@ -119,7 +119,7 @@ : octave_base_stdiostream (n, f, arg_md, flt_fmt), os (0) { if (f) - os = new std::ostdiostream (f); + os = new o_c_file_ptr_stream (f); } octave_ostdiostream::~octave_ostdiostream (void)
--- a/src/oct-stdstrm.h +++ b/src/oct-stdstrm.h @@ -23,9 +23,8 @@ #if !defined (octave_octave_stdiostream_h) #define octave_octave_stdiostream_h 1 -#include <stdiostream.h> - #include "oct-stream.h" +#include "c_file_ptr_stream.h" class octave_base_stdiostream : public octave_base_stream @@ -50,7 +49,7 @@ std::string name (void) const { return nm; } - virtual stdiobuf *rdbuf (void) const = 0; + virtual c_file_ptr_buf *rdbuf (void) const = 0; virtual bool bad (void) const = 0; @@ -95,8 +94,7 @@ std::ostream *output_stream (void) { return 0; } // XXX FIXME XXX -- should not have to cast away const here. - stdiobuf *rdbuf (void) const - { return is ? (const_cast<std::istdiostream *> (is))->rdbuf () : 0; } + c_file_ptr_buf *rdbuf (void) const { return is ? is->rdbuf () : 0; } bool bad (void) const { return is ? is->bad () : true; } @@ -108,7 +106,7 @@ protected: - std::istdiostream *is; + i_c_file_ptr_stream *is; ~octave_istdiostream (void); @@ -145,8 +143,8 @@ std::ostream *output_stream (void) { return os; } // XXX FIXME XXX -- should not have to cast away const here. - stdiobuf *rdbuf (void) const - { return os ? (const_cast<std::ostdiostream *> (os))->rdbuf () : 0; } + c_file_ptr_buf *rdbuf (void) const + { return os ? (const_cast<o_c_file_ptr_stream *> (os))->rdbuf () : 0; } bool bad (void) const { return os ? os->bad () : true; } @@ -158,7 +156,7 @@ protected: - std::ostdiostream *os; + o_c_file_ptr_stream *os; ~octave_ostdiostream (void);
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -247,7 +247,7 @@ // functions,.. static void -set_real_format (bool sign, int digits, bool inf_or_nan, bool nan_or_int, +set_real_format (bool sign, int digits, bool inf_or_nan, bool int_only, int &fw) { static float_format fmt; @@ -274,7 +274,7 @@ fw = 8 * sizeof (double); rd = 0; } - else if (nan_or_int) + else if (inf_or_nan || int_only) { fw = digits; if (inf_or_nan && fw < 3) @@ -320,6 +320,8 @@ if (print_big_e) fmt.uppercase (); } + else if (inf_or_nan || int_only) + fmt = float_format (fw, rd); else fmt = float_format (fw, rd, std::ios::fixed); @@ -339,14 +341,14 @@ bool inf_or_nan = (xisinf (d) || xisnan (d)); - bool nan_or_int = (xisnan (d) || D_NINT (d) == d); + bool int_only = (! inf_or_nan && D_NINT (d) == d); double d_abs = d < 0.0 ? -d : d; int digits = (inf_or_nan || d_abs == 0.0) ? 0 : static_cast<int> (floor (log10 (d_abs) + 1.0)); - set_real_format (sign, digits, inf_or_nan, nan_or_int, fw); + set_real_format (sign, digits, inf_or_nan, int_only, fw); } static inline void @@ -459,6 +461,8 @@ if (print_big_e) fmt.uppercase (); } + else if (int_or_inf_or_nan) + fmt = float_format (fw, rd); else fmt = float_format (fw, rd, std::ios::fixed); @@ -606,6 +610,11 @@ i_fmt.uppercase (); } } + else if (inf_or_nan || int_only) + { + r_fmt = float_format (r_fw, rd); + i_fmt = float_format (i_fw, rd); + } else { r_fmt = float_format (r_fw, rd, std::ios::fixed); @@ -779,6 +788,11 @@ i_fmt.uppercase (); } } + else if (int_or_inf_or_nan) + { + r_fmt = float_format (r_fw, rd); + i_fmt = float_format (i_fw, rd); + } else { r_fmt = float_format (r_fw, rd, std::ios::fixed); @@ -932,6 +946,8 @@ if (print_big_e) fmt.uppercase (); } + else if (all_ints) + fmt = float_format (fw, rd); else fmt = float_format (fw, rd, std::ios::fixed);