comparison src/symtab.cc @ 276:4cf3c7df0e3d

[project @ 1994-01-07 02:05:57 by jwe]
author jwe
date Fri, 07 Jan 1994 02:05:57 +0000
parents 221a5fa8bf01
children ee3da0884aaa
comparison
equal deleted inserted replaced
275:a419f80fc9a8 276:4cf3c7df0e3d
1 // Symbol table classes. -*- C++ -*- 1 // Symbol table classes. -*- C++ -*-
2 /* 2 /*
3 3
4 Copyright (C) 1992, 1993 John W. Eaton 4 Copyright (C) 1992, 1993, 1994 John W. Eaton
5 5
6 This file is part of Octave. 6 This file is part of Octave.
7 7
8 Octave is free software; you can redistribute it and/or modify it 8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
177 delete [] help_string; 177 delete [] help_string;
178 help_string = strsave (h); 178 help_string = strsave (h);
179 } 179 }
180 180
181 int 181 int
182 symbol_def::save (ostream& os, int mark_as_global) 182 symbol_def::save (ostream& os, int mark_as_global, int precision)
183 { 183 {
184 return definition->save (os, mark_as_global); 184 return definition->save (os, mark_as_global, precision);
185 } 185 }
186 186
187 int 187 int
188 maybe_delete (symbol_def *def) 188 maybe_delete (symbol_def *def)
189 { 189 {
524 warning ("documenting undefined variable `%s'", nm); 524 warning ("documenting undefined variable `%s'", nm);
525 } 525 }
526 } 526 }
527 527
528 int 528 int
529 symbol_record::save (ostream& os, int mark_as_global = 0) 529 symbol_record::save (ostream& os, int mark_as_global = 0,
530 int precision = 17)
530 { 531 {
531 int status = -1; 532 int status = -1;
532 533
533 // This is a kludge, but hey, it doesn't make sense to save them 534 // This is a kludge, but hey, it doesn't make sense to save them
534 // anyway, does it? Even if it did, we would just have trouble trying 535 // anyway, does it? Even if it did, we would just have trouble trying
541 else if (is_function ()) 542 else if (is_function ())
542 warning ("save: sorry, can't save function `%s'", nm); 543 warning ("save: sorry, can't save function `%s'", nm);
543 else if (is_defined ()) 544 else if (is_defined ())
544 { 545 {
545 os << "# name: " << nm << "\n"; 546 os << "# name: " << nm << "\n";
546 status = definition->save (os, mark_as_global); 547 status = definition->save (os, mark_as_global, precision);
547 } 548 }
548 549
549 return status; 550 return status;
550 } 551 }
551 552
959 960
960 return 0; 961 return 0;
961 } 962 }
962 963
963 int 964 int
964 symbol_table::save (ostream& os, int mark_as_global = 0) 965 symbol_table::save (ostream& os, int mark_as_global = 0,
966 int precision = 17)
965 { 967 {
966 int status = 0; 968 int status = 0;
967 int count; 969 int count;
968 char **names = list (count, 1, symbol_def::USER_VARIABLE); 970 char **names = list (count, 1, symbol_def::USER_VARIABLE);
969 char **ptr = names; 971 char **ptr = names;
970 if (ptr != (char **) NULL) 972 if (ptr != (char **) NULL)
971 { 973 {
972 while (*ptr != (char *) NULL) 974 while (*ptr != (char *) NULL)
973 { 975 {
974 if (save (os, *ptr, mark_as_global)) 976 if (save (os, *ptr, mark_as_global, precision))
975 status++; 977 status++;
976 delete [] *ptr++; 978 delete [] *ptr++;
977 } 979 }
978 delete [] names; 980 delete [] names;
979 } 981 }
980 return status; 982 return status;
981 } 983 }
982 984
983 int 985 int
984 symbol_table::save (ostream& os, const char *name, int mark_as_global = 0) 986 symbol_table::save (ostream& os, const char *name,
987 int mark_as_global = 0, int precision = 17)
985 { 988 {
986 int status = 0; 989 int status = 0;
987 symbol_record *sr = lookup (name, 0, 0); 990 symbol_record *sr = lookup (name, 0, 0);
988 if (sr != (symbol_record *) NULL) 991 if (sr != (symbol_record *) NULL)
989 status = sr->save (os, mark_as_global); 992 status = sr->save (os, mark_as_global, precision);
990 return status; 993 return status;
991 } 994 }
992 995
993 int 996 int
994 symbol_table::size (void) const 997 symbol_table::size (void) const