Mercurial > hg > octave-nkf
diff src/pr-output.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | cd96d29c5efa |
children | 12884915a8e4 |
line wrap: on
line diff
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -139,7 +139,7 @@ public: float_format (int w = current_output_max_field_width (), - int p = current_output_precision (), int f = 0) + int p = current_output_precision (), int f = 0) : fw (w), prec (p), fmt (f), up (0), sp (0) { } float_format (const float_format& ff) @@ -148,13 +148,13 @@ float_format& operator = (const float_format& ff) { if (&ff != this) - { - fw = ff.fw; - prec = ff.prec; - fmt = ff.fmt; - up = ff.up; - sp = ff.sp; - } + { + fw = ff.fw; + prec = ff.prec; + fmt = ff.fmt; + up = ff.up; + sp = ff.sp; + } return *this; } @@ -176,10 +176,10 @@ { sp = tz ? std::ios::showpoint : 0; return *this; } friend std::ostream& operator << (std::ostream& os, - const pr_formatted_float& pff); + const pr_formatted_float& pff); friend std::ostream& operator << (std::ostream& os, - const pr_rational_float& pff); + const pr_rational_float& pff); private: @@ -266,57 +266,57 @@ s = buf2.str(); while (1) - { - double flip = 1. / frac; - double step = xround (flip); - double nextn = n; - double nextd = d; - - // Have we converged to 1/intmax ? - if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) - { - lastn = n; - lastd = d; - break; - } - - frac = flip - step; - n = n * step + lastn; - d = d * step + lastd; - lastn = nextn; - lastd = nextd; - - std::ostringstream buf; - buf.flags (std::ios::fixed); - buf << std::setprecision (0) << static_cast<int>(n) - << "/" << static_cast<int>(d); - m++; - - if (n < 0 && d < 0) - { - // Double negative, string can be two characters longer.. - if (buf.str().length() > static_cast<unsigned int>(len + 2) && - m > 1) - break; - } - else if (buf.str().length() > static_cast<unsigned int>(len) && - m > 1) - break; - - s = buf.str(); - } + { + double flip = 1. / frac; + double step = xround (flip); + double nextn = n; + double nextd = d; + + // Have we converged to 1/intmax ? + if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) + { + lastn = n; + lastd = d; + break; + } + + frac = flip - step; + n = n * step + lastn; + d = d * step + lastd; + lastn = nextn; + lastd = nextd; + + std::ostringstream buf; + buf.flags (std::ios::fixed); + buf << std::setprecision (0) << static_cast<int>(n) + << "/" << static_cast<int>(d); + m++; + + if (n < 0 && d < 0) + { + // Double negative, string can be two characters longer.. + if (buf.str().length() > static_cast<unsigned int>(len + 2) && + m > 1) + break; + } + else if (buf.str().length() > static_cast<unsigned int>(len) && + m > 1) + break; + + s = buf.str(); + } if (lastd < 0.) - { - // Move sign to the top - lastd = - lastd; - lastn = - lastn; - std::ostringstream buf; - buf.flags (std::ios::fixed); - buf << std::setprecision (0) << static_cast<int>(lastn) - << "/" << static_cast<int>(lastd); - s = buf.str(); - } + { + // Move sign to the top + lastd = - lastd; + lastn = - lastn; + std::ostringstream buf; + buf.flags (std::ios::fixed); + buf << std::setprecision (0) << static_cast<int>(lastn) + << "/" << static_cast<int>(lastd); + s = buf.str(); + } } return s; @@ -378,14 +378,14 @@ for (octave_idx_type j = 0; j < nc; j++) for (octave_idx_type i = 0; i < nr; i++) { - double val = m(i,j); - if (xisinf (val) || xisnan (val)) - continue; - - all_inf_or_nan = false; - - if (val > result) - result = val; + double val = m(i,j); + if (xisinf (val) || xisnan (val)) + continue; + + all_inf_or_nan = false; + + if (val > result) + result = val; } if (all_inf_or_nan) @@ -407,14 +407,14 @@ for (octave_idx_type j = 0; j < nc; j++) for (octave_idx_type i = 0; i < nr; i++) { - double val = m(i,j); - if (xisinf (val) || xisnan (val)) - continue; - - all_inf_or_nan = false; - - if (val < result) - result = val; + double val = m(i,j); + if (xisinf (val) || xisnan (val)) + continue; + + all_inf_or_nan = false; + + if (val < result) + result = val; } if (all_inf_or_nan) @@ -444,7 +444,7 @@ { fw = digits < 0 ? 4 : digits + 3; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; rd = 2; } else if (hex_format) @@ -461,49 +461,49 @@ { fw = 1 + digits; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; rd = fw; } else { if (digits > 0) - { - ld = digits; - rd = prec > digits ? prec - digits : prec; - digits++; - } + { + ld = digits; + rd = prec > digits ? prec - digits : prec; + digits++; + } else - { - ld = 1; - rd = prec > digits ? prec - digits : prec; - digits = -digits + 1; - } + { + ld = 1; + rd = prec > digits ? prec - digits : prec; + digits = -digits + 1; + } fw = 1 + ld + 1 + rd; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; } if (! (rat_format || bank_format || hex_format || bit_format) && (fw > Voutput_max_field_width || print_e || print_g)) { if (print_g) - fmt = float_format (); + fmt = float_format (); else - { - int exp_field = 4; - if (digits > 100) - exp_field++; - - fw = 2 + prec + exp_field; - if (inf_or_nan && fw < 4) - fw = 4; - - fmt = float_format (fw, prec - 1, std::ios::scientific); - } + { + int exp_field = 4; + if (digits > 100) + exp_field++; + + fw = 2 + prec + exp_field; + if (inf_or_nan && fw < 4) + fw = 4; + + fmt = float_format (fw, prec - 1, std::ios::scientific); + } if (print_big_e) - fmt.uppercase (); + fmt.uppercase (); } else if (! bank_format && (inf_or_nan || int_only)) fmt = float_format (fw, rd); @@ -543,7 +543,7 @@ static void set_real_matrix_format (int x_max, int x_min, bool inf_or_nan, - int int_or_inf_or_nan, int& fw) + int int_or_inf_or_nan, int& fw) { static float_format fmt; @@ -561,7 +561,7 @@ int digits = x_max > x_min ? x_max : x_min; fw = digits <= 0 ? 4 : digits + 3; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; rd = 2; } else if (hex_format) @@ -579,76 +579,76 @@ rd = prec; fw = rd + 2; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; } else if (int_or_inf_or_nan) { int digits = x_max > x_min ? x_max : x_min; fw = digits <= 0 ? 2 : digits + 1; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; rd = fw; } else { int ld_max, rd_max; if (x_max > 0) - { - ld_max = x_max; - rd_max = prec > x_max ? prec - x_max : prec; - x_max++; - } + { + ld_max = x_max; + rd_max = prec > x_max ? prec - x_max : prec; + x_max++; + } else - { - ld_max = 1; - rd_max = prec > x_max ? prec - x_max : prec; - x_max = -x_max + 1; - } + { + ld_max = 1; + rd_max = prec > x_max ? prec - x_max : prec; + x_max = -x_max + 1; + } int ld_min, rd_min; if (x_min > 0) - { - ld_min = x_min; - rd_min = prec > x_min ? prec - x_min : prec; - x_min++; - } + { + ld_min = x_min; + rd_min = prec > x_min ? prec - x_min : prec; + x_min++; + } else - { - ld_min = 1; - rd_min = prec > x_min ? prec - x_min : prec; - x_min = -x_min + 1; - } + { + ld_min = 1; + rd_min = prec > x_min ? prec - x_min : prec; + x_min = -x_min + 1; + } ld = ld_max > ld_min ? ld_max : ld_min; rd = rd_max > rd_min ? rd_max : rd_min; fw = 1 + ld + 1 + rd; if (inf_or_nan && fw < 4) - fw = 4; + fw = 4; } if (! (rat_format || bank_format || hex_format || bit_format) && (print_e - || print_g - || (! Vfixed_point_format && fw > Voutput_max_field_width))) + || print_g + || (! Vfixed_point_format && fw > Voutput_max_field_width))) { if (print_g) - fmt = float_format (); + fmt = float_format (); else - { - int exp_field = 4; - if (x_max > 100 || x_min > 100) - exp_field++; - - fw = 2 + prec + exp_field; - if (inf_or_nan && fw < 4) - fw = 4; - - fmt = float_format (fw, prec - 1, std::ios::scientific); - } + { + int exp_field = 4; + if (x_max > 100 || x_min > 100) + exp_field++; + + fw = 2 + prec + exp_field; + if (inf_or_nan && fw < 4) + fw = 4; + + fmt = float_format (fw, prec - 1, std::ios::scientific); + } if (print_big_e) - fmt.uppercase (); + fmt.uppercase (); } else if (! bank_format && int_or_inf_or_nan) fmt = float_format (fw, rd); @@ -696,7 +696,7 @@ static void set_complex_format (int x_max, int x_min, int r_x, bool inf_or_nan, - int int_only, int& r_fw, int& i_fw) + int int_only, int& r_fw, int& i_fw) { static float_format r_fmt; static float_format i_fmt; @@ -717,7 +717,7 @@ i_fw = 0; r_fw = digits <= 0 ? 4 : digits + 3; if (inf_or_nan && r_fw < 4) - r_fw = 4; + r_fw = 4; rd = 2; } else if (hex_format) @@ -738,41 +738,41 @@ i_fw = digits <= 0 ? 1 : digits; r_fw = i_fw + 1; if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } + { + i_fw = 3; + r_fw = 4; + } rd = r_fw; } else { int ld_max, rd_max; if (x_max > 0) - { - ld_max = x_max; - rd_max = prec > x_max ? prec - x_max : prec; - x_max++; - } + { + ld_max = x_max; + rd_max = prec > x_max ? prec - x_max : prec; + x_max++; + } else - { - ld_max = 1; - rd_max = prec > x_max ? prec - x_max : prec; - x_max = -x_max + 1; - } + { + ld_max = 1; + rd_max = prec > x_max ? prec - x_max : prec; + x_max = -x_max + 1; + } int ld_min, rd_min; if (x_min > 0) - { - ld_min = x_min; - rd_min = prec > x_min ? prec - x_min : prec; - x_min++; - } + { + ld_min = x_min; + rd_min = prec > x_min ? prec - x_min : prec; + x_min++; + } else - { - ld_min = 1; - rd_min = prec > x_min ? prec - x_min : prec; - x_min = -x_min + 1; - } + { + ld_min = 1; + rd_min = prec > x_min ? prec - x_min : prec; + x_min = -x_min + 1; + } ld = ld_max > ld_min ? ld_max : ld_min; rd = rd_max > rd_min ? rd_max : rd_min; @@ -780,43 +780,43 @@ i_fw = ld + 1 + rd; r_fw = i_fw + 1; if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } + { + i_fw = 3; + r_fw = 4; + } } if (! (rat_format || bank_format || hex_format || bit_format) && (r_fw > Voutput_max_field_width || print_e || print_g)) { if (print_g) - { - r_fmt = float_format (); - i_fmt = float_format (); - } + { + r_fmt = float_format (); + i_fmt = float_format (); + } else - { - int exp_field = 4; - if (x_max > 100 || x_min > 100) - exp_field++; - - i_fw = prec + exp_field; - r_fw = i_fw + 1; - if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } - - r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); - i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); - } + { + int exp_field = 4; + if (x_max > 100 || x_min > 100) + exp_field++; + + i_fw = prec + exp_field; + r_fw = i_fw + 1; + if (inf_or_nan && i_fw < 3) + { + i_fw = 3; + r_fw = 4; + } + + r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); + i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); + } if (print_big_e) - { - r_fmt.uppercase (); - i_fmt.uppercase (); - } + { + r_fmt.uppercase (); + i_fmt.uppercase (); + } } else if (! bank_format && (inf_or_nan || int_only)) { @@ -883,8 +883,8 @@ static void set_complex_matrix_format (int x_max, int x_min, int r_x_max, - int r_x_min, bool inf_or_nan, - int int_or_inf_or_nan, int& r_fw, int& i_fw) + int r_x_min, bool inf_or_nan, + int int_or_inf_or_nan, int& r_fw, int& i_fw) { static float_format r_fmt; static float_format i_fmt; @@ -905,7 +905,7 @@ i_fw = 0; r_fw = digits <= 0 ? 4 : digits + 3; if (inf_or_nan && r_fw < 4) - r_fw = 4; + r_fw = 4; rd = 2; } else if (hex_format) @@ -926,10 +926,10 @@ i_fw = rd + 1; r_fw = i_fw + 1; if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } + { + i_fw = 3; + r_fw = 4; + } } else if (int_or_inf_or_nan) { @@ -937,41 +937,41 @@ i_fw = digits <= 0 ? 1 : digits; r_fw = i_fw + 1; if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } + { + i_fw = 3; + r_fw = 4; + } rd = r_fw; } else { int ld_max, rd_max; if (x_max > 0) - { - ld_max = x_max; - rd_max = prec > x_max ? prec - x_max : prec; - x_max++; - } + { + ld_max = x_max; + rd_max = prec > x_max ? prec - x_max : prec; + x_max++; + } else - { - ld_max = 1; - rd_max = prec > x_max ? prec - x_max : prec; - x_max = -x_max + 1; - } + { + ld_max = 1; + rd_max = prec > x_max ? prec - x_max : prec; + x_max = -x_max + 1; + } int ld_min, rd_min; if (x_min > 0) - { - ld_min = x_min; - rd_min = prec > x_min ? prec - x_min : prec; - x_min++; - } + { + ld_min = x_min; + rd_min = prec > x_min ? prec - x_min : prec; + x_min++; + } else - { - ld_min = 1; - rd_min = prec > x_min ? prec - x_min : prec; - x_min = -x_min + 1; - } + { + ld_min = 1; + rd_min = prec > x_min ? prec - x_min : prec; + x_min = -x_min + 1; + } ld = ld_max > ld_min ? ld_max : ld_min; rd = rd_max > rd_min ? rd_max : rd_min; @@ -979,45 +979,45 @@ i_fw = ld + 1 + rd; r_fw = i_fw + 1; if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } + { + i_fw = 3; + r_fw = 4; + } } if (! (rat_format || bank_format || hex_format || bit_format) && (print_e - || print_g - || (! Vfixed_point_format && r_fw > Voutput_max_field_width))) + || print_g + || (! Vfixed_point_format && r_fw > Voutput_max_field_width))) { if (print_g) - { - r_fmt = float_format (); - i_fmt = float_format (); - } + { + r_fmt = float_format (); + i_fmt = float_format (); + } else - { - int exp_field = 4; - if (x_max > 100 || x_min > 100) - exp_field++; - - i_fw = prec + exp_field; - r_fw = i_fw + 1; - if (inf_or_nan && i_fw < 3) - { - i_fw = 3; - r_fw = 4; - } - - r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); - i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); - } + { + int exp_field = 4; + if (x_max > 100 || x_min > 100) + exp_field++; + + i_fw = prec + exp_field; + r_fw = i_fw + 1; + if (inf_or_nan && i_fw < 3) + { + i_fw = 3; + r_fw = 4; + } + + r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); + i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); + } if (print_big_e) - { - r_fmt.uppercase (); - i_fmt.uppercase (); - } + { + r_fmt.uppercase (); + i_fmt.uppercase (); + } } else if (! bank_format && int_or_inf_or_nan) { @@ -1049,7 +1049,7 @@ bool inf_or_nan = cm.any_element_is_inf_or_nan (); bool int_or_inf_or_nan = (rp.all_elements_are_int_or_inf_or_nan () - && ip.all_elements_are_int_or_inf_or_nan ()); + && ip.all_elements_are_int_or_inf_or_nan ()); Matrix r_m_abs = rp.abs (); double r_max_abs = pr_max_internal (r_m_abs); @@ -1077,7 +1077,7 @@ scale = (x_max == 0 || int_or_inf_or_nan) ? 1.0 : std::pow (10.0, x_max - 1); set_complex_matrix_format (x_max, x_min, r_x_max, r_x_min, inf_or_nan, - int_or_inf_or_nan, r_fw, i_fw); + int_or_inf_or_nan, r_fw, i_fw); } static inline void @@ -1133,31 +1133,31 @@ { int ld_max, rd_max; if (x_max > 0) - { - ld_max = x_max; - rd_max = prec > x_max ? prec - x_max : prec; - x_max++; - } + { + ld_max = x_max; + rd_max = prec > x_max ? prec - x_max : prec; + x_max++; + } else - { - ld_max = 1; - rd_max = prec > x_max ? prec - x_max : prec; - x_max = -x_max + 1; - } + { + ld_max = 1; + rd_max = prec > x_max ? prec - x_max : prec; + x_max = -x_max + 1; + } int ld_min, rd_min; if (x_min > 0) - { - ld_min = x_min; - rd_min = prec > x_min ? prec - x_min : prec; - x_min++; - } + { + ld_min = x_min; + rd_min = prec > x_min ? prec - x_min : prec; + x_min++; + } else - { - ld_min = 1; - rd_min = prec > x_min ? prec - x_min : prec; - x_min = -x_min + 1; - } + { + ld_min = 1; + rd_min = prec > x_min ? prec - x_min : prec; + x_min = -x_min + 1; + } ld = ld_max > ld_min ? ld_max : ld_min; rd = rd_max > rd_min ? rd_max : rd_min; @@ -1167,24 +1167,24 @@ if (! (rat_format || bank_format || hex_format || bit_format) && (print_e - || print_g - || (! Vfixed_point_format && fw > Voutput_max_field_width))) + || print_g + || (! Vfixed_point_format && fw > Voutput_max_field_width))) { if (print_g) - fmt = float_format (); + fmt = float_format (); else - { - int exp_field = 4; - if (x_max > 100 || x_min > 100) - exp_field++; - - fw = 3 + prec + exp_field; - - fmt = float_format (fw, prec - 1, std::ios::scientific); - } + { + int exp_field = 4; + if (x_max > 100 || x_min > 100) + exp_field++; + + fw = 3 + prec + exp_field; + + fmt = float_format (fw, prec - 1, std::ios::scientific); + } if (print_big_e) - fmt.uppercase (); + fmt.uppercase (); } else if (! bank_format && all_ints) fmt = float_format (fw, rd); @@ -1291,108 +1291,108 @@ // {bit,hex}_format == 2: print native if (hex_format) - { - equiv tmp; - tmp.d = d; - - // Unless explicitly asked for, always print in big-endian - // format. - - // FIXME -- is it correct to swap bytes for VAX - // formats and not for Cray? - - // FIXME -- 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'); - - std::ios::fmtflags oflags - = os.flags (std::ios::right | std::ios::hex); - - if (hex_format > 1 - || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian - || flt_fmt == oct_mach_info::flt_fmt_cray - || flt_fmt == oct_mach_info::flt_fmt_unknown) - { - for (size_t i = 0; i < sizeof (double); i++) - os << std::setw (2) << static_cast<int> (tmp.i[i]); - } - else - { - for (int i = sizeof (double) - 1; i >= 0; i--) - os << std::setw (2) << static_cast<int> (tmp.i[i]); - } - - os.fill (ofill); - os.setf (oflags); - } + { + equiv tmp; + tmp.d = d; + + // Unless explicitly asked for, always print in big-endian + // format. + + // FIXME -- is it correct to swap bytes for VAX + // formats and not for Cray? + + // FIXME -- 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'); + + std::ios::fmtflags oflags + = os.flags (std::ios::right | std::ios::hex); + + if (hex_format > 1 + || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian + || flt_fmt == oct_mach_info::flt_fmt_cray + || flt_fmt == oct_mach_info::flt_fmt_unknown) + { + for (size_t i = 0; i < sizeof (double); i++) + os << std::setw (2) << static_cast<int> (tmp.i[i]); + } + else + { + for (int i = sizeof (double) - 1; i >= 0; i--) + os << std::setw (2) << static_cast<int> (tmp.i[i]); + } + + os.fill (ofill); + os.setf (oflags); + } else if (bit_format) - { - equiv tmp; - tmp.d = d; - - // FIXME -- is it correct to swap bytes for VAX - // formats and not for Cray? - - oct_mach_info::float_format flt_fmt = - oct_mach_info::native_float_format (); - - if (flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian - || flt_fmt == oct_mach_info::flt_fmt_cray - || flt_fmt == oct_mach_info::flt_fmt_unknown) - { - for (size_t i = 0; i < sizeof (double); i++) - PRINT_CHAR_BITS (os, tmp.i[i]); - } - else - { - if (bit_format > 1) - { - for (size_t i = 0; i < sizeof (double); i++) - PRINT_CHAR_BITS_SWAPPED (os, tmp.i[i]); - } - else - { - for (int i = sizeof (double) - 1; i >= 0; i--) - PRINT_CHAR_BITS (os, tmp.i[i]); - } - } - } + { + equiv tmp; + tmp.d = d; + + // FIXME -- is it correct to swap bytes for VAX + // formats and not for Cray? + + oct_mach_info::float_format flt_fmt = + oct_mach_info::native_float_format (); + + if (flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian + || flt_fmt == oct_mach_info::flt_fmt_cray + || flt_fmt == oct_mach_info::flt_fmt_unknown) + { + for (size_t i = 0; i < sizeof (double); i++) + PRINT_CHAR_BITS (os, tmp.i[i]); + } + else + { + if (bit_format > 1) + { + for (size_t i = 0; i < sizeof (double); i++) + PRINT_CHAR_BITS_SWAPPED (os, tmp.i[i]); + } + else + { + for (int i = sizeof (double) - 1; i >= 0; i--) + PRINT_CHAR_BITS (os, tmp.i[i]); + } + } + } else if (octave_is_NA (d)) - { - if (fw > 0) - os << std::setw (fw) << "NA"; - else - os << "NA"; - } + { + if (fw > 0) + os << std::setw (fw) << "NA"; + else + os << "NA"; + } else if (rat_format) - os << pr_rational_float (*fmt, d); + os << pr_rational_float (*fmt, d); else if (xisinf (d)) - { - const char *s; - if (d < 0.0) - s = "-Inf"; - else - s = "Inf"; - - if (fw > 0) - os << std::setw (fw) << s; - else - os << s; - } + { + const char *s; + if (d < 0.0) + s = "-Inf"; + else + s = "Inf"; + + if (fw > 0) + os << std::setw (fw) << s; + else + os << s; + } else if (xisnan (d)) - { - if (fw > 0) - os << std::setw (fw) << "NaN"; - else - os << "NaN"; - } + { + if (fw > 0) + os << std::setw (fw) << "NaN"; + else + os << "NaN"; + } else - os << pr_formatted_float (*fmt, d); + os << pr_formatted_float (*fmt, d); } else os << d; @@ -1415,7 +1415,7 @@ static void pr_complex (std::ostream& os, const Complex& c, int r_fw = 0, - int i_fw = 0, double scale = 1.0) + int i_fw = 0, double scale = 1.0) { Complex tmp = (Vfixed_point_format && ! print_g && scale != 1.0) ? c / scale : c; @@ -1428,20 +1428,20 @@ { double i = tmp.imag (); if (! (hex_format || bit_format) && lo_ieee_signbit (i)) - { - os << " - "; - i = -i; - pr_imag_float (os, i, i_fw); - } + { + os << " - "; + i = -i; + pr_imag_float (os, i, i_fw); + } else - { - if (hex_format || bit_format) - os << " "; - else - os << " + "; - - pr_imag_float (os, i, i_fw); - } + { + if (hex_format || bit_format) + os << " "; + else + os << " + "; + + pr_imag_float (os, i, i_fw); + } os << "i"; } } @@ -1454,22 +1454,22 @@ if (pr_as_read_syntax) { if (nr == 0 && nc == 0) - os << "[]"; + os << "[]"; else - os << "zeros (" << nr << ", " << nc << ")"; + os << "zeros (" << nr << ", " << nc << ")"; } else { os << "[]"; if (Vprint_empty_dimensions) - os << "(" << nr << "x" << nc << ")"; + os << "(" << nr << "x" << nc << ")"; } } static void print_empty_nd_array (std::ostream& os, const dim_vector& dims, - bool pr_as_read_syntax) + bool pr_as_read_syntax) { assert (dims.any_zero ()); @@ -1480,7 +1480,7 @@ os << "[]"; if (Vprint_empty_dimensions) - os << "(" << dims.str () << ")"; + os << "(" << dims.str () << ")"; } } @@ -1490,44 +1490,44 @@ if (Vfixed_point_format && ! print_g && scale != 1.0) { os << " " - << std::setw (8) << std::setprecision (1) - << std::setiosflags (std::ios::scientific|std::ios::left) - << scale - << std::resetiosflags (std::ios::scientific|std::ios::left) - << " *\n"; + << std::setw (8) << std::setprecision (1) + << std::setiosflags (std::ios::scientific|std::ios::left) + << scale + << std::resetiosflags (std::ios::scientific|std::ios::left) + << " *\n"; if (! compact_format) - os << "\n"; + os << "\n"; } } static void pr_col_num_header (std::ostream& os, octave_idx_type total_width, int max_width, - octave_idx_type lim, octave_idx_type col, int extra_indent) + octave_idx_type lim, octave_idx_type col, int extra_indent) { if (total_width > max_width && Vsplit_long_rows) { if (col != 0) - { - if (compact_format) - os << "\n"; - else - os << "\n\n"; - } + { + if (compact_format) + os << "\n"; + else + os << "\n\n"; + } octave_idx_type num_cols = lim - col; os << std::setw (extra_indent) << ""; if (num_cols == 1) - os << " Column " << col + 1 << ":\n"; + os << " Column " << col + 1 << ":\n"; else if (num_cols == 2) - os << " Columns " << col + 1 << " and " << lim << ":\n"; + os << " Columns " << col + 1 << " and " << lim << ":\n"; else - os << " Columns " << col + 1 << " through " << lim << ":\n"; + os << " Columns " << col + 1 << " through " << lim << ":\n"; if (! compact_format) - os << "\n"; + os << "\n"; } } @@ -1545,7 +1545,7 @@ void octave_print_internal (std::ostream& os, double d, - bool /* pr_as_read_syntax */) + bool /* pr_as_read_syntax */) { if (plus_format) { @@ -1555,15 +1555,15 @@ { set_format (d); if (free_format) - os << d; + os << d; else - pr_float (os, d); + pr_float (os, d); } } void octave_print_internal (std::ostream& os, const Matrix& m, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); @@ -1573,17 +1573,17 @@ else if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < nr; i++) - { - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); - - pr_plus_format (os, m(i,j)); - } - - if (i < nr - 1) - os << "\n"; - } + { + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + + pr_plus_format (os, m(i,j)); + } + + if (i < nr - 1) + os << "\n"; + } } else { @@ -1595,109 +1595,109 @@ octave_idx_type max_width = command_editor::terminal_cols (); if (pr_as_read_syntax) - max_width -= 4; + max_width -= 4; else - max_width -= extra_indent; + max_width -= extra_indent; if (max_width < 0) - max_width = 0; + max_width = 0; if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - os << m; - - if (pr_as_read_syntax) - os << "]"; - - return; - } + { + if (pr_as_read_syntax) + os << "[\n"; + + os << m; + + if (pr_as_read_syntax) + os << "]"; + + return; + } octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } if (pr_as_read_syntax) - { - for (octave_idx_type i = 0; i < nr; i++) - { - octave_idx_type col = 0; - while (col < nc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - if (i == 0 && j == 0) - os << "[ "; - else - { - if (j > col && j < lim) - os << ", "; - else - os << " "; - } - - pr_float (os, m(i,j)); - } - - col += inc; - - if (col >= nc) - { - if (i == nr - 1) - os << " ]"; - else - os << ";\n"; - } - else - os << " ...\n"; - } - } - } + { + for (octave_idx_type i = 0; i < nr; i++) + { + octave_idx_type col = 0; + while (col < nc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + if (i == 0 && j == 0) + os << "[ "; + else + { + if (j > col && j < lim) + os << ", "; + else + os << " "; + } + + pr_float (os, m(i,j)); + } + + col += inc; + + if (col >= nc) + { + if (i == nr - 1) + os << " ]"; + else + os << ";\n"; + } + else + os << " ...\n"; + } + } + } else - { - pr_scale_header (os, scale); - - for (octave_idx_type col = 0; col < nc; col += inc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type i = 0; i < nr; i++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - os << " "; - - pr_float (os, m(i,j), fw, scale); - } - - if (i < nr - 1) - os << "\n"; - } - } - } + { + pr_scale_header (os, scale); + + for (octave_idx_type col = 0; col < nc; col += inc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type i = 0; i < nr; i++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + os << " "; + + pr_float (os, m(i,j), fw, scale); + } + + if (i < nr - 1) + os << "\n"; + } + } + } } } void octave_print_internal (std::ostream& os, const DiagMatrix& m, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); @@ -1707,17 +1707,17 @@ else if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < nr; i++) - { - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); - - pr_plus_format (os, m(i,j)); - } - - if (i < nr - 1) - os << "\n"; - } + { + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + + pr_plus_format (os, m(i,j)); + } + + if (i < nr - 1) + os << "\n"; + } } else { @@ -1729,36 +1729,36 @@ octave_idx_type max_width = command_editor::terminal_cols (); if (pr_as_read_syntax) - max_width -= 4; + max_width -= 4; else - max_width -= extra_indent; + max_width -= extra_indent; if (max_width < 0) - max_width = 0; + max_width = 0; if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - os << Matrix (m); - - if (pr_as_read_syntax) - os << "]"; - - return; - } + { + if (pr_as_read_syntax) + os << "[\n"; + + os << Matrix (m); + + if (pr_as_read_syntax) + os << "]"; + + return; + } octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } if (pr_as_read_syntax) - { + { os << "diag ("; octave_idx_type col = 0; @@ -1791,11 +1791,11 @@ os << " ...\n"; } os << ")"; - } + } else - { + { os << "Diagonal Matrix\n\n"; - pr_scale_header (os, scale); + pr_scale_header (os, scale); // kluge. Get the true width of a number. int zero_fw; @@ -1806,35 +1806,35 @@ zero_fw = tmp_oss.str ().length (); } - for (octave_idx_type col = 0; col < nc; col += inc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type i = 0; i < nr; i++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - os << " "; + for (octave_idx_type col = 0; col < nc; col += inc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type i = 0; i < nr; i++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + os << " "; if (i == j) pr_float (os, m(i,j), fw, scale); else os << std::setw (zero_fw) << '0'; - } - - if (i < nr - 1) - os << "\n"; - } - } - } + } + + if (i < nr - 1) + os << "\n"; + } + } + } } } #define PRINT_ND_ARRAY(os, nda, NDA_T, ELT_T, MAT_T) \ @@ -1861,7 +1861,7 @@ \ for (octave_idx_type i = 0; i < m; i++) \ { \ - octave_quit (); \ + octave_quit (); \ \ std::string nm = "ans"; \ \ @@ -1869,7 +1869,7 @@ { \ nm += "(:,:,"; \ \ - std::ostringstream buf; \ + std::ostringstream buf; \ \ for (int k = 2; k < ndims; k++) \ { \ @@ -1906,14 +1906,14 @@ void octave_print_internal (std::ostream& os, const NDArray& nda, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { switch (nda.ndims ()) { case 1: case 2: octave_print_internal (os, nda.matrix_value (), - pr_as_read_syntax, extra_indent); + pr_as_read_syntax, extra_indent); break; default: @@ -1932,9 +1932,9 @@ if (rp == 0.0) { if (ip == 0.0) - os << " "; + os << " "; else - os << "i"; + os << "i"; } else if (ip == 0.0) pr_plus_format (os, rp); @@ -1944,7 +1944,7 @@ void octave_print_internal (std::ostream& os, const Complex& c, - bool /* pr_as_read_syntax */) + bool /* pr_as_read_syntax */) { if (plus_format) { @@ -1954,15 +1954,15 @@ { set_format (c); if (free_format) - os << c; + os << c; else - pr_complex (os, c); + pr_complex (os, c); } } void octave_print_internal (std::ostream& os, const ComplexMatrix& cm, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_idx_type nr = cm.rows (); octave_idx_type nc = cm.columns (); @@ -1972,17 +1972,17 @@ else if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < nr; i++) - { - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); - - pr_plus_format (os, cm(i,j)); - } - - if (i < nr - 1) - os << "\n"; - } + { + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + + pr_plus_format (os, cm(i,j)); + } + + if (i < nr - 1) + os << "\n"; + } } else { @@ -1991,114 +1991,114 @@ set_format (cm, r_fw, i_fw, scale); int column_width = i_fw + r_fw; column_width += (rat_format || bank_format || hex_format - || bit_format) ? 2 : 7; + || bit_format) ? 2 : 7; octave_idx_type total_width = nc * column_width; octave_idx_type max_width = command_editor::terminal_cols (); if (pr_as_read_syntax) - max_width -= 4; + max_width -= 4; else - max_width -= extra_indent; + max_width -= extra_indent; if (max_width < 0) - max_width = 0; + max_width = 0; if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - os << cm; - - if (pr_as_read_syntax) - os << "]"; - - return; - } + { + if (pr_as_read_syntax) + os << "[\n"; + + os << cm; + + if (pr_as_read_syntax) + os << "]"; + + return; + } octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } if (pr_as_read_syntax) - { - for (octave_idx_type i = 0; i < nr; i++) - { - octave_idx_type col = 0; - while (col < nc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - if (i == 0 && j == 0) - os << "[ "; - else - { - if (j > col && j < lim) - os << ", "; - else - os << " "; - } - - pr_complex (os, cm(i,j)); - } - - col += inc; - - if (col >= nc) - { - if (i == nr - 1) - os << " ]"; - else - os << ";\n"; - } - else - os << " ...\n"; - } - } - } + { + for (octave_idx_type i = 0; i < nr; i++) + { + octave_idx_type col = 0; + while (col < nc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + if (i == 0 && j == 0) + os << "[ "; + else + { + if (j > col && j < lim) + os << ", "; + else + os << " "; + } + + pr_complex (os, cm(i,j)); + } + + col += inc; + + if (col >= nc) + { + if (i == nr - 1) + os << " ]"; + else + os << ";\n"; + } + else + os << " ...\n"; + } + } + } else - { - pr_scale_header (os, scale); - - for (octave_idx_type col = 0; col < nc; col += inc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type i = 0; i < nr; i++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - os << " "; - - pr_complex (os, cm(i,j), r_fw, i_fw, scale); - } - - if (i < nr - 1) - os << "\n"; - } - } - } + { + pr_scale_header (os, scale); + + for (octave_idx_type col = 0; col < nc; col += inc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type i = 0; i < nr; i++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + os << " "; + + pr_complex (os, cm(i,j), r_fw, i_fw, scale); + } + + if (i < nr - 1) + os << "\n"; + } + } + } } } void octave_print_internal (std::ostream& os, const ComplexDiagMatrix& cm, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_idx_type nr = cm.rows (); octave_idx_type nc = cm.columns (); @@ -2108,17 +2108,17 @@ else if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < nr; i++) - { - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); - - pr_plus_format (os, cm(i,j)); - } - - if (i < nr - 1) - os << "\n"; - } + { + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + + pr_plus_format (os, cm(i,j)); + } + + if (i < nr - 1) + os << "\n"; + } } else { @@ -2127,41 +2127,41 @@ set_format (ComplexMatrix (cm.diag ()), r_fw, i_fw, scale); int column_width = i_fw + r_fw; column_width += (rat_format || bank_format || hex_format - || bit_format) ? 2 : 7; + || bit_format) ? 2 : 7; octave_idx_type total_width = nc * column_width; octave_idx_type max_width = command_editor::terminal_cols (); if (pr_as_read_syntax) - max_width -= 4; + max_width -= 4; else - max_width -= extra_indent; + max_width -= extra_indent; if (max_width < 0) - max_width = 0; + max_width = 0; if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - os << ComplexMatrix (cm); - - if (pr_as_read_syntax) - os << "]"; - - return; - } + { + if (pr_as_read_syntax) + os << "[\n"; + + os << ComplexMatrix (cm); + + if (pr_as_read_syntax) + os << "]"; + + return; + } octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } if (pr_as_read_syntax) - { + { os << "diag ("; octave_idx_type col = 0; @@ -2194,11 +2194,11 @@ os << " ...\n"; } os << ")"; - } + } else - { + { os << "Diagonal Matrix\n\n"; - pr_scale_header (os, scale); + pr_scale_header (os, scale); // kluge. Get the true width of a number. int zero_fw; @@ -2209,40 +2209,40 @@ zero_fw = tmp_oss.str ().length (); } - for (octave_idx_type col = 0; col < nc; col += inc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type i = 0; i < nr; i++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - os << " "; + for (octave_idx_type col = 0; col < nc; col += inc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type i = 0; i < nr; i++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + os << " "; if (i == j) pr_complex (os, cm(i,j), r_fw, i_fw, scale); else os << std::setw (zero_fw) << '0'; - } - - if (i < nr - 1) - os << "\n"; - } - } - } + } + + if (i < nr - 1) + os << "\n"; + } + } + } } } void octave_print_internal (std::ostream& os, const PermMatrix& m, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); @@ -2252,17 +2252,17 @@ else if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < nr; i++) - { - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); - - pr_plus_format (os, m(i,j)); - } - - if (i < nr - 1) - os << "\n"; - } + { + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); + + pr_plus_format (os, m(i,j)); + } + + if (i < nr - 1) + os << "\n"; + } } else { @@ -2272,33 +2272,33 @@ octave_idx_type max_width = command_editor::terminal_cols (); if (pr_as_read_syntax) - max_width -= 4; + max_width -= 4; else - max_width -= extra_indent; + max_width -= extra_indent; if (max_width < 0) - max_width = 0; + max_width = 0; if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - os << Matrix (m); - - if (pr_as_read_syntax) - os << "]"; - - return; - } + { + if (pr_as_read_syntax) + os << "[\n"; + + os << Matrix (m); + + if (pr_as_read_syntax) + os << "]"; + + return; + } octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } if (pr_as_read_syntax) { @@ -2339,49 +2339,49 @@ } if (! colp) os << ", :"; os << ")"; - } + } else - { + { os << "Permutation Matrix\n\n"; - for (octave_idx_type col = 0; col < nc; col += inc) - { - octave_idx_type lim = col + inc < nc ? col + inc : nc; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type i = 0; i < nr; i++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type j = col; j < lim; j++) - { - octave_quit (); - - os << " "; + for (octave_idx_type col = 0; col < nc; col += inc) + { + octave_idx_type lim = col + inc < nc ? col + inc : nc; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type i = 0; i < nr; i++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type j = col; j < lim; j++) + { + octave_quit (); + + os << " "; os << std::setw (fw) << m(i,j); - } - - if (i < nr - 1) - os << "\n"; - } - } - } + } + + if (i < nr - 1) + os << "\n"; + } + } + } } } void octave_print_internal (std::ostream& os, const ComplexNDArray& nda, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { switch (nda.ndims ()) { case 1: case 2: octave_print_internal (os, nda.matrix_value (), - pr_as_read_syntax, extra_indent); + pr_as_read_syntax, extra_indent); break; default: @@ -2406,56 +2406,56 @@ void octave_print_internal (std::ostream& os, const FloatMatrix& m, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, Matrix (m), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const FloatDiagMatrix& m, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, DiagMatrix (m), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const FloatNDArray& nda, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, NDArray (nda), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const FloatComplex& c, - bool pr_as_read_syntax) + bool pr_as_read_syntax) { octave_print_internal (os, Complex (c), pr_as_read_syntax); } void octave_print_internal (std::ostream& os, const FloatComplexMatrix& cm, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, ComplexMatrix (cm), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const FloatComplexDiagMatrix& cm, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, ComplexDiagMatrix (cm), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const FloatComplexNDArray& nda, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { octave_print_internal (os, ComplexNDArray (nda), pr_as_read_syntax, extra_indent); } void octave_print_internal (std::ostream& os, const Range& r, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { double base = r.base (); double increment = r.inc (); @@ -2465,13 +2465,13 @@ if (plus_format && ! pr_as_read_syntax) { for (octave_idx_type i = 0; i < num_elem; i++) - { - octave_quit (); - - double val = base + i * increment; - - pr_plus_format (os, val); - } + { + octave_quit (); + + double val = base + i * increment; + + pr_plus_format (os, val); + } } else { @@ -2480,93 +2480,93 @@ set_format (r, fw, scale); if (pr_as_read_syntax) - { - if (free_format) - { - os << base << " : "; - if (increment != 1.0) - os << increment << " : "; - os << limit; - } - else - { - pr_float (os, base, fw); - os << " : "; - if (increment != 1.0) - { - pr_float (os, increment, fw); - os << " : "; - } - pr_float (os, limit, fw); - } - } + { + if (free_format) + { + os << base << " : "; + if (increment != 1.0) + os << increment << " : "; + os << limit; + } + else + { + pr_float (os, base, fw); + os << " : "; + if (increment != 1.0) + { + pr_float (os, increment, fw); + os << " : "; + } + pr_float (os, limit, fw); + } + } else - { - int column_width = fw + 2; - octave_idx_type total_width = num_elem * column_width; - octave_idx_type max_width = command_editor::terminal_cols (); - - if (free_format) - { - os << r; - return; - } - - octave_idx_type inc = num_elem; - if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } - - max_width -= extra_indent; - - if (max_width < 0) - max_width = 0; - - pr_scale_header (os, scale); - - octave_idx_type col = 0; - while (col < num_elem) - { - octave_idx_type lim = col + inc < num_elem ? col + inc : num_elem; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - os << std::setw (extra_indent) << ""; - - for (octave_idx_type i = col; i < lim; i++) - { - octave_quit (); - - double val = base + i * increment; - - if (i == num_elem - 1) - { - // See the comments in Range::matrix_value. - - if ((increment > 0 && val > limit) - || (increment < 0 && val < limit)) - val = limit; - } - - os << " "; - - pr_float (os, val, fw, scale); - } - - col += inc; - } - } + { + int column_width = fw + 2; + octave_idx_type total_width = num_elem * column_width; + octave_idx_type max_width = command_editor::terminal_cols (); + + if (free_format) + { + os << r; + return; + } + + octave_idx_type inc = num_elem; + if (total_width > max_width && Vsplit_long_rows) + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } + + max_width -= extra_indent; + + if (max_width < 0) + max_width = 0; + + pr_scale_header (os, scale); + + octave_idx_type col = 0; + while (col < num_elem) + { + octave_idx_type lim = col + inc < num_elem ? col + inc : num_elem; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + os << std::setw (extra_indent) << ""; + + for (octave_idx_type i = col; i < lim; i++) + { + octave_quit (); + + double val = base + i * increment; + + if (i == num_elem - 1) + { + // See the comments in Range::matrix_value. + + if ((increment > 0 && val > limit) + || (increment < 0 && val < limit)) + val = limit; + } + + os << " "; + + pr_float (os, val, fw, scale); + } + + col += inc; + } + } } } void octave_print_internal (std::ostream& os, const boolMatrix& bm, - bool pr_as_read_syntax, - int extra_indent) + bool pr_as_read_syntax, + int extra_indent) { Matrix tmp (bm); octave_print_internal (os, tmp, pr_as_read_syntax, extra_indent); @@ -2574,15 +2574,15 @@ void octave_print_internal (std::ostream& os, const boolNDArray& nda, - bool pr_as_read_syntax, - int extra_indent) + bool pr_as_read_syntax, + int extra_indent) { switch (nda.ndims ()) { case 1: case 2: octave_print_internal (os, nda.matrix_value (), - pr_as_read_syntax, extra_indent); + pr_as_read_syntax, extra_indent); break; default: @@ -2593,44 +2593,44 @@ void octave_print_internal (std::ostream& os, const charMatrix& chm, - bool pr_as_read_syntax, - int /* extra_indent FIXME */, - bool pr_as_string) + bool pr_as_read_syntax, + int /* extra_indent FIXME */, + bool pr_as_string) { if (pr_as_string) { octave_idx_type nstr = chm.rows (); if (pr_as_read_syntax && nstr > 1) - os << "[ "; + os << "[ "; if (nstr != 0) - { - for (octave_idx_type i = 0; i < nstr; i++) - { - octave_quit (); - - std::string row = chm.row_as_string (i); - - if (pr_as_read_syntax) - { - os << "\"" << undo_string_escapes (row) << "\""; - - if (i < nstr - 1) - os << "; "; - } - else - { - os << row; - - if (i < nstr - 1) - os << "\n"; - } - } - } + { + for (octave_idx_type i = 0; i < nstr; i++) + { + octave_quit (); + + std::string row = chm.row_as_string (i); + + if (pr_as_read_syntax) + { + os << "\"" << undo_string_escapes (row) << "\""; + + if (i < nstr - 1) + os << "; "; + } + else + { + os << row; + + if (i < nstr - 1) + os << "\n"; + } + } + } if (pr_as_read_syntax && nstr > 1) - os << " ]"; + os << " ]"; } else { @@ -2640,15 +2640,15 @@ void octave_print_internal (std::ostream& os, const charNDArray& nda, - bool pr_as_read_syntax, int extra_indent, - bool pr_as_string) + bool pr_as_read_syntax, int extra_indent, + bool pr_as_string) { switch (nda.ndims ()) { case 1: case 2: octave_print_internal (os, nda.matrix_value (), - pr_as_read_syntax, extra_indent, pr_as_string); + pr_as_read_syntax, extra_indent, pr_as_string); break; default: @@ -2659,7 +2659,7 @@ void octave_print_internal (std::ostream& os, const std::string& s, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { Array<std::string> nda (dim_vector (1, 1), s); @@ -2668,7 +2668,7 @@ void octave_print_internal (std::ostream& os, const Array<std::string>& nda, - bool pr_as_read_syntax, int /* extra_indent */) + bool pr_as_read_syntax, int /* extra_indent */) { // FIXME -- this mostly duplicates the code in the // PRINT_ND_ARRAY macro. @@ -2690,66 +2690,66 @@ octave_idx_type m = 1; for (int i = 2; i < ndims; i++) - m *= dims(i); + m *= dims(i); octave_idx_type nr = dims(0); octave_idx_type nc = dims(1); for (octave_idx_type i = 0; i < m; i++) - { - std::string nm = "ans"; - - if (m > 1) - { - nm += "(:,:,"; - - std::ostringstream buf; - - for (int k = 2; k < ndims; k++) - { - buf << ra_idx(k) + 1; - - if (k < ndims - 1) - buf << ","; - else - buf << ")"; - } - - nm += buf.str (); - } - - Array<idx_vector> idx (ndims); - - idx(0) = idx_vector (':'); - idx(1) = idx_vector (':'); - - for (int k = 2; k < ndims; k++) - idx(k) = idx_vector (ra_idx(k)); - - Array2<std::string> page (nda.index (idx), nr, nc); - - // FIXME -- need to do some more work to put these - // in neatly aligned columns... - - octave_idx_type n_rows = page.rows (); - octave_idx_type n_cols = page.cols (); - - os << nm << " =\n\n"; - - for (octave_idx_type ii = 0; ii < n_rows; ii++) - { - for (octave_idx_type jj = 0; jj < n_cols; jj++) - os << " " << page(ii,jj); - - os << "\n"; - } - - if (i < m - 1) - os << "\n"; - - if (i < m) - increment_index (ra_idx, dims, 2); - } + { + std::string nm = "ans"; + + if (m > 1) + { + nm += "(:,:,"; + + std::ostringstream buf; + + for (int k = 2; k < ndims; k++) + { + buf << ra_idx(k) + 1; + + if (k < ndims - 1) + buf << ","; + else + buf << ")"; + } + + nm += buf.str (); + } + + Array<idx_vector> idx (ndims); + + idx(0) = idx_vector (':'); + idx(1) = idx_vector (':'); + + for (int k = 2; k < ndims; k++) + idx(k) = idx_vector (ra_idx(k)); + + Array2<std::string> page (nda.index (idx), nr, nc); + + // FIXME -- need to do some more work to put these + // in neatly aligned columns... + + octave_idx_type n_rows = page.rows (); + octave_idx_type n_cols = page.cols (); + + os << nm << " =\n\n"; + + for (octave_idx_type ii = 0; ii < n_rows; ii++) + { + for (octave_idx_type jj = 0; jj < n_cols; jj++) + os << " " << page(ii,jj); + + os << "\n"; + } + + if (i < m - 1) + os << "\n"; + + if (i < m) + increment_index (ra_idx, dims, 2); + } } } @@ -2793,50 +2793,50 @@ char ofill = os.fill ('0'); std::ios::fmtflags oflags - = os.flags (std::ios::right | std::ios::hex); + = os.flags (std::ios::right | std::ios::hex); if (hex_format > 1 || oct_mach_info::words_big_endian ()) - { - for (size_t i = 0; i < sz; i++) - os << std::setw (2) << static_cast<int> (tmpi[i]); - } + { + for (size_t i = 0; i < sz; i++) + os << std::setw (2) << static_cast<int> (tmpi[i]); + } else - { - for (int i = sz - 1; i >= 0; i--) - os << std::setw (2) << static_cast<int> (tmpi[i]); - } + { + for (int i = sz - 1; i >= 0; i--) + os << std::setw (2) << static_cast<int> (tmpi[i]); + } os.fill (ofill); - os.setf (oflags); + os.setf (oflags); } else if (bit_format) { if (oct_mach_info::words_big_endian ()) - { - for (size_t i = 0; i < sz; i++) - PRINT_CHAR_BITS (os, tmpi[i]); - } + { + for (size_t i = 0; i < sz; i++) + PRINT_CHAR_BITS (os, tmpi[i]); + } else - { - if (bit_format > 1) - { - for (size_t i = 0; i < sz; i++) - PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); - } - else - { - for (int i = sz - 1; i >= 0; i--) - PRINT_CHAR_BITS (os, tmpi[i]); - } - } + { + if (bit_format > 1) + { + for (size_t i = 0; i < sz; i++) + PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); + } + else + { + for (int i = sz - 1; i >= 0; i--) + PRINT_CHAR_BITS (os, tmpi[i]); + } + } } else { os << std::setw (fw) - << typename octave_print_conv<T>::print_conv_type (d); + << typename octave_print_conv<T>::print_conv_type (d); if (bank_format) - os << ".00"; + os << ".00"; } } @@ -2903,7 +2903,7 @@ template <class T> void octave_print_internal_template (std::ostream& os, const octave_int<T>& val, - bool) + bool) { if (plus_format) { @@ -2912,9 +2912,9 @@ else { if (free_format) - os << typename octave_print_conv<octave_int<T> >::print_conv_type (val); + os << typename octave_print_conv<octave_int<T> >::print_conv_type (val); else - pr_int (os, val); + pr_int (os, val); } } @@ -2937,7 +2937,7 @@ template <class T> /* static */ inline void octave_print_internal_template (std::ostream& os, const intNDArray<T>& nda, - bool pr_as_read_syntax, int extra_indent) + bool pr_as_read_syntax, int extra_indent) { // FIXME -- this mostly duplicates the code in the // PRINT_ND_ARRAY macro. @@ -2957,63 +2957,63 @@ octave_idx_type m = 1; for (int i = 2; i < ndims; i++) - m *= dims(i); + m *= dims(i); octave_idx_type nr = dims(0); octave_idx_type nc = dims(1); for (octave_idx_type i = 0; i < m; i++) - { - if (m > 1) - { - std::string nm = "ans(:,:,"; - - std::ostringstream buf; - - for (int k = 2; k < ndims; k++) - { - buf << ra_idx(k) + 1; - - if (k < ndims - 1) - buf << ","; - else - buf << ")"; - } - - nm += buf.str (); - - os << nm << " =\n\n"; - } - - Array<idx_vector> idx (ndims); - - idx(0) = idx_vector (':'); - idx(1) = idx_vector (':'); - - for (int k = 2; k < ndims; k++) - idx(k) = idx_vector (ra_idx(k)); - - Array2<T> page (nda.index (idx), nr, nc); - - for (octave_idx_type ii = 0; ii < nr; ii++) - { - for (octave_idx_type jj = 0; jj < nc; jj++) - { - octave_quit (); - - pr_plus_format (os, page(ii,jj)); - } - - if ((ii < nr - 1) || (i < m -1)) - os << "\n"; - } - - if (i < m - 1) - { - os << "\n"; - increment_index (ra_idx, dims, 2); - } - } + { + if (m > 1) + { + std::string nm = "ans(:,:,"; + + std::ostringstream buf; + + for (int k = 2; k < ndims; k++) + { + buf << ra_idx(k) + 1; + + if (k < ndims - 1) + buf << ","; + else + buf << ")"; + } + + nm += buf.str (); + + os << nm << " =\n\n"; + } + + Array<idx_vector> idx (ndims); + + idx(0) = idx_vector (':'); + idx(1) = idx_vector (':'); + + for (int k = 2; k < ndims; k++) + idx(k) = idx_vector (ra_idx(k)); + + Array2<T> page (nda.index (idx), nr, nc); + + for (octave_idx_type ii = 0; ii < nr; ii++) + { + for (octave_idx_type jj = 0; jj < nc; jj++) + { + octave_quit (); + + pr_plus_format (os, page(ii,jj)); + } + + if ((ii < nr - 1) || (i < m -1)) + os << "\n"; + } + + if (i < m - 1) + { + os << "\n"; + increment_index (ra_idx, dims, 2); + } + } } else { @@ -3026,140 +3026,140 @@ octave_idx_type m = 1; for (int i = 2; i < ndims; i++) - m *= dims(i); + m *= dims(i); octave_idx_type nr = dims(0); octave_idx_type nc = dims(1); int fw = 0; if (hex_format) - fw = 2 * nda(0).byte_size (); + fw = 2 * nda(0).byte_size (); else if (bit_format) - fw = nda(0).nbits (); + fw = nda(0).nbits (); else - { - bool isneg = false; - int digits = 0; - - for (octave_idx_type i = 0; i < dims.numel (); i++) - { - int new_digits = static_cast<int> - (floor (log10 (double (abs (nda(i).value ()))) + 1.0)); - - if (new_digits > digits) - digits = new_digits; - - if (! isneg) - isneg = (abs (nda(i).value ()) != nda(i).value ()); - } - - fw = digits + isneg; - } + { + bool isneg = false; + int digits = 0; + + for (octave_idx_type i = 0; i < dims.numel (); i++) + { + int new_digits = static_cast<int> + (floor (log10 (double (abs (nda(i).value ()))) + 1.0)); + + if (new_digits > digits) + digits = new_digits; + + if (! isneg) + isneg = (abs (nda(i).value ()) != nda(i).value ()); + } + + fw = digits + isneg; + } int column_width = fw + (rat_format ? 0 : (bank_format ? 5 : 2)); octave_idx_type total_width = nc * column_width; int max_width = command_editor::terminal_cols () - extra_indent; octave_idx_type inc = nc; if (total_width > max_width && Vsplit_long_rows) - { - inc = max_width / column_width; - if (inc == 0) - inc++; - } + { + inc = max_width / column_width; + if (inc == 0) + inc++; + } for (octave_idx_type i = 0; i < m; i++) - { - if (m > 1) - { - std::string nm = "ans(:,:,"; - - std::ostringstream buf; - - for (int k = 2; k < ndims; k++) - { - buf << ra_idx(k) + 1; - - if (k < ndims - 1) - buf << ","; - else - buf << ")"; - } - - nm += buf.str (); - - os << nm << " =\n\n"; - } - - Array<idx_vector> idx (ndims); - - idx(0) = idx_vector (':'); - idx(1) = idx_vector (':'); - - for (int k = 2; k < ndims; k++) - idx(k) = idx_vector (ra_idx(k)); - - Array2<T> page (nda.index (idx), nr, nc); - - if (free_format) - { - if (pr_as_read_syntax) - os << "[\n"; - - for (octave_idx_type ii = 0; ii < nr; ii++) - { - for (octave_idx_type jj = 0; jj < nc; jj++) - { - octave_quit (); - os << " "; - os << typename octave_print_conv<T>::print_conv_type (page(ii,jj)); - } - os << "\n"; - } - - if (pr_as_read_syntax) - os << "]"; - } - else - { - octave_idx_type n_rows = page.rows (); - octave_idx_type n_cols = page.cols (); - - for (octave_idx_type col = 0; col < n_cols; col += inc) - { - octave_idx_type lim = col + inc < n_cols ? col + inc : n_cols; - - pr_col_num_header (os, total_width, max_width, lim, col, - extra_indent); - - for (octave_idx_type ii = 0; ii < n_rows; ii++) - { - os << std::setw (extra_indent) << ""; - - for (octave_idx_type jj = col; jj < lim; jj++) - { - octave_quit (); - os << " "; - pr_int (os, page(ii,jj), fw); - } - if ((ii < n_rows - 1) || (i < m -1)) - os << "\n"; - } - } - } - - if (i < m - 1) - { - os << "\n"; - increment_index (ra_idx, dims, 2); - } - } + { + if (m > 1) + { + std::string nm = "ans(:,:,"; + + std::ostringstream buf; + + for (int k = 2; k < ndims; k++) + { + buf << ra_idx(k) + 1; + + if (k < ndims - 1) + buf << ","; + else + buf << ")"; + } + + nm += buf.str (); + + os << nm << " =\n\n"; + } + + Array<idx_vector> idx (ndims); + + idx(0) = idx_vector (':'); + idx(1) = idx_vector (':'); + + for (int k = 2; k < ndims; k++) + idx(k) = idx_vector (ra_idx(k)); + + Array2<T> page (nda.index (idx), nr, nc); + + if (free_format) + { + if (pr_as_read_syntax) + os << "[\n"; + + for (octave_idx_type ii = 0; ii < nr; ii++) + { + for (octave_idx_type jj = 0; jj < nc; jj++) + { + octave_quit (); + os << " "; + os << typename octave_print_conv<T>::print_conv_type (page(ii,jj)); + } + os << "\n"; + } + + if (pr_as_read_syntax) + os << "]"; + } + else + { + octave_idx_type n_rows = page.rows (); + octave_idx_type n_cols = page.cols (); + + for (octave_idx_type col = 0; col < n_cols; col += inc) + { + octave_idx_type lim = col + inc < n_cols ? col + inc : n_cols; + + pr_col_num_header (os, total_width, max_width, lim, col, + extra_indent); + + for (octave_idx_type ii = 0; ii < n_rows; ii++) + { + os << std::setw (extra_indent) << ""; + + for (octave_idx_type jj = col; jj < lim; jj++) + { + octave_quit (); + os << " "; + pr_int (os, page(ii,jj), fw); + } + if ((ii < n_rows - 1) || (i < m -1)) + os << "\n"; + } + } + } + + if (i < m - 1) + { + os << "\n"; + increment_index (ra_idx, dims, 2); + } + } } } #define PRINT_INT_ARRAY_INTERNAL(TYPE) \ OCTINTERP_API void \ octave_print_internal (std::ostream& os, const intNDArray<TYPE>& nda, \ - bool pr_as_read_syntax, int extra_indent) \ + bool pr_as_read_syntax, int extra_indent) \ { \ octave_print_internal_template (os, nda, pr_as_read_syntax, extra_indent); \ } @@ -3212,48 +3212,48 @@ rat_string_len = 9; if (nargin == 2) - rat_string_len = args(1).nint_value (); + rat_string_len = args(1).nint_value (); if (! error_state) - { - octave_value arg = args(0); - - if (arg.is_numeric_type ()) - { - frame.protect_var (rat_format); - - rat_format = true; - - std::ostringstream buf; - args(0).print (buf); - std::string s = buf.str (); - - std::list<std::string> lst; - - size_t n = 0; - size_t s_len = s.length (); - - while (n < s_len) - { - size_t m = s.find ('\n', n); - - if (m == std::string::npos) - { - lst.push_back (s.substr (n)); - break; - } - else - { - lst.push_back (s.substr (n, m - n)); - n = m + 1; - } - } - - retval = string_vector (lst); - } - else - error ("rats: expecting numeric input"); - } + { + octave_value arg = args(0); + + if (arg.is_numeric_type ()) + { + frame.protect_var (rat_format); + + rat_format = true; + + std::ostringstream buf; + args(0).print (buf); + std::string s = buf.str (); + + std::list<std::string> lst; + + size_t n = 0; + size_t s_len = s.length (); + + while (n < s_len) + { + size_t m = s.find ('\n', n); + + if (m == std::string::npos) + { + lst.push_back (s.substr (n)); + break; + } + else + { + lst.push_back (s.substr (n, m - n)); + n = m + 1; + } + } + + retval = string_vector (lst); + } + else + error ("rats: expecting numeric input"); + } } return retval; @@ -3288,14 +3288,14 @@ if (nargin == 1 && nargout < 2) { if (nargout == 0) - args(0).print (octave_stdout); + args(0).print (octave_stdout); else - { - octave_value arg = args(0); - std::ostringstream buf; - arg.print (buf); - retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\''); - } + { + octave_value arg = args(0); + std::ostringstream buf; + arg.print (buf); + retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\''); + } } else print_usage (); @@ -3333,14 +3333,14 @@ octave_stream os = octave_stream_list::lookup (fid, "fdisp"); if (! error_state) - { - std::ostream *osp = os.output_stream (); - - if (osp) - args(1).print (*osp); - else - error ("fdisp: stream not open for writing"); - } + { + std::ostream *osp = os.output_stream (); + + if (osp) + args(1).print (*osp); + else + error ("fdisp: stream not open for writing"); + } } else print_usage (); @@ -3392,155 +3392,155 @@ std::string arg = argv[idx++]; if (arg == "short") - { - if (--argc > 0) - { - arg = argv[idx++]; - - if (arg == "e") - { - init_format_state (); - print_e = true; - } - else if (arg == "E") - { - init_format_state (); - print_e = true; - print_big_e = true; - } - else if (arg == "g") - { - init_format_state (); - print_g = true; - } - else if (arg == "G") - { - init_format_state (); - print_g = true; - print_big_e = true; - } - else - { - error ("format: unrecognized option `short %s'", - arg.c_str ()); - return; - } - } - else - init_format_state (); - - set_output_prec_and_fw (5, 10); - } + { + if (--argc > 0) + { + arg = argv[idx++]; + + if (arg == "e") + { + init_format_state (); + print_e = true; + } + else if (arg == "E") + { + init_format_state (); + print_e = true; + print_big_e = true; + } + else if (arg == "g") + { + init_format_state (); + print_g = true; + } + else if (arg == "G") + { + init_format_state (); + print_g = true; + print_big_e = true; + } + else + { + error ("format: unrecognized option `short %s'", + arg.c_str ()); + return; + } + } + else + init_format_state (); + + set_output_prec_and_fw (5, 10); + } else if (arg == "long") - { - if (--argc > 0) - { - arg = argv[idx++]; - - if (arg == "e") - { - init_format_state (); - print_e = true; - } - else if (arg == "E") - { - init_format_state (); - print_e = true; - print_big_e = true; - } - else if (arg == "g") - { - init_format_state (); - print_g = true; - } - else if (arg == "G") - { - init_format_state (); - print_g = true; - print_big_e = true; - } - else - { - error ("format: unrecognized option `long %s'", - arg.c_str ()); - return; - } - } - else - init_format_state (); - - set_output_prec_and_fw (15, 20); - } + { + if (--argc > 0) + { + arg = argv[idx++]; + + if (arg == "e") + { + init_format_state (); + print_e = true; + } + else if (arg == "E") + { + init_format_state (); + print_e = true; + print_big_e = true; + } + else if (arg == "g") + { + init_format_state (); + print_g = true; + } + else if (arg == "G") + { + init_format_state (); + print_g = true; + print_big_e = true; + } + else + { + error ("format: unrecognized option `long %s'", + arg.c_str ()); + return; + } + } + else + init_format_state (); + + set_output_prec_and_fw (15, 20); + } else if (arg == "hex") - { - init_format_state (); - hex_format = 1; - } + { + init_format_state (); + hex_format = 1; + } else if (arg == "native-hex") - { - init_format_state (); - hex_format = 2; - } + { + init_format_state (); + hex_format = 2; + } else if (arg == "bit") - { - init_format_state (); - bit_format = 1; - } + { + init_format_state (); + bit_format = 1; + } else if (arg == "native-bit") - { - init_format_state (); - bit_format = 2; - } + { + init_format_state (); + bit_format = 2; + } else if (arg == "+" || arg == "plus") - { - if (--argc > 0) - { - arg = argv[idx++]; - - if (arg.length () == 3) - plus_format_chars = arg; - else - { - error ("format: invalid option for plus format"); - return; - } - } - else - plus_format_chars = "+ "; - - init_format_state (); - plus_format = true; - } + { + if (--argc > 0) + { + arg = argv[idx++]; + + if (arg.length () == 3) + plus_format_chars = arg; + else + { + error ("format: invalid option for plus format"); + return; + } + } + else + plus_format_chars = "+ "; + + init_format_state (); + plus_format = true; + } else if (arg == "rat") - { - init_format_state (); - rat_format = true; - } + { + init_format_state (); + rat_format = true; + } else if (arg == "bank") - { - init_format_state (); - bank_format = true; - } + { + init_format_state (); + bank_format = true; + } else if (arg == "free") - { - init_format_state (); - free_format = true; - } + { + init_format_state (); + free_format = true; + } else if (arg == "none") - { - init_format_state (); - free_format = true; - } + { + init_format_state (); + free_format = true; + } else if (arg == "compact") - { - compact_format = true; - } + { + compact_format = true; + } else if (arg == "loose") - { - compact_format = false; - } + { + compact_format = false; + } else - error ("format: unrecognized format state `%s'", arg.c_str ()); + error ("format: unrecognized format state `%s'", arg.c_str ()); } else { @@ -3842,5 +3842,5 @@ @end deftypefn") { return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print, - -1, INT_MAX); + -1, INT_MAX); }