annotate libinterp/corefcn/load-save.cc @ 30000:362029cc0202

* load-save.h (dump_octave_core): Deprecate function. Change all uses.
author John W. Eaton <jwe@octave.org>
date Wed, 18 Aug 2021 09:23:45 -0400
parents 7d6709900da7
children d809b99f1280
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29006
diff changeset
3 // Copyright (C) 1994-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
28 #endif
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
29
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
30 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
31
4249
8a1ef8fe4036 [project @ 2002-12-31 04:42:32 by jwe]
jwe
parents: 4247
diff changeset
32 #include <fstream>
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3465
diff changeset
33 #include <iomanip>
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3465
diff changeset
34 #include <iostream>
23455
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
35 #include <list>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
36 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
37 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
38
1961
41ff3c38af7e [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents: 1957
diff changeset
39 #include "byte-swap.h"
23455
73ff72d3d603 maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents: 23450
diff changeset
40 #include "dMatrix.h"
1961
41ff3c38af7e [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents: 1957
diff changeset
41 #include "data-conv.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2890
diff changeset
42 #include "file-ops.h"
6159
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
43 #include "file-stat.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2890
diff changeset
44 #include "glob-match.h"
2890
42901f9a9266 [project @ 1997-04-28 01:44:22 by jwe]
jwe
parents: 2859
diff changeset
45 #include "lo-mappers.h"
2318
31e7eb125d89 [project @ 1996-07-14 22:44:50 by jwe]
jwe
parents: 2305
diff changeset
46 #include "mach-info.h"
3185
9580887dd160 [project @ 1998-09-26 02:45:55 by jwe]
jwe
parents: 3145
diff changeset
47 #include "oct-env.h"
21888
00f1249f2483 create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents: 21835
diff changeset
48 #include "oct-locbuf.h"
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3233
diff changeset
49 #include "oct-time.h"
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4153
diff changeset
50 #include "quit.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
51 #include "str-vec.h"
21888
00f1249f2483 create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents: 21835
diff changeset
52 #include "strftime-wrapper.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
53
4332
e41906608e0f [project @ 2003-02-19 01:15:59 by jwe]
jwe
parents: 4329
diff changeset
54 #include "Cell.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
55 #include "defun.h"
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
56 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21040
diff changeset
57 #include "errwarn.h"
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
58 #include "interpreter.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23584
diff changeset
59 #include "interpreter-private.h"
6159
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
60 #include "load-path.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
61 #include "load-save.h"
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
62 #include "oct-hdf5.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
63 #include "ovl.h"
3687
b5a285d1c1f4 [project @ 2000-06-29 21:33:00 by jwe]
jwe
parents: 3682
diff changeset
64 #include "oct-map.h"
4332
e41906608e0f [project @ 2003-02-19 01:15:59 by jwe]
jwe
parents: 4329
diff changeset
65 #include "ov-cell.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
66 #include "pager.h"
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
67 #include "syminfo.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
68 #include "sysdep.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
69 #include "unwind-prot.h"
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
70 #include "utils.h"
2371
dd29ab8af9e7 [project @ 1996-10-12 00:09:55 by jwe]
jwe
parents: 2345
diff changeset
71 #include "variables.h"
3185
9580887dd160 [project @ 1998-09-26 02:45:55 by jwe]
jwe
parents: 3145
diff changeset
72 #include "version.h"
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
73
4633
d95dd6ae89fd [project @ 2003-11-19 18:32:50 by jwe]
jwe
parents: 4587
diff changeset
74 #include "ls-hdf5.h"
d95dd6ae89fd [project @ 2003-11-19 18:32:50 by jwe]
jwe
parents: 4587
diff changeset
75 #include "ls-mat-ascii.h"
d95dd6ae89fd [project @ 2003-11-19 18:32:50 by jwe]
jwe
parents: 4587
diff changeset
76 #include "ls-mat4.h"
d95dd6ae89fd [project @ 2003-11-19 18:32:50 by jwe]
jwe
parents: 4587
diff changeset
77 #include "ls-mat5.h"
20447
c6224b4e7774 maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents: 20443
diff changeset
78 #include "ls-oct-text.h"
4633
d95dd6ae89fd [project @ 2003-11-19 18:32:50 by jwe]
jwe
parents: 4587
diff changeset
79 #include "ls-oct-binary.h"
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
80
10309
cd925a5a82df another #undef for gnulib
John W. Eaton <jwe@octave.org>
parents: 10305
diff changeset
81 // Remove gnulib definitions, if any.
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
82 #if defined (close)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21118
diff changeset
83 # undef close
10309
cd925a5a82df another #undef for gnulib
John W. Eaton <jwe@octave.org>
parents: 10305
diff changeset
84 #endif
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
85 #if defined (open)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21118
diff changeset
86 # undef open
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
87 #endif
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
88
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
89 #if defined (HAVE_ZLIB)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21118
diff changeset
90 # include "zfstream.h"
10305
d6cdf08d0424 load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
91 #endif
d6cdf08d0424 load-save.cc: avoid gnulib definition of close
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
92
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
93 OCTAVE_NAMESPACE_BEGIN
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
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 OCTAVE_NORETURN static
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
96 void
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
97 err_file_open (const std::string& fcn, const std::string& file)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
98 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
99 if (fcn == "load")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
100 error ("%s: unable to open input file '%s'", fcn.c_str (), file.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
101 else if (fcn == "save")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
102 error ("%s: unable to open output file '%s'", fcn.c_str (), file.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
103 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
104 error ("%s: unable to open file '%s'", fcn.c_str (), file.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
105 }
4788
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
106
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
107 // Return TRUE if NAME matches one of the given globbing PATTERNS.
5369
4bbde94b5cf8 [project @ 2005-05-23 23:39:28 by jwe]
jwe
parents: 5351
diff changeset
108
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
109 static bool
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
110 matches_patterns (const string_vector& patterns, int pat_idx,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
111 int num_pat, const std::string& name)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
112 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
113 for (int i = pat_idx; i < num_pat; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
114 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
115 glob_match pattern (patterns[i]);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
116
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
117 if (pattern.match (name))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
118 return true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
119 }
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23603
diff changeset
120
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
121 return false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
122 }
25201
c80323fe4938 improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents: 25106
diff changeset
123
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
124 static int
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
125 read_binary_file_header (std::istream& is, bool& swap,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
126 mach_info::float_format& flt_fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
127 bool quiet = false)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
128 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
129 const int magic_len = 10;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
130 char magic[magic_len+1];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
131 is.read (magic, magic_len);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
132 magic[magic_len] = '\0';
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
133
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
134 if (strncmp (magic, "Octave-1-L", magic_len) == 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
135 swap = mach_info::words_big_endian ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
136 else if (strncmp (magic, "Octave-1-B", magic_len) == 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
137 swap = ! mach_info::words_big_endian ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
138 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
139 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
140 if (! quiet)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
141 error ("load: unable to read binary file");
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
142
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
143 return -1;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
144 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
145
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
146 char tmp = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
147 is.read (&tmp, 1);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
148
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
149 flt_fmt = mopt_digit_to_float_format (tmp);
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20801
diff changeset
150
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
151 if (flt_fmt == mach_info::flt_fmt_unknown)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
152 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
153 if (! quiet)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
154 error ("load: unrecognized binary format!");
2318
31e7eb125d89 [project @ 1996-07-14 22:44:50 by jwe]
jwe
parents: 2305
diff changeset
155
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
156 return -1;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
157 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
158
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
159 return 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
160 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
161
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
162 #if defined (HAVE_ZLIB)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
163 static bool
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
164 check_gzip_magic (const std::string& fname)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
165 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
166 bool retval = false;
21972
d31e0f704d0b Open files in binary mode when testing file format (bug #48201).
Rik <rik@octave.org>
parents: 21966
diff changeset
167
29006
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
168 std::ifstream file = sys::ifstream (fname.c_str (),
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
169 std::ios::in | std::ios::binary);
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
170
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
171 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
172 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
173 && 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
174 retval = true;
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
175
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
176 file.close ();
23777
cda0614beaec Replace static instances of OCTAVE_LOCAL_BUFFER with local variables.
Rik <rik@octave.org>
parents: 23693
diff changeset
177
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
178 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
179 }
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
180 #endif
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
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 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
183 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
184 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
185 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
186
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
187 std::size_t dot_pos = fname.rfind ('.');
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
188 std::size_t sep_pos = fname.find_last_of (sys::file_ops::dir_sep_chars ());
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
189
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 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
191 || (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
192 {
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 // 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
194 // 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
195
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 sys::file_stat fs (fname);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
197
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
198 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
199 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
200 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
201 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
202 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
203 sys::file_stat fs (fname);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
204
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
205 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
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 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
208
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
209 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
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 }
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 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
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 // Return TRUE if PATTERN has any special globbing chars in it.
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
217
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
218 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
219 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
220 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
221 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
222
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
223 int len = pattern.length ();
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
224
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
225 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
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 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
228
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
229 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
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 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
232 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
233 return true;
1180
0a9c94ee69e8 [project @ 1995-03-24 06:20:14 by jwe]
jwe
parents: 1159
diff changeset
234
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
235 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
236 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
237 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
238
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 ']':
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 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
241 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
242 continue;
1180
0a9c94ee69e8 [project @ 1995-03-24 06:20:14 by jwe]
jwe
parents: 1159
diff changeset
243
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
244 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
245 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
246 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
247 continue;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
248
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
249 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
250 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
251 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
252 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
253
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
254 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
255 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
256
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
257 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
258 : 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
259 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
260 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
261 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
262 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
263 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
264 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
265 {
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 #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
267 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
268 #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
269 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
270
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
271 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
272 {
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 #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
274 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
275 #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
276 }
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4153
diff changeset
277
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
278 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
279 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
280 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
281 {
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 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
283 "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
284 }
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 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
287 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
288 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
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 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
291 "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
292 }
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
293
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
294 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
295 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
296 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
297 {
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 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
299 "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
300 }
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 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
303 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
304 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
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 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
307 "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
308 }
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
309
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
310 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
311 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
312 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
313 {
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 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
315 "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
316 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
317
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
318 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
319 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
320 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
321 {
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 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
323 "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
324 }
5977
27dd5b29489b [project @ 2006-08-30 20:03:53 by jwe]
jwe
parents: 5958
diff changeset
325
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
326 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
327 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
328 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
329 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
330 {
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_format retval = UNKNOWN;
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
332
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
333 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
334
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
335 #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
336 // 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
337 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
338 return HDF5;
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
339 #endif
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
340
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
341 #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
342 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
343 #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
344 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
345 #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
346
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
347 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
348 {
29006
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
349 std::ifstream file = sys::ifstream (fname.c_str (),
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
350 std::ios::in | std::ios::binary);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
351 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
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 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
354 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
355 }
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 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
357 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
358 }
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 #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
360 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
361 {
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 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
363 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
364 {
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 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
366 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
367 }
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 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
369 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
370 }
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 #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
372
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
373 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
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
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 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
377 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
378 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
379 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
380 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
381 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
382 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
383 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
384 {
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 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
386
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
387 octave_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
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 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
390 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
391
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 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
393
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
394 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
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 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
397 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
398
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 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
400 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
401
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 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
403 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
404 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
405 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
406 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
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 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
409 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
410 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
411 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
412
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 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
414 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
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_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
418 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
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 #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
422 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
423 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
424 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
425 break;
5977
27dd5b29489b [project @ 2006-08-30 20:03:53 by jwe]
jwe
parents: 5958
diff changeset
426 #endif
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
427
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
428 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
429 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
430 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
431 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
432 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
433
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 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
435 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
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
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 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
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 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
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 (! 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
444 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
445
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 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
447 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
448 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
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
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 || 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
452 || 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
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 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
455 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
456 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
457 if (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
458 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
459 if (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
460 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
461 << "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
462 << "==== ==== ==== ====\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
463
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 << 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
466 << 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
467 << 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
468 << 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
469 << 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
470 << " " << 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
471 }
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 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
473 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
474 }
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 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
476 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
477 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
478 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
479 if (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
480 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
481 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
482 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
483 }
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 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
485 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
486 }
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
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 // 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
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 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
492 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
493 }
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
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 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
497 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
498 if (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
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 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
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 (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
503 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
504 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
505 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
506 }
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 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
508 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
509 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
510 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
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 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
514
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
515 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
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 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
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 }
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 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
522 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
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 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
525 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
526
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 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
528 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
529 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
530 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
531 {
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 #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
533 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
534 #endif
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
535
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
536 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
537 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
538
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
539 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
540 bool do_tabs = false;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
541
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
542 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
543 {
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 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
545 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
546 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
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 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
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 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
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] == "-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
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 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
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] == "-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
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_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
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] == "-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
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 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
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] == "-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
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 (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
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] == "-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
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 #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
571 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
572 #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
573 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
574 #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
575 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
576 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
577 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
578 error ("save: Matlab file format -v7.3 is not yet implemented");
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
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 #if defined (HAVE_ZLIB)
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
581 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
582 || argv[i] == "-mat7-binary")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
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 (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
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 #endif
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
587 else if (argv[i] == "-mat" || argv[i] == "-m"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
588 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
589 || argv[i] == "-mat-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
590 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
591 fmt.set_type (MAT5_BINARY);
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
592 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
593 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
594 || argv[i] == "-mat4-binary")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
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
e6d0041aedf3 [project @ 2000-10-31 02:08:49 by jwe]
jwe
parents: 3709
diff changeset
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
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
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
b79da8779a0e [project @ 2002-08-17 19:38:32 by jwe]
jwe
parents: 4009
diff changeset
645
29019
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
646 if (append && use_zlib
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
647 && (fmt.type () != TEXT && fmt.type () != MAT_ASCII))
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
648 error ("save: -append and -zip options can only be used together with a text format (-text or -ascii)");
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
649
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
650 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
651 }
4051
b79da8779a0e [project @ 2002-08-17 19:38:32 by jwe]
jwe
parents: 4009
diff changeset
652
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
653 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
654 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
655 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
656 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
657 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
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 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
660 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
661 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
662
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
663 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
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 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
666 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
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
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 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
670 }
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
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 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
673 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
674 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
675 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
676 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
677 {
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 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
679 write_header (os, fmt);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
680
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
681 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
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 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
684 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
685 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
686 {
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 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
688 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
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 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
691
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
692 if (! m_interpreter.is_variable (struct_name))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
693 error ("save: no such variable: '%s'", struct_name.c_str ());
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
694
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
695 octave_value struct_var = m_interpreter.varval (struct_name);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
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 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
698 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
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 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
701
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 ++argv_idx;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
703
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
704 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
705 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
706 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
707 {
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 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
709 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
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 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
712 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
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 }
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 }
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 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
717 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
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 {
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 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
722 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
723 if (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
724 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
725 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
726 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
727 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
728 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
729 }
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 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
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 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
734 {
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 // FIXME: should choose better filename?
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
736
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
737 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
738
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
739 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
740
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
741 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
742
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
743 bool 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
744
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
745 bool 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
746
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
747 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
748
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 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
750 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
751 use_zlib);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
752
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
753 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
754
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
755 // 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
756 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
757 use_zlib = false;
2511
9b0dd36714eb [project @ 1996-11-14 02:57:33 by jwe]
jwe
parents: 2499
diff changeset
758
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
759 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
760 #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
761 || 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
762 #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
763 || 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
764 || 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
765 || 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
766 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
767
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 mode |= append ? std::ios::ate : std::ios::trunc;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
769
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
770 #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
771 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
772 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
773 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
774
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
775 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
776 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
777 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
778
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
779 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
780 }
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 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
782 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
783 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
784 }
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 else
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
786 #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
787 // 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
788 // 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
789 {
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 #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
791 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
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 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
794
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
795 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
796 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
797 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
798
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
799 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
800 }
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 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
802 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
803 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
804 }
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 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
806 #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
807 {
29006
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
808 std::ofstream file = sys::ofstream (fname, mode);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
809
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
810 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
811 {
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 dump_octave_core (file, fname, fmt, save_as_floats);
3687
b5a285d1c1f4 [project @ 2000-06-29 21:33:00 by jwe]
jwe
parents: 3682
diff changeset
813
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
814 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
815 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
816 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
817 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
818 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
819 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
820 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
821 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
822 }
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 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
825 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
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 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
828 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
829 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
830 {
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 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
832 ? "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
833
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
834 mach_info::float_format flt_fmt = mach_info::native_float_format ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
835
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
836 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
837
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
838 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
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 break;
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
841
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
842 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
843 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
844 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
845 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
846 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
847 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
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 // 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
850 const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave "
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
851 OCTAVE_VERSION ", %Y-%m-%d %T UTC";
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
852 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
853
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
854 std::size_t len = std::min (comment_string.length (), static_cast<std::size_t> (124));
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
855 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
856 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
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 // 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
859 // 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
860 // 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
861 // 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
862 // 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
863 // 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
864 // 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
865 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
866 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
867 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
868 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
869
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 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
871 os.write (headertext, 128);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
872 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
873
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
874 break;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
875
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
876 #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
877 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
878 #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
879 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
880 {
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 sys::localtime now;
3136
af7ec9d3a5e6 [project @ 1998-02-01 20:11:06 by jwe]
jwe
parents: 3131
diff changeset
882
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
883 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
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 if (! comment_string.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
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 #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
888 if (fmt.type () == HDF5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
889 {
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
890 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
891 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
892 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
893 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
894 #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
895 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
896 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
897 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
898 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
899
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 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
901 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
902 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
903 }
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
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 // 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
906 // 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
907
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
908 std::size_t load_save_system::save_vars (std::ostream& os,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
909 const std::string& pattern,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
910 const load_save_format& fmt,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
911 bool 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
912 {
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
913 tree_evaluator& tw = m_interpreter.get_evaluator ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
914
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
915 symbol_info_list syminfo_list = tw.glob_symbol_info (pattern);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
916
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
917 std::size_t saved = 0;
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 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
920 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
921 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
922
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
923 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
924 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
925
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
926 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
927 }
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 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
930 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
931 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
932 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
933 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
934 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
935 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
936 {
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 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
938 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
939 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
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 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
942 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
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 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
946 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
947 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
948 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
949 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
950 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
951
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 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
953 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
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 #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
957 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
958 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
959 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
960 #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
961
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 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
963 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
964 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
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 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
967 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
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 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
971 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
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 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
975
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
976 // 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
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 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
979 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
980 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
981 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
982 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
983 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
984
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 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
986 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
987 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
988 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
989 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
990
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
991 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
992 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
993 }
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 // 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
996 // 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
997
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
998 std::size_t load_save_system::save_fields (std::ostream& os,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
999 const octave_scalar_map& m,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
1000 const std::string& pattern,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
1001 const load_save_format& fmt,
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
1002 bool 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
1003 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1004 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
1005
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29413
diff changeset
1006 std::size_t saved = 0;
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
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 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
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 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
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 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
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 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
1015 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
1016
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1017 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
1018 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1019 }
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 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
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 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
1025 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
1026 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
1027 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
1028 {
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 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
1030
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
1031 tree_evaluator& tw = m_interpreter.get_evaluator ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1032
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
1033 symbol_info_list syminfo_list = tw.top_scope_symbol_info ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1034
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1035 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
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 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
1038 {
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1039 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
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 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
1042 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
1043 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
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 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
1046
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1047 // 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
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 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
1050 || 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
1051 {
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1052 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
1053
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1054 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
1055 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1056 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1057
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1058 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
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 // 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
1062 // 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
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 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
1065 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
1066 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
1067 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
1068 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
1069 m_interpreter.install_variable (name, val, global);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1070 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1071
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1072 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
1073 {
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 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
1075 (std::string ("# Created by Octave " OCTAVE_VERSION
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
1076 ", %a %b %d %H:%M:%S %Y %Z <")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1077 + 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
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 + 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
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 }
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 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
1084 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
1085 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
1086 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1087 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
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 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
1090 = 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
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 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
1093
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 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
1095 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
1096 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
1097 {
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 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
1099 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
1100
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1101 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
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 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
1104 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
1105
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 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
1107 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
1108 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
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 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
1111 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
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 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
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 (! 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
1116 {
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 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
1118 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
1119 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
1120 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1121 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
1122 {
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 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
1124 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
1125
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 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
1127 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
1128
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 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
1130 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
1131 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
1132 {
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 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
1134 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
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 // 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
1137 // 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
1138 // 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
1139 // 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
1140 // 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
1141 // 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
1142 // 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
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 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
1145 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
1146 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1147 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1148 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1149 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1150
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1151 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
1152 }
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 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
1155 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
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 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
1158
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1159 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
1160
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1161 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
1162
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 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
1164 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
1165
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 // 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
1167 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
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 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
1170 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
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
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 // 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
1174 // 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
1175 // 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
1176
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1177 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
1178
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 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
1180 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
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 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
1183 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1184 if (argv[i] == "-text" || argv[i] == "-t")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1185 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1186 format = TEXT;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1187 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1188 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
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 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
1191 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1192 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
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 #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
1195 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
1196 #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
1197 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
1198 #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
1199 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1200 else if (argv[i] == "-ascii" || argv[i] == "-a")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1201 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1202 format = MAT_ASCII;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1203 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1204 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1205 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1206 error ("load: Matlab file format -v7.3 is not yet implemented");
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1207 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1208 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1209 || argv[i] == "-mat7-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1210 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1211 format = MAT7_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1212 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1213 else if (argv[i] == "-mat" || argv[i] == "-m"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1214 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1215 || argv[i] == "-mat-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1216 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1217 format = MAT5_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1218 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1219 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1220 || argv[i] == "-mat4-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1221 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1222 format = MAT_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1223 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1224 else if (argv[i] == "-force" || argv[i] == "-f")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1225 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1226 // Silently ignore this
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1227 // warning ("load: -force ignored");
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1228 }
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
1229 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
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 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
1232 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1233 else if (argv[i] == "-list" || argv[i] == "-l")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1234 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1235 list_only = true;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1236 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1237 else if (argv[i] == "-verbose" || argv[i] == "-v")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1238 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1239 verbose = true;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1240 }
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 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
1242 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
1243 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1244
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1245 if (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
1246 {
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 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
1248 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
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 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
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
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 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
1254
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1255 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
1256
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1257 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
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 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
1260 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1261 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
1262
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 #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
1264 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
1265 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
1266 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
1267 #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
1268 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
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 // 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
1271 // 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
1272 // 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
1273 // 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
1274
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 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
1276 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
1277 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
1278 }
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 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
1280 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
1281 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1282 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
1283 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1284 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
1285
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1286 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
1287
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1288 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
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 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
1291 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
1292
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 #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
1294 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
1295 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1296 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
1297
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1298 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
1299
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 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
1301 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
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 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
1304 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
1305 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
1306
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1307 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
1308 }
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 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
1310 #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
1311 // 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
1312 // 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
1313 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
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 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
1316
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 // 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
1318 // 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
1319 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
1320
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 #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
1322 if (use_zlib)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
1323 {
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
1324 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
1325
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 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
1327 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
1328
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1329 if (format.type () == BINARY)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
1330 {
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
1331 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
1332 {
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 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
1334 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
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 }
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 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
1338 || 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
1339 {
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 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
1341 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
1342 {
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 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
1344 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
1345 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
1346 }
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
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 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
1349 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
1350 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
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 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
1353 }
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 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
1355 #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
1356 {
29006
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
1357 std::ifstream file = sys::ifstream (fname.c_str (), mode);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1358
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 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
1360 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
1361 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
1362
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1363 if (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
1364 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1365 if (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
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 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
1368 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
1369 }
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 }
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 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
1372 || 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
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 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
1375 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
1376 {
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 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
1378 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
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 }
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 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
1383 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
1384 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
1385
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 file.close ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
1387 }
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
1388 }
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
1389 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
1390 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
1391 orig_fname.c_str ());
2511
9b0dd36714eb [project @ 1996-11-14 02:57:33 by jwe]
jwe
parents: 2499
diff changeset
1392
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
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
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 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
1399 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
1400 {
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 // 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
1402 // 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
1403 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
1404 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
1405 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
1406 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
1407
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
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1409 // 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
1410 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
1411 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
1412
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 // 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
1414 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
1415
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1416 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
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 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
1419 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
1420
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 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
1422 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
1423
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 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
1425 error ("save: cannot specify both -text and -float-binary");
2511
9b0dd36714eb [project @ 1996-11-14 02:57:33 by jwe]
jwe
parents: 2499
diff changeset
1426
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
1427 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
1428
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1429 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
1430 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1431 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
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 #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
1434 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
1435 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
1436 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
1437 #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
1438 // 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
1439 // 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
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 (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
1442 warning ("save: ignoring -append option for output to stdout");
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
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 if (nargout == 0)
26009
3fc9d7453ba6 where possible, use octave_stdout and avoid including <iostream>
John W. Eaton <jwe@octave.org>
parents: 25993
diff changeset
1445 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
1446 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
1447 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
1448 {
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 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
1450 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
1451 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
1452 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
1453 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1454 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1455 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1456
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1457 // 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
1458
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1459 else 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
1460 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
1461 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
1462 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1463 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
1464
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 i++;
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
1466
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
1467 // 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
1468 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
1469 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
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 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
1472 = (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
1473
28993
cc287e633588 Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28660
diff changeset
1474 // Always open in binary mode to save line endings as is.
cc287e633588 Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28660
diff changeset
1475 mode |= std::ios::binary;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1476
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 #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
1478 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
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 // 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
1481 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
1482 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
1483
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1484 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
1485
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 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
1487 = ! (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
1488
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1489 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
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 (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
1492 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
1493
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 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
1495 write_header_info);
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1496
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
1497 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
1498 }
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 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
1500 #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
1501 // 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
1502 // 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
1503 {
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 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
1505 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
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 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
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 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
1510 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
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 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
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 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
1515 write_header_info);
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1516
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
1517 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
1518 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1519 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
1520 #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
1521 {
29006
139df373c107 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28993
diff changeset
1522 std::ofstream file = sys::ofstream (fname.c_str (), mode);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1523
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 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
1525 err_file_open ("save", fname);
621
9e90d4df19e2 [project @ 1994-08-16 14:55:18 by jwe]
jwe
parents: 620
diff changeset
1526
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
1527 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
1528
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 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
1530 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
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 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
1533 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1534 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1535 }
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 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
1538 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29655
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 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
1541 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
1542 @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
1543 @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
1544 @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
1545 @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
1546 @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
1547 @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
1548 @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
1549 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
1550 @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
1551
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1552 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
1553 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
1554 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
1555 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
1556 option.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1557
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1558 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
1559
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1560 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1561 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
1562 @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
1563
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1564 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1565 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
1566 (@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
1567
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1568 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
1569 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
1570 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
1571 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
1572 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
1573
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1574 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
1575 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
1576 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
1577 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
1578 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
1579
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1580 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
1581 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
1582 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
1583 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
1584 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
1585 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
1586
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1587 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
1588
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1589 @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
1590 @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
1591 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
1592 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
1593 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
1594
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1595 @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
1596 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
1597 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
1598 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
1599 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
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 @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
1602 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
1603
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1604 @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
1605 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
1606 (@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
1607 Center for Supercomputing Applications at the University of Illinois.)
27065
ad77f3204eda doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents: 26376
diff changeset
1608 Note that Octave can only read @sc{hdf5} files that were created by itself with
ad77f3204eda doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents: 26376
diff changeset
1609 @code{save}. This format is only available if Octave was built with a link to
ad77f3204eda doc: state that Octave can only load HDF5 files created by itself (bug #56148).
Rik <rik@octave.org>
parents: 26376
diff changeset
1610 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
1611
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1612 @item -import
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1613 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
1614 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
1615 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
1616
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1617 @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
1618 Force Octave to assume the file is in Octave's text format.
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1619
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1620 @item -v7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1621 @itemx -V7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1622 @itemx -7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1623 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format.
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1624
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1625 @item -v7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1626 @itemx -V7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1627 @itemx -7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1628 @itemx -mat7-binary
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1629 Force Octave to assume the file is in @sc{matlab}'s version 7 binary format.
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1630
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1631 @item -v6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1632 @itemx -V6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1633 @itemx -6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1634 @itemx -mat
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1635 @itemx -mat-binary
28660
dc80e087df4b maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents: 28217
diff changeset
1636 Force Octave to assume the file is in @sc{matlab}'s version 6 binary format.
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1637
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1638 @item -v4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1639 @itemx -V4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1640 @itemx -4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1641 @itemx -mat4-binary
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1642 Force Octave to assume the file is in @sc{matlab}'s version 4 binary format.
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1643
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1644 @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
1645 @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
1646 @end deftypefn */)
863
a2e030473d6d [project @ 1994-10-31 23:41:05 by jwe]
jwe
parents: 777
diff changeset
1647 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1648 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
1649
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
1650 return load_save_sys.load (args, nargout);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1651 }
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1652
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
1653 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
1654 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
1655 @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
1656 @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
1657 @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
1658 @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
1659 @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
1660 @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
1661 @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
1662 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
1663
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1664 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
1665 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
1666 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
1667 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
1668 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
1669 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
1670 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
1671 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
1672
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1673 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
1674 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
1675 @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
1676
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1677 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
1678
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1679 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1680 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
1681 @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
1682
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1683 @noindent
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1684 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
1685 @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
1686
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1687 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
1688 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
1689
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1690 @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
1691 @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
1692 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
1693
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1694 @item -ascii
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1695 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
1696 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
1697 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
1698 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
1699
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1700 @table @code
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1701 @item -double
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1702 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
1703
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1704 @item -tabs
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1705 Separate numbers with tabs.
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1706 @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
1707
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1708 @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
1709 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
1710
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1711 @item -float-binary
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1712 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
1713 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
1714 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
1715
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1716 @item -hdf5
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1717 Save the data in @sc{hdf5} format.
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1718 (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
1719 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
1720 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
1721
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1722 @item -float-hdf5
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1723 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
1724 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
1725 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
1726
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1727 @item -text
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1728 Save the data in Octave's text data format. (default)
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1729
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1730 @item -v7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1731 @itemx -V7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1732 @itemx -7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1733 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format.
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1734
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1735 @item -v7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1736 @itemx -V7
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1737 @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
1738 @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
1739 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
1740
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1741 @item -v6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1742 @itemx -V6
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1743 @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
1744 @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
1745 @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
1746 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
1747
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1748 @item -v4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1749 @itemx -V4
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1750 @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
1751 @itemx -mat4-binary
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1752 Save the data in @sc{matlab}'s v4 binary data format.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1753
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1754 @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
1755 @itemx -z
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1756 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
1757 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
1758 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
1759 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
1760 @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
1761
29413
cb2d14b384df doc: Add note that wildcard patterns for "save" are glob patterns (bug #60157).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
1762 The list of variables to save may use wildcard patterns (glob patterns)
cb2d14b384df doc: Add note that wildcard patterns for "save" are glob patterns (bug #60157).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
1763 containing the 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
1764
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1765 @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
1766 @item ?
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1767 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
1768
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1769 @item *
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1770 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
1771
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1772 @item [ @var{list} ]
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1773 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
1774 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
1775 @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
1776 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
1777
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1778 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
1779 @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
1780
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1781 @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
1782
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1783 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
1784 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
1785 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
1786 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
1787
28660
dc80e087df4b maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents: 28217
diff changeset
1788 Example:
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1789
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1790 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
1791
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1792 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1793 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
1794 @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
1795
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1796 @noindent
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1797 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
1798 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
1799 @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
1800 @end deftypefn */)
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1801 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1802 load_save_system& load_save_sys = interp.get_load_save_system ();
6759
dd8cef76043d [project @ 2007-06-26 15:54:40 by jwe]
jwe
parents: 6653
diff changeset
1803
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
1804 return load_save_sys.save (args, nargout);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1805 }
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1806
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1807 /*
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1808 ## Save and load strings with "-v6"
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1809 %!test
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1810 %! A = A2 = "foobar"; # normal string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1811 %! B = B2 = "a"; # short string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1812 %! C = C2 = ["foo"; "bar"]; # character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1813 %! D = D2 = "ab".'; # short character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1814 %! E = E2 = {"foo", "bar"}; # cell string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1815 %! F = F2 = {"Saint Barthélemy", "Saint Kitts and Nevis"}; % non-ASCII
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1816 %! mat_file = [tempname(), ".mat"];
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1817 %! unwind_protect
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1818 %! save (mat_file, "A", "B", "C", "D", "E", "F", "-v6");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1819 %! clear ("A", "B", "C", "D", "E", "F");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1820 %! load (mat_file);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1821 %! unwind_protect_cleanup
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1822 %! unlink (mat_file);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1823 %! end_unwind_protect
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1824 %! assert (A, A2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1825 %! assert (B, B2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1826 %! assert (C, C2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1827 %! assert (D, D2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1828 %! assert (E, E2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1829 %! assert (F, F2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1830
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1831 ## Save and load strings with "-v7"
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1832 %!testif HAVE_ZLIB
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1833 %! A = A2 = "foobar"; # normal string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1834 %! B = B2 = "a"; # short string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1835 %! C = C2 = ["foo"; "bar"]; # character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1836 %! D = D2 = "ab".'; # short character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1837 %! E = E2 = {"foo", "bar"}; # cell string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1838 %! F = F2 = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1839 %! mat_file = [tempname(), ".mat"];
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1840 %! unwind_protect
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1841 %! save (mat_file, "A", "B", "C", "D", "E", "F", "-v7");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1842 %! clear ("A", "B", "C", "D", "E", "F");
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1843 %! load (mat_file);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1844 %! unwind_protect_cleanup
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1845 %! unlink (mat_file);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1846 %! end_unwind_protect
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1847 %! assert (A, A2);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1848 %! assert (B, B2);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1849 %! assert (C, C2);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1850 %! assert (D, D2);
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1851 %! assert (E, E2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1852 %! assert (F, F2);
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1853
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1854 ## Save and load struct with "-v6"
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1855 %!test
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1856 %! struc.a = "foobar"; # normal string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1857 %! struc.b = "a"; # short string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1858 %! struc.c = ["foo"; "bar"]; # character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1859 %! struc.d = "ab".'; # short character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1860 %! struc.e = {"foo", "bar"}; # cell string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1861 %! struc.f = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1862 %! struc.g = [1 2 3]; # double vector
29134
5f90526a9c40 load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29128
diff changeset
1863 %! struc.h = 1:5; # range
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1864 %! struc2 = struc;
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1865 %! mat_file = [tempname(), ".mat"];
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1866 %! unwind_protect
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1867 %! save (mat_file, "struc", "-v6");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1868 %! clear ("struc");
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1869 %! load (mat_file);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1870 %! unwind_protect_cleanup
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1871 %! unlink (mat_file);
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1872 %! end_unwind_protect
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1873 %! assert (struc, struc2);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1874
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1875 ## Save and load struct with "-v7"
29134
5f90526a9c40 load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29128
diff changeset
1876 %!testif HAVE_ZLIB
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1877 %! struc.a = "foobar"; # normal string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1878 %! struc.b = "a"; # short string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1879 %! struc.c = ["foo"; "bar"]; # character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1880 %! struc.d = "ab".'; # short character matrix
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1881 %! struc.e = {"foo", "bar"}; # cell string
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1882 %! struc.f = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1883 %! struc.g = [1 2 3]; # double vector
29134
5f90526a9c40 load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29128
diff changeset
1884 %! struc.h = 1:5; # range
29128
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1885 %! struc2 = struc;
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1886 %! mat_file = [tempname(), ".mat"];
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1887 %! unwind_protect
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1888 %! save (mat_file, "struc", "-v7");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1889 %! clear ("struc");
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1890 %! load (mat_file);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1891 %! unwind_protect_cleanup
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1892 %! unlink (mat_file);
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1893 %! end_unwind_protect
cdc2f3799c85 Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29022
diff changeset
1894 %! assert (struc, struc2);
29019
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
1895
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
1896 ## Test input validation
29022
e8fa10f8920c Fix typo in BIST for save() and mark it as fixed.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29021
diff changeset
1897 %!testif HAVE_ZLIB <*59225>
29019
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
1898 %! fname = tempname ();
be883573bbcc Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents: 29007
diff changeset
1899 %! x = 1;
29020
1db3841f042f load-save.cc: Run BIST with "-zip" only if HAVE_ZLIB is defined.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29019
diff changeset
1900 %! fail ('save ("-append", "-zip", "-binary", fname, "x")',
29022
e8fa10f8920c Fix typo in BIST for save() and mark it as fixed.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29021
diff changeset
1901 %! "-append and -zip options .* with a text format");
28313
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1902 */
d13ad9dc9348 Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28217
diff changeset
1903
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
1904 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
1905 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
1906 @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
1907 @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
1908 @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
1909 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
1910 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
1911 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
1912
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1913 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
1914 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
1915 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
1916 @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
1917 @end deftypefn */)
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1918 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1919 load_save_system& load_save_sys = interp.get_load_save_system ();
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
1920
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1921 return load_save_sys.crash_dumps_octave_core (args, nargout);
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1922 }
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1923
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1924 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
1925 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
1926 @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
1927 @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
1928 @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
1929 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
1930 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
1931
23557
00b11cee2100 doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents: 23455
diff changeset
1932 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
1933 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
1934
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1935 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
1936 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
1937 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
1938 @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
1939 @end deftypefn */)
4788
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
1940 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1941 load_save_system& load_save_sys = interp.get_load_save_system ();
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
1942
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1943 return load_save_sys.save_default_options (args, nargout);
4788
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
1944 }
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
1945
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
1946 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
1947 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
1948 @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
1949 @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
1950 @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
1951 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
1952 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
1953
25106
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25103
diff changeset
1954 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
1955 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
1956 @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
1957
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25103
diff changeset
1958 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
1959 @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
1960 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
1961 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
1962
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1963 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
1964 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
1965 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
1966 @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
1967 @end deftypefn */)
3709
c73bea82af94 [project @ 2000-08-02 02:23:26 by jwe]
jwe
parents: 3697
diff changeset
1968 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1969 load_save_system& load_save_sys = interp.get_load_save_system ();
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
1970
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1971 return load_save_sys.octave_core_file_limit (args, nargout);
3709
c73bea82af94 [project @ 2000-08-02 02:23:26 by jwe]
jwe
parents: 3697
diff changeset
1972 }
c73bea82af94 [project @ 2000-08-02 02:23:26 by jwe]
jwe
parents: 3697
diff changeset
1973
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
1974 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
1975 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
1976 @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
1977 @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
1978 @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
1979 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
1980 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
1981
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1982 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
1983
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1984 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
1985 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
1986 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
1987 @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
1988 @end deftypefn */)
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1989 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1990 load_save_system& load_save_sys = interp.get_load_save_system ();
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
1991
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1992 return load_save_sys.octave_core_file_name (args, nargout);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1993 }
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4788
diff changeset
1994
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
1995 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
1996 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
1997 @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
1998 @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
1999 @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
2000 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
2001 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
2002
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
2003 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
2004 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
2005 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
2006
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
2007 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
2008 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
2009 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
2010 @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
2011 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
2012 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2013 load_save_system& load_save_sys = interp.get_load_save_system ();
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
2014
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
2015 return load_save_sys.octave_core_file_options (args, nargout);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
2016 }
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
2017
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
2018 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
2019 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
2020 @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
2021 @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
2022 @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
2023 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
2024 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
2025 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
2026
23557
00b11cee2100 doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents: 23455
diff changeset
2027 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
2028 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
2029 @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
2030 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
2031 @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
2032
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
2033 @smallexample
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
2034 "# 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
2035 @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
2036
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
2037 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
2038 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
2039 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
2040 @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
2041 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
2042 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2043 load_save_system& load_save_sys = interp.get_load_save_system ();
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
2044
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
2045 return load_save_sys.save_header_format_string (args, nargout);
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
2046 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
2047
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
2048 OCTAVE_NAMESPACE_END
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2049
30000
362029cc0202 * load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
2050 // DEPRECATED in Octave 7
362029cc0202 * load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
2051
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2052 void
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2053 dump_octave_core (void)
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2054 {
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2055 octave::load_save_system& load_save_sys
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2056 = octave::__get_load_save_system__ ("dump_octave_core");
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2057
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2058 load_save_sys.dump_octave_core ();
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
2059 }