Mercurial > hg > octave-lyh
changeset 3682:19e1ac7359fb
[project @ 2000-06-27 03:23:10 by jwe]
author | jwe |
---|---|
date | Tue, 27 Jun 2000 03:23:10 +0000 |
parents | df54d394acc0 |
children | 505f5c35a2c9 |
files | src/ChangeLog src/load-save.cc src/pr-output.cc |
diffstat | 3 files changed, 33 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2000-06-26 John W. Eaton <jwe@bevo.che.wisc.edu> + * pr-output.cc (float_format::float_format): Set default values + for width and precision to -1. + (operator << (ostream&, pr_formatted_float&): Set width and + precision if values are >= 0. + (set_real_format, set_real_matrix_format, set_range_format, + set_complex_format, set_complex_matrix_format): If we have all + integers, infinities, or nans, set precision equal to field width. + + * load-save.cc (read_ascii_data): Allow empty strings and string + vectors to be restored. + * variables.cc (var_matches_any_pattern): New function. (Fclear): Use it to make exclusive clear work correctly.
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -584,7 +584,7 @@ else if (strncmp (ptr, "string array", 12) == 0) { int elements; - if (extract_keyword (is, "elements", elements) && elements > 0) + if (extract_keyword (is, "elements", elements) && elements >= 0) { // XXX FIXME XXX -- need to be able to get max length // before doing anything. @@ -627,14 +627,22 @@ else if (strncmp (ptr, "string", 6) == 0) { int len; - if (extract_keyword (is, "length", len) && len > 0) + if (extract_keyword (is, "length", len) && len >= 0) { char *tmp = new char [len+1]; - is.get (tmp, len+1, EOF); - if (is) - tc = tmp; + if (len > 0 && ! is.read (X_CAST (char *, tmp), len)) + { + error ("load: failed to load string constant"); + } else - error ("load: failed to load string constant"); + { + tmp [len] = '\0'; + + if (is) + tc = tmp; + else + error ("load: failed to load string constant"); + } } else error ("load: failed to extract string length");
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -104,7 +104,7 @@ { public: - float_format (int w = 0, int p = 0, int f = 0) + float_format (int w = -1, int p = -1, int f = 0) : fw (w), prec (p), fmt (f), up (0), sp (0) { } float_format (const float_format& ff) @@ -177,10 +177,10 @@ std::ostream& operator << (std::ostream& os, const pr_formatted_float& pff) { - if (pff.f.fw > 0) + if (pff.f.fw >= 0) os << std::setw (pff.f.fw); - if (pff.f.prec > 0) + if (pff.f.prec >= 0) os << std::setprecision (pff.f.prec); std::ios::fmtflags oflags = os.flags (pff.f.fmt | pff.f.up | pff.f.sp); @@ -280,7 +280,7 @@ if (inf_or_nan && fw < 3) fw = 3; fw += sign; - rd = 0; + rd = fw; } else { @@ -402,7 +402,7 @@ if (inf_or_nan && fw < 3) fw = 3; fw += sign; - rd = 0; + rd = fw; } else { @@ -548,7 +548,7 @@ if (inf_or_nan && i_fw < 3) i_fw = r_fw = 3; r_fw += sign; - rd = 0; + rd = r_fw; } else { @@ -725,7 +725,7 @@ if (inf_or_nan && i_fw < 3) i_fw = r_fw = 3; r_fw += sign; - rd = 0; + rd = r_fw; } else { @@ -888,7 +888,7 @@ { int digits = x_max > x_min ? x_max : x_min; fw = sign + digits; - rd = 0; + rd = fw; } else if (Vfixed_point_format) {