Mercurial > octave
annotate libinterp/corefcn/load-save.cc @ 29358:0a5b15007766 stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:52:15 -0500 |
parents | 139df373c107 |
children | 7854d5752dd2 cb2d14b384df |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
3 // Copyright (C) 1994-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
604 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
604 | 28 #endif |
29 | |
1343 | 30 #include <cstring> |
31 | |
4249 | 32 #include <fstream> |
3503 | 33 #include <iomanip> |
34 #include <iostream> | |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
35 #include <list> |
5765 | 36 #include <sstream> |
1728 | 37 #include <string> |
38 | |
1961 | 39 #include "byte-swap.h" |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
40 #include "dMatrix.h" |
1961 | 41 #include "data-conv.h" |
2926 | 42 #include "file-ops.h" |
6159 | 43 #include "file-stat.h" |
2926 | 44 #include "glob-match.h" |
2890 | 45 #include "lo-mappers.h" |
2318 | 46 #include "mach-info.h" |
3185 | 47 #include "oct-env.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
48 #include "oct-locbuf.h" |
3258 | 49 #include "oct-time.h" |
4171 | 50 #include "quit.h" |
1755 | 51 #include "str-vec.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
52 #include "strftime-wrapper.h" |
1755 | 53 |
4332 | 54 #include "Cell.h" |
1352 | 55 #include "defun.h" |
604 | 56 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
57 #include "errwarn.h" |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
58 #include "interpreter.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23584
diff
changeset
|
59 #include "interpreter-private.h" |
6159 | 60 #include "load-path.h" |
1352 | 61 #include "load-save.h" |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
62 #include "oct-hdf5.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
63 #include "ovl.h" |
3687 | 64 #include "oct-map.h" |
4332 | 65 #include "ov-cell.h" |
1352 | 66 #include "pager.h" |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
67 #include "syminfo.h" |
1352 | 68 #include "sysdep.h" |
69 #include "unwind-prot.h" | |
604 | 70 #include "utils.h" |
2371 | 71 #include "variables.h" |
3185 | 72 #include "version.h" |
3688 | 73 |
4633 | 74 #include "ls-hdf5.h" |
75 #include "ls-mat-ascii.h" | |
76 #include "ls-mat4.h" | |
77 #include "ls-mat5.h" | |
20447
c6224b4e7774
maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents:
20443
diff
changeset
|
78 #include "ls-oct-text.h" |
4633 | 79 #include "ls-oct-binary.h" |
3688 | 80 |
10309 | 81 // Remove gnulib definitions, if any. |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
82 #if defined (close) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
83 # undef close |
10309 | 84 #endif |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
85 #if defined (open) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
86 # undef open |
5269 | 87 #endif |
88 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
89 #if defined (HAVE_ZLIB) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
90 # include "zfstream.h" |
10305
d6cdf08d0424
load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
91 #endif |
d6cdf08d0424
load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
92 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
93 namespace octave |
5794 | 94 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
95 OCTAVE_NORETURN static |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
96 void |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
97 err_file_open (const std::string& fcn, const std::string& file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
98 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
99 if (fcn == "load") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
100 error ("%s: unable to open input file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
101 else if (fcn == "save") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
102 error ("%s: unable to open output file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
103 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
104 error ("%s: unable to open file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
105 } |
4788 | 106 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
107 // Return TRUE if NAME matches one of the given globbing PATTERNS. |
5369 | 108 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
109 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
110 matches_patterns (const string_vector& patterns, int pat_idx, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
111 int num_pat, const std::string& name) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
112 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
113 for (int i = pat_idx; i < num_pat; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
114 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
115 glob_match pattern (patterns[i]); |
604 | 116 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
117 if (pattern.match (name)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
118 return true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
119 } |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23603
diff
changeset
|
120 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
121 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
122 } |
25201
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25106
diff
changeset
|
123 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
124 static int |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
125 read_binary_file_header (std::istream& is, bool& swap, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
126 mach_info::float_format& flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
127 bool quiet = false) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
128 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
129 const int magic_len = 10; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
130 char magic[magic_len+1]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
131 is.read (magic, magic_len); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
132 magic[magic_len] = '\0'; |
604 | 133 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
134 if (strncmp (magic, "Octave-1-L", magic_len) == 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
135 swap = mach_info::words_big_endian (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
136 else if (strncmp (magic, "Octave-1-B", magic_len) == 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
137 swap = ! mach_info::words_big_endian (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
138 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
139 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
140 if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
141 error ("load: unable to read binary file"); |
604 | 142 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
143 return -1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
144 } |
3688 | 145 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
146 char tmp = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
147 is.read (&tmp, 1); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
148 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
149 flt_fmt = mopt_digit_to_float_format (tmp); |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20801
diff
changeset
|
150 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
151 if (flt_fmt == mach_info::flt_fmt_unknown) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
152 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
153 if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
154 error ("load: unrecognized binary format!"); |
2318 | 155 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
156 return -1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
157 } |
3688 | 158 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
159 return 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
160 } |
604 | 161 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
162 #if defined (HAVE_ZLIB) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
163 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
164 check_gzip_magic (const std::string& fname) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
165 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
166 bool retval = false; |
21972
d31e0f704d0b
Open files in binary mode when testing file format (bug #48201).
Rik <rik@octave.org>
parents:
21966
diff
changeset
|
167 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
168 std::string ascii_fname = sys::get_ASCII_filename (fname); |
25604
ca413f326224
Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25580
diff
changeset
|
169 |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
170 std::ifstream file = sys::ifstream (fname.c_str (), |
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
171 std::ios::in | std::ios::binary); |
5269 | 172 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
173 unsigned char magic[2]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
174 if (file.read (reinterpret_cast<char *> (&magic[0]), 2) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
175 && magic[0] == 0x1f && magic[1] == 0x8b) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
176 retval = true; |
5269 | 177 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
178 file.close (); |
23777
cda0614beaec
Replace static instances of OCTAVE_LOCAL_BUFFER with local variables.
Rik <rik@octave.org>
parents:
23693
diff
changeset
|
179 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
180 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
181 } |
5269 | 182 #endif |
183 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
184 static std::string |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
185 find_file_to_load (const std::string& name, const std::string& orig_name) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
186 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
187 std::string fname = find_data_file_in_load_path ("load", name, true); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
188 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
189 size_t dot_pos = fname.rfind ('.'); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
190 size_t sep_pos = fname.find_last_of (sys::file_ops::dir_sep_chars ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
191 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
192 if (dot_pos == std::string::npos |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
193 || (sep_pos != std::string::npos && dot_pos < sep_pos)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
194 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
195 // Either no '.' in name or no '.' appears after last directory |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
196 // separator. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
197 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
198 sys::file_stat fs (fname); |
604 | 199 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
200 if (! (fs.exists () && fs.is_reg ())) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
201 fname = find_file_to_load (fname + ".mat", orig_name); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
202 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
203 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
204 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
205 sys::file_stat fs (fname); |
604 | 206 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
207 if (! (fs.exists () && fs.is_reg ())) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
208 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
209 fname = ""; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
210 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
211 error ("load: unable to find file %s", orig_name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
212 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
213 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
214 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
215 return fname; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
216 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
217 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
218 // Return TRUE if PATTERN has any special globbing chars in it. |
3019 | 219 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
220 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
221 glob_pattern_p (const std::string& pattern) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
222 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
223 int open = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
224 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
225 int len = pattern.length (); |
604 | 226 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
227 for (int i = 0; i < len; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
228 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
229 char c = pattern[i]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
230 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
231 switch (c) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
232 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
233 case '?': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
234 case '*': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
235 return true; |
1180 | 236 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
237 case '[': // Only accept an open brace if there is a close |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
238 open++; // brace to match it. Bracket expressions must be |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
239 continue; // complete, according to Posix.2 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
240 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
241 case ']': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
242 if (open) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
243 return true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
244 continue; |
1180 | 245 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
246 case '\\': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
247 if (i == len - 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
248 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
249 continue; |
604 | 250 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
251 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
252 continue; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
253 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
254 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
255 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
256 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
257 } |
3688 | 258 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
259 load_save_system::load_save_system (interpreter& interp) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
260 : m_interpreter (interp), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
261 m_crash_dumps_octave_core (true), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
262 m_octave_core_file_limit (-1.0), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
263 m_octave_core_file_name ("octave-workspace"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
264 m_save_default_options ("-text"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
265 m_octave_core_file_options ("-binary"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
266 m_save_header_format_string (init_save_header_format ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
267 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
268 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
269 H5dont_atexit (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
270 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
271 } |
3688 | 272 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
273 load_save_system::~load_save_system (void) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
274 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
275 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
276 H5close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
277 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
278 } |
4171 | 279 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
280 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
281 load_save_system::crash_dumps_octave_core (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
282 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
283 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
284 return set_internal_variable (m_crash_dumps_octave_core, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
285 "crash_dumps_octave_core"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
286 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
287 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
288 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
289 load_save_system::octave_core_file_limit (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
290 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
291 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
292 return set_internal_variable (m_octave_core_file_limit, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
293 "octave_core_file_limit"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
294 } |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
295 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
296 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
297 load_save_system::octave_core_file_name (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
298 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
299 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
300 return set_internal_variable (m_octave_core_file_name, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
301 "octave_core_file_name", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
302 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
303 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
304 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
305 load_save_system::save_default_options (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
306 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
307 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
308 return set_internal_variable (m_save_default_options, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
309 "save_default_options", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
310 } |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
311 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
312 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
313 load_save_system::octave_core_file_options (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
314 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
315 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
316 return set_internal_variable (m_octave_core_file_options, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
317 "octave_core_file_options", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
318 } |
604 | 319 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
320 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
321 load_save_system::save_header_format_string (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
322 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
323 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
324 return set_internal_variable (m_save_header_format_string, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
325 "save_header_format_string"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
326 } |
5977 | 327 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
328 load_save_format |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
329 load_save_system::get_file_format (const std::string& fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
330 const std::string& orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
331 bool& use_zlib, bool quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
332 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
333 load_save_format retval = UNKNOWN; |
5269 | 334 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
335 std::string ascii_fname = sys::get_ASCII_filename (fname); |
25604
ca413f326224
Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25580
diff
changeset
|
336 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
337 #if defined (HAVE_HDF5) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
338 // check this before we open the file |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
339 if (H5Fis_hdf5 (ascii_fname.c_str ()) > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
340 return HDF5; |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
341 #endif |
604 | 342 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
343 #if defined (HAVE_ZLIB) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
344 use_zlib = check_gzip_magic (fname); |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
345 #else |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
346 use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
347 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
348 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
349 if (! use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
350 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
351 std::ifstream file = sys::ifstream (fname.c_str (), |
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
352 std::ios::in | std::ios::binary); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
353 if (file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
354 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
355 retval = get_file_format (file, orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
356 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
357 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
358 else if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
359 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
360 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
361 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
362 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
363 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
364 gzifstream gzfile (fname.c_str (), std::ios::in | std::ios::binary); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
365 if (gzfile) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
366 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
367 retval = get_file_format (gzfile, orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
368 gzfile.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
369 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
370 else if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
371 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
372 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
373 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
374 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
375 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
376 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
377 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
378 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
379 load_save_system::load_vars (std::istream& stream, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
380 const std::string& orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
381 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
382 mach_info::float_format flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
383 bool list_only, bool swap, bool verbose, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
384 const string_vector& argv, int argv_idx, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
385 int argc, int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
386 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
387 octave_value retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
388 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
389 octave_scalar_map retstruct; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
390 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
391 std::ostringstream output_buf; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
392 std::list<std::string> symbol_names; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
393 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
394 octave_idx_type count = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
395 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
396 for (;;) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
397 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
398 bool global = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
399 octave_value tc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
400 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
401 std::string name; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
402 std::string doc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
403 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
404 switch (fmt.type ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
405 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
406 case TEXT: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
407 name = read_text_data (stream, orig_fname, global, tc, count); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
408 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
409 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
410 case BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
411 name = read_binary_data (stream, swap, flt_fmt, orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
412 global, tc, doc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
413 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
414 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
415 case MAT_ASCII: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
416 name = read_mat_ascii_data (stream, orig_fname, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
417 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
418 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
419 case MAT_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
420 name = read_mat_binary_data (stream, orig_fname, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
421 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
422 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
423 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
424 case HDF5: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
425 name = read_hdf5_data (stream, orig_fname, global, tc, doc, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
426 argv, argv_idx, argc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
427 break; |
5977 | 428 #endif |
5269 | 429 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
430 case MAT5_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
431 case MAT7_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
432 name = read_mat5_binary_element (stream, orig_fname, swap, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
433 global, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
434 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
435 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
436 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
437 err_unrecognized_data_fmt ("load"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
438 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
439 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
440 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
441 if (stream.eof () || name.empty ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
442 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
443 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
444 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
445 if (! tc.is_defined ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
446 error ("load: unable to load variable '%s'", name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
447 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
448 if (fmt.type () == MAT_ASCII && argv_idx < argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
449 warning ("load: loaded ASCII file '%s' -- ignoring extra args", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
450 orig_fname.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
451 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
452 if (fmt.type () == MAT_ASCII |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
453 || argv_idx == argc |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
454 || matches_patterns (argv, argv_idx, argc, name)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
455 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
456 count++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
457 if (list_only) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
458 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
459 if (verbose) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
460 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
461 if (count == 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
462 output_buf |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
463 << "type rows cols name\n" |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
464 << "==== ==== ==== ====\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
465 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
466 output_buf |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
467 << std::setiosflags (std::ios::left) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
468 << std::setw (16) << tc.type_name ().c_str () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
469 << std::setiosflags (std::ios::right) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
470 << std::setw (7) << tc.rows () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
471 << std::setw (7) << tc.columns () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
472 << " " << name << "\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
473 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
474 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
475 symbol_names.push_back (name); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
476 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
477 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
478 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
479 if (nargout == 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
480 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
481 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
482 retval = tc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
483 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
484 retstruct.assign (name, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
485 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
486 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
487 install_loaded_variable (name, tc, global, doc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
488 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
489 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
490 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
491 // Only attempt to read one item from a headless text file. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
492 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
493 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
494 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
495 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
496 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
497 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
498 if (list_only && count) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
499 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
500 if (verbose) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
501 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
502 std::string msg = output_buf.str (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
503 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
504 if (nargout > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
505 retval = msg; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
506 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
507 octave_stdout << msg; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
508 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
509 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
510 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
511 if (nargout > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
512 retval = Cell (string_vector (symbol_names)); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
513 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
514 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
515 string_vector names (symbol_names); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
516 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
517 names.list_in_columns (octave_stdout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
518 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
519 octave_stdout << "\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
520 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
521 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
522 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
523 else if (retstruct.nfields () != 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
524 retval = retstruct; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
525 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
526 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
527 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
528 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
529 string_vector |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
530 load_save_system::parse_save_options (const string_vector& argv, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
531 load_save_format& fmt, bool& append, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
532 bool& save_as_floats, bool& use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
533 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
534 #if ! defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
535 octave_unused_parameter (use_zlib); |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
536 #endif |
604 | 537 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
538 string_vector retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
539 int argc = argv.numel (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
540 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
541 bool do_double = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
542 bool do_tabs = false; |
604 | 543 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
544 for (int i = 0; i < argc; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
545 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
546 if (argv[i] == "-append") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
547 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
548 append = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
549 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
550 else if (argv[i] == "-ascii" || argv[i] == "-a") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
551 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
552 fmt.set_type (MAT_ASCII); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
553 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
554 else if (argv[i] == "-double") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
555 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
556 do_double = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
557 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
558 else if (argv[i] == "-tabs") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
559 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
560 do_tabs = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
561 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
562 else if (argv[i] == "-text" || argv[i] == "-t") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
563 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
564 fmt.set_type (TEXT); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
565 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
566 else if (argv[i] == "-binary" || argv[i] == "-b") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
567 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
568 fmt.set_type (BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
569 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
570 else if (argv[i] == "-hdf5" || argv[i] == "-h") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
571 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
572 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
573 fmt.set_type (HDF5); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
574 #else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
575 err_disabled_feature ("save", "HDF5"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
576 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
577 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
578 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
579 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
580 error ("save: Matlab file format -v7.3 is not yet implemented"); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
581 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
582 #if defined (HAVE_ZLIB) |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
583 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
584 || argv[i] == "-mat7-binary") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
585 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
586 fmt.set_type (MAT7_BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
587 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
588 #endif |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
589 else if (argv[i] == "-mat" || argv[i] == "-m" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
590 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
591 || argv[i] == "-mat-binary") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
592 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
593 fmt.set_type (MAT5_BINARY); |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
594 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
595 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
596 || argv[i] == "-mat4-binary") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
597 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
598 fmt.set_type (MAT_BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
599 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
600 else if (argv[i] == "-float-binary" || argv[i] == "-f") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
601 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
602 fmt.set_type (BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
603 save_as_floats = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
604 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
605 else if (argv[i] == "-float-hdf5") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
606 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
607 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
608 fmt.set_type (HDF5); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
609 save_as_floats = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
610 #else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
611 err_disabled_feature ("save", "HDF5"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
612 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
613 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
614 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
615 else if (argv[i] == "-zip" || argv[i] == "-z") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
616 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
617 use_zlib = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
618 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
619 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
620 else if (argv[i] == "-struct") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
621 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
622 retval.append (argv[i]); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
623 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
624 else if (argv[i][0] == '-' && argv[i] != "-") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
625 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
626 error ("save: Unrecognized option '%s'", argv[i].c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
627 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
628 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
629 retval.append (argv[i]); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
630 } |
3727 | 631 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
632 if (do_double) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
633 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
634 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
635 fmt.set_option (MAT_ASCII_LONG); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
636 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
637 warning (R"(save: "-double" option only has an effect with "-ascii")"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
638 } |
604 | 639 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
640 if (do_tabs) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
641 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
642 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
643 fmt.set_option (MAT_ASCII_TABS); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
644 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
645 warning (R"(save: "-tabs" option only has an effect with "-ascii")"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
646 } |
4051 | 647 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
648 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
649 } |
4051 | 650 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
651 string_vector |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
652 load_save_system::parse_save_options (const std::string& arg, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
653 load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
654 bool& append, bool& save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
655 bool& use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
656 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
657 std::istringstream is (arg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
658 std::string str; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
659 string_vector argv; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
660 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
661 while (! is.eof ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
662 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
663 is >> str; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
664 argv.append (str); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
665 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
666 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
667 return parse_save_options (argv, fmt, append, save_as_floats, use_zlib); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
668 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
669 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
670 void load_save_system::save_vars (const string_vector& argv, int argv_idx, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
671 int argc, std::ostream& os, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
672 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
673 bool save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
674 bool write_header_info) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
675 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
676 if (write_header_info) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
677 write_header (os, fmt); |
604 | 678 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
679 if (argv_idx == argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
680 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
681 save_vars (os, "*", fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
682 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
683 else if (argv[argv_idx] == "-struct") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
684 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
685 if (++argv_idx >= argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
686 error ("save: missing struct name"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
687 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
688 std::string struct_name = argv[argv_idx]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
689 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
690 if (! m_interpreter.is_variable (struct_name)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
691 error ("save: no such variable: '%s'", struct_name.c_str ()); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
692 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
693 octave_value struct_var = m_interpreter.varval (struct_name); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
694 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
695 if (! struct_var.isstruct () || struct_var.numel () != 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
696 error ("save: '%s' is not a scalar structure", struct_name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
697 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
698 octave_scalar_map struct_var_map = struct_var.scalar_map_value (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
699 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
700 ++argv_idx; |
604 | 701 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
702 if (argv_idx < argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
703 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
704 for (int i = argv_idx; i < argc; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
705 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
706 if (! save_fields (os, struct_var_map, argv[i], fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
707 save_as_floats)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
708 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
709 warning ("save: no such field '%s.%s'", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
710 struct_name.c_str (), argv[i].c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
711 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
712 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
713 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
714 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
715 save_fields (os, struct_var_map, "*", fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
716 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
717 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
718 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
719 for (int i = argv_idx; i < argc; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
720 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
721 if (argv[i] == "") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
722 continue; // Skip empty vars for Matlab compatibility |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
723 if (! save_vars (os, argv[i], fmt, save_as_floats)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
724 warning ("save: no such variable '%s'", argv[i].c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
725 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
726 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
727 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
728 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
729 void load_save_system::dump_octave_core (void) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
730 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
731 if (m_crash_dumps_octave_core) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
732 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
733 // FIXME: should choose better filename? |
604 | 734 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
735 const char *fname = m_octave_core_file_name.c_str (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
736 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
737 message (nullptr, "attempting to save variables to '%s'...", fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
738 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
739 load_save_format fmt (BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
740 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
741 bool save_as_floats = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
742 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
743 bool append = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
744 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
745 bool use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
746 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
747 load_save_system::parse_save_options (m_octave_core_file_options, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
748 fmt, append, save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
749 use_zlib); |
604 | 750 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
751 std::ios::openmode mode = std::ios::out; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
752 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
753 // Matlab v7 files are always compressed |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
754 if (fmt.type () == MAT7_BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
755 use_zlib = false; |
2511 | 756 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
757 if (fmt.type () == BINARY |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
758 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
759 || fmt.type () == HDF5 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
760 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
761 || fmt.type () == MAT_BINARY |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
762 || fmt.type () == MAT5_BINARY |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
763 || fmt.type () == MAT7_BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
764 mode |= std::ios::binary; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
765 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
766 mode |= append ? std::ios::ate : std::ios::trunc; |
604 | 767 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
768 #if defined (HAVE_HDF5) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
769 if (fmt.type () == HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
770 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
771 hdf5_ofstream file (fname, mode); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
772 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
773 if (file.file_id >= 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
774 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
775 dump_octave_core (file, fname, fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
776 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
777 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
778 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
779 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
780 warning ("dump_octave_core: unable to open '%s' for writing...", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
781 fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
782 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
783 else |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
784 #endif |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
785 // don't insert any commands here! The open brace below must |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
786 // go with the else above! |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
787 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
788 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
789 if (use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
790 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
791 gzofstream file (fname, mode); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
792 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
793 if (file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
794 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
795 dump_octave_core (file, fname, fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
796 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
797 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
798 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
799 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
800 warning ("dump_octave_core: unable to open '%s' for writing...", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
801 fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
802 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
803 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
804 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
805 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
806 std::ofstream file = sys::ofstream (fname, mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
807 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
808 if (file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
809 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
810 dump_octave_core (file, fname, fmt, save_as_floats); |
3687 | 811 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
812 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
813 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
814 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
815 warning ("dump_octave_core: unable to open '%s' for writing...", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
816 fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
817 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
818 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
819 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
820 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
821 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
822 void load_save_system::write_header (std::ostream& os, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
823 const load_save_format& fmt) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
824 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
825 switch (fmt.type ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
826 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
827 case BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
828 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
829 os << (mach_info::words_big_endian () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
830 ? "Octave-1-B" : "Octave-1-L"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
831 |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
832 mach_info::float_format flt_fmt = mach_info::native_float_format (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
833 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
834 char tmp = static_cast<char> (float_format_to_mopt_digit (flt_fmt)); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
835 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
836 os.write (&tmp, 1); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
837 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
838 break; |
3688 | 839 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
840 case MAT5_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
841 case MAT7_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
842 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
843 char const *versionmagic; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
844 char headertext[128]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
845 sys::gmtime now; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
846 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
847 // ISO 8601 format date |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
848 const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave " |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
849 OCTAVE_VERSION ", %Y-%m-%d %T UTC"; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
850 std::string comment_string = now.strftime (matlab_format); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
851 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
852 size_t len = std::min (comment_string.length (), static_cast<size_t> (124)); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
853 memset (headertext, ' ', 124); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
854 memcpy (headertext, comment_string.data (), len); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
855 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
856 // The first pair of bytes give the version of the MAT file |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
857 // format. The second pair of bytes form a magic number which |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
858 // signals a MAT file. MAT file data are always written in |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
859 // native byte order. The order of the bytes in the second |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
860 // pair indicates whether the file was written by a big- or |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
861 // little-endian machine. However, the version number is |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
862 // written in the *opposite* byte order from everything else! |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
863 if (mach_info::words_big_endian ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
864 versionmagic = "\x01\x00\x4d\x49"; // this machine is big endian |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
865 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
866 versionmagic = "\x00\x01\x49\x4d"; // this machine is little endian |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
867 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
868 memcpy (headertext+124, versionmagic, 4); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
869 os.write (headertext, 128); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
870 } |
604 | 871 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
872 break; |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
873 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
874 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
875 case HDF5: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
876 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
877 case TEXT: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
878 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
879 sys::localtime now; |
3136 | 880 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
881 std::string comment_string = now.strftime (m_save_header_format_string); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
882 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
883 if (! comment_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
884 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
885 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
886 if (fmt.type () == HDF5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
887 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
888 hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
889 H5Gset_comment (hs.file_id, "/", comment_string.c_str ()); |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
890 } |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
891 else |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
892 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
893 os << comment_string << "\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
894 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
895 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
896 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
897 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
898 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
899 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
900 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
901 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
902 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
903 // Save variables with names matching PATTERN on stream OS in the |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
904 // format specified by FMT. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
905 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
906 size_t load_save_system::save_vars (std::ostream& os, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
907 const std::string& pattern, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
908 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
909 bool save_as_floats) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
910 { |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
911 tree_evaluator& tw = m_interpreter.get_evaluator (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
912 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
913 symbol_info_list syminfo_list = tw.glob_symbol_info (pattern); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
914 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
915 size_t saved = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
916 |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
917 for (const auto& syminfo : syminfo_list) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
918 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
919 do_save (os, syminfo, fmt, save_as_floats); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
920 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
921 saved++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
922 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
923 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
924 return saved; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
925 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
926 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
927 void load_save_system::do_save (std::ostream& os, const octave_value& tc, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
928 const std::string& name, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
929 const std::string& help, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
930 bool global, const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
931 bool save_as_floats) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
932 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
933 switch (fmt.type ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
934 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
935 case TEXT: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
936 save_text_data (os, tc, name, global, 0); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
937 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
938 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
939 case BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
940 save_binary_data (os, tc, name, help, global, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
941 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
942 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
943 case MAT_ASCII: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
944 if (! save_mat_ascii_data (os, tc, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
945 fmt.options () & MAT_ASCII_LONG ? 16 : 8, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
946 fmt.options () & MAT_ASCII_TABS)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
947 warning ("save: unable to save %s in ASCII format", name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
948 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
949 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
950 case MAT_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
951 save_mat_binary_data (os, tc, name); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
952 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
953 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
954 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
955 case HDF5: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
956 save_hdf5_data (os, tc, name, help, global, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
957 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
958 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
959 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
960 case MAT5_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
961 save_mat5_binary_element (os, tc, name, global, false, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
962 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
963 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
964 case MAT7_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
965 save_mat5_binary_element (os, tc, name, global, true, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
966 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
967 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
968 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
969 err_unrecognized_data_fmt ("save"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
970 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
971 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
972 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
973 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
974 // Save the info from SR on stream OS in the format specified by FMT. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
975 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
976 void load_save_system::do_save (std::ostream& os, |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
977 const symbol_info& syminfo, |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
978 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
979 bool save_as_floats) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
980 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
981 octave_value val = syminfo.value (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
982 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
983 if (val.is_defined ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
984 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
985 std::string name = syminfo.name (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
986 std::string help; |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
987 bool global = syminfo.is_global (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
988 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
989 do_save (os, val, name, help, global, fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
990 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
991 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
992 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
993 // save fields of a scalar structure STR matching PATTERN on stream OS |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
994 // in the format specified by FMT. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
995 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
996 size_t load_save_system::save_fields (std::ostream& os, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
997 const octave_scalar_map& m, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
998 const std::string& pattern, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
999 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1000 bool save_as_floats) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1001 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1002 glob_match pat (pattern); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1003 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1004 size_t saved = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1005 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1006 for (auto it = m.begin (); it != m.end (); it++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1007 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1008 std::string empty_str; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1009 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1010 if (pat.match (m.key (it))) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1011 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1012 do_save (os, m.contents (it), m.key (it), empty_str, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1013 0, fmt, save_as_floats); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1014 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1015 saved++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1016 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1017 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1018 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1019 return saved; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1020 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1021 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1022 void load_save_system::dump_octave_core (std::ostream& os, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1023 const char *fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1024 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1025 bool save_as_floats) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1026 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1027 write_header (os, fmt); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1028 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
1029 tree_evaluator& tw = m_interpreter.get_evaluator (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1030 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
1031 symbol_info_list syminfo_list = tw.top_scope_symbol_info (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1032 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1033 double save_mem_size = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1034 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1035 for (const auto& syminfo : syminfo_list) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1036 { |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1037 octave_value val = syminfo.value (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1038 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1039 std::string name = syminfo.name (); |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1040 std::string help; |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1041 bool global = syminfo.is_global (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1042 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1043 double val_size = val.byte_size () / 1024; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1044 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1045 // FIXME: maybe we should try to throw out the largest first... |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1046 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1047 if (m_octave_core_file_limit < 0 |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1048 || save_mem_size + val_size < m_octave_core_file_limit) |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1049 { |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1050 save_mem_size += val_size; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1051 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1052 do_save (os, val, name, help, global, fmt, save_as_floats); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1053 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1054 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1055 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1056 message (nullptr, "save to '%s' complete", fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1057 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1058 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1059 // Install a variable with name NAME and the value VAL in the |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1060 // symbol table. If GLOBAL is TRUE, make the variable global. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1061 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1062 void load_save_system::install_loaded_variable (const std::string& name, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1063 const octave_value& val, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1064 bool global, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1065 const std::string& /*doc*/) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1066 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1067 m_interpreter.install_variable (name, val, global); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1068 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1069 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1070 std::string load_save_system::init_save_header_format (void) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1071 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1072 return |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1073 (std::string ("# Created by Octave " OCTAVE_VERSION |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1074 ", %a %b %d %H:%M:%S %Y %Z <") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1075 + sys::env::get_user_name () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1076 + '@' |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1077 + sys::env::get_host_name () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1078 + '>'); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1079 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1080 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1081 load_save_format |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1082 load_save_system::get_file_format (std::istream& file, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1083 const std::string& filename) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1084 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1085 load_save_format retval = load_save_system::UNKNOWN; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1086 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1087 mach_info::float_format flt_fmt |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1088 = mach_info::flt_fmt_unknown; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1089 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1090 bool swap = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1091 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1092 if (read_binary_file_header (file, swap, flt_fmt, true) == 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1093 retval = BINARY; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1094 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1095 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1096 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1097 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1098 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1099 int32_t mopt, nr, nc, imag, len; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1100 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1101 int err = read_mat_file_header (file, swap, mopt, nr, nc, imag, len, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1102 true); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1103 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1104 if (! err) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1105 retval = MAT_BINARY; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1106 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1107 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1108 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1109 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1110 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1111 err = read_mat5_binary_file_header (file, swap, true, filename); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1112 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1113 if (! err) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1114 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1115 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1116 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1117 retval = MAT5_BINARY; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1118 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1119 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1120 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1121 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1122 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1123 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1124 std::string name_val = extract_keyword (file, "name"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1125 std::string type_val = extract_keyword (file, "type"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1126 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1127 if (name_val.empty () != true && type_val.empty () != true) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1128 retval = TEXT; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1129 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1130 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1131 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1132 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1133 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1134 // FIXME: looks_like_mat_ascii_file does not check |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1135 // to see whether the file contains numbers. It |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1136 // just skips comments and checks for the same |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1137 // number of words on each line. We may need a |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1138 // better check here. The best way to do that might |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1139 // be just to try to read the file and see if it |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1140 // works. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1141 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1142 if (looks_like_mat_ascii_file (file, filename)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1143 retval = MAT_ASCII; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1144 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1145 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1146 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1147 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1148 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1149 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1150 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1151 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1152 octave_value_list |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1153 load_save_system::load (const octave_value_list& args, int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1154 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1155 octave_value_list retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1156 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1157 int argc = args.length () + 1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1158 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1159 string_vector argv = args.make_argv ("load"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1160 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1161 int i = 1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1162 std::string orig_fname = ""; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1163 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1164 // Function called with Matlab-style ["filename", options] syntax |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1165 if (argc > 1 && ! argv[1].empty () && argv[1].at (0) != '-') |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1166 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1167 orig_fname = argv[1]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1168 i++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1169 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1170 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1171 // It isn't necessary to have the default load format stored in a |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1172 // user preference variable since we can determine the type of file |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1173 // as we are reading. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1174 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1175 load_save_format format = UNKNOWN; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1176 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1177 bool list_only = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1178 bool verbose = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1179 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1180 for (; i < argc; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1181 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1182 if (argv[i] == "-text" || argv[i] == "-t") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1183 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1184 format = TEXT; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1185 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1186 else if (argv[i] == "-binary" || argv[i] == "-b") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1187 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1188 format = BINARY; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1189 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1190 else if (argv[i] == "-hdf5" || argv[i] == "-h") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1191 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1192 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1193 format = HDF5; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1194 #else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1195 err_disabled_feature ("load", "HDF5"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1196 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1197 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1198 else if (argv[i] == "-ascii" || argv[i] == "-a") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1199 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1200 format = MAT_ASCII; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1201 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1202 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1203 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1204 error ("load: Matlab file format -v7.3 is not yet implemented"); |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1205 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1206 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1207 || argv[i] == "-mat7-binary") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1208 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1209 format = MAT7_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1210 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1211 else if (argv[i] == "-mat" || argv[i] == "-m" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1212 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1213 || argv[i] == "-mat-binary") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1214 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1215 format = MAT5_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1216 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1217 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4" |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1218 || argv[i] == "-mat4-binary") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1219 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1220 format = MAT_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1221 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1222 else if (argv[i] == "-force" || argv[i] == "-f") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1223 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1224 // Silently ignore this |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1225 // warning ("load: -force ignored"); |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1226 } |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1227 else if (argv[i] == "-import" || argv[i] == "-i") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1228 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1229 warning ("load: -import ignored"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1230 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1231 else if (argv[i] == "-list" || argv[i] == "-l") |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1232 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1233 list_only = true; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1234 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1235 else if (argv[i] == "-verbose" || argv[i] == "-v") |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1236 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1237 verbose = true; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1238 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1239 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1240 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1241 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1242 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1243 if (orig_fname == "") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1244 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1245 if (i == argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1246 print_usage (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1247 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1248 orig_fname = argv[i]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1249 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1250 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1251 i--; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1252 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1253 mach_info::float_format flt_fmt = mach_info::flt_fmt_unknown; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1254 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1255 bool swap = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1256 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1257 if (orig_fname == "-") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1258 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1259 i++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1260 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1261 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1262 if (format.type () == HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1263 error ("load: cannot read HDF5 format from stdin"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1264 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1265 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1266 if (format.type () != UNKNOWN) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1267 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1268 // FIXME: if we have already seen EOF on a previous call, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1269 // how do we fix up the state of std::cin so that we can get |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1270 // additional input? I'm afraid that we can't fix this |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1271 // using std::cin only. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1272 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1273 retval = load_vars (std::cin, orig_fname, format, flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1274 list_only, swap, verbose, argv, i, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1275 argc, nargout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1276 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1277 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1278 error ("load: must specify file format if reading from stdin"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1279 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1280 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1281 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1282 std::string fname = sys::file_ops::tilde_expand (orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1283 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1284 fname = find_file_to_load (fname, orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1285 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1286 bool use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1287 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1288 if (format.type () == UNKNOWN) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1289 format = get_file_format (fname, orig_fname, use_zlib); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1290 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1291 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1292 if (format.type () == HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1293 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1294 i++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1295 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1296 hdf5_ifstream hdf5_file (fname.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1297 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1298 if (hdf5_file.file_id < 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1299 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1300 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1301 retval = load_vars (hdf5_file, orig_fname, format, flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1302 list_only, swap, verbose, argv, i, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1303 argc, nargout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1304 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1305 hdf5_file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1306 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1307 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1308 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1309 // don't insert any statements here; the "else" above has to |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1310 // go with the "if" below!!!!! |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1311 if (format.type () != UNKNOWN) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1312 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1313 i++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1314 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1315 // Always open in binary mode and handle various |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1316 // line-endings explicitly. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1317 std::ios::openmode mode = std::ios::in | std::ios::binary; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1318 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1319 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1320 if (use_zlib) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1321 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1322 gzifstream file (fname.c_str (), mode); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1323 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1324 if (! file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1325 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1326 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1327 if (format.type () == BINARY) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1328 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1329 if (read_binary_file_header (file, swap, flt_fmt) < 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1330 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1331 if (file) file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1332 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1333 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1334 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1335 else if (format.type () == MAT5_BINARY |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1336 || format.type () == MAT7_BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1337 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1338 if (read_mat5_binary_file_header (file, swap, false, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1339 orig_fname) < 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1340 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1341 if (file) file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1342 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1343 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1344 } |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1345 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1346 retval = load_vars (file, orig_fname, format, flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1347 list_only, swap, verbose, argv, i, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1348 argc, nargout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1349 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1350 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1351 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1352 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1353 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1354 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
1355 std::ifstream file = sys::ifstream (fname.c_str (), mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1356 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1357 if (! file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1358 error ("load: unable to open input file '%s'", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1359 orig_fname.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1360 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1361 if (format.type () == BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1362 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1363 if (read_binary_file_header (file, swap, flt_fmt) < 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1364 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1365 if (file) file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1366 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1367 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1368 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1369 else if (format.type () == MAT5_BINARY |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1370 || format.type () == MAT7_BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1371 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1372 if (read_mat5_binary_file_header (file, swap, false, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1373 orig_fname) < 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1374 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1375 if (file) file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1376 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1377 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1378 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1379 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1380 retval = load_vars (file, orig_fname, format, flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1381 list_only, swap, verbose, argv, i, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1382 argc, nargout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1383 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1384 file.close (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1385 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1386 } |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1387 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1388 error ("load: unable to determine file format of '%s'", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1389 orig_fname.c_str ()); |
2511 | 1390 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1391 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1392 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1393 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1394 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1395 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1396 octave_value_list |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1397 load_save_system::save (const octave_value_list& args, int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1398 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1399 // Here is where we would get the default save format if it were |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1400 // stored in a user preference variable. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1401 load_save_format format = TEXT; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1402 bool save_as_floats = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1403 bool append = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1404 bool use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1405 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1406 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1407 // get default options |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1408 parse_save_options (save_default_options (), format, append, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1409 save_as_floats, use_zlib); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1410 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1411 // override from command line |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1412 string_vector argv = args.make_argv (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1413 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1414 argv = parse_save_options (argv, format, append, save_as_floats, use_zlib); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1415 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1416 int argc = argv.numel (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1417 int i = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1418 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1419 if (i == argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1420 print_usage (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1421 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1422 if (save_as_floats && format.type () == TEXT) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1423 error ("save: cannot specify both -text and -float-binary"); |
2511 | 1424 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1425 octave_value_list retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1426 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1427 if (argv[i] == "-") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1428 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1429 i++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1430 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1431 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1432 if (format.type () == HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1433 error ("save: cannot write HDF5 format to stdout"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1434 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1435 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1436 // don't insert any commands here! the brace below must go |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1437 // with the "else" above! |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1438 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1439 if (append) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1440 warning ("save: ignoring -append option for output to stdout"); |
604 | 1441 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1442 if (nargout == 0) |
26009
3fc9d7453ba6
where possible, use octave_stdout and avoid including <iostream>
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
1443 save_vars (argv, i, argc, octave_stdout, format, |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1444 save_as_floats, true); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1445 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1446 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1447 std::ostringstream output_buf; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1448 save_vars (argv, i, argc, output_buf, format, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1449 save_as_floats, true); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1450 retval = octave_value (output_buf.str()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1451 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1452 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1453 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1454 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1455 // Guard against things like 'save a*', which are probably mistakes... |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1456 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1457 else if (i == argc - 1 && glob_pattern_p (argv[i])) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1458 print_usage (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1459 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1460 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1461 std::string fname = sys::file_ops::tilde_expand (argv[i]); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1462 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1463 i++; |
2095 | 1464 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1465 // Matlab v7 files are always compressed |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1466 if (format.type () == MAT7_BINARY) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1467 use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1468 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1469 std::ios::openmode mode |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1470 = (append ? (std::ios::app | std::ios::ate) : std::ios::out); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1471 |
28993
cc287e633588
Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28660
diff
changeset
|
1472 // Always open in binary mode to save line endings as is. |
cc287e633588
Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28660
diff
changeset
|
1473 mode |= std::ios::binary; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1474 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1475 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1476 if (format.type () == HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1477 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1478 // FIXME: It should be possible to append to HDF5 files. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1479 if (append) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1480 error ("save: appending to HDF5 files is not implemented"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1481 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1482 std::string ascii_fname = sys::get_ASCII_filename (fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1483 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1484 bool write_header_info |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1485 = ! (append && H5Fis_hdf5 (ascii_fname.c_str ()) > 0); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1486 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1487 hdf5_ofstream hdf5_file (fname.c_str (), mode); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1488 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1489 if (hdf5_file.file_id == -1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1490 err_file_open ("save", fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1491 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1492 save_vars (argv, i, argc, hdf5_file, format, save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1493 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1494 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1495 hdf5_file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1496 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1497 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1498 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1499 // don't insert any statements here! The brace below must go |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1500 // with the "else" above! |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1501 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1502 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1503 if (use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1504 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1505 gzofstream file (fname.c_str (), mode); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1506 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1507 if (! file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1508 err_file_open ("save", fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1509 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1510 bool write_header_info = ! file.tellp (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1511 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1512 save_vars (argv, i, argc, file, format, save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1513 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1514 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1515 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1516 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1517 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1518 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1519 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
1520 std::ofstream file = sys::ofstream (fname.c_str (), mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1521 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1522 if (! file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1523 err_file_open ("save", fname); |
621 | 1524 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1525 bool write_header_info = ! file.tellp (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1526 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1527 save_vars (argv, i, argc, file, format, save_as_floats, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1528 write_header_info); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1529 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1530 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1531 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1532 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1533 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1534 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1535 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1536 } |
863 | 1537 } |
1538 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1539 void |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1540 dump_octave_core (void) |
6159 | 1541 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1542 octave::load_save_system& load_save_sys |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1543 = octave::__get_load_save_system__ ("dump_octave_core"); |
6159 | 1544 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1545 load_save_sys.dump_octave_core (); |
6159 | 1546 } |
1547 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1548 DEFMETHOD (load, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1549 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1550 @deftypefn {} {} load file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1551 @deftypefnx {} {} load options file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1552 @deftypefnx {} {} load options file v1 v2 @dots{} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1553 @deftypefnx {} {S =} load ("options", "file", "v1", "v2", @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1554 @deftypefnx {} {} load file options |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1555 @deftypefnx {} {} load file options v1 v2 @dots{} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1556 @deftypefnx {} {S =} load ("file", "options", "v1", "v2", @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1557 Load the named variables @var{v1}, @var{v2}, @dots{}, from the file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1558 @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1559 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1560 If no variables are specified then all variables found in the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1561 file will be loaded. As with @code{save}, the list of variables to extract |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1562 can be full names or use a pattern syntax. The format of the file is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1563 automatically detected but may be overridden by supplying the appropriate |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1564 option. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1565 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1566 If load is invoked using the functional form |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1567 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1568 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1569 load ("-option1", @dots{}, "file", "v1", @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1570 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1571 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1572 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1573 then the @var{options}, @var{file}, and variable name arguments |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1574 (@var{v1}, @dots{}) must be specified as character strings. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1575 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1576 If a variable that is not marked as global is loaded from a file when a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1577 global symbol with the same name already exists, it is loaded in the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1578 global symbol table. Also, if a variable is marked as global in a file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1579 and a local symbol exists, the local symbol is moved to the global |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1580 symbol table and given the value from the file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1581 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1582 If invoked with a single output argument, Octave returns data instead |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1583 of inserting variables in the symbol table. If the data file contains |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1584 only numbers (TAB- or space-delimited columns), a matrix of values is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1585 returned. Otherwise, @code{load} returns a structure with members |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1586 corresponding to the names of the variables in the file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1587 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1588 The @code{load} command can read data stored in Octave's text and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1589 binary formats, and @sc{matlab}'s binary format. If compiled with zlib |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1590 support, it can also load gzip-compressed files. It will automatically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1591 detect the type of file and do conversion from different floating point |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1592 formats (currently only IEEE big and little endian, though other formats |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1593 may be added in the future). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1594 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1595 Valid options for @code{load} are listed in the following table. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1596 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1597 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1598 @item -force |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1599 This option is accepted for backward compatibility but is ignored. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1600 Octave now overwrites variables currently in memory with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1601 those of the same name found in the file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1602 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1603 @item -ascii |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1604 Force Octave to assume the file contains columns of numbers in text format |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1605 without any header or other information. Data in the file will be loaded |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1606 as a single numeric matrix with the name of the variable derived from the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1607 name of the file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1608 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1609 @item -binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1610 Force Octave to assume the file is in Octave's binary format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1611 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1612 @item -hdf5 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1613 Force Octave to assume the file is in @sc{hdf5} format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1614 (@sc{hdf5} is a free, portable binary format developed by the National |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1615 Center for Supercomputing Applications at the University of Illinois.) |
27065
ad77f3204eda
doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1616 Note that Octave can only read @sc{hdf5} files that were created by itself with |
ad77f3204eda
doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1617 @code{save}. This format is only available if Octave was built with a link to |
ad77f3204eda
doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1618 the @sc{hdf5} libraries. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1619 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1620 @item -import |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1621 This option is accepted for backward compatibility but is ignored. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1622 Octave can now support multi-dimensional HDF data and automatically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1623 modifies variable names if they are invalid Octave identifiers. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1624 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1625 @item -text |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1626 Force Octave to assume the file is in Octave's text format. |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1627 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1628 @item -v7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1629 @itemx -V7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1630 @itemx -7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1631 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1632 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1633 @item -v7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1634 @itemx -V7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1635 @itemx -7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1636 @itemx -mat7-binary |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1637 Force Octave to assume the file is in @sc{matlab}'s version 7 binary format. |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1638 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1639 @item -v6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1640 @itemx -V6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1641 @itemx -6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1642 @itemx -mat |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1643 @itemx -mat-binary |
28660
dc80e087df4b
maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents:
28217
diff
changeset
|
1644 Force Octave to assume the file is in @sc{matlab}'s version 6 binary format. |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1645 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1646 @item -v4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1647 @itemx -V4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1648 @itemx -4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1649 @itemx -mat4-binary |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1650 Force Octave to assume the file is in @sc{matlab}'s version 4 binary format. |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1651 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1652 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1653 @seealso{save, dlmwrite, csvwrite, fwrite} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1654 @end deftypefn */) |
863 | 1655 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1656 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
25604
ca413f326224
Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25580
diff
changeset
|
1657 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1658 return load_save_sys.load (args, nargout); |
604 | 1659 } |
1660 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1661 DEFMETHOD (save, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1662 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1663 @deftypefn {} {} save file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1664 @deftypefnx {} {} save options file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1665 @deftypefnx {} {} save options file @var{v1} @var{v2} @dots{} |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1666 @deftypefnx {} {} save options file -struct @var{STRUCT} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1667 @deftypefnx {} {} save options file -struct @var{STRUCT} @var{f1} @var{f2} @dots{} |
23047
97a9fd0af57b
doc: Don't use @code in @deftypefn because it expands badly in plain text format.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1668 @deftypefnx {} {} save - @var{v1} @var{v2} @dots{} |
97a9fd0af57b
doc: Don't use @code in @deftypefn because it expands badly in plain text format.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1669 @deftypefnx {} {@var{str} =} save ("-", @qcode{"@var{v1}"}, @qcode{"@var{v2}"}, @dots{}) |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1670 Save the named variables @var{v1}, @var{v2}, @dots{}, in the file @var{file}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1671 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1672 The special filename @samp{-} may be used to return the content of the |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1673 variables as a string. If no variable names are listed, Octave saves all the |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1674 variables in the current scope. Otherwise, full variable names or pattern |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1675 syntax can be used to specify the variables to save. If the @option{-struct} |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1676 modifier is used then the fields of the @strong{scalar} struct are saved as if |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1677 they were variables with the corresponding field names. The @option{-struct} |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1678 option can be combined with specific field names @var{f1}, @var{f2}, @dots{} to |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1679 write only certain fields to the file. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1680 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1681 Valid options for the @code{save} command are listed in the following table. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1682 Options that modify the output format override the format specified by |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1683 @code{save_default_options}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1684 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1685 If save is invoked using the functional form |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1686 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1687 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1688 save ("-option1", @dots{}, "file", "v1", @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1689 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1690 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1691 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1692 then the @var{options}, @var{file}, and variable name arguments (@var{v1}, |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1693 @dots{}) must be specified as character strings. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1694 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1695 If called with a filename of @qcode{"-"}, write the output to stdout if nargout |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1696 is 0, otherwise return the output in a character string. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1697 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1698 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1699 @item -append |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1700 Append to the destination instead of overwriting. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1701 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1702 @item -ascii |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1703 Save a matrix in a text file without a header or any other information. The |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1704 matrix must be 2-D and only the real part of any complex value is written to |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1705 the file. Numbers are stored in single-precision format and separated by |
24986
0b9e7fcaab91
doc: grammarcheck docstrings in C++ files ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
1706 spaces. Additional options for the @option{-ascii} format are |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1707 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1708 @table @code |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1709 @item -double |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1710 Store numbers in double-precision format. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1711 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1712 @item -tabs |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1713 Separate numbers with tabs. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1714 @end table |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1715 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1716 @item -binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1717 Save the data in Octave's binary data format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1718 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1719 @item -float-binary |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1720 Save the data in Octave's binary data format but using only single precision. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1721 Use this format @strong{only} if you know that all the values to be saved can |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1722 be represented in single precision. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1723 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1724 @item -hdf5 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1725 Save the data in @sc{hdf5} format. |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1726 (HDF5 is a free, portable, binary format developed by the National Center for |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1727 Supercomputing Applications at the University of Illinois.) This format is only |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1728 available if Octave was built with a link to the @sc{hdf5} libraries. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1729 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1730 @item -float-hdf5 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1731 Save the data in @sc{hdf5} format but using only single precision. Use this |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1732 format @strong{only} if you know that all the values to be saved can be |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1733 represented in single precision. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1734 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1735 @item -text |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1736 Save the data in Octave's text data format. (default) |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1737 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1738 @item -v7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1739 @itemx -V7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1740 @itemx -7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1741 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1742 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1743 @item -v7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1744 @itemx -V7 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1745 @itemx -7 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1746 @itemx -mat7-binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1747 Save the data in @sc{matlab}'s v7 binary data format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1748 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1749 @item -v6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1750 @itemx -V6 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1751 @itemx -6 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1752 @itemx -mat |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1753 @itemx -mat-binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1754 Save the data in @sc{matlab}'s v6 binary data format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1755 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1756 @item -v4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1757 @itemx -V4 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1758 @itemx -4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1759 @itemx -mat4-binary |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1760 Save the data in @sc{matlab}'s v4 binary data format. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1761 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1762 @item -zip |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1763 @itemx -z |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1764 Use the gzip algorithm to compress the file. This works on files that are |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1765 compressed with gzip outside of Octave, and gzip can also be used to convert |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1766 the files for backward compatibility. This option is only available if Octave |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1767 was built with a link to the zlib libraries. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1768 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1769 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1770 The list of variables to save may use wildcard patterns containing the |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1771 following special characters: |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1772 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1773 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1774 @item ? |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1775 Match any single character. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1776 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1777 @item * |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1778 Match zero or more characters. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1779 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1780 @item [ @var{list} ] |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1781 Match the list of characters specified by @var{list}. If the first character |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1782 is @code{!} or @code{^}, match all characters except those specified by |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1783 @var{list}. For example, the pattern @code{[a-zA-Z]} will match all lower and |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1784 uppercase alphabetic characters. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1785 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1786 Wildcards may also be used in the field name specifications when using the |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1787 @option{-struct} modifier (but not in the struct name itself). |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1788 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1789 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1790 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1791 Except when using the @sc{matlab} binary data file format or the @samp{-ascii} |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1792 format, saving global variables also saves the global status of the variable. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1793 If the variable is restored at a later time using @samp{load}, it will be |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1794 restored as a global variable. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1795 |
28660
dc80e087df4b
maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents:
28217
diff
changeset
|
1796 Example: |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1797 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1798 The command |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1799 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1800 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1801 save -binary data a b* |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1802 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1803 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1804 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1805 saves the variable @samp{a} and all variables beginning with @samp{b} to the |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1806 file @file{data} in Octave's binary format. |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1807 @seealso{load, save_default_options, save_header_format_string, save_precision, dlmread, csvread, fread} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1808 @end deftypefn */) |
604 | 1809 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1810 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
6759 | 1811 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1812 return load_save_sys.save (args, nargout); |
604 | 1813 } |
1814 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1815 DEFMETHOD (crash_dumps_octave_core, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1816 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1817 @deftypefn {} {@var{val} =} crash_dumps_octave_core () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1818 @deftypefnx {} {@var{old_val} =} crash_dumps_octave_core (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1819 @deftypefnx {} {} crash_dumps_octave_core (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1820 Query or set the internal variable that controls whether Octave tries |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1821 to save all current variables to the file @file{octave-workspace} if it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1822 crashes or receives a hangup, terminate or similar signal. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1823 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1824 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1825 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1826 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1827 @seealso{octave_core_file_limit, octave_core_file_name, octave_core_file_options} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1828 @end deftypefn */) |
2194 | 1829 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1830 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1831 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1832 return load_save_sys.crash_dumps_octave_core (args, nargout); |
2194 | 1833 } |
1834 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1835 DEFMETHOD (save_default_options, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1836 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1837 @deftypefn {} {@var{val} =} save_default_options () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1838 @deftypefnx {} {@var{old_val} =} save_default_options (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1839 @deftypefnx {} {} save_default_options (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1840 Query or set the internal variable that specifies the default options |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1841 for the @code{save} command, and defines the default format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1842 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1843 The default value is @qcode{"-text"} (Octave's own text-based file format). |
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1844 See the documentation of the @code{save} command for other choices. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1845 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1846 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1847 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1848 The original variable value is restored when exiting the function. |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1849 @seealso{save, save_header_format_string, save_precision} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1850 @end deftypefn */) |
4788 | 1851 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1852 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1853 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1854 return load_save_sys.save_default_options (args, nargout); |
4788 | 1855 } |
1856 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1857 DEFMETHOD (octave_core_file_limit, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1858 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1859 @deftypefn {} {@var{val} =} octave_core_file_limit () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1860 @deftypefnx {} {@var{old_val} =} octave_core_file_limit (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1861 @deftypefnx {} {} octave_core_file_limit (@var{new_val}, "local") |
25106
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1862 Query or set the internal variable that specifies the maximum amount of memory |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1863 that Octave will save when writing a crash dump file. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1864 |
25106
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1865 The limit is measured in kilobytes and is applied to the top-level workspace. |
25579
07c2c42f457e
doc: Miscellaneous documentation fixes all over the manual (bug #54288).
Rik <rik@octave.org>
parents:
25201
diff
changeset
|
1866 The name of the crash dump file is specified by |
07c2c42f457e
doc: Miscellaneous documentation fixes all over the manual (bug #54288).
Rik <rik@octave.org>
parents:
25201
diff
changeset
|
1867 @var{octave_core_file_name}. |
25106
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1868 |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1869 If @var{octave_core_file_options} flags specify a binary format, then |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1870 @var{octave_core_file_limit} will be approximately the maximum size of the |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1871 file. If a text file format is used, then the file could be much larger than |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1872 the limit. The default value is -1 (unlimited). |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1873 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1874 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1875 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1876 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1877 @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_options} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1878 @end deftypefn */) |
3709 | 1879 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1880 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1881 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1882 return load_save_sys.octave_core_file_limit (args, nargout); |
3709 | 1883 } |
1884 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1885 DEFMETHOD (octave_core_file_name, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1886 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1887 @deftypefn {} {@var{val} =} octave_core_file_name () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1888 @deftypefnx {} {@var{old_val} =} octave_core_file_name (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1889 @deftypefnx {} {} octave_core_file_name (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1890 Query or set the internal variable that specifies the name of the file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1891 used for saving data from the top-level workspace if Octave aborts. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1892 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1893 The default value is @qcode{"octave-workspace"} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1894 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1895 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1896 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1897 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1898 @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_options} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1899 @end deftypefn */) |
2194 | 1900 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1901 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1902 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1903 return load_save_sys.octave_core_file_name (args, nargout); |
5794 | 1904 } |
4791 | 1905 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1906 DEFMETHOD (octave_core_file_options, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1907 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1908 @deftypefn {} {@var{val} =} octave_core_file_options () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1909 @deftypefnx {} {@var{old_val} =} octave_core_file_options (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1910 @deftypefnx {} {} octave_core_file_options (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1911 Query or set the internal variable that specifies the options used for |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1912 saving the workspace data if Octave aborts. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1913 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1914 The value of @code{octave_core_file_options} should follow the same format |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1915 as the options for the @code{save} function. The default value is Octave's |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1916 binary format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1917 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1918 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1919 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1920 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1921 @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_limit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1922 @end deftypefn */) |
5794 | 1923 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1924 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1925 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1926 return load_save_sys.octave_core_file_options (args, nargout); |
5794 | 1927 } |
2194 | 1928 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1929 DEFMETHOD (save_header_format_string, interp, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1930 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1931 @deftypefn {} {@var{val} =} save_header_format_string () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1932 @deftypefnx {} {@var{old_val} =} save_header_format_string (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1933 @deftypefnx {} {} save_header_format_string (@var{new_val}, "local") |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1934 Query or set the internal variable that specifies the format string used for |
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1935 the comment line written at the beginning of text-format data files saved by |
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1936 Octave. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1937 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1938 The format string is passed to @code{strftime} and must begin with the |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1939 character @samp{#} and contain no newline characters. If the value of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1940 @code{save_header_format_string} is the empty string, the header comment is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1941 omitted from text-format data files. The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1942 @c Set example in small font to prevent overfull line |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1943 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1944 @smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1945 "# Created by Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1946 @end smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1947 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1948 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1949 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1950 The original variable value is restored when exiting the function. |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1951 @seealso{strftime, save_default_options} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1952 @end deftypefn */) |
5794 | 1953 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1954 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1955 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1956 return load_save_sys.save_header_format_string (args, nargout); |
2194 | 1957 } |