Mercurial > hg > octave-terminal
changeset 276:4cf3c7df0e3d
[project @ 1994-01-07 02:05:57 by jwe]
author | jwe |
---|---|
date | Fri, 07 Jan 1994 02:05:57 +0000 |
parents | a419f80fc9a8 |
children | 1781618ec883 |
files | src/pt-const.cc src/pt-const.h src/symtab.cc src/symtab.h src/t-builtins.cc |
diffstat | 5 files changed, 34 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -1274,7 +1274,7 @@ } int -tree_constant_rep::save (ostream& os, int mark_as_global) +tree_constant_rep::save (ostream& os, int mark_as_global, int precision) { switch (type_tag) { @@ -1294,6 +1294,9 @@ break; } + long old_precision = os.precision (); + os.precision (precision); + switch (type_tag) { case scalar_constant: @@ -1335,6 +1338,9 @@ panic_impossible (); break; } + + os.precision (old_precision); + // Really want to return 1 only if write is successful. return 1; }
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -447,7 +447,7 @@ tree_constant do_matrix_index (constant_type i, const Range& j) const; tree_constant do_matrix_index (constant_type i, constant_type j) const; - int save (ostream& os, int mark_as_global); + int save (ostream& os, int mark_as_global, int precision); int save_three_d (ostream& os, int parametric); int load (istream& is); constant_type load (istream& is, constant_type t); @@ -681,8 +681,8 @@ return *this; } - int save (ostream& os, int mark_as_global = 0) - { return rep->save (os, mark_as_global); } + int save (ostream& os, int mark_as_global = 0, int precision = 17) + { return rep->save (os, mark_as_global, precision); } int save_three_d (ostream& os, int parametric = 0) { return rep->save_three_d (os, parametric); }
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -1,7 +1,7 @@ // Symbol table classes. -*- C++ -*- /* -Copyright (C) 1992, 1993 John W. Eaton +Copyright (C) 1992, 1993, 1994 John W. Eaton This file is part of Octave. @@ -179,9 +179,9 @@ } int -symbol_def::save (ostream& os, int mark_as_global) +symbol_def::save (ostream& os, int mark_as_global, int precision) { - return definition->save (os, mark_as_global); + return definition->save (os, mark_as_global, precision); } int @@ -526,7 +526,8 @@ } int -symbol_record::save (ostream& os, int mark_as_global = 0) +symbol_record::save (ostream& os, int mark_as_global = 0, + int precision = 17) { int status = -1; @@ -543,7 +544,7 @@ else if (is_defined ()) { os << "# name: " << nm << "\n"; - status = definition->save (os, mark_as_global); + status = definition->save (os, mark_as_global, precision); } return status; @@ -961,7 +962,8 @@ } int -symbol_table::save (ostream& os, int mark_as_global = 0) +symbol_table::save (ostream& os, int mark_as_global = 0, + int precision = 17) { int status = 0; int count; @@ -971,7 +973,7 @@ { while (*ptr != (char *) NULL) { - if (save (os, *ptr, mark_as_global)) + if (save (os, *ptr, mark_as_global, precision)) status++; delete [] *ptr++; } @@ -981,12 +983,13 @@ } int -symbol_table::save (ostream& os, const char *name, int mark_as_global = 0) +symbol_table::save (ostream& os, const char *name, + int mark_as_global = 0, int precision = 17) { int status = 0; symbol_record *sr = lookup (name, 0, 0); if (sr != (symbol_record *) NULL) - status = sr->save (os, mark_as_global); + status = sr->save (os, mark_as_global, precision); return status; }
--- a/src/symtab.h +++ b/src/symtab.h @@ -1,7 +1,7 @@ // Symbol table classes. -*- C++ -*- /* -Copyright (C) 1992, 1993 John W. Eaton +Copyright (C) 1992, 1993, 1994 John W. Eaton This file is part of Octave. @@ -87,7 +87,7 @@ char *help (void) const; void document (const char *h); - int save (ostream& os, int mark_as_global); + int save (ostream& os, int mark_as_global, int precision); enum TYPE { @@ -164,7 +164,7 @@ void document (const char *h); - int save (ostream& os, int mark_as_global = 0); + int save (ostream& os, int mark_as_global = 0, int precision = 17); int clear (void); @@ -293,8 +293,9 @@ void clear (int clear_user_functions = 1); int clear (const char *nm, int clear_user_functions = 1); - int save (ostream& os, int mark_as_global = 0); - int save (ostream& os, const char *name, int mark_as_global = 0); + int save (ostream& os, int mark_as_global = 0, int precision = 17); + int save (ostream& os, const char *name, int mark_as_global = 0, + int precicion = 17); int size (void) const;
--- a/src/t-builtins.cc +++ b/src/t-builtins.cc @@ -894,8 +894,11 @@ return retval; } stream = file; + } + int prec = user_pref.save_precision; + if (argc == 1) { int count; @@ -905,7 +908,7 @@ for (int i = 0; i < count; i++) curr_sym_tab->save (stream, vars[i], - is_globally_visible (vars[i])); + is_globally_visible (vars[i]), prec); delete [] vars; } @@ -924,7 +927,7 @@ for (i = 0; i < count; i++) { if (fnmatch (*argv, lvars[i], __FNM_FLAGS) == 0 - && curr_sym_tab->save (stream, lvars[i]) != 0) + && curr_sym_tab->save (stream, lvars[i], 0, prec) != 0) saved_or_error++; } @@ -934,7 +937,7 @@ for (i = 0; i < count; i++) { if (fnmatch (*argv, bvars[i], __FNM_FLAGS) == 0 - && global_sym_tab->save (stream, bvars[i]) != 0) + && global_sym_tab->save (stream, bvars[i], 0, prec) != 0) saved_or_error++; }