Mercurial > hg > octave-avbm
changeset 607:ae3b8b2924a0
[project @ 1994-08-13 20:11:17 by jwe]
author | jwe |
---|---|
date | Sat, 13 Aug 1994 20:11:17 +0000 |
parents | 91ab3cfc2376 |
children | a675e03540dd |
files | src/pt-plot.cc src/tc-rep.cc src/utils.cc src/utils.h src/variables.h |
diffstat | 5 files changed, 56 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -47,6 +47,7 @@ #include "tree-cmd.h" #include "tree-const.h" #include "tree-plot.h" +#include "load-save.h" #include "help.h" #include "error.h" #include "utils.h" @@ -806,10 +807,10 @@ switch (ndim) { case 2: - t.save (file); + save_ascii_data (file, t); break; case 3: - t.save_three_d (file, parametric); + save_three_d (file, t, parametric); break; default: panic_impossible ();
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -1512,124 +1512,6 @@ return retval; } -int -tree_constant_rep::save (ostream& os, int mark_as_global, int precision) -{ - switch (type_tag) - { - case scalar_constant: - case matrix_constant: - case complex_scalar_constant: - case complex_matrix_constant: - case string_constant: - case range_constant: - if (mark_as_global) - os << "# type: global "; - else - os << "# type: "; - break; - case magic_colon: - default: - break; - } - - long old_precision = os.precision (); - os.precision (precision); - - switch (type_tag) - { - case scalar_constant: - os << "scalar\n" - << scalar << "\n"; - break; - case matrix_constant: - os << "matrix\n" - << "# rows: " << rows () << "\n" - << "# columns: " << columns () << "\n" - << *matrix ; - break; - case complex_scalar_constant: - os << "complex scalar\n" - << *complex_scalar << "\n"; - break; - case complex_matrix_constant: - os << "complex matrix\n" - << "# rows: " << rows () << "\n" - << "# columns: " << columns () << "\n" - << *complex_matrix ; - break; - case string_constant: - os << "string\n" - << "# length: " << strlen (string) << "\n" - << string << "\n"; - break; - case range_constant: - { - os << "range\n" - << "# base, limit, increment\n" - << range->base () << " " - << range->limit () << " " - << range->inc () << "\n"; - } - break; - case magic_colon: - default: - panic_impossible (); - break; - } - - os.precision (old_precision); - -// Really want to return 1 only if write is successful. - return 1; -} - -int -tree_constant_rep::save_three_d (ostream& os, int parametric) -{ - int nr = rows (); - int nc = columns (); - - switch (type_tag) - { - case matrix_constant: - os << "# 3D data...\n" - << "# type: matrix\n" - << "# total rows: " << nr << "\n" - << "# total columns: " << nc << "\n"; - - if (parametric) - { - int extras = nc % 3; - if (extras) - warning ("ignoring last %d columns", extras); - - for (int i = 0; i < nc-extras; i += 3) - { - os << matrix->extract (0, i, nr-1, i+2); - if (i+3 < nc-extras) - os << "\n"; - } - } - else - { - for (int i = 0; i < nc; i++) - { - os << matrix->extract (0, i, nr-1, i); - if (i+1 < nc) - os << "\n"; - } - } - break; - default: - ::error ("for now, I can only save real matrices in 3D format"); - return 0; - break; - } -// Really want to return 1 only if write is successful. - return 1; -} - double tree_constant_rep::double_value (void) const {
--- a/src/utils.cc +++ b/src/utils.cc @@ -157,6 +157,46 @@ stream.putback ((char) c); } +#if 0 + +// XXX UNTESTED XXX + +// Read input until a given character is read. Returns characters +// read in a new string that must be freed by the caller. + +char * +read_until (istream& stream, char character) +{ + int grow_size = 8; + int limit = grow_size; + char *buf = new char [limit]; + char *bp = buf; + + get_more: + is.getline (bp, limit, character); + + if (is.gcount () == 0) + { + delete [] buf; + return 0; + } + + if (is.gcount () == limit && buf[limit-1] != '\0') + { + char *tmp = new char [limit + grow_size]; + strcpy (tmp, buf); + delete [] buf; + buf = tmp; + bp = tmp + limit - 1; + limit += grow_size; + grow_size *= 2; + goto get_more; + } + + return buf; +} +#endif + char ** pathstring_to_vector (char *pathstring) {
--- a/src/utils.h +++ b/src/utils.h @@ -38,20 +38,31 @@ extern char *strsave (const char *); extern char *strconcat (const char *, const char *); + extern void discard_until (istream&, char); + +#if 0 +extern char *read_until (istream&, char); +#endif + extern char *file_in_path (const char *, const char *); extern char *fcn_file_in_path (const char *); extern char *oct_file_in_path (const char *); + extern char **pathstring_to_vector (char *pathstring); + extern void jump_to_top_level (void); + extern int almost_match (const char *std, const char *s, int min_match_len = 1, int case_sens = 1); extern int keyword_almost_match (const char **std, int *min_len, const char *s, int min_toks_to_match, int max_toks); + extern char **get_fcn_file_names (int& ffl_len, const char *dir, int no_suffix); extern char **get_fcn_file_names (int& ffl_len, int no_suffix); + extern int NINT (double x); extern double D_NINT (double x);
--- a/src/variables.h +++ b/src/variables.h @@ -78,7 +78,8 @@ extern void force_link_to_function (const char *s); extern int is_builtin_variable (const char *name); -extern int is_text_function_name (const char *s); +extern int is_text_function_name (const char *name); +extern int is_globally_visible (const char *name); extern tree_fvc *is_valid_function (const tree_constant&, char *, int warn = 0);