annotate libinterp/corefcn/load-save.cc @ 28217:87554d9ac6f8 stable

Warn if -v7.3 format is used for load/save (bug #45706). * load-save.cc (Fload, Fsave): Document that -v7.3 format is not implemented. * load-save.cc (load_save_system::parse_save_options): Detect '-v7.3' option and issue an error() that format is not implemented. * load-save.cc (load_save_system::load): Detect '-v7.3' option and issue an error() that format is not implemented. Re-order if/elseif tree for clarity.
author Rik <rik@octave.org>
date Tue, 14 Apr 2020 11:09:42 -0700
parents 9f9ac219896d
children d13ad9dc9348 dc80e087df4b
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1994-2020 The Octave Project Developers
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
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
93 namespace octave
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
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
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
168 std::string ascii_fname = sys::get_ASCII_filename (fname);
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25580
diff changeset
169
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
170 std::ifstream file (ascii_fname.c_str (),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
171 std::ios::in | std::ios::binary);
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
172
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
173 unsigned char magic[2];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
174 if (file.read (reinterpret_cast<char *> (&magic[0]), 2)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
175 && magic[0] == 0x1f && magic[1] == 0x8b)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
176 retval = true;
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
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 file.close ();
23777
cda0614beaec Replace static instances of OCTAVE_LOCAL_BUFFER with local variables.
Rik <rik@octave.org>
parents: 23693
diff changeset
179
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
180 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
181 }
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
182 #endif
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
183
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
184 static std::string
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
185 find_file_to_load (const std::string& name, const std::string& orig_name)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
186 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
187 std::string fname = find_data_file_in_load_path ("load", name, true);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
188
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
189 size_t dot_pos = fname.rfind ('.');
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
190 size_t sep_pos = fname.find_last_of (sys::file_ops::dir_sep_chars ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
191
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
192 if (dot_pos == std::string::npos
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
193 || (sep_pos != std::string::npos && dot_pos < sep_pos))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
194 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
195 // Either no '.' in name or no '.' appears after last directory
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
196 // separator.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
197
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
198 sys::file_stat fs (fname);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
199
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
200 if (! (fs.exists () && fs.is_reg ()))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
201 fname = find_file_to_load (fname + ".mat", orig_name);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
202 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
203 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
204 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
205 sys::file_stat fs (fname);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
206
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
207 if (! (fs.exists () && fs.is_reg ()))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
208 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
209 fname = "";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
210
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
211 error ("load: unable to find file %s", orig_name.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
212 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
213 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
214
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
215 return fname;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
216 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
217
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
218 // Return TRUE if PATTERN has any special globbing chars in it.
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
219
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
220 static bool
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
221 glob_pattern_p (const std::string& pattern)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
222 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
223 int open = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
224
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
225 int len = pattern.length ();
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
226
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
227 for (int i = 0; i < len; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
228 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
229 char c = pattern[i];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
230
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
231 switch (c)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
232 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
233 case '?':
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
234 case '*':
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
235 return true;
1180
0a9c94ee69e8 [project @ 1995-03-24 06:20:14 by jwe]
jwe
parents: 1159
diff changeset
236
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
237 case '[': // Only accept an open brace if there is a close
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
238 open++; // brace to match it. Bracket expressions must be
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
239 continue; // complete, according to Posix.2
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
240
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
241 case ']':
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
242 if (open)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
243 return true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
244 continue;
1180
0a9c94ee69e8 [project @ 1995-03-24 06:20:14 by jwe]
jwe
parents: 1159
diff changeset
245
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
246 case '\\':
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
247 if (i == len - 1)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
248 return false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
249 continue;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
250
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
251 default:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
252 continue;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
253 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
254 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
255
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
256 return false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
257 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
258
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
259 load_save_system::load_save_system (interpreter& interp)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
260 : m_interpreter (interp),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
261 m_crash_dumps_octave_core (true),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
262 m_octave_core_file_limit (-1.0),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
263 m_octave_core_file_name ("octave-workspace"),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
264 m_save_default_options ("-text"),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
265 m_octave_core_file_options ("-binary"),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
266 m_save_header_format_string (init_save_header_format ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
267 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
268 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
269 H5dont_atexit ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
270 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
271 }
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
272
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
273 load_save_system::~load_save_system (void)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
274 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
275 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
276 H5close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
277 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
278 }
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4153
diff changeset
279
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
280 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
281 load_save_system::crash_dumps_octave_core (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
282 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
283 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
284 return set_internal_variable (m_crash_dumps_octave_core, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
285 "crash_dumps_octave_core");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
286 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
287
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
288 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
289 load_save_system::octave_core_file_limit (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
290 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
291 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
292 return set_internal_variable (m_octave_core_file_limit, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
293 "octave_core_file_limit");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
294 }
17183
ca5103ab0b21 check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17170
diff changeset
295
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
296 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
297 load_save_system::octave_core_file_name (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
298 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
299 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
300 return set_internal_variable (m_octave_core_file_name, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
301 "octave_core_file_name", false);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
302 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
303
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
304 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
305 load_save_system::save_default_options (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
306 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
307 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
308 return set_internal_variable (m_save_default_options, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
309 "save_default_options", false);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
310 }
17183
ca5103ab0b21 check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17170
diff changeset
311
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
312 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
313 load_save_system::octave_core_file_options (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
314 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
315 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
316 return set_internal_variable (m_octave_core_file_options, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
317 "octave_core_file_options", false);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
318 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
319
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
320 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
321 load_save_system::save_header_format_string (const octave_value_list& args,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
322 int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
323 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
324 return set_internal_variable (m_save_header_format_string, args, nargout,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
325 "save_header_format_string");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
326 }
5977
27dd5b29489b [project @ 2006-08-30 20:03:53 by jwe]
jwe
parents: 5958
diff changeset
327
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
328 load_save_format
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
329 load_save_system::get_file_format (const std::string& fname,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
330 const std::string& orig_fname,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
331 bool& use_zlib, bool quiet)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
332 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
333 load_save_format retval = UNKNOWN;
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
334
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
335 std::string ascii_fname = sys::get_ASCII_filename (fname);
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25580
diff changeset
336
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
337 #if defined (HAVE_HDF5)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
338 // check this before we open the file
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
339 if (H5Fis_hdf5 (ascii_fname.c_str ()) > 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
340 return HDF5;
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
341 #endif
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
342
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
343 #if defined (HAVE_ZLIB)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
344 use_zlib = check_gzip_magic (fname);
17183
ca5103ab0b21 check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17170
diff changeset
345 #else
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
346 use_zlib = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
347 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
348
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
349 if (! use_zlib)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
350 {
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 std::ifstream file (ascii_fname.c_str (),
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
352 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
353 if (file)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
354 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
355 retval = get_file_format (file, orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
356 file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
357 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
358 else if (! quiet)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
359 err_file_open ("load", orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
360 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
361 #if defined (HAVE_ZLIB)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
362 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
363 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
364 gzifstream gzfile (fname.c_str (), std::ios::in | std::ios::binary);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
365 if (gzfile)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
366 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
367 retval = get_file_format (gzfile, orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
368 gzfile.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
369 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
370 else if (! quiet)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
371 err_file_open ("load", orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
372 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
373 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
374
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
375 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
376 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
377
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
378 octave_value
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
379 load_save_system::load_vars (std::istream& stream,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
380 const std::string& orig_fname,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
381 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
382 mach_info::float_format flt_fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
383 bool list_only, bool swap, bool verbose,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
384 const string_vector& argv, int argv_idx,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
385 int argc, int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
386 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
387 octave_value retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
388
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
389 octave_scalar_map retstruct;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
390
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
391 std::ostringstream output_buf;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
392 std::list<std::string> symbol_names;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
393
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
394 octave_idx_type count = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
395
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
396 for (;;)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
397 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
398 bool global = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
399 octave_value tc;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
400
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
401 std::string name;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
402 std::string doc;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
403
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
404 switch (fmt.type ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
405 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
406 case TEXT:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
407 name = read_text_data (stream, orig_fname, global, tc, count);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
408 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
409
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
410 case BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
411 name = read_binary_data (stream, swap, flt_fmt, orig_fname,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
412 global, tc, doc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
413 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
414
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
415 case MAT_ASCII:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
416 name = read_mat_ascii_data (stream, orig_fname, tc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
417 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
418
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
419 case MAT_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
420 name = read_mat_binary_data (stream, orig_fname, tc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
421 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
422
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
423 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
424 case HDF5:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
425 name = read_hdf5_data (stream, orig_fname, global, tc, doc,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
426 argv, argv_idx, argc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
427 break;
5977
27dd5b29489b [project @ 2006-08-30 20:03:53 by jwe]
jwe
parents: 5958
diff changeset
428 #endif
5269
a90ce2dc8b1e [project @ 2005-04-06 19:20:09 by dbateman]
dbateman
parents: 5256
diff changeset
429
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
430 case MAT5_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
431 case MAT7_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
432 name = read_mat5_binary_element (stream, orig_fname, swap,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
433 global, tc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
434 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
435
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
436 default:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
437 err_unrecognized_data_fmt ("load");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
438 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
439 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
440
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
441 if (stream.eof () || name.empty ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
442 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
443 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
444 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
445 if (! tc.is_defined ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
446 error ("load: unable to load variable '%s'", name.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
447
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
448 if (fmt.type () == MAT_ASCII && argv_idx < argc)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
449 warning ("load: loaded ASCII file '%s' -- ignoring extra args",
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
450 orig_fname.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
451
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
452 if (fmt.type () == MAT_ASCII
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
453 || argv_idx == argc
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
454 || matches_patterns (argv, argv_idx, argc, name))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
455 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
456 count++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
457 if (list_only)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
458 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
459 if (verbose)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
460 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
461 if (count == 1)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
462 output_buf
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
463 << "type rows cols name\n"
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
464 << "==== ==== ==== ====\n";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
465
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
466 output_buf
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
467 << std::setiosflags (std::ios::left)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
468 << std::setw (16) << tc.type_name ().c_str ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
469 << std::setiosflags (std::ios::right)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
470 << std::setw (7) << tc.rows ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
471 << std::setw (7) << tc.columns ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
472 << " " << name << "\n";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
473 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
474 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
475 symbol_names.push_back (name);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
476 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
477 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
478 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
479 if (nargout == 1)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
480 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
481 if (fmt.type () == MAT_ASCII)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
482 retval = tc;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
483 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
484 retstruct.assign (name, tc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
485 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
486 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
487 install_loaded_variable (name, tc, global, doc);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
488 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
489 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
490
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
491 // Only attempt to read one item from a headless text file.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
492
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
493 if (fmt.type () == MAT_ASCII)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
494 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
495 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
496 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
497
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
498 if (list_only && count)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
499 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
500 if (verbose)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
501 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
502 std::string msg = output_buf.str ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
503
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
504 if (nargout > 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
505 retval = msg;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
506 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
507 octave_stdout << msg;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
508 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
509 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
510 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
511 if (nargout > 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
512 retval = Cell (string_vector (symbol_names));
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
513 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
514 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
515 string_vector names (symbol_names);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
516
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
517 names.list_in_columns (octave_stdout);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
518
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
519 octave_stdout << "\n";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
520 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
521 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
522 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
523 else if (retstruct.nfields () != 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
524 retval = retstruct;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
525
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
526 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
527 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
528
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
529 string_vector
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
530 load_save_system::parse_save_options (const string_vector& argv,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
531 load_save_format& fmt, bool& append,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
532 bool& save_as_floats, bool& use_zlib)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
533 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
534 #if ! defined (HAVE_ZLIB)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
535 octave_unused_parameter (use_zlib);
17183
ca5103ab0b21 check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17170
diff changeset
536 #endif
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
537
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
538 string_vector retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
539 int argc = argv.numel ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
540
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
541 bool do_double = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
542 bool do_tabs = false;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
543
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
544 for (int i = 0; i < argc; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
545 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
546 if (argv[i] == "-append")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
547 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
548 append = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
549 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
550 else if (argv[i] == "-ascii" || argv[i] == "-a")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
551 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
552 fmt.set_type (MAT_ASCII);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
553 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
554 else if (argv[i] == "-double")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
555 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
556 do_double = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
557 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
558 else if (argv[i] == "-tabs")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
559 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
560 do_tabs = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
561 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
562 else if (argv[i] == "-text" || argv[i] == "-t")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
563 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
564 fmt.set_type (TEXT);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
565 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
566 else if (argv[i] == "-binary" || argv[i] == "-b")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
567 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
568 fmt.set_type (BINARY);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
569 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
570 else if (argv[i] == "-hdf5" || argv[i] == "-h")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
571 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
572 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
573 fmt.set_type (HDF5);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
574 #else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
575 err_disabled_feature ("save", "HDF5");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
576 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
577 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
578 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
579 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
580 error ("save: Matlab file format -v7.3 is not yet implemented");
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
581 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
582 #if defined (HAVE_ZLIB)
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
583 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
584 || argv[i] == "-mat7-binary")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
585 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
586 fmt.set_type (MAT7_BINARY);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
587 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
588 #endif
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
589 else if (argv[i] == "-mat" || argv[i] == "-m"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
590 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
591 || argv[i] == "-mat-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
592 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
593 fmt.set_type (MAT5_BINARY);
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
594 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
595 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
596 || argv[i] == "-mat4-binary")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
597 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
598 fmt.set_type (MAT_BINARY);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
599 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
600 else if (argv[i] == "-float-binary" || argv[i] == "-f")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
601 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
602 fmt.set_type (BINARY);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
603 save_as_floats = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
604 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
605 else if (argv[i] == "-float-hdf5")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
606 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
607 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
608 fmt.set_type (HDF5);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
609 save_as_floats = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
610 #else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
611 err_disabled_feature ("save", "HDF5");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
612 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
613 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
614 #if defined (HAVE_ZLIB)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
615 else if (argv[i] == "-zip" || argv[i] == "-z")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
616 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
617 use_zlib = true;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
618 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
619 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
620 else if (argv[i] == "-struct")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
621 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
622 retval.append (argv[i]);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
623 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
624 else if (argv[i][0] == '-' && argv[i] != "-")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
625 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
626 error ("save: Unrecognized option '%s'", argv[i].c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
627 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
628 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
629 retval.append (argv[i]);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
630 }
3727
e6d0041aedf3 [project @ 2000-10-31 02:08:49 by jwe]
jwe
parents: 3709
diff changeset
631
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
632 if (do_double)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
633 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
634 if (fmt.type () == MAT_ASCII)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
635 fmt.set_option (MAT_ASCII_LONG);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
636 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
637 warning (R"(save: "-double" option only has an effect with "-ascii")");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
638 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
639
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
640 if (do_tabs)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
641 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
642 if (fmt.type () == MAT_ASCII)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
643 fmt.set_option (MAT_ASCII_TABS);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
644 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
645 warning (R"(save: "-tabs" option only has an effect with "-ascii")");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
646 }
4051
b79da8779a0e [project @ 2002-08-17 19:38:32 by jwe]
jwe
parents: 4009
diff changeset
647
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
648 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
649 }
4051
b79da8779a0e [project @ 2002-08-17 19:38:32 by jwe]
jwe
parents: 4009
diff changeset
650
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
651 string_vector
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
652 load_save_system::parse_save_options (const std::string& arg,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
653 load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
654 bool& append, bool& save_as_floats,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
655 bool& use_zlib)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
656 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
657 std::istringstream is (arg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
658 std::string str;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
659 string_vector argv;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
660
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
661 while (! is.eof ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
662 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
663 is >> str;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
664 argv.append (str);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
665 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
666
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
667 return parse_save_options (argv, fmt, append, save_as_floats, use_zlib);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
668 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
669
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
670 void load_save_system::save_vars (const string_vector& argv, int argv_idx,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
671 int argc, std::ostream& os,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
672 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
673 bool save_as_floats,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
674 bool write_header_info)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
675 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
676 if (write_header_info)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
677 write_header (os, fmt);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
678
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
679 if (argv_idx == argc)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
680 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
681 save_vars (os, "*", fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
682 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
683 else if (argv[argv_idx] == "-struct")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
684 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
685 if (++argv_idx >= argc)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
686 error ("save: missing struct name");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
687
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
688 std::string struct_name = argv[argv_idx];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
689
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
690 if (! m_interpreter.is_variable (struct_name))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
691 error ("save: no such variable: '%s'", struct_name.c_str ());
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
692
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
693 octave_value struct_var = m_interpreter.varval (struct_name);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
694
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
695 if (! struct_var.isstruct () || struct_var.numel () != 1)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
696 error ("save: '%s' is not a scalar structure", struct_name.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
697
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
698 octave_scalar_map struct_var_map = struct_var.scalar_map_value ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
699
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
700 ++argv_idx;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
701
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
702 if (argv_idx < argc)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
703 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
704 for (int i = argv_idx; i < argc; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
705 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
706 if (! save_fields (os, struct_var_map, argv[i], fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
707 save_as_floats))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
708 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
709 warning ("save: no such field '%s.%s'",
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
710 struct_name.c_str (), argv[i].c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
711 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
712 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
713 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
714 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
715 save_fields (os, struct_var_map, "*", fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
716 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
717 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
718 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
719 for (int i = argv_idx; i < argc; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
720 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
721 if (argv[i] == "")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
722 continue; // Skip empty vars for Matlab compatibility
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
723 if (! save_vars (os, argv[i], fmt, save_as_floats))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
724 warning ("save: no such variable '%s'", argv[i].c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
725 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
726 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
727 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
728
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
729 void load_save_system::dump_octave_core (void)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
730 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
731 if (m_crash_dumps_octave_core)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
732 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
733 // FIXME: should choose better filename?
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
734
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
735 const char *fname = m_octave_core_file_name.c_str ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
736
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
737 message (nullptr, "attempting to save variables to '%s'...", fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
738
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
739 load_save_format fmt (BINARY);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
740
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
741 bool save_as_floats = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
742
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
743 bool append = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
744
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
745 bool use_zlib = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
746
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
747 load_save_system::parse_save_options (m_octave_core_file_options,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
748 fmt, append, save_as_floats,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
749 use_zlib);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
750
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
751 std::ios::openmode mode = std::ios::out;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
752
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
753 // Matlab v7 files are always compressed
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
754 if (fmt.type () == MAT7_BINARY)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
755 use_zlib = false;
2511
9b0dd36714eb [project @ 1996-11-14 02:57:33 by jwe]
jwe
parents: 2499
diff changeset
756
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
757 if (fmt.type () == BINARY
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
758 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
759 || fmt.type () == HDF5
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
760 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
761 || fmt.type () == MAT_BINARY
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
762 || fmt.type () == MAT5_BINARY
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
763 || fmt.type () == MAT7_BINARY)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
764 mode |= std::ios::binary;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
765
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
766 mode |= append ? std::ios::ate : std::ios::trunc;
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
767
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
768 #if defined (HAVE_HDF5)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
769 if (fmt.type () == HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
770 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
771 hdf5_ofstream file (fname, mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
772
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
773 if (file.file_id >= 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
774 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
775 dump_octave_core (file, fname, fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
776
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
777 file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
778 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
779 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
780 warning ("dump_octave_core: unable to open '%s' for writing...",
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
781 fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
782 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
783 else
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
784 #endif
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
785 // don't insert any commands here! The open brace below must
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
786 // go with the else above!
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
787 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
788 #if defined (HAVE_ZLIB)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
789 if (use_zlib)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
790 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
791 gzofstream file (fname, mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
792
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
793 if (file)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
794 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
795 dump_octave_core (file, fname, fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
796
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
797 file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
798 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
799 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
800 warning ("dump_octave_core: unable to open '%s' for writing...",
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
801 fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
802 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
803 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
804 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
805 {
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 std::ofstream file (fname, mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
807
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
808 if (file)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
809 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
810 dump_octave_core (file, fname, fmt, save_as_floats);
3687
b5a285d1c1f4 [project @ 2000-06-29 21:33:00 by jwe]
jwe
parents: 3682
diff changeset
811
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
812 file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
813 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
814 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
815 warning ("dump_octave_core: unable to open '%s' for writing...",
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
816 fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
817 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
818 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
819 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
820 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
821
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
822 void load_save_system::write_header (std::ostream& os,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
823 const load_save_format& fmt)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
824 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
825 switch (fmt.type ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
826 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
827 case BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
828 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
829 os << (mach_info::words_big_endian ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
830 ? "Octave-1-B" : "Octave-1-L");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
831
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
832 mach_info::float_format flt_fmt = mach_info::native_float_format ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
833
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
834 char tmp = static_cast<char> (float_format_to_mopt_digit (flt_fmt));
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
835
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
836 os.write (&tmp, 1);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
837 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
838 break;
3688
8aea513ff224 [project @ 2000-06-29 22:50:23 by jwe]
jwe
parents: 3687
diff changeset
839
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
840 case MAT5_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
841 case MAT7_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
842 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
843 char const *versionmagic;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
844 char headertext[128];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
845 sys::gmtime now;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
846
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
847 // ISO 8601 format date
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
848 const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave "
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
849 OCTAVE_VERSION ", %Y-%m-%d %T UTC";
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
850 std::string comment_string = now.strftime (matlab_format);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
851
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
852 size_t len = std::min (comment_string.length (), static_cast<size_t> (124));
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
853 memset (headertext, ' ', 124);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
854 memcpy (headertext, comment_string.data (), len);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
855
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
856 // The first pair of bytes give the version of the MAT file
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
857 // format. The second pair of bytes form a magic number which
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
858 // signals a MAT file. MAT file data are always written in
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
859 // native byte order. The order of the bytes in the second
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
860 // pair indicates whether the file was written by a big- or
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
861 // little-endian machine. However, the version number is
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
862 // written in the *opposite* byte order from everything else!
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
863 if (mach_info::words_big_endian ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
864 versionmagic = "\x01\x00\x4d\x49"; // this machine is big endian
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
865 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
866 versionmagic = "\x00\x01\x49\x4d"; // this machine is little endian
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
867
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
868 memcpy (headertext+124, versionmagic, 4);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
869 os.write (headertext, 128);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
870 }
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
871
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
872 break;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
873
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
874 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
875 case HDF5:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
876 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
877 case TEXT:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
878 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
879 sys::localtime now;
3136
af7ec9d3a5e6 [project @ 1998-02-01 20:11:06 by jwe]
jwe
parents: 3131
diff changeset
880
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
881 std::string comment_string = now.strftime (m_save_header_format_string);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
882
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
883 if (! comment_string.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
884 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
885 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
886 if (fmt.type () == HDF5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
887 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
888 hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
889 H5Gset_comment (hs.file_id, "/", comment_string.c_str ());
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
890 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
891 else
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
892 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
893 os << comment_string << "\n";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
894 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
895 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
896 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
897
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
898 default:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
899 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
900 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
901 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
902
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
903 // Save variables with names matching PATTERN on stream OS in the
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
904 // format specified by FMT.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
905
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
906 size_t load_save_system::save_vars (std::ostream& os,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
907 const std::string& pattern,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
908 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
909 bool save_as_floats)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
910 {
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
911 tree_evaluator& tw = m_interpreter.get_evaluator ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
912
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
913 symbol_info_list syminfo_list = tw.glob_symbol_info (pattern);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
914
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
915 size_t saved = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
916
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
917 for (const auto& syminfo : syminfo_list)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
918 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
919 do_save (os, syminfo, fmt, save_as_floats);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
920
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
921 saved++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
922 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
923
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
924 return saved;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
925 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
926
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
927 void load_save_system::do_save (std::ostream& os, const octave_value& tc,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
928 const std::string& name,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
929 const std::string& help,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
930 bool global, const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
931 bool save_as_floats)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
932 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
933 switch (fmt.type ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
934 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
935 case TEXT:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
936 save_text_data (os, tc, name, global, 0);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
937 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
938
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
939 case BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
940 save_binary_data (os, tc, name, help, global, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
941 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
942
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
943 case MAT_ASCII:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
944 if (! save_mat_ascii_data (os, tc,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
945 fmt.options () & MAT_ASCII_LONG ? 16 : 8,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
946 fmt.options () & MAT_ASCII_TABS))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
947 warning ("save: unable to save %s in ASCII format", name.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
948 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
949
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
950 case MAT_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
951 save_mat_binary_data (os, tc, name);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
952 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
953
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
954 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
955 case HDF5:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
956 save_hdf5_data (os, tc, name, help, global, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
957 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
958 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
959
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
960 case MAT5_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
961 save_mat5_binary_element (os, tc, name, global, false, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
962 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
963
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
964 case MAT7_BINARY:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
965 save_mat5_binary_element (os, tc, name, global, true, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
966 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
967
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
968 default:
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
969 err_unrecognized_data_fmt ("save");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
970 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
971 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
972 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
973
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
974 // Save the info from SR on stream OS in the format specified by FMT.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
975
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
976 void load_save_system::do_save (std::ostream& os,
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
977 const symbol_info& syminfo,
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
978 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
979 bool save_as_floats)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
980 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
981 octave_value val = syminfo.value ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
982
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
983 if (val.is_defined ())
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
984 {
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
985 std::string name = syminfo.name ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
986 std::string help;
26092
661dfb062485 use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents: 26009
diff changeset
987 bool global = syminfo.is_global ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
988
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
989 do_save (os, val, name, help, global, fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
990 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
991 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
992
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
993 // save fields of a scalar structure STR matching PATTERN on stream OS
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
994 // in the format specified by FMT.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
995
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
996 size_t load_save_system::save_fields (std::ostream& os,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
997 const octave_scalar_map& m,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
998 const std::string& pattern,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
999 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1000 bool save_as_floats)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1001 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1002 glob_match pat (pattern);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1003
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1004 size_t saved = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1005
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1006 for (auto it = m.begin (); it != m.end (); it++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1007 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1008 std::string empty_str;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1009
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1010 if (pat.match (m.key (it)))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1011 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1012 do_save (os, m.contents (it), m.key (it), empty_str,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1013 0, fmt, save_as_floats);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1014
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1015 saved++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1016 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1017 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1018
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1019 return saved;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1020 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1021
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1022 void load_save_system::dump_octave_core (std::ostream& os,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1023 const char *fname,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1024 const load_save_format& fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1025 bool save_as_floats)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1026 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1027 write_header (os, fmt);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1028
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
1029 tree_evaluator& tw = m_interpreter.get_evaluator ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1030
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27073
diff changeset
1031 symbol_info_list syminfo_list = tw.top_scope_symbol_info ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1032
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1033 double save_mem_size = 0;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1034
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1035 for (const auto& syminfo : syminfo_list)
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1036 {
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1037 octave_value val = syminfo.value ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1038
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1039 std::string name = syminfo.name ();
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1040 std::string help;
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1041 bool global = syminfo.is_global ();
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1042
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1043 double val_size = val.byte_size () / 1024;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1044
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1045 // FIXME: maybe we should try to throw out the largest first...
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1046
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1047 if (m_octave_core_file_limit < 0
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1048 || save_mem_size + val_size < m_octave_core_file_limit)
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1049 {
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1050 save_mem_size += val_size;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1051
26093
6a03af2c4c9e use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents: 26092
diff changeset
1052 do_save (os, val, name, help, global, fmt, save_as_floats);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1053 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1054 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1055
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1056 message (nullptr, "save to '%s' complete", fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1057 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1058
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1059 // Install a variable with name NAME and the value VAL in the
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1060 // symbol table. If GLOBAL is TRUE, make the variable global.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1061
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1062 void load_save_system::install_loaded_variable (const std::string& name,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1063 const octave_value& val,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1064 bool global,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1065 const std::string& /*doc*/)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1066 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
1067 m_interpreter.install_variable (name, val, global);
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1068 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1069
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1070 std::string load_save_system::init_save_header_format (void)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1071 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1072 return
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1073 (std::string ("# Created by Octave " OCTAVE_VERSION
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
1074 ", %a %b %d %H:%M:%S %Y %Z <")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1075 + sys::env::get_user_name ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1076 + '@'
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1077 + sys::env::get_host_name ()
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1078 + '>');
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1079 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1080
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1081 load_save_format
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1082 load_save_system::get_file_format (std::istream& file,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1083 const std::string& filename)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1084 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1085 load_save_format retval = load_save_system::UNKNOWN;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1086
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1087 mach_info::float_format flt_fmt
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1088 = mach_info::flt_fmt_unknown;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1089
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1090 bool swap = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1091
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1092 if (read_binary_file_header (file, swap, flt_fmt, true) == 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1093 retval = BINARY;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1094 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1095 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1096 file.clear ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1097 file.seekg (0, std::ios::beg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1098
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1099 int32_t mopt, nr, nc, imag, len;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1100
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1101 int err = read_mat_file_header (file, swap, mopt, nr, nc, imag, len,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1102 true);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1103
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1104 if (! err)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1105 retval = MAT_BINARY;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1106 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1107 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1108 file.clear ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1109 file.seekg (0, std::ios::beg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1110
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1111 err = read_mat5_binary_file_header (file, swap, true, filename);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1112
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1113 if (! err)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1114 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1115 file.clear ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1116 file.seekg (0, std::ios::beg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1117 retval = MAT5_BINARY;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1118 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1119 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1120 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1121 file.clear ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1122 file.seekg (0, std::ios::beg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1123
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1124 std::string name_val = extract_keyword (file, "name");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1125 std::string type_val = extract_keyword (file, "type");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1126
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1127 if (name_val.empty () != true && type_val.empty () != true)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1128 retval = TEXT;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1129 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1130 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1131 file.clear ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1132 file.seekg (0, std::ios::beg);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1133
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1134 // FIXME: looks_like_mat_ascii_file does not check
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1135 // to see whether the file contains numbers. It
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1136 // just skips comments and checks for the same
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1137 // number of words on each line. We may need a
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1138 // better check here. The best way to do that might
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1139 // be just to try to read the file and see if it
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1140 // works.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1141
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1142 if (looks_like_mat_ascii_file (file, filename))
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1143 retval = MAT_ASCII;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1144 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1145 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1146 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1147 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1148
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1149 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1150 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1151
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1152 octave_value_list
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1153 load_save_system::load (const octave_value_list& args, int nargout)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1154 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1155 octave_value_list retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1156
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1157 int argc = args.length () + 1;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1158
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1159 string_vector argv = args.make_argv ("load");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1160
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1161 int i = 1;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1162 std::string orig_fname = "";
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1163
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1164 // Function called with Matlab-style ["filename", options] syntax
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1165 if (argc > 1 && ! argv[1].empty () && argv[1].at (0) != '-')
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1166 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1167 orig_fname = argv[1];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1168 i++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1169 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1170
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1171 // It isn't necessary to have the default load format stored in a
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1172 // user preference variable since we can determine the type of file
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1173 // as we are reading.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1174
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1175 load_save_format format = UNKNOWN;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1176
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1177 bool list_only = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1178 bool verbose = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1179
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1180 for (; i < argc; i++)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1181 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1182 if (argv[i] == "-text" || argv[i] == "-t")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1183 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1184 format = TEXT;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1185 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1186 else if (argv[i] == "-binary" || argv[i] == "-b")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1187 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1188 format = BINARY;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1189 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1190 else if (argv[i] == "-hdf5" || argv[i] == "-h")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1191 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1192 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1193 format = HDF5;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1194 #else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1195 err_disabled_feature ("load", "HDF5");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1196 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1197 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1198 else if (argv[i] == "-ascii" || argv[i] == "-a")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1199 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1200 format = MAT_ASCII;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1201 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1202 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1203 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1204 error ("load: Matlab file format -v7.3 is not yet implemented");
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1205 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1206 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1207 || argv[i] == "-mat7-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1208 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1209 format = MAT7_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1210 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1211 else if (argv[i] == "-mat" || argv[i] == "-m"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1212 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1213 || argv[i] == "-mat-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1214 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1215 format = MAT5_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1216 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1217 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4"
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1218 || argv[i] == "-mat4-binary")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1219 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1220 format = MAT_BINARY;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1221 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1222 else if (argv[i] == "-force" || argv[i] == "-f")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1223 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1224 // Silently ignore this
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1225 // warning ("load: -force ignored");
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1226 }
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1227 else if (argv[i] == "-import" || argv[i] == "-i")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1228 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1229 warning ("load: -import ignored");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1230 }
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1231 else if (argv[i] == "-list" || argv[i] == "-l")
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1232 {
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1233 list_only = true;
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1234 }
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1235 else if (argv[i] == "-verbose" || argv[i] == "-v")
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1236 {
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1237 verbose = true;
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1238 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1239 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1240 break;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1241 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1242
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1243 if (orig_fname == "")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1244 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1245 if (i == argc)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1246 print_usage ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1247
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1248 orig_fname = argv[i];
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1249 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1250 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1251 i--;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1252
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1253 mach_info::float_format flt_fmt = mach_info::flt_fmt_unknown;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1254
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1255 bool swap = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1256
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1257 if (orig_fname == "-")
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1258 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1259 i++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1260
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1261 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1262 if (format.type () == HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1263 error ("load: cannot read HDF5 format from stdin");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1264 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1265 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1266 if (format.type () != UNKNOWN)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1267 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1268 // FIXME: if we have already seen EOF on a previous call,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1269 // how do we fix up the state of std::cin so that we can get
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1270 // additional input? I'm afraid that we can't fix this
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1271 // using std::cin only.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1272
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1273 retval = load_vars (std::cin, orig_fname, format, flt_fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1274 list_only, swap, verbose, argv, i,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1275 argc, nargout);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1276 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1277 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1278 error ("load: must specify file format if reading from stdin");
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1279 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1280 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1281 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1282 std::string fname = sys::file_ops::tilde_expand (orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1283
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1284 fname = find_file_to_load (fname, orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1285
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1286 bool use_zlib = false;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1287
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1288 if (format.type () == UNKNOWN)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1289 format = get_file_format (fname, orig_fname, use_zlib);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1290
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1291 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1292 if (format.type () == HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1293 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1294 i++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1295
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1296 hdf5_ifstream hdf5_file (fname.c_str ());
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1297
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1298 if (hdf5_file.file_id < 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1299 err_file_open ("load", orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1300
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1301 retval = load_vars (hdf5_file, orig_fname, format, flt_fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1302 list_only, swap, verbose, argv, i,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1303 argc, nargout);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1304
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1305 hdf5_file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1306 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1307 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1308 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1309 // don't insert any statements here; the "else" above has to
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1310 // go with the "if" below!!!!!
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1311 if (format.type () != UNKNOWN)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1312 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1313 i++;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1314
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1315 // Always open in binary mode and handle various
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1316 // line-endings explicitly.
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1317 std::ios::openmode mode = std::ios::in | std::ios::binary;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1318
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1319 #if defined (HAVE_ZLIB)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1320 if (use_zlib)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
1321 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1322 gzifstream file (fname.c_str (), mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1323
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1324 if (! file)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1325 err_file_open ("load", orig_fname);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1326
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1327 if (format.type () == BINARY)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
1328 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1329 if (read_binary_file_header (file, swap, flt_fmt) < 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1330 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1331 if (file) file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1332 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1333 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1334 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1335 else if (format.type () == MAT5_BINARY
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1336 || format.type () == MAT7_BINARY)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1337 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1338 if (read_mat5_binary_file_header (file, swap, false,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1339 orig_fname) < 0)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1340 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1341 if (file) file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1342 return retval;
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1343 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10309
diff changeset
1344 }
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1345
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1346 retval = load_vars (file, orig_fname, format, flt_fmt,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1347 list_only, swap, verbose, argv, i,
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1348 argc, nargout);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1349
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1350 file.close ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1351 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1352 else
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1353 #endif
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1354 {
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 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
1356
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1357 std::ifstream file (ascii_fname.c_str (), mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
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
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1474 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
1475 #if defined (HAVE_HDF5)
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1476 || format.type () == HDF5
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1477 #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
1478 || format.type () == MAT_BINARY
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1479 || 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
1480 || 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
1481 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
1482
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 #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
1484 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
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 // 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
1487 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
1488 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
1489
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 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
1491
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1492 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
1493 = ! (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
1494
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1495 hdf5_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
1496
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1497 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
1498 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
1499
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1500 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
1501 write_header_info);
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1502
25993
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 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
1504 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1505 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
1506 #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
1507 // 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
1508 // 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
1509 {
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1510 #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
1511 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
1512 {
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 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
1514
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 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
1516 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
1517
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 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
1519
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 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
1521 write_header_info);
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1522
25993
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 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
1524 }
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 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
1526 #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
1527 {
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 std::ofstream file (fname.c_str (), mode);
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1529
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1530 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
1531 err_file_open ("save", fname);
621
9e90d4df19e2 [project @ 1994-08-16 14:55:18 by jwe]
jwe
parents: 620
diff changeset
1532
25993
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 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
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 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
1536 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
1537
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 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
1539 }
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 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1541 }
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1542
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1543 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
1544 }
863
a2e030473d6d [project @ 1994-10-31 23:41:05 by jwe]
jwe
parents: 777
diff changeset
1545 }
a2e030473d6d [project @ 1994-10-31 23:41:05 by jwe]
jwe
parents: 777
diff changeset
1546
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1547 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
1548 dump_octave_core (void)
6159
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
1549 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1550 octave::load_save_system& load_save_sys
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1551 = octave::__get_load_save_system__ ("dump_octave_core");
6159
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
1552
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1553 load_save_sys.dump_octave_core ();
6159
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
1554 }
645605133a6f [project @ 2006-11-14 02:55:05 by jwe]
jwe
parents: 5977
diff changeset
1555
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1556 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
1557 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
1558 @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
1559 @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
1560 @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
1561 @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
1562 @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
1563 @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
1564 @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
1565 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
1566 @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
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 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
1569 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
1570 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
1571 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
1572 option.
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 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
1575
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1576 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1577 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
1578 @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
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 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1581 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
1582 (@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
1583
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1584 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
1585 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
1586 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
1587 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
1588 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
1589
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1590 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
1591 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
1592 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
1593 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
1594 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
1595
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1596 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
1597 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
1598 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
1599 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
1600 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
1601 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
1602
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1603 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
1604
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1605 @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
1606 @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
1607 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
1608 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
1609 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
1610
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1611 @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
1612 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
1613 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
1614 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
1615 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
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 -binary
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 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
1619
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1620 @item -hdf5
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1621 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
1622 (@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
1623 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
1624 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
1625 @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
1626 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
1627
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1628 @item -import
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1629 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
1630 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
1631 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
1632
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1633 @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
1634 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
1635
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1636 @item -v7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1637 @itemx -V7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1638 @itemx -7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1639 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
1640
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1641 @item -v7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1642 @itemx -V7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1643 @itemx -7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1644 @itemx -mat7-binary
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1645 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
1646
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1647 @item -v6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1648 @itemx -V6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1649 @itemx -6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1650 @itemx -mat
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1651 @itemx -mat-binary
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1652 Force Octave to assume the file is in @sc{matlab}'s version 6 binary format.
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1653
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1654 @item -v4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1655 @itemx -V4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1656 @itemx -4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1657 @itemx -mat4-binary
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1658 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
1659
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1660 @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
1661 @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
1662 @end deftypefn */)
863
a2e030473d6d [project @ 1994-10-31 23:41:05 by jwe]
jwe
parents: 777
diff changeset
1663 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1664 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25580
diff changeset
1665
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1666 return load_save_sys.load (args, nargout);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1667 }
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1668
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1669 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
1670 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
1671 @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
1672 @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
1673 @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
1674 @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
1675 @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
1676 @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
1677 @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
1678 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
1679
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1680 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
1681 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
1682 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
1683 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
1684 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
1685 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
1686 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
1687 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
1688
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1689 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
1690 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
1691 @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
1692
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1693 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
1694
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1695 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1696 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
1697 @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
1698
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1699 @noindent
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1700 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
1701 @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
1702
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1703 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
1704 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
1705
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1706 @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
1707 @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
1708 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
1709
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1710 @item -ascii
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1711 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
1712 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
1713 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
1714 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
1715
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1716 @table @code
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1717 @item -double
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1718 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
1719
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1720 @item -tabs
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1721 Separate numbers with tabs.
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1722 @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
1723
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1724 @item -binary
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1725 Save the data in 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
1726
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1727 @item -float-binary
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1728 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
1729 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
1730 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
1731
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1732 @item -hdf5
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1733 Save the data in @sc{hdf5} format.
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1734 (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
1735 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
1736 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
1737
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1738 @item -float-hdf5
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1739 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
1740 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
1741 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
1742
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1743 @item -text
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1744 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
1745
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1746 @item -v7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1747 @itemx -V7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1748 @itemx -7.3
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1749 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
1750
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1751 @item -v7
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1752 @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
1753 @itemx -7
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1754 @itemx -mat7-binary
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1755 Save the data in @sc{matlab}'s v7 binary data format.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1756
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1757 @item -v6
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1758 @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
1759 @itemx -6
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1760 @itemx -mat
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1761 @itemx -mat-binary
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1762 Save the data in @sc{matlab}'s v6 binary data format.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1763
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1764 @item -v4
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1765 @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
1766 @itemx -4
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1767 @itemx -mat4-binary
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1768 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
1769
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1770 @item -zip
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1771 @itemx -z
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1772 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
1773 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
1774 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
1775 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
1776 @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
1777
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1778 The list of variables to save may use wildcard patterns containing the
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1779 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
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 @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
1782 @item ?
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1783 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
1784
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1785 @item *
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1786 Match 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
1787
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1788 @item [ @var{list} ]
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1789 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
1790 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
1791 @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
1792 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
1793
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1794 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
1795 @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
1796
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1797 @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
1798
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1799 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
1800 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
1801 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
1802 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
1803
28217
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1804 Example:
87554d9ac6f8 Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents: 27985
diff changeset
1805
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1806 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
1807
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1808 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1809 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
1810 @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
1811
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1812 @noindent
23985
aa127fce67e4 doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents: 23807
diff changeset
1813 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
1814 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
1815 @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
1816 @end deftypefn */)
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1817 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1818 octave::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
1819
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1820 return load_save_sys.save (args, nargout);
604
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1821 }
1acdc9e50cd2 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents:
diff changeset
1822
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1823 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
1824 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
1825 @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
1826 @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
1827 @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
1828 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
1829 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
1830 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
1831
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1832 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
1833 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
1834 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
1835 @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
1836 @end deftypefn */)
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1837 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1838 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1839
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1840 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
1841 }
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1842
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1843 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
1844 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
1845 @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
1846 @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
1847 @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
1848 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
1849 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
1850
23557
00b11cee2100 doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents: 23455
diff changeset
1851 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
1852 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
1853
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1854 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
1855 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
1856 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
1857 @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
1858 @end deftypefn */)
4788
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
1859 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1860 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1861
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1862 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
1863 }
82a558043db9 [project @ 2004-02-18 22:31:57 by jwe]
jwe
parents: 4726
diff changeset
1864
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1865 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
1866 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
1867 @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
1868 @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
1869 @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
1870 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
1871 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
1872
25106
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25103
diff changeset
1873 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
1874 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
1875 @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
1876
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25103
diff changeset
1877 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
1878 @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
1879 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
1880 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
1881
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1882 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
1883 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
1884 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
1885 @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
1886 @end deftypefn */)
3709
c73bea82af94 [project @ 2000-08-02 02:23:26 by jwe]
jwe
parents: 3697
diff changeset
1887 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1888 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1889
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1890 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
1891 }
c73bea82af94 [project @ 2000-08-02 02:23:26 by jwe]
jwe
parents: 3697
diff changeset
1892
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1893 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
1894 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
1895 @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
1896 @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
1897 @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
1898 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
1899 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
1900
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1901 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
1902
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1903 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
1904 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
1905 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
1906 @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
1907 @end deftypefn */)
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1908 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1909 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1910
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1911 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
1912 }
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4788
diff changeset
1913
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1914 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
1915 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
1916 @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
1917 @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
1918 @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
1919 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
1920 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
1921
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1922 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
1923 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
1924 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
1925
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1926 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
1927 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
1928 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
1929 @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
1930 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1931 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1932 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1933
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1934 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
1935 }
2194
c04b563fb768 [project @ 1996-05-14 08:50:17 by jwe]
jwe
parents: 2181
diff changeset
1936
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1937 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
1938 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
1939 @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
1940 @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
1941 @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
1942 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
1943 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
1944 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
1945
23557
00b11cee2100 doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents: 23455
diff changeset
1946 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
1947 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
1948 @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
1949 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
1950 @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
1951
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1952 @smallexample
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1953 "# 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
1954 @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
1955
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
1956 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
1957 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
1958 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
1959 @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
1960 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1961 {
25993
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1962 octave::load_save_system& load_save_sys = interp.get_load_save_system ();
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1963
f75bb9d659e0 eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents: 25697
diff changeset
1964 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
1965 }