Mercurial > octave
annotate libinterp/corefcn/load-save.cc @ 26093:6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
* call-stack.h, call-stack.cc (stack_frame::make_symbol_info_list):
New function.
(stack_frame::glob_symbol_info): Use it.
(stack_frame::regexp_symbol_info, stack_frame::get_symbol_info):
New functions.
* (call_stack::regexp_symbol_info, call_stack::get_symbol_info,
call_stack::top_scope_symbol_info): New functions.
* load-save.cc (load_save_system::dump_octave_core): Call
call_stack::top_scope_symbol_info to get data to save.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 16 Nov 2018 02:42:26 -0500 |
parents | 661dfb062485 |
children | 00f796120a6d |
rev | line source |
---|---|
6763 | 1 /* |
604 | 2 |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24986
diff
changeset
|
3 Copyright (C) 1994-2018 John W. Eaton |
604 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24456
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24456
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
604 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
604 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24456
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
604 | 20 |
21 */ | |
22 | |
3911 | 23 // Author: John W. Eaton. |
24 // HDF5 support by Steven G. Johnson <stevenj@alum.mit.edu> | |
25 // Matlab v5 support by James R. Van Zandt <jrv@vanzandt.mv.com> | |
3687 | 26 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
28 # include "config.h" |
604 | 29 #endif |
30 | |
1343 | 31 #include <cstring> |
32 | |
4249 | 33 #include <fstream> |
3503 | 34 #include <iomanip> |
35 #include <iostream> | |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
36 #include <list> |
5765 | 37 #include <sstream> |
1728 | 38 #include <string> |
39 | |
1961 | 40 #include "byte-swap.h" |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
41 #include "dMatrix.h" |
1961 | 42 #include "data-conv.h" |
2926 | 43 #include "file-ops.h" |
6159 | 44 #include "file-stat.h" |
2926 | 45 #include "glob-match.h" |
2890 | 46 #include "lo-mappers.h" |
2318 | 47 #include "mach-info.h" |
3185 | 48 #include "oct-env.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
49 #include "oct-locbuf.h" |
3258 | 50 #include "oct-time.h" |
4171 | 51 #include "quit.h" |
1755 | 52 #include "str-vec.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
53 #include "strftime-wrapper.h" |
1755 | 54 |
4332 | 55 #include "Cell.h" |
1352 | 56 #include "defun.h" |
604 | 57 #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
|
58 #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
|
59 #include "interpreter.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23584
diff
changeset
|
60 #include "interpreter-private.h" |
6159 | 61 #include "load-path.h" |
1352 | 62 #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
|
63 #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
|
64 #include "ovl.h" |
3687 | 65 #include "oct-map.h" |
4332 | 66 #include "ov-cell.h" |
1352 | 67 #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
|
68 #include "syminfo.h" |
1352 | 69 #include "symtab.h" |
70 #include "sysdep.h" | |
71 #include "unwind-prot.h" | |
604 | 72 #include "utils.h" |
2371 | 73 #include "variables.h" |
3185 | 74 #include "version.h" |
3688 | 75 |
4633 | 76 #include "ls-hdf5.h" |
77 #include "ls-mat-ascii.h" | |
78 #include "ls-mat4.h" | |
79 #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
|
80 #include "ls-oct-text.h" |
4633 | 81 #include "ls-oct-binary.h" |
3688 | 82 |
10309 | 83 // 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
|
84 #if defined (close) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
85 # undef close |
10309 | 86 #endif |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
87 #if defined (open) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
88 # undef open |
5269 | 89 #endif |
90 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
91 #if defined (HAVE_ZLIB) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
92 # include "zfstream.h" |
10305
d6cdf08d0424
load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
93 #endif |
d6cdf08d0424
load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
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 namespace octave |
5794 | 96 { |
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
|
97 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
|
98 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
|
99 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
|
100 { |
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 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 } |
4788 | 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 // Return TRUE if NAME matches one of the given globbing PATTERNS. |
5369 | 110 |
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
|
111 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
|
112 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
|
113 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
|
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 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
|
116 { |
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 glob_match pattern (patterns[i]); |
604 | 118 |
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
|
119 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
|
120 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
|
121 } |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23603
diff
changeset
|
122 |
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
|
123 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
|
124 } |
25201
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25106
diff
changeset
|
125 |
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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 { |
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 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
|
132 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
|
133 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
|
134 magic[magic_len] = '\0'; |
604 | 135 |
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
|
136 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
|
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 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
|
139 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
|
140 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
|
141 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
142 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
|
143 error ("load: unable to read binary file"); |
604 | 144 |
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
|
145 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
|
146 } |
3688 | 147 |
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
|
148 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
|
149 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
|
150 |
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 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
|
152 |
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
|
153 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
|
154 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
155 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
|
156 error ("load: unrecognized binary format!"); |
2318 | 157 |
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
|
158 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
|
159 } |
3688 | 160 |
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
|
161 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
|
162 } |
604 | 163 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
164 #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
|
165 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
|
166 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
|
167 { |
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 bool retval = false; |
21972
d31e0f704d0b
Open files in binary mode when testing file format (bug #48201).
Rik <rik@octave.org>
parents:
21966
diff
changeset
|
169 |
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
|
170 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
|
171 |
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
|
172 std::ifstream file (ascii_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
|
173 std::ios::in | std::ios::binary); |
5269 | 174 |
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
|
175 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
|
176 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
|
177 && 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
|
178 retval = true; |
5269 | 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 file.close (); |
23777
cda0614beaec
Replace static instances of OCTAVE_LOCAL_BUFFER with local variables.
Rik <rik@octave.org>
parents:
23693
diff
changeset
|
181 |
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
|
182 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
|
183 } |
5269 | 184 #endif |
185 | |
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
|
186 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
|
187 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
|
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 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
|
190 |
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 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
|
192 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
|
193 |
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 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
|
195 || (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
|
196 { |
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 // 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
|
198 // 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
|
199 |
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 sys::file_stat fs (fname); |
604 | 201 |
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
|
202 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
|
203 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
|
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 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
|
206 { |
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 sys::file_stat fs (fname); |
604 | 208 |
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
|
209 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
|
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 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
|
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 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
|
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 } |
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 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
|
218 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
219 |
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 // Return TRUE if PATTERN has any special globbing chars in it. |
3019 | 221 |
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
|
222 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
|
223 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
|
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 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
|
226 |
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 int len = pattern.length (); |
604 | 228 |
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
|
229 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
|
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 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
|
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 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
|
234 { |
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 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
|
236 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
|
237 return true; |
1180 | 238 |
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
|
239 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
|
240 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
|
241 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
|
242 |
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 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
|
244 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
|
245 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
|
246 continue; |
1180 | 247 |
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
|
248 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
|
249 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
|
250 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
|
251 continue; |
604 | 252 |
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
|
253 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
|
254 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
|
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 } |
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 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
258 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
|
259 } |
3688 | 260 |
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
|
261 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
|
262 : 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 { |
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 #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
|
271 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
|
272 #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
|
273 } |
3688 | 274 |
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
|
275 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
|
276 { |
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 #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
|
278 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
|
279 #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
|
280 } |
4171 | 281 |
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
|
282 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
|
283 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
|
284 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
|
285 { |
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 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
|
287 "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
|
288 } |
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 |
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 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
|
291 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
|
292 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
|
293 { |
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 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
|
295 "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
|
296 } |
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
|
297 |
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
|
298 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
|
299 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
|
300 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
|
301 { |
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 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
|
303 "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
|
304 } |
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 |
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 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
|
307 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
|
308 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
|
309 { |
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 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
|
311 "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
|
312 } |
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
|
313 |
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
|
314 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
|
315 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
|
316 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
|
317 { |
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 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
|
319 "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
|
320 } |
604 | 321 |
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
|
322 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
|
323 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
|
324 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
|
325 { |
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 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
|
327 "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
|
328 } |
5977 | 329 |
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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 { |
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 load_save_format retval = UNKNOWN; |
5269 | 336 |
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
|
337 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
|
338 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
339 #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
|
340 // 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
|
341 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
|
342 return HDF5; |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
343 #endif |
604 | 344 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
345 #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
|
346 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
|
347 #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
|
348 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
|
349 #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
|
350 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
351 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
|
352 { |
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 std::ifstream file (ascii_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
|
354 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
|
355 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
|
356 { |
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 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
|
358 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
|
359 } |
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 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
|
361 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
|
362 } |
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 #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
|
364 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
|
365 { |
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 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
|
367 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
|
368 { |
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 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
|
370 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
|
371 } |
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 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
|
373 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
|
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 #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
|
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 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
|
378 } |
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 |
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 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
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_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
|
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 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
|
392 |
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 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
|
394 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
|
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 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
|
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 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
|
399 { |
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 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
|
401 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
|
402 |
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 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
|
404 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
|
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 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
|
407 { |
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 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
|
409 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
|
410 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
|
411 |
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 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
|
413 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
|
414 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
|
415 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
|
416 |
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 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
|
418 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
|
419 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
|
420 |
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 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
|
422 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
|
423 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
|
424 |
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 #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
|
426 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
|
427 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
|
428 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
|
429 break; |
5977 | 430 #endif |
5269 | 431 |
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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 |
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 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
|
439 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
|
440 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
|
441 } |
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 |
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 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
|
444 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
|
445 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
|
446 { |
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 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
|
448 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
|
449 |
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 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
|
451 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
|
452 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
|
453 |
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 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
|
455 || 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
|
456 || 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
|
457 { |
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 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
|
459 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
|
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 (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
|
462 { |
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 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
|
464 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
|
465 << "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
|
466 << "==== ==== ==== ====\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
|
467 |
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 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
|
469 << 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
|
470 << 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
|
471 << 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
|
472 << 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
|
473 << 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
|
474 << " " << 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
|
475 } |
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 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
|
477 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
|
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 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
|
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 (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
|
482 { |
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 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
|
484 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
|
485 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
|
486 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
|
487 } |
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 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
|
489 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
|
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 } |
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 // 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
|
494 |
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 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
|
496 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
|
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 } |
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 (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
|
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 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
|
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 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
|
505 |
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 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
|
507 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
|
508 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
|
509 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
|
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 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
|
512 { |
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 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
|
514 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
|
515 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
|
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 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
|
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 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
|
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 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
|
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 } |
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 } |
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 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
|
526 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
|
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 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
|
529 } |
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 |
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 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
|
532 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
|
533 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
|
534 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
|
535 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
536 #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
|
537 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
|
538 #endif |
604 | 539 |
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
|
540 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
|
541 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
|
542 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
543 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
|
544 bool do_tabs = false; |
604 | 545 |
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
|
546 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 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
|
573 { |
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 #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
|
575 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
|
576 #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
|
577 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
|
578 #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
|
579 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
580 else if (argv[i] == "-mat-binary" || argv[i] == "-mat" |
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 || argv[i] == "-m" || argv[i] == "-6" || argv[i] == "-v6" |
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 || argv[i] == "-V6") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
583 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
584 fmt.set_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
|
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 #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
|
587 else if (argv[i] == "-mat7-binary" || argv[i] == "-7" |
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 || argv[i] == "-v7" || argv[i] == "-V7") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
589 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
590 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
|
591 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
592 #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
|
593 else if (argv[i] == "-mat4-binary" || argv[i] == "-V4" |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
594 || argv[i] == "-v4" || argv[i] == "-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
|
595 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
596 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
|
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 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
|
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 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
|
601 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
|
602 } |
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 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
|
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 #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
|
606 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
|
607 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
|
608 #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
|
609 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
|
610 #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
|
611 } |
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 #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
|
613 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
|
614 { |
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 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
|
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 #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
|
618 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
|
619 { |
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 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
|
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 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
|
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 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
|
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 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
|
627 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
|
628 } |
3727 | 629 |
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
|
630 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
|
631 { |
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 (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
|
633 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
|
634 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
|
635 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
|
636 } |
604 | 637 |
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
|
638 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
|
639 { |
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 (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
|
641 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
|
642 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
|
643 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
|
644 } |
4051 | 645 |
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
|
646 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
|
647 } |
4051 | 648 |
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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 { |
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 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
|
656 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
|
657 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
|
658 |
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 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
|
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 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
|
662 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
|
663 } |
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 |
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 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
|
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 |
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 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 { |
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 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
|
675 write_header (os, fmt); |
604 | 676 |
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
|
677 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
|
678 { |
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 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
|
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 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
|
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 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
|
684 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
|
685 |
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 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
|
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 symbol_scope scope = m_interpreter.get_current_scope (); |
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 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
690 octave_value struct_var; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
691 |
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 if (scope) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
693 { |
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 if (! scope.is_variable (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
|
695 error ("save: no such variable: '%s'", 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
|
696 |
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 struct_var = scope.varval (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
|
698 } |
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 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
|
701 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
|
702 |
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 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
|
704 |
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 ++argv_idx; |
604 | 706 |
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
|
707 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
|
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 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
|
710 { |
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 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
|
712 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
|
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 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
|
715 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
|
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 } |
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 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
|
720 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
|
721 } |
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 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
|
723 { |
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 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
|
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 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
|
727 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
|
728 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
|
729 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
|
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 } |
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 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
734 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
|
735 { |
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 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
|
737 { |
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 // FIXME: should choose better filename? |
604 | 739 |
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
|
740 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
|
741 |
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 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
|
743 |
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 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
|
745 |
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 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
|
747 |
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 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
|
749 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
750 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
|
751 |
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 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
|
753 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
|
754 use_zlib); |
604 | 755 |
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
|
756 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
|
757 |
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 // 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
|
759 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
|
760 use_zlib = false; |
2511 | 761 |
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
|
762 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
|
763 #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
|
764 || 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
|
765 #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
|
766 || 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
|
767 || 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
|
768 || 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
|
769 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
|
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 mode |= append ? std::ios::ate : std::ios::trunc; |
604 | 772 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
773 #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
|
774 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
|
775 { |
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 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
|
777 |
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 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
|
779 { |
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 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
|
781 |
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 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
|
783 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
784 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
|
785 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
|
786 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
|
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 else |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
789 #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
|
790 // 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
|
791 // 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
|
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 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
|
794 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
|
795 { |
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 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
|
797 |
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 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
|
799 { |
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 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
|
801 |
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 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
|
803 } |
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 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
|
805 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
|
806 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
|
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 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
|
809 #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
|
810 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
811 std::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
|
812 |
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 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
|
814 { |
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 dump_octave_core (file, fname, fmt, save_as_floats); |
3687 | 816 |
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
|
817 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
|
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 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
|
820 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
|
821 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
|
822 } |
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 } |
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 } |
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 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
|
828 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
|
829 { |
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 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
|
831 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
832 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
|
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 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
|
835 ? "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
|
836 |
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 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
|
838 mach_info::native_float_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
|
839 |
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 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
|
841 |
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 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
|
843 } |
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 break; |
3688 | 845 |
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
|
846 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
|
847 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
|
848 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
849 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
|
850 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
|
851 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
|
852 |
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 // 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
|
854 const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave " |
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 OCTAVE_VERSION ", %Y-%m-%d %T UTC"; |
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 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
|
857 |
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 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
|
859 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
|
860 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
|
861 |
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 // 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
|
863 // 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
|
864 // 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
|
865 // 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
|
866 // 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
|
867 // 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
|
868 // 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 |
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 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
|
875 os.write (headertext, 128); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
876 } |
604 | 877 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
878 break; |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
879 |
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
|
880 #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
|
881 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
|
882 #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
|
883 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
|
884 { |
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 sys::localtime now; |
3136 | 886 |
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
|
887 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
|
888 |
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 if (! comment_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
890 { |
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
|
891 #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
|
892 if (fmt.type () == HDF5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
893 { |
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
|
894 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
|
895 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
|
896 } |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
897 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
|
898 #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
|
899 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
|
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 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
|
903 |
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 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
|
905 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
|
906 } |
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 } |
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 |
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 // 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
|
910 // 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
|
911 |
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 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
|
913 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
|
914 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
|
915 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
|
916 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
917 call_stack& cs = m_interpreter.get_call_stack (); |
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 symbol_info_list syminfo_list = cs.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
|
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 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
|
922 |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
923 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
|
924 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
925 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
|
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 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
|
928 } |
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 |
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 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
|
931 } |
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 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
|
934 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
|
935 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
|
936 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
|
937 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
|
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 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
|
940 { |
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 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
|
942 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
|
943 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
|
944 |
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 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
|
946 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
|
947 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
|
948 |
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 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 |
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 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
|
957 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
|
958 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
|
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 #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
|
961 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
|
962 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
|
963 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
|
964 #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
|
965 |
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 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
|
967 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
|
968 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
|
969 |
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 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
|
971 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
|
972 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
|
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 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
|
975 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
|
976 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
|
977 } |
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 } |
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 |
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 // 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
|
981 |
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 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
|
983 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
|
984 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
|
985 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
|
986 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
987 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
|
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 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
|
990 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 |
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 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
|
996 } |
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 } |
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 |
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 // 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
|
1000 // 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
|
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 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
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
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 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
|
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 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
|
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 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
|
1013 { |
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 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
|
1015 |
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 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
|
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 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
|
1019 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
|
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 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
|
1022 } |
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 } |
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 |
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 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
|
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 |
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 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
|
1029 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
|
1030 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
|
1031 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
|
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 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
|
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 call_stack& cs = m_interpreter.get_call_stack (); |
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 symbol_info_list syminfo_list = cs.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
|
1038 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1039 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
|
1040 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1041 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
|
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 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
|
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 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
|
1046 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
|
1047 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
|
1048 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1049 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
|
1050 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1051 // 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
|
1052 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1053 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
|
1054 || 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
|
1055 { |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1056 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
|
1057 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1058 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
|
1059 } |
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 } |
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 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
|
1063 } |
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 |
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 // 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
|
1066 // 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
|
1067 |
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 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
|
1069 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
|
1070 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
|
1071 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
|
1072 { |
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 symbol_table& symtab = m_interpreter.get_symbol_table (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1074 |
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 symbol_scope scope = symtab.require_current_scope ("load_save_system::install_loaded_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
|
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 if (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
|
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 symbol_record sym = scope.find_symbol (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
|
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 if (! sym.is_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
|
1082 { |
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 symbol_scope global_scope = symtab.global_scope (); |
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 symbol_record global_sym = global_scope.find_symbol (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
|
1085 |
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 sym.bind_fwd_rep (global_scope.get_rep (), global_sym); |
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 } |
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 } |
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 scope.assign (name, 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
|
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 |
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 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
|
1094 { |
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 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
|
1096 (std::string ("# Created by Octave " OCTAVE_VERSION |
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 ", %a %b %d %H:%M:%S %Y %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
|
1098 + 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
|
1099 + '@' |
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 + 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
|
1101 + '>'); |
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 } |
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 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
|
1105 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
|
1106 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
|
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 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
|
1109 |
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 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
|
1111 = 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
|
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 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
|
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 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
|
1116 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
|
1117 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
|
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 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
|
1120 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
|
1121 |
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 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
|
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 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
|
1125 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
|
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 (! 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
|
1128 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
|
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 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
|
1135 |
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 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
|
1137 { |
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 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
|
1139 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
|
1140 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
|
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 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
|
1143 { |
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 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
|
1145 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
|
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 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
|
1148 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
|
1149 |
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 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
|
1151 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
|
1152 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
|
1153 { |
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 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
|
1155 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
|
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 // 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
|
1158 // 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
|
1159 // 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
|
1160 // 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
|
1161 // 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
|
1162 // 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
|
1163 // 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
|
1164 |
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 (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
|
1166 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
|
1167 } |
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 } |
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 |
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 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
|
1173 } |
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 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
|
1176 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
|
1177 { |
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 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
|
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 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
|
1181 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1182 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
|
1183 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1184 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
|
1185 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
|
1186 |
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 // 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
|
1188 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
|
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 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
|
1191 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
|
1192 } |
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 |
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 // 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
|
1195 // 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
|
1196 // 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
|
1197 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1198 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
|
1199 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1200 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
|
1201 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
|
1202 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1203 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
|
1204 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1205 if (argv[i] == "-force" || 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
|
1206 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1207 // Silently ignore 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
|
1208 // warning ("load: -force 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
|
1209 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1210 else if (argv[i] == "-list" || argv[i] == "-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
|
1211 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1212 list_only = 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
|
1213 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1214 else if (argv[i] == "-verbose" || argv[i] == "-v") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1215 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1216 verbose = 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
|
1217 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1218 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
|
1219 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1220 format = 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
|
1221 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1222 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
|
1223 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1224 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
|
1225 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1226 else if (argv[i] == "-mat-binary" || argv[i] == "-mat" |
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 || argv[i] == "-m" || argv[i] == "-6" || argv[i] == "-v6") |
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 format = 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
|
1230 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1231 else if (argv[i] == "-7" || argv[i] == "-v7") |
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 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1233 format = 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
|
1234 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1235 else if (argv[i] == "-mat4-binary" || argv[i] == "-V4" |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1236 || argv[i] == "-v4" || argv[i] == "-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
|
1237 { |
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 format = 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
|
1239 } |
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 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
|
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 #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
|
1243 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
|
1244 #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
|
1245 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
|
1246 #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
|
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 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
|
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 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
|
1251 } |
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 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
|
1253 { |
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 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
|
1255 } |
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 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
|
1257 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
|
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 |
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 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
|
1261 { |
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 (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
|
1263 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
|
1264 |
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 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
|
1266 } |
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 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
|
1268 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
|
1269 |
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 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
|
1271 |
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 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
|
1273 |
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 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
|
1275 { |
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 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
|
1277 |
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 #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
|
1279 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
|
1280 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
|
1281 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
|
1282 #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
|
1283 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
|
1284 { |
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 // 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
|
1286 // 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
|
1287 // 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
|
1288 // 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
|
1289 |
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 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
|
1291 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
|
1292 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
|
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 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
|
1295 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
|
1296 } |
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 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
|
1298 { |
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 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
|
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 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
|
1302 |
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 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
|
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 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
|
1306 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
|
1307 |
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 #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
|
1309 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
|
1310 { |
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 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
|
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 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
|
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 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
|
1316 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
|
1317 |
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 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
|
1319 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
|
1320 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
|
1321 |
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 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
|
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 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
|
1325 #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
|
1326 // 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
|
1327 // 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
|
1328 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
|
1329 { |
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 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
|
1331 |
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 // 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
|
1333 // 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
|
1334 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
|
1335 |
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 #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
|
1337 if (use_zlib) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1338 { |
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
|
1339 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
|
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) |
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 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
|
1343 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1344 if (format.type () == BINARY) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1345 { |
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
|
1346 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
|
1347 { |
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 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
|
1349 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
|
1350 } |
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 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
|
1353 || 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
|
1354 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1355 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
|
1356 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
|
1357 { |
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 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
|
1359 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
|
1360 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1361 } |
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
|
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 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
|
1364 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
|
1365 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
|
1366 |
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 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
|
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 |
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 #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
|
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 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
|
1373 |
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 std::ifstream file (ascii_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
|
1375 |
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 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
|
1377 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
|
1378 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
|
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 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
|
1381 { |
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 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
|
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 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
|
1385 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
|
1386 } |
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 } |
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 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
|
1389 || 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
|
1390 { |
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 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
|
1392 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
|
1393 { |
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 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
|
1395 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
|
1396 } |
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 } |
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 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
|
1400 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
|
1401 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
|
1402 |
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 file.close (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1404 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1405 } |
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
|
1406 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
|
1407 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
|
1408 orig_fname.c_str ()); |
2511 | 1409 |
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
|
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 |
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 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
|
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 |
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 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
|
1416 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
|
1417 { |
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 // 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
|
1419 // 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
|
1420 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
|
1421 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
|
1422 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
|
1423 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
|
1424 |
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 |
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 // 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
|
1427 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
|
1428 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
|
1429 |
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 // 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
|
1431 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
|
1432 |
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 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
|
1434 |
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 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
|
1436 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
|
1437 |
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 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
|
1439 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
|
1440 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1441 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
|
1442 error ("save: cannot specify both -text and -float-binary"); |
2511 | 1443 |
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 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
|
1445 |
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 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
|
1447 { |
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 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
|
1449 |
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 #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
|
1451 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
|
1452 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
|
1453 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
|
1454 #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
|
1455 // 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
|
1456 // 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
|
1457 { |
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 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
|
1459 warning ("save: ignoring -append option for output to stdout"); |
604 | 1460 |
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
|
1461 if (nargout == 0) |
26009
3fc9d7453ba6
where possible, use octave_stdout and avoid including <iostream>
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
1462 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
|
1463 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
|
1464 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
|
1465 { |
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 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
|
1467 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
|
1468 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
|
1469 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
|
1470 } |
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 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1472 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1473 |
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 // 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
|
1475 |
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 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
|
1477 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
|
1478 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
|
1479 { |
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 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
|
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 i++; |
2095 | 1483 |
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
|
1484 // 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
|
1485 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
|
1486 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
|
1487 |
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 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
|
1489 = (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
|
1490 |
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 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
|
1492 #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
|
1493 || 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
|
1494 #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
|
1495 || format.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
|
1496 || 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
|
1497 || 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
|
1498 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
|
1499 |
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 #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
|
1501 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
|
1502 { |
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 // 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
|
1504 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
|
1505 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
|
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 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
|
1508 |
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 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
|
1510 = ! (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
|
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 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
|
1513 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1514 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
|
1515 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
|
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 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
|
1518 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1519 |
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
|
1520 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
|
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 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
|
1523 #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
|
1524 // 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
|
1525 // 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
|
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 #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
|
1528 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
|
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 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
|
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 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
|
1533 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
|
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 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
|
1536 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1537 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
|
1538 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1539 |
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
|
1540 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
|
1541 } |
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 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
|
1543 #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
|
1544 { |
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 std::ofstream 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
|
1546 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1547 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
|
1548 err_file_open ("save", fname); |
621 | 1549 |
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
|
1550 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
|
1551 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1552 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
|
1553 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
|
1554 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1555 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
|
1556 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1557 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1558 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1559 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1560 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
|
1561 } |
863 | 1562 } |
1563 | |
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
|
1564 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
|
1565 dump_octave_core (void) |
6159 | 1566 { |
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
|
1567 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
|
1568 = octave::__get_load_save_system__ ("dump_octave_core"); |
6159 | 1569 |
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
|
1570 load_save_sys.dump_octave_core (); |
6159 | 1571 } |
1572 | |
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
|
1573 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
|
1574 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
|
1575 @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
|
1576 @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
|
1577 @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
|
1578 @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
|
1579 @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
|
1580 @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
|
1581 @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
|
1582 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
|
1583 @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
|
1584 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1585 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
|
1586 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
|
1587 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
|
1588 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
|
1589 option. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1590 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1591 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
|
1592 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1593 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1594 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
|
1595 @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
|
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 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1598 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
|
1599 (@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
|
1600 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1601 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
|
1602 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
|
1603 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
|
1604 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
|
1605 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
|
1606 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1607 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
|
1608 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
|
1609 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
|
1610 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
|
1611 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
|
1612 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1613 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
|
1614 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
|
1615 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
|
1616 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
|
1617 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
|
1618 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
|
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 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
|
1621 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1622 @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
|
1623 @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
|
1624 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
|
1625 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
|
1626 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
|
1627 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1628 @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
|
1629 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
|
1630 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
|
1631 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
|
1632 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
|
1633 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1634 @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
|
1635 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
|
1636 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1637 @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
|
1638 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
|
1639 (@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
|
1640 Center for Supercomputing Applications at the University of Illinois.) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1641 Note that Octave can read @sc{hdf5} files not created by itself, but may |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1642 skip some datasets in formats that it cannot support. This format is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1643 only available if Octave was built with a link to the @sc{hdf5} libraries. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1644 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1645 @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
|
1646 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
|
1647 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
|
1648 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
|
1649 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1650 @item -mat |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1651 @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
|
1652 @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
|
1653 @itemx -v6 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1654 @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
|
1655 @itemx -v7 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1656 Force Octave to assume the file is in @sc{matlab}'s version 6 or 7 binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1657 format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1658 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1659 @item -mat4-binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1660 @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
|
1661 @itemx -v4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1662 @itemx -V4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1663 Force Octave to assume the file is in the binary format written by |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1664 @sc{matlab} version 4. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1665 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1666 @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
|
1667 Force Octave to assume the file is in Octave's 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
|
1668 @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
|
1669 @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
|
1670 @end deftypefn */) |
863 | 1671 { |
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
|
1672 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
|
1673 |
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
|
1674 return load_save_sys.load (args, nargout); |
604 | 1675 } |
1676 | |
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
|
1677 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
|
1678 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
|
1679 @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
|
1680 @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
|
1681 @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
|
1682 @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
|
1683 @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
|
1684 @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
|
1685 @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
|
1686 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
|
1687 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1688 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
|
1689 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
|
1690 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
|
1691 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
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1697 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
|
1698 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
|
1699 @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
|
1700 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1701 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
|
1702 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1703 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1704 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
|
1705 @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
|
1706 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1707 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1708 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
|
1709 @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
|
1710 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1711 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
|
1712 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
|
1713 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1714 @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
|
1715 @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
|
1716 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
|
1717 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1718 @item -ascii |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1719 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
|
1720 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
|
1721 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
|
1722 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
|
1723 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1724 @table @code |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1725 @item -double |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1726 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
|
1727 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1728 @item -tabs |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1729 Separate numbers with tabs. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1730 @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
|
1731 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1732 @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
|
1733 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
|
1734 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1735 @item -float-binary |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1736 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
|
1737 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
|
1738 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
|
1739 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1740 @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
|
1741 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
|
1742 (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
|
1743 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
|
1744 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
|
1745 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1746 @item -float-hdf5 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1747 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
|
1748 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
|
1749 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
|
1750 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1751 @item -V7 |
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 -v7 |
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 -7 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1754 @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
|
1755 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
|
1756 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1757 @item -V6 |
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 -v6 |
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 -6 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1760 @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
|
1761 @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
|
1762 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
|
1763 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1764 @item -V4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1765 @itemx -v4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1766 @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
|
1767 @itemx -mat4-binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1768 Save the data in the binary format written by @sc{matlab} version 4. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1769 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1770 @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
|
1771 Save the data in Octave's text data format. (default). |
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 @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
|
1774 @itemx -z |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1775 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
|
1776 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
|
1777 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
|
1778 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
|
1779 @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
|
1780 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1781 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
|
1782 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
|
1783 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1784 @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
|
1785 @item ? |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1786 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
|
1787 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1788 @item * |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1789 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
|
1790 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1791 @item [ @var{list} ] |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1792 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
|
1793 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
|
1794 @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
|
1795 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
|
1796 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1797 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
|
1798 @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
|
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 @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
|
1801 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1802 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
|
1803 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
|
1804 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
|
1805 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
|
1806 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1807 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
|
1808 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1809 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1810 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
|
1811 @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
|
1812 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1813 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1814 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
|
1815 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
|
1816 @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
|
1817 @end deftypefn */) |
604 | 1818 { |
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
|
1819 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
6759 | 1820 |
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
|
1821 return load_save_sys.save (args, nargout); |
604 | 1822 } |
1823 | |
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
|
1824 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
|
1825 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
|
1826 @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
|
1827 @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
|
1828 @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
|
1829 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
|
1830 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
|
1831 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
|
1832 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1833 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
|
1834 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
|
1835 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
|
1836 @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
|
1837 @end deftypefn */) |
2194 | 1838 { |
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
|
1839 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
|
1840 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1841 return load_save_sys.crash_dumps_octave_core (args, nargout); |
2194 | 1842 } |
1843 | |
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
|
1844 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
|
1845 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
|
1846 @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
|
1847 @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
|
1848 @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
|
1849 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
|
1850 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
|
1851 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1852 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
|
1853 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
|
1854 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1855 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
|
1856 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
|
1857 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
|
1858 @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
|
1859 @end deftypefn */) |
4788 | 1860 { |
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
|
1861 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
|
1862 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1863 return load_save_sys.save_default_options (args, nargout); |
4788 | 1864 } |
1865 | |
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
|
1866 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
|
1867 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
|
1868 @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
|
1869 @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
|
1870 @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
|
1871 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
|
1872 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
|
1873 |
25106
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1874 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
|
1875 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
|
1876 @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
|
1877 |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1878 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
|
1879 @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
|
1880 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
|
1881 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
|
1882 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1883 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
|
1884 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
|
1885 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
|
1886 @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
|
1887 @end deftypefn */) |
3709 | 1888 { |
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
|
1889 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
|
1890 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1891 return load_save_sys.octave_core_file_limit (args, nargout); |
3709 | 1892 } |
1893 | |
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
|
1894 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
|
1895 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
|
1896 @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
|
1897 @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
|
1898 @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
|
1899 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
|
1900 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
|
1901 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1902 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
|
1903 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1904 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
|
1905 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
|
1906 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
|
1907 @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
|
1908 @end deftypefn */) |
2194 | 1909 { |
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
|
1910 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
|
1911 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1912 return load_save_sys.octave_core_file_name (args, nargout); |
5794 | 1913 } |
4791 | 1914 |
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
|
1915 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
|
1916 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
|
1917 @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
|
1918 @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
|
1919 @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
|
1920 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
|
1921 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
|
1922 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1923 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
|
1924 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
|
1925 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
|
1926 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1927 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
|
1928 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
|
1929 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
|
1930 @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
|
1931 @end deftypefn */) |
5794 | 1932 { |
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
|
1933 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
|
1934 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1935 return load_save_sys.octave_core_file_options (args, nargout); |
5794 | 1936 } |
2194 | 1937 |
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
|
1938 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
|
1939 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
|
1940 @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
|
1941 @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
|
1942 @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
|
1943 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
|
1944 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
|
1945 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
|
1946 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1947 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
|
1948 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
|
1949 @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
|
1950 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
|
1951 @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
|
1952 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1953 @smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1954 "# 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
|
1955 @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
|
1956 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1957 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
|
1958 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
|
1959 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
|
1960 @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
|
1961 @end deftypefn */) |
5794 | 1962 { |
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
|
1963 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
|
1964 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1965 return load_save_sys.save_header_format_string (args, nargout); |
2194 | 1966 } |