Mercurial > hg > octave-nkf
diff src/pr-output.cc @ 3013:66a1cede95e7
[project @ 1997-06-02 19:35:05 by jwe]
author | jwe |
---|---|
date | Mon, 02 Jun 1997 19:41:17 +0000 |
parents | 66ef74ee5d9f |
children | 38de16594cb4 |
line wrap: on
line diff
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -30,6 +30,7 @@ #include <string> +#include <iomanip.h> #include <iostream.h> #include <strstream.h> @@ -882,7 +883,7 @@ stmp[6] = (ctmp & 0x02) ? '1' : '0'; \ stmp[7] = (ctmp & 0x01) ? '1' : '0'; \ stmp[8] = '\0'; \ - os.form ("%s", stmp); \ + os << stmp; \ } \ while (0) @@ -900,7 +901,7 @@ stmp[6] = (ctmp & 0x40) ? '1' : '0'; \ stmp[7] = (ctmp & 0x80) ? '1' : '0'; \ stmp[8] = '\0'; \ - os.form ("%s", stmp); \ + os << stmp; \ } \ while (0) @@ -929,22 +930,34 @@ // XXX FIXME XXX -- is it correct to swap bytes for VAX // formats and not for Cray? + // XXX FIXME XXX -- will bad things happen if we are + // interrupted before resetting the format flags and fill + // character? + oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format (); + char ofill = os.fill ('0'); + + ios::fmtflags oflags = os.setf (ios::right); + os.setf (ios::hex, ios::basefield); + if (hex_format > 1 || flt_fmt == oct_mach_info::ieee_big_endian || flt_fmt == oct_mach_info::cray || flt_fmt == oct_mach_info::unknown) { for (size_t i = 0; i < sizeof (double); i++) - os.form ("%02x", static_cast<int> (tmp.i[i])); + os << setw (2) << static_cast<int> (tmp.i[i]); } else { for (int i = sizeof (double) - 1; i >= 0; i--) - os.form ("%02x", static_cast<int> (tmp.i[i])); + os << setw (2) << static_cast<int> (tmp.i[i]); } + + os.fill (ofill); + os.setf (oflags); } else if (bit_format) { @@ -990,14 +1003,14 @@ s = "Inf"; if (fw > 0) - os.form ("%*s", fw, s); + os << setw (fw) << s; else os << s; } else if (xisnan (d)) { if (fw > 0) - os.form ("%*s", fw, "NaN"); + os << setw (fw) << "NaN"; else os << "NaN"; } @@ -1078,7 +1091,7 @@ int num_cols = lim - col; - os.form ("%*s", extra_indent, ""); + os << setw (extra_indent) << ""; if (num_cols == 1) os << " Column " << col + 1 << ":\n"; @@ -1226,7 +1239,7 @@ for (int i = 0; i < nr; i++) { - os.form ("%*s", extra_indent, ""); + os << setw (extra_indent) << ""; for (int j = col; j < lim; j++) { @@ -1379,7 +1392,7 @@ for (int i = 0; i < nr; i++) { - os.form ("%*s", extra_indent, ""); + os << setw (extra_indent) << ""; for (int j = col; j < lim; j++) { @@ -1476,7 +1489,7 @@ pr_col_num_header (os, total_width, max_width, lim, col, extra_indent); - os.form ("%*s", extra_indent, ""); + os << setw (extra_indent) << ""; for (int i = col; i < lim; i++) {