Mercurial > hg > octave-nkf
diff src/load-save.cc @ 8425:2e777f5135a3
support -tabs option for save -ascii
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 25 Dec 2008 12:31:07 +0100 |
parents | 679c22082ac7 |
children | 22462fd58e66 |
line wrap: on
line diff
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -347,7 +347,7 @@ std::string name; std::string doc; - switch (format) + switch (format.type) { case LS_ASCII: name = read_ascii_data (stream, orig_fname, global, tc, count); @@ -928,7 +928,7 @@ const std::string& name, const std::string& help, bool global, load_save_format fmt, bool save_as_floats) { - switch (fmt) + switch (fmt.type) { case LS_ASCII: save_ascii_data (os, tc, name, global, 0); @@ -939,8 +939,8 @@ break; case LS_MAT_ASCII: - case LS_MAT_ASCII_LONG: - if (! save_mat_ascii_data (os, tc, fmt == LS_MAT_ASCII ? 8 : 16)) + if (! save_mat_ascii_data (os, tc, fmt.opts & LS_MAT_ASCII_LONG ? 16 : 8, + fmt.opts & LS_MAT_ASCII_TABS)) warning ("save: unable to save %s in ASCII format", name.c_str ()); break; @@ -1048,7 +1048,7 @@ string_vector retval; int argc = argv.length (); - bool do_double = false; + bool do_double = false, do_tabs = false; for (int i = 0; i < argc; i++) { @@ -1064,6 +1064,10 @@ { do_double = true; } + else if (argv[i] == "-tabs") + { + do_tabs = true; + } else if (argv[i] == "-text" || argv[i] == "-t") { format = LS_ASCII; @@ -1125,11 +1129,19 @@ if (do_double) { if (format == LS_MAT_ASCII) - format = LS_MAT_ASCII_LONG; + format.opts |= LS_MAT_ASCII_LONG; else warning ("save: \"-double\" option only has an effect with \"-ascii\""); } + if (do_tabs) + { + if (format == LS_MAT_ASCII) + format.opts |= LS_MAT_ASCII_TABS; + else + warning ("save: \"-tabs\" option only has an effect with \"-ascii\""); + } + return retval; } @@ -1155,7 +1167,7 @@ void write_header (std::ostream& os, load_save_format format) { - switch (format) + switch (format.type) { case LS_BINARY: {