Mercurial > octave
annotate libinterp/corefcn/load-save.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 670a0d878af1 |
children | dfa5d9c3ae72 aac27ad79be6 |
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 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30329
diff
changeset
|
3 // Copyright (C) 1994-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
604 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
604 | 28 #endif |
29 | |
1343 | 30 #include <cstring> |
31 | |
4249 | 32 #include <fstream> |
3503 | 33 #include <iomanip> |
34 #include <iostream> | |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
35 #include <list> |
5765 | 36 #include <sstream> |
1728 | 37 #include <string> |
38 | |
1961 | 39 #include "byte-swap.h" |
23455
73ff72d3d603
maint: Eliminate <cfloat.h> header from libinterp files
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
40 #include "dMatrix.h" |
1961 | 41 #include "data-conv.h" |
2926 | 42 #include "file-ops.h" |
6159 | 43 #include "file-stat.h" |
2926 | 44 #include "glob-match.h" |
2890 | 45 #include "lo-mappers.h" |
2318 | 46 #include "mach-info.h" |
3185 | 47 #include "oct-env.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
48 #include "oct-locbuf.h" |
3258 | 49 #include "oct-time.h" |
4171 | 50 #include "quit.h" |
1755 | 51 #include "str-vec.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21835
diff
changeset
|
52 #include "strftime-wrapper.h" |
1755 | 53 |
4332 | 54 #include "Cell.h" |
1352 | 55 #include "defun.h" |
604 | 56 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
57 #include "errwarn.h" |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
58 #include "interpreter.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23584
diff
changeset
|
59 #include "interpreter-private.h" |
6159 | 60 #include "load-path.h" |
1352 | 61 #include "load-save.h" |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
62 #include "oct-hdf5.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
63 #include "ovl.h" |
3687 | 64 #include "oct-map.h" |
4332 | 65 #include "ov-cell.h" |
1352 | 66 #include "pager.h" |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
67 #include "syminfo.h" |
1352 | 68 #include "sysdep.h" |
69 #include "unwind-prot.h" | |
604 | 70 #include "utils.h" |
2371 | 71 #include "variables.h" |
3185 | 72 #include "version.h" |
3688 | 73 |
4633 | 74 #include "ls-hdf5.h" |
75 #include "ls-mat-ascii.h" | |
76 #include "ls-mat4.h" | |
77 #include "ls-mat5.h" | |
20447
c6224b4e7774
maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents:
20443
diff
changeset
|
78 #include "ls-oct-text.h" |
4633 | 79 #include "ls-oct-binary.h" |
3688 | 80 |
10309 | 81 // Remove gnulib definitions, if any. |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
82 #if defined (close) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
83 # undef close |
10309 | 84 #endif |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
85 #if defined (open) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
86 # undef open |
5269 | 87 #endif |
88 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
89 #if defined (HAVE_ZLIB) |
30118
d809b99f1280
maint: rename "zfstream.[h|cc]" to "gzfstream.[h|cc]" to match class name.
Rik <rik@octave.org>
parents:
30000
diff
changeset
|
90 # include "gzfstream.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 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
93 OCTAVE_BEGIN_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
94 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
95 OCTAVE_NORETURN static |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
96 void |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
97 err_file_open (const std::string& fcn, const std::string& file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
98 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
99 if (fcn == "load") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
100 error ("%s: unable to open input file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
101 else if (fcn == "save") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
102 error ("%s: unable to open output file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
103 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
104 error ("%s: unable to open file '%s'", fcn.c_str (), file.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
105 } |
4788 | 106 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
107 // Return TRUE if NAME matches one of the given globbing PATTERNS. |
5369 | 108 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
109 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
110 matches_patterns (const string_vector& patterns, int pat_idx, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
111 int num_pat, const std::string& name) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
112 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
113 for (int i = pat_idx; i < num_pat; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
114 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
115 glob_match pattern (patterns[i]); |
604 | 116 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
117 if (pattern.match (name)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
118 return true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
119 } |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23603
diff
changeset
|
120 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
121 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
122 } |
25201
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25106
diff
changeset
|
123 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
124 static int |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
125 read_binary_file_header (std::istream& is, bool& swap, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
126 mach_info::float_format& flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
127 bool quiet = false) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
128 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
129 const int magic_len = 10; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
130 char magic[magic_len+1]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
131 is.read (magic, magic_len); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
132 magic[magic_len] = '\0'; |
604 | 133 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
134 if (strncmp (magic, "Octave-1-L", magic_len) == 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
135 swap = mach_info::words_big_endian (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
136 else if (strncmp (magic, "Octave-1-B", magic_len) == 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
137 swap = ! mach_info::words_big_endian (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
138 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
139 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
140 if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
141 error ("load: unable to read binary file"); |
604 | 142 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
143 return -1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
144 } |
3688 | 145 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
146 char tmp = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
147 is.read (&tmp, 1); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
148 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
149 flt_fmt = mopt_digit_to_float_format (tmp); |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20801
diff
changeset
|
150 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
151 if (flt_fmt == mach_info::flt_fmt_unknown) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
152 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
153 if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
154 error ("load: unrecognized binary format!"); |
2318 | 155 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
156 return -1; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
157 } |
3688 | 158 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
159 return 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
160 } |
604 | 161 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
162 #if defined (HAVE_ZLIB) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
163 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
164 check_gzip_magic (const std::string& fname) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
165 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
166 bool retval = false; |
21972
d31e0f704d0b
Open files in binary mode when testing file format (bug #48201).
Rik <rik@octave.org>
parents:
21966
diff
changeset
|
167 |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
168 std::ifstream file = sys::ifstream (fname.c_str (), |
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
169 std::ios::in | std::ios::binary); |
5269 | 170 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
171 unsigned char magic[2]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
172 if (file.read (reinterpret_cast<char *> (&magic[0]), 2) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
173 && magic[0] == 0x1f && magic[1] == 0x8b) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
174 retval = true; |
5269 | 175 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
176 file.close (); |
23777
cda0614beaec
Replace static instances of OCTAVE_LOCAL_BUFFER with local variables.
Rik <rik@octave.org>
parents:
23693
diff
changeset
|
177 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
178 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
179 } |
5269 | 180 #endif |
181 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
182 static std::string |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
183 find_file_to_load (const std::string& name, const std::string& orig_name) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
184 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
185 std::string fname = find_data_file_in_load_path ("load", name, true); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
186 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
187 std::size_t dot_pos = fname.rfind ('.'); |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
188 std::size_t sep_pos = fname.find_last_of (sys::file_ops::dir_sep_chars ()); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
189 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
190 if (dot_pos == std::string::npos |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
191 || (sep_pos != std::string::npos && dot_pos < sep_pos)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
192 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
193 // Either no '.' in name or no '.' appears after last directory |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
194 // separator. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
195 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
196 sys::file_stat fs (fname); |
604 | 197 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
198 if (! (fs.exists () && fs.is_reg ())) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
199 fname = find_file_to_load (fname + ".mat", orig_name); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
200 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
201 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
202 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
203 sys::file_stat fs (fname); |
604 | 204 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
205 if (! (fs.exists () && fs.is_reg ())) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
206 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
207 fname = ""; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
208 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
209 error ("load: unable to find file %s", orig_name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
210 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
211 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
212 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
213 return fname; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
214 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
215 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
216 // Return TRUE if PATTERN has any special globbing chars in it. |
3019 | 217 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
218 static bool |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
219 glob_pattern_p (const std::string& pattern) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
220 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
221 int open = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
222 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
223 int len = pattern.length (); |
604 | 224 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
225 for (int i = 0; i < len; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
226 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
227 char c = pattern[i]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
228 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
229 switch (c) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
230 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
231 case '?': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
232 case '*': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
233 return true; |
1180 | 234 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
235 case '[': // Only accept an open brace if there is a close |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
236 open++; // brace to match it. Bracket expressions must be |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
237 continue; // complete, according to Posix.2 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
238 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
239 case ']': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
240 if (open) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
241 return true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
242 continue; |
1180 | 243 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
244 case '\\': |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
245 if (i == len - 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
246 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
247 continue; |
604 | 248 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
249 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
250 continue; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
251 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
252 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
253 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
254 return false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
255 } |
3688 | 256 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
257 load_save_system::load_save_system (interpreter& interp) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
258 : m_interpreter (interp), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
259 m_crash_dumps_octave_core (true), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
260 m_octave_core_file_limit (-1.0), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
261 m_octave_core_file_name ("octave-workspace"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
262 m_save_default_options ("-text"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
263 m_octave_core_file_options ("-binary"), |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
264 m_save_header_format_string (init_save_header_format ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
265 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
266 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
267 H5dont_atexit (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
268 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
269 } |
3688 | 270 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
271 load_save_system::~load_save_system (void) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
272 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
273 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
274 H5close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
275 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
276 } |
4171 | 277 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
278 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
279 load_save_system::crash_dumps_octave_core (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
280 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
281 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
282 return set_internal_variable (m_crash_dumps_octave_core, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
283 "crash_dumps_octave_core"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
284 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
285 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
286 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
287 load_save_system::octave_core_file_limit (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
288 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
289 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
290 return set_internal_variable (m_octave_core_file_limit, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
291 "octave_core_file_limit"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
292 } |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
293 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
294 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
295 load_save_system::octave_core_file_name (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
296 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
297 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
298 return set_internal_variable (m_octave_core_file_name, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
299 "octave_core_file_name", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
300 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
301 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
302 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
303 load_save_system::save_default_options (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
304 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
305 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
306 return set_internal_variable (m_save_default_options, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
307 "save_default_options", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
308 } |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
309 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
310 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
311 load_save_system::octave_core_file_options (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
312 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
313 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
314 return set_internal_variable (m_octave_core_file_options, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
315 "octave_core_file_options", false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
316 } |
604 | 317 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
318 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
319 load_save_system::save_header_format_string (const octave_value_list& args, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
320 int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
321 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
322 return set_internal_variable (m_save_header_format_string, args, nargout, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
323 "save_header_format_string"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
324 } |
5977 | 325 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
326 load_save_format |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
327 load_save_system::get_file_format (const std::string& fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
328 const std::string& orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
329 bool& use_zlib, bool quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
330 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
331 load_save_format retval = UNKNOWN; |
5269 | 332 |
30243
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
333 #if defined (HAVE_HDF5_UTF8) |
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
334 std::string ascii_fname = fname; |
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
335 #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
|
336 std::string ascii_fname = sys::get_ASCII_filename (fname); |
30243
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
337 #endif |
25604
ca413f326224
Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25580
diff
changeset
|
338 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
339 #if defined (HAVE_HDF5) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
340 // check this before we open the file |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
341 if (H5Fis_hdf5 (ascii_fname.c_str ()) > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
342 return HDF5; |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
343 #endif |
604 | 344 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
345 #if defined (HAVE_ZLIB) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
346 use_zlib = check_gzip_magic (fname); |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
347 #else |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
348 use_zlib = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
349 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
350 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
351 if (! use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
352 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
353 std::ifstream file = sys::ifstream (fname.c_str (), |
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
354 std::ios::in | std::ios::binary); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
355 if (file) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
356 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
357 retval = get_file_format (file, orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
358 file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
359 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
360 else if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
361 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
362 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
363 #if defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
364 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
365 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
366 gzifstream gzfile (fname.c_str (), std::ios::in | std::ios::binary); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
367 if (gzfile) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
368 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
369 retval = get_file_format (gzfile, orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
370 gzfile.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
371 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
372 else if (! quiet) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
373 err_file_open ("load", orig_fname); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
374 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
375 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
376 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
377 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
378 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
379 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
380 octave_value |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
381 load_save_system::load_vars (std::istream& stream, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
382 const std::string& orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
383 const load_save_format& fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
384 mach_info::float_format flt_fmt, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
385 bool list_only, bool swap, bool verbose, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
386 const string_vector& argv, int argv_idx, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
387 int argc, int nargout) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
388 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
389 octave_value retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
390 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
391 octave_scalar_map retstruct; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
392 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
393 std::ostringstream output_buf; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
394 std::list<std::string> symbol_names; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
395 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
396 octave_idx_type count = 0; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
397 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
398 for (;;) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
399 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
400 bool global = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
401 octave_value tc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
402 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
403 std::string name; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
404 std::string doc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
405 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
406 switch (fmt.type ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
407 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
408 case TEXT: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
409 name = read_text_data (stream, orig_fname, global, tc, count); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
410 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
411 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
412 case BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
413 name = read_binary_data (stream, swap, flt_fmt, orig_fname, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
414 global, tc, doc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
415 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
416 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
417 case MAT_ASCII: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
418 name = read_mat_ascii_data (stream, orig_fname, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
419 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
420 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
421 case MAT_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
422 name = read_mat_binary_data (stream, orig_fname, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
423 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
424 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
425 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
426 case HDF5: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
427 name = read_hdf5_data (stream, orig_fname, global, tc, doc, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
428 argv, argv_idx, argc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
429 break; |
5977 | 430 #endif |
5269 | 431 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
432 case MAT5_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
433 case MAT7_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
434 name = read_mat5_binary_element (stream, orig_fname, swap, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
435 global, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
436 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
437 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
438 default: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
439 err_unrecognized_data_fmt ("load"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
440 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
441 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
442 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
443 if (stream.eof () || name.empty ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
444 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
445 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
446 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
447 if (! tc.is_defined ()) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
448 error ("load: unable to load variable '%s'", name.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
449 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
450 if (fmt.type () == MAT_ASCII && argv_idx < argc) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
451 warning ("load: loaded ASCII file '%s' -- ignoring extra args", |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
452 orig_fname.c_str ()); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
453 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
454 if (fmt.type () == MAT_ASCII |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
455 || argv_idx == argc |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
456 || matches_patterns (argv, argv_idx, argc, name)) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
457 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
458 count++; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
459 if (list_only) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
460 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
461 if (verbose) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
462 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
463 if (count == 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
464 output_buf |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
465 << "type rows cols name\n" |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
466 << "==== ==== ==== ====\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
467 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
468 output_buf |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
469 << std::setiosflags (std::ios::left) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
470 << std::setw (16) << tc.type_name ().c_str () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
471 << std::setiosflags (std::ios::right) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
472 << std::setw (7) << tc.rows () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
473 << std::setw (7) << tc.columns () |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
474 << " " << name << "\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
475 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
476 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
477 symbol_names.push_back (name); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
478 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
479 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
480 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
481 if (nargout == 1) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
482 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
483 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
484 retval = tc; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
485 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
486 retstruct.assign (name, tc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
487 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
488 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
489 install_loaded_variable (name, tc, global, doc); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
490 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
491 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
492 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
493 // Only attempt to read one item from a headless text file. |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
494 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
495 if (fmt.type () == MAT_ASCII) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
496 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
497 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
498 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
499 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
500 if (list_only && count) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
501 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
502 if (verbose) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
503 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
504 std::string msg = output_buf.str (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
505 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
506 if (nargout > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
507 retval = msg; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
508 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
509 octave_stdout << msg; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
510 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
511 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
512 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
513 if (nargout > 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
514 retval = Cell (string_vector (symbol_names)); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
515 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
516 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
517 string_vector names (symbol_names); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
518 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
519 names.list_in_columns (octave_stdout); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
520 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
521 octave_stdout << "\n"; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
522 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
523 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
524 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
525 else if (retstruct.nfields () != 0) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
526 retval = retstruct; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
527 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
528 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
529 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
530 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
531 string_vector |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
532 load_save_system::parse_save_options (const string_vector& argv, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
533 load_save_format& fmt, bool& append, |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
534 bool& save_as_floats, bool& use_zlib) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
535 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
536 #if ! defined (HAVE_ZLIB) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
537 octave_unused_parameter (use_zlib); |
17183
ca5103ab0b21
check_gzip_magic before get_file_format (wrong type detection, bug #39652)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17170
diff
changeset
|
538 #endif |
604 | 539 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
540 string_vector retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
541 int argc = argv.numel (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
542 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
543 bool do_double = false; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
544 bool do_tabs = false; |
604 | 545 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
546 for (int i = 0; i < argc; i++) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
547 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
548 if (argv[i] == "-append") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
549 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
550 append = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
551 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
552 else if (argv[i] == "-ascii" || argv[i] == "-a") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
553 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
554 fmt.set_type (MAT_ASCII); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
555 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
556 else if (argv[i] == "-double") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
557 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
558 do_double = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
559 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
560 else if (argv[i] == "-tabs") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
561 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
562 do_tabs = true; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
563 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
564 else if (argv[i] == "-text" || argv[i] == "-t") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
565 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
566 fmt.set_type (TEXT); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
567 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
568 else if (argv[i] == "-binary" || argv[i] == "-b") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
569 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
570 fmt.set_type (BINARY); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
571 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
572 else if (argv[i] == "-hdf5" || argv[i] == "-h") |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
573 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
574 #if defined (HAVE_HDF5) |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
575 fmt.set_type (HDF5); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
576 #else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
577 err_disabled_feature ("save", "HDF5"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
578 #endif |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
579 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
580 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
|
581 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
582 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
|
583 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
584 #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
|
585 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
|
586 || 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
|
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 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
|
589 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
590 #endif |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
591 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
|
592 || 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
|
593 || 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
|
594 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
595 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
|
596 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
597 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
|
598 || 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
|
599 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
600 fmt.set_type (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
|
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 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
|
603 { |
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 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
|
605 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
|
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 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
|
608 { |
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 #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
|
610 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
|
611 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
|
612 #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
|
613 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
|
614 #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
|
615 } |
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 #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
|
617 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
|
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 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
|
620 } |
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 #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
|
622 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
|
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 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
|
625 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
626 else 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
|
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 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
|
629 } |
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 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
|
631 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
|
632 } |
3727 | 633 |
25993
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 (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
|
635 { |
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 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
|
637 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
|
638 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
|
639 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
|
640 } |
604 | 641 |
25993
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 (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
|
643 { |
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 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
|
645 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
|
646 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
|
647 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
|
648 } |
4051 | 649 |
29019
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
650 if (append && use_zlib |
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
651 && (fmt.type () != TEXT && fmt.type () != MAT_ASCII)) |
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
652 error ("save: -append and -zip options can only be used together with a text format (-text or -ascii)"); |
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
653 |
25993
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 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
|
655 } |
4051 | 656 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
657 string_vector |
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 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
|
659 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
|
660 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
|
661 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
|
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 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
|
664 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
|
665 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
|
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 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
|
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 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
|
670 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
|
671 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
672 |
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 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
|
674 } |
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 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 { |
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 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
|
683 write_header (os, fmt); |
604 | 684 |
25993
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 { |
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 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
|
688 } |
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 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
|
690 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
691 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
|
692 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
|
693 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
694 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
|
695 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
696 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
|
697 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
|
698 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
699 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
|
700 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
701 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
|
702 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
|
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 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
|
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 ++argv_idx; |
604 | 707 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
708 if (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
|
709 { |
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 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
|
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 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
|
713 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
|
714 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
715 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
|
716 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
|
717 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
718 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
719 } |
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 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
|
721 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
|
722 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
723 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
|
724 { |
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 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
|
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 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
|
728 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
|
729 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
|
730 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
|
731 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
732 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
733 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
734 |
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 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
|
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 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
|
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 // FIXME: should choose better filename? |
604 | 740 |
25993
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 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
|
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 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
|
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 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
|
746 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
747 bool 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
|
748 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
749 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
|
750 |
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 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
|
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 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
|
754 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
|
755 use_zlib); |
604 | 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 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
|
758 |
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 // 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
|
760 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
|
761 use_zlib = false; |
2511 | 762 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
763 if (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
|
764 #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
|
765 || 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
|
766 #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
|
767 || 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
|
768 || 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
|
769 || 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
|
770 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
|
771 |
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 mode |= append ? std::ios::ate : std::ios::trunc; |
604 | 773 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
774 #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
|
775 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
|
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 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
|
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 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
|
780 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
781 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
|
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 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
|
784 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
785 else |
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 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
|
787 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
|
788 } |
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 else |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
790 #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
|
791 // 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
|
792 // 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
|
793 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
794 #if 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
|
795 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
|
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 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
|
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 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
|
800 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
801 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
|
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 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
|
804 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
805 else |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
806 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
|
807 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
|
808 } |
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 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
|
810 #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
|
811 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
812 std::ofstream file = sys::ofstream (fname, mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
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 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
|
815 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
816 dump_octave_core (file, fname, fmt, save_as_floats); |
3687 | 817 |
25993
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 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
|
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 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
|
821 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
|
822 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
|
823 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
824 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
825 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
826 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
827 |
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 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
|
829 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
|
830 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
831 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
|
832 { |
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 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
|
834 { |
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 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
|
836 ? "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
|
837 |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
838 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
|
839 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
840 char tmp = static_cast<char> (float_format_to_mopt_digit (flt_fmt)); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
841 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
842 os.write (&tmp, 1); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
843 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
844 break; |
3688 | 845 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
846 case MAT5_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
847 case MAT7_BINARY: |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
848 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
849 char const *versionmagic; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
850 char headertext[128]; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
851 sys::gmtime now; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
852 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
853 // ISO 8601 format date |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
854 const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave " |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
855 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
|
856 std::string comment_string = now.strftime (matlab_format); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
857 |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30329
diff
changeset
|
858 std::size_t len = std::min (comment_string.length (), |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30329
diff
changeset
|
859 static_cast<std::size_t> (124)); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
860 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
|
861 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
|
862 |
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 // 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
|
864 // 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
|
865 // 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
|
866 // 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
|
867 // 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
|
868 // 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
|
869 // 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 |
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 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
|
876 os.write (headertext, 128); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
877 } |
604 | 878 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
879 break; |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
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 #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
|
882 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
|
883 #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
|
884 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
|
885 { |
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 sys::localtime now; |
3136 | 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 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
|
889 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
890 if (! comment_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
891 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
892 #if 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
|
893 if (fmt.type () == HDF5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
894 { |
25993
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 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
|
896 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
|
897 } |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
898 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
|
899 #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
|
900 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
|
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 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
|
904 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
905 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
|
906 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
|
907 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
908 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
909 |
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 // 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
|
911 // 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
|
912 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
913 std::size_t load_save_system::save_vars (std::ostream& os, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
914 const std::string& pattern, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
915 const load_save_format& fmt, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
916 bool save_as_floats) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
917 { |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
918 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
|
919 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
920 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
|
921 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
922 std::size_t saved = 0; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
923 |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
924 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
|
925 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
926 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
|
927 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
928 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
|
929 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
930 |
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 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
|
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 |
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 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 { |
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 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
|
941 { |
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 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
|
943 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
|
944 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
|
945 |
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 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
|
947 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
|
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_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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 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
|
956 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
957 case 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
|
958 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
|
959 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
960 |
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 #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
|
962 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
|
963 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
|
964 break; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
965 #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
|
966 |
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 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
|
968 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
|
969 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
|
970 |
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 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
|
972 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
|
973 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
|
974 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
975 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
|
976 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
|
977 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
|
978 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
979 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
980 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
981 // 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
|
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 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
|
984 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
|
985 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
|
986 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
|
987 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
988 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
|
989 |
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 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
|
991 { |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26009
diff
changeset
|
992 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
|
993 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
|
994 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
|
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 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
|
997 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
998 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
999 |
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 // 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
|
1001 // 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
|
1002 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1003 std::size_t load_save_system::save_fields (std::ostream& os, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1004 const octave_scalar_map& m, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1005 const std::string& pattern, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1006 const load_save_format& fmt, |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1007 bool save_as_floats) |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1008 { |
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 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
|
1010 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29413
diff
changeset
|
1011 std::size_t saved = 0; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1012 |
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 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
|
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 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
|
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 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
|
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 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
|
1020 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
|
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 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
|
1023 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1024 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1025 |
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 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
|
1027 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1028 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 { |
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 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
|
1035 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
1036 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
|
1037 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27073
diff
changeset
|
1038 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
|
1039 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1040 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
|
1041 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1042 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
|
1043 { |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1044 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
|
1045 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1046 std::string 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
|
1047 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
|
1048 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
|
1049 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1050 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
|
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 // 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
|
1053 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1054 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
|
1055 || 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
|
1056 { |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1057 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
|
1058 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
1059 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
|
1060 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1061 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1062 |
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 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
|
1064 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1065 |
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 // 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
|
1067 // 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
|
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 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
|
1070 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
|
1071 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
|
1072 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
|
1073 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1074 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
|
1075 } |
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 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
|
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 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
|
1080 (std::string ("# Created by Octave " OCTAVE_VERSION |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1081 ", %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
|
1082 + 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
|
1083 + '@' |
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 + 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
|
1085 + '>'); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1086 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1087 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1088 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
|
1089 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
|
1090 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
|
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 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
|
1093 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1094 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
|
1095 = 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
|
1096 |
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 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
|
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 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
|
1100 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
|
1101 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
|
1102 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1103 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
|
1104 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
|
1105 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1106 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
|
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 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
|
1109 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
|
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 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
|
1112 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
|
1113 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
|
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 |
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 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
|
1119 |
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 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
|
1121 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1122 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
|
1123 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
|
1124 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
|
1125 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1126 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
|
1127 { |
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 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
|
1129 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
|
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 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
|
1132 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
|
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 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
|
1135 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
|
1136 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
|
1137 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1138 file.clear (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1139 file.seekg (0, std::ios::beg); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1140 |
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 // 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
|
1142 // 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
|
1143 // 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
|
1144 // 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
|
1145 // 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
|
1146 // 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
|
1147 // 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
|
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 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
|
1150 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
|
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 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1153 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1154 } |
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 |
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 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
|
1157 } |
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 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
|
1160 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
|
1161 { |
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 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
|
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 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
|
1165 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1166 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
|
1167 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1168 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
|
1169 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
|
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 // 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
|
1172 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
|
1173 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1174 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
|
1175 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
|
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 |
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 // 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
|
1179 // 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
|
1180 // 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
|
1181 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1182 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
|
1183 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1184 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
|
1185 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
|
1186 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1187 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
|
1188 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1189 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
|
1190 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1191 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
|
1192 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1193 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
|
1194 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1195 format = 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
|
1196 } |
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 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
|
1198 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1199 #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
|
1200 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
|
1201 #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
|
1202 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
|
1203 #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
|
1204 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1205 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
|
1206 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1207 format = MAT_ASCII; |
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 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
|
1210 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1211 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
|
1212 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1213 else if (argv[i] == "-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
|
1214 || 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
|
1215 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1216 format = MAT7_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1217 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1218 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
|
1219 || 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
|
1220 || 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
|
1221 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1222 format = MAT5_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1223 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1224 else if (argv[i] == "-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
|
1225 || 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
|
1226 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1227 format = MAT_BINARY; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1228 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1229 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
|
1230 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1231 // Silently ignore this |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1232 // 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
|
1233 } |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1234 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
|
1235 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1236 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
|
1237 } |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1238 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
|
1239 { |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1240 list_only = true; |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1241 } |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1242 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
|
1243 { |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1244 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
|
1245 } |
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 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
|
1247 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
|
1248 } |
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 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
|
1251 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1252 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
|
1253 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
|
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 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
|
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 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
|
1258 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
|
1259 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1260 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
|
1261 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1262 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
|
1263 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1264 if (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
|
1265 { |
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 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
|
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 #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
|
1269 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
|
1270 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
|
1271 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
|
1272 #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
|
1273 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
|
1274 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1275 // 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
|
1276 // 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
|
1277 // 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
|
1278 // 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
|
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 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
|
1281 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
|
1282 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
|
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 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
|
1285 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
|
1286 } |
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 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
|
1288 { |
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 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
|
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 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
|
1292 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1293 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
|
1294 |
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 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
|
1296 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
|
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 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
|
1299 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
|
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 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
|
1302 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1303 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
|
1304 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1305 if (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
|
1306 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
|
1307 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1308 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
|
1309 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
|
1310 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
|
1311 |
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 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
|
1313 } |
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 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
|
1315 #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
|
1316 // 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
|
1317 // 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
|
1318 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
|
1319 { |
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 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
|
1321 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1322 // 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
|
1323 // 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
|
1324 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
|
1325 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1326 #if 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
|
1327 if (use_zlib) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
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 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
|
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) |
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 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
|
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 if (format.type () == BINARY) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1335 { |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1336 if (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
|
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 (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
|
1339 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
|
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 } |
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 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
|
1343 || 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
|
1344 { |
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 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
|
1346 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
|
1347 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1348 if (file) file.close (); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1349 return retval; |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1350 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1351 } |
25993
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 |
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 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
|
1354 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
|
1355 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
|
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 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
|
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 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
|
1360 #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
|
1361 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
1362 std::ifstream file = sys::ifstream (fname.c_str (), mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1363 |
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 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
|
1365 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
|
1366 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
|
1367 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1368 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
|
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 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
|
1371 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1372 if (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
|
1373 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
|
1374 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1375 } |
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 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
|
1377 || 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
|
1378 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1379 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
|
1380 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
|
1381 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1382 if (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
|
1383 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
|
1384 } |
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 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1387 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
|
1388 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
|
1389 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
|
1390 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1391 file.close (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10309
diff
changeset
|
1392 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1393 } |
25993
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 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
|
1395 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
|
1396 orig_fname.c_str ()); |
2511 | 1397 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1398 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1399 |
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 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
|
1401 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1402 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1403 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
|
1404 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
|
1405 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1406 // 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
|
1407 // 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
|
1408 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
|
1409 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
|
1410 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
|
1411 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
|
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 |
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 // 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
|
1415 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
|
1416 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 // 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
|
1419 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
|
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 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
|
1422 |
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 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
|
1424 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
|
1425 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1426 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
|
1427 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
|
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 (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
|
1430 error ("save: cannot specify both -text and -float-binary"); |
2511 | 1431 |
25993
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 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
|
1433 |
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 (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
|
1435 { |
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 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
|
1437 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1438 #if 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
|
1439 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
|
1440 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
|
1441 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
|
1442 #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
|
1443 // 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
|
1444 // 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
|
1445 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1446 if (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
|
1447 warning ("save: ignoring -append option for output to stdout"); |
604 | 1448 |
25993
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 if (nargout == 0) |
26009
3fc9d7453ba6
where possible, use octave_stdout and avoid including <iostream>
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
1450 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
|
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 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
|
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 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
|
1455 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
|
1456 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
|
1457 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
|
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 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1460 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1461 |
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 // 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
|
1463 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1464 else 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
|
1465 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
|
1466 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
|
1467 { |
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 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
|
1469 |
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 i++; |
2095 | 1471 |
25993
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 // 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
|
1473 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
|
1474 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
|
1475 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1476 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
|
1477 = (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
|
1478 |
28993
cc287e633588
Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28660
diff
changeset
|
1479 // Always open in binary mode to save line endings as is. |
cc287e633588
Always open files in binary mode for saving variables (bug #59238).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28660
diff
changeset
|
1480 mode |= std::ios::binary; |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1481 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1482 #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
|
1483 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
|
1484 { |
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 // 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
|
1486 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
|
1487 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
|
1488 |
30243
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
1489 # if defined (HAVE_HDF5_UTF8) |
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
1490 bool write_header_info |
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
1491 = ! (append && H5Fis_hdf5 (fname.c_str ()) > 0); |
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
1492 # 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
|
1493 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
|
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 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
|
1496 = ! (append && H5Fis_hdf5 (ascii_fname.c_str ()) > 0); |
30243
a4061ae5ff79
Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30118
diff
changeset
|
1497 # 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
|
1498 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1499 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
|
1500 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1501 if (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
|
1502 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
|
1503 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1504 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
|
1505 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1506 |
25993
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 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
|
1508 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1509 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
|
1510 #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
|
1511 // 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
|
1512 // 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
|
1513 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1514 #if 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
|
1515 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
|
1516 { |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1517 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
|
1518 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1519 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
|
1520 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
|
1521 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1522 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
|
1523 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1524 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
|
1525 write_header_info); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1526 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1527 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
|
1528 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1529 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
|
1530 #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
|
1531 { |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28993
diff
changeset
|
1532 std::ofstream file = sys::ofstream (fname.c_str (), mode); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1533 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1534 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
|
1535 err_file_open ("save", fname); |
621 | 1536 |
25993
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 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
|
1538 |
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 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
|
1540 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
|
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 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
|
1543 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1544 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1545 } |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1546 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1547 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
|
1548 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29655
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 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
|
1551 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
|
1552 @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
|
1553 @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
|
1554 @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
|
1555 @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
|
1556 @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
|
1557 @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
|
1558 @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
|
1559 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
|
1560 @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
|
1561 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 option. |
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 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
|
1569 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1570 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1571 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
|
1572 @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
|
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 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1575 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
|
1576 (@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
|
1577 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1578 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
|
1579 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
|
1580 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
|
1581 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
|
1582 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
|
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 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
|
1585 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
|
1586 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
|
1587 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
|
1588 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
|
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 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
|
1591 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
|
1592 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
|
1593 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
|
1594 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
|
1595 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
|
1596 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1597 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
|
1598 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1599 @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
|
1600 @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
|
1601 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
|
1602 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
|
1603 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
|
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 @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
|
1606 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
|
1607 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
|
1608 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
|
1609 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
|
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 -binary |
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 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
|
1613 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1614 @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
|
1615 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
|
1616 (@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
|
1617 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
|
1618 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
|
1619 @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
|
1620 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
|
1621 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1622 @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
|
1623 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
|
1624 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
|
1625 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
|
1626 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1627 @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
|
1628 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
|
1629 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1630 @item -v7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1631 @itemx -V7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1632 @itemx -7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1633 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
|
1634 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1635 @item -v7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1636 @itemx -V7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1637 @itemx -7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1638 @itemx -mat7-binary |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1639 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
|
1640 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1641 @item -v6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1642 @itemx -V6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1643 @itemx -6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1644 @itemx -mat |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1645 @itemx -mat-binary |
28660
dc80e087df4b
maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents:
28217
diff
changeset
|
1646 Force Octave to assume the file is in @sc{matlab}'s version 6 binary format. |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1647 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1648 @item -v4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1649 @itemx -V4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1650 @itemx -4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1651 @itemx -mat4-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 4 binary format. |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1653 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1654 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1655 @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
|
1656 @end deftypefn */) |
863 | 1657 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1658 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
|
1659 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1660 return load_save_sys.load (args, nargout); |
604 | 1661 } |
1662 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1663 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
|
1664 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
|
1665 @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
|
1666 @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
|
1667 @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
|
1668 @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
|
1669 @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
|
1670 @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
|
1671 @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
|
1672 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
|
1673 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1674 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
|
1675 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
|
1676 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
|
1677 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
|
1678 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
|
1679 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
|
1680 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
|
1681 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
|
1682 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1683 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
|
1684 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
|
1685 @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
|
1686 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1687 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
|
1688 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1689 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1690 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
|
1691 @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
|
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 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1694 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
|
1695 @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
|
1696 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1697 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
|
1698 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
|
1699 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1700 @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
|
1701 @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
|
1702 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
|
1703 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1704 @item -ascii |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1705 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
|
1706 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
|
1707 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
|
1708 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
|
1709 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1710 @table @code |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1711 @item -double |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1712 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
|
1713 |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1714 @item -tabs |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1715 Separate numbers with tabs. |
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1716 @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
|
1717 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1718 @item -binary |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1719 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
|
1720 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1721 @item -float-binary |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1722 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
|
1723 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
|
1724 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
|
1725 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1726 @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
|
1727 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
|
1728 (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
|
1729 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
|
1730 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
|
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 -float-hdf5 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1733 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
|
1734 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
|
1735 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
|
1736 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1737 @item -text |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1738 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
|
1739 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1740 @item -v7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1741 @itemx -V7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1742 @itemx -7.3 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1743 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
|
1744 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1745 @item -v7 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1746 @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
|
1747 @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
|
1748 @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
|
1749 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
|
1750 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1751 @item -v6 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1752 @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
|
1753 @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
|
1754 @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
|
1755 @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
|
1756 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
|
1757 |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1758 @item -v4 |
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1759 @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
|
1760 @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
|
1761 @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
|
1762 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
|
1763 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1764 @item -zip |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1765 @itemx -z |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 @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
|
1771 |
29413
cb2d14b384df
doc: Add note that wildcard patterns for "save" are glob patterns (bug #60157).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
1772 The list of variables to save may use wildcard patterns (glob patterns) |
cb2d14b384df
doc: Add note that wildcard patterns for "save" are glob patterns (bug #60157).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
1773 containing the following special characters: |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1774 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1775 @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
|
1776 @item ? |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1777 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
|
1778 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1779 @item * |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1780 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
|
1781 |
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 [ @var{list} ] |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1783 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
|
1784 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
|
1785 @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
|
1786 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
|
1787 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1788 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
|
1789 @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
|
1790 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1791 @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
|
1792 |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1793 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
|
1794 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
|
1795 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
|
1796 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
|
1797 |
28660
dc80e087df4b
maint: Strip trailing spaces from files.
Rik <rik@octave.org>
parents:
28217
diff
changeset
|
1798 Example: |
28217
87554d9ac6f8
Warn if -v7.3 format is used for load/save (bug #45706).
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
1799 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1800 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
|
1801 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1802 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1803 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
|
1804 @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
|
1805 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1806 @noindent |
23985
aa127fce67e4
doc: Document extra save options for -ascii format (bug #51898).
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
1807 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
|
1808 file @file{data} in Octave's binary format. |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1809 @seealso{load, save_default_options, save_header_format_string, save_precision, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1810 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
|
1811 @end deftypefn */) |
604 | 1812 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1813 load_save_system& load_save_sys = interp.get_load_save_system (); |
6759 | 1814 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1815 return load_save_sys.save (args, nargout); |
604 | 1816 } |
1817 | |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1818 /* |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1819 ## Save and load strings with "-v6" |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1820 %!test |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1821 %! A = A2 = "foobar"; # normal string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1822 %! B = B2 = "a"; # short string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1823 %! C = C2 = ["foo"; "bar"]; # character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1824 %! D = D2 = "ab".'; # short character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1825 %! E = E2 = {"foo", "bar"}; # cell string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1826 %! F = F2 = {"Saint Barthélemy", "Saint Kitts and Nevis"}; % non-ASCII |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1827 %! mat_file = [tempname(), ".mat"]; |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1828 %! unwind_protect |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1829 %! save (mat_file, "A", "B", "C", "D", "E", "F", "-v6"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1830 %! clear ("A", "B", "C", "D", "E", "F"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1831 %! load (mat_file); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1832 %! unwind_protect_cleanup |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1833 %! unlink (mat_file); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1834 %! end_unwind_protect |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1835 %! assert (A, A2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1836 %! assert (B, B2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1837 %! assert (C, C2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1838 %! assert (D, D2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1839 %! assert (E, E2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1840 %! assert (F, F2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1841 |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1842 ## Save and load strings with "-v7" |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1843 %!testif HAVE_ZLIB |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1844 %! A = A2 = "foobar"; # normal string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1845 %! B = B2 = "a"; # short string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1846 %! C = C2 = ["foo"; "bar"]; # character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1847 %! D = D2 = "ab".'; # short character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1848 %! E = E2 = {"foo", "bar"}; # cell string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1849 %! F = F2 = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1850 %! mat_file = [tempname(), ".mat"]; |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1851 %! unwind_protect |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1852 %! save (mat_file, "A", "B", "C", "D", "E", "F", "-v7"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1853 %! clear ("A", "B", "C", "D", "E", "F"); |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1854 %! load (mat_file); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1855 %! unwind_protect_cleanup |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1856 %! unlink (mat_file); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1857 %! end_unwind_protect |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1858 %! assert (A, A2); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1859 %! assert (B, B2); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1860 %! assert (C, C2); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1861 %! assert (D, D2); |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1862 %! assert (E, E2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1863 %! assert (F, F2); |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1864 |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1865 ## Save and load struct with "-v6" |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1866 %!test |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1867 %! struc.a = "foobar"; # normal string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1868 %! struc.b = "a"; # short string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1869 %! struc.c = ["foo"; "bar"]; # character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1870 %! struc.d = "ab".'; # short character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1871 %! struc.e = {"foo", "bar"}; # cell string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1872 %! struc.f = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1873 %! struc.g = [1 2 3]; # double vector |
29134
5f90526a9c40
load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29128
diff
changeset
|
1874 %! struc.h = 1:5; # range |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1875 %! struc2 = struc; |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1876 %! mat_file = [tempname(), ".mat"]; |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1877 %! unwind_protect |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1878 %! save (mat_file, "struc", "-v6"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1879 %! clear ("struc"); |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1880 %! load (mat_file); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1881 %! unwind_protect_cleanup |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1882 %! unlink (mat_file); |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1883 %! end_unwind_protect |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1884 %! assert (struc, struc2); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1885 |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1886 ## Save and load struct with "-v7" |
29134
5f90526a9c40
load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29128
diff
changeset
|
1887 %!testif HAVE_ZLIB |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1888 %! struc.a = "foobar"; # normal string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1889 %! struc.b = "a"; # short string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1890 %! struc.c = ["foo"; "bar"]; # character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1891 %! struc.d = "ab".'; # short character matrix |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1892 %! struc.e = {"foo", "bar"}; # cell string |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1893 %! struc.f = {"Saint Barthélemy", "Saint Kitts and Nevis"}; # non-ASCII |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1894 %! struc.g = [1 2 3]; # double vector |
29134
5f90526a9c40
load-save.cc: Fix typos in cdc2f3799c85.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29128
diff
changeset
|
1895 %! struc.h = 1:5; # range |
29128
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1896 %! struc2 = struc; |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1897 %! mat_file = [tempname(), ".mat"]; |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1898 %! unwind_protect |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1899 %! save (mat_file, "struc", "-v7"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1900 %! clear ("struc"); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1901 %! load (mat_file); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1902 %! unwind_protect_cleanup |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1903 %! unlink (mat_file); |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1904 %! end_unwind_protect |
cdc2f3799c85
Correctly handle short strings when saving to .mat files (-v6 or -v7) (bug #59591).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29022
diff
changeset
|
1905 %! assert (struc, struc2); |
29019
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
1906 |
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
1907 ## Test input validation |
29022
e8fa10f8920c
Fix typo in BIST for save() and mark it as fixed.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29021
diff
changeset
|
1908 %!testif HAVE_ZLIB <*59225> |
29019
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
1909 %! fname = tempname (); |
be883573bbcc
Emit an error if save is called with -append, -zip, and a binary format (bug #59225)
Rik <rik@octave.org>
parents:
29007
diff
changeset
|
1910 %! x = 1; |
29020
1db3841f042f
load-save.cc: Run BIST with "-zip" only if HAVE_ZLIB is defined.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29019
diff
changeset
|
1911 %! fail ('save ("-append", "-zip", "-binary", fname, "x")', |
29022
e8fa10f8920c
Fix typo in BIST for save() and mark it as fixed.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29021
diff
changeset
|
1912 %! "-append and -zip options .* with a text format"); |
28313
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1913 */ |
d13ad9dc9348
Store character vectors in .mat files (-v6 or -v7) as UTF-16 (bug #58368).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28217
diff
changeset
|
1914 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1915 DEFMETHOD (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
|
1916 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1917 @deftypefn {} {@var{val} =} 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
|
1918 @deftypefnx {} {@var{old_val} =} crash_dumps_octave_core (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
1919 @deftypefnx {} {@var{old_val} =} crash_dumps_octave_core (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1920 Query or set the internal variable that 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
|
1921 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
|
1922 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
|
1923 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1924 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
|
1925 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
|
1926 The original variable value is restored when exiting the function. |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1927 @seealso{octave_core_file_limit, octave_core_file_name, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1928 octave_core_file_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
|
1929 @end deftypefn */) |
2194 | 1930 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1931 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1932 |
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 return load_save_sys.crash_dumps_octave_core (args, nargout); |
2194 | 1934 } |
1935 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1936 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
|
1937 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
|
1938 @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
|
1939 @deftypefnx {} {@var{old_val} =} save_default_options (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
1940 @deftypefnx {} {@var{old_val} =} save_default_options (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1941 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
|
1942 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
|
1943 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
1944 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
|
1945 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
|
1946 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1947 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
|
1948 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
|
1949 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
|
1950 @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
|
1951 @end deftypefn */) |
4788 | 1952 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1953 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1954 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1955 return load_save_sys.save_default_options (args, nargout); |
4788 | 1956 } |
1957 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1958 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
|
1959 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
|
1960 @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
|
1961 @deftypefnx {} {@var{old_val} =} octave_core_file_limit (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
1962 @deftypefnx {} {@var{old_val} =} 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
|
1963 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
|
1964 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
|
1965 |
25106
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1966 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
|
1967 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
|
1968 @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
|
1969 |
d7ad543255c5
doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
1970 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
|
1971 @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
|
1972 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
|
1973 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
|
1974 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1975 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
|
1976 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
|
1977 The original variable value is restored when exiting the function. |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1978 @seealso{crash_dumps_octave_core, octave_core_file_name, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
1979 octave_core_file_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
|
1980 @end deftypefn */) |
3709 | 1981 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1982 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1983 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1984 return load_save_sys.octave_core_file_limit (args, nargout); |
3709 | 1985 } |
1986 | |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
1987 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
|
1988 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
|
1989 @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
|
1990 @deftypefnx {} {@var{old_val} =} octave_core_file_name (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
1991 @deftypefnx {} {@var{old_val} =} octave_core_file_name (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1992 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
|
1993 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
|
1994 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1995 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
|
1996 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
1997 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
|
1998 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
|
1999 The original variable value is restored when exiting the function. |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
2000 @seealso{crash_dumps_octave_core, octave_core_file_name, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30243
diff
changeset
|
2001 octave_core_file_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
|
2002 @end deftypefn */) |
2194 | 2003 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2004 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2005 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2006 return load_save_sys.octave_core_file_name (args, nargout); |
5794 | 2007 } |
4791 | 2008 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2009 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
|
2010 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
|
2011 @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
|
2012 @deftypefnx {} {@var{old_val} =} octave_core_file_options (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
2013 @deftypefnx {} {@var{old_val} =} octave_core_file_options (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2014 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
|
2015 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
|
2016 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2017 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
|
2018 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
|
2019 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
|
2020 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2021 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
|
2022 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
|
2023 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
|
2024 @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
|
2025 @end deftypefn */) |
5794 | 2026 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2027 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2028 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2029 return load_save_sys.octave_core_file_options (args, nargout); |
5794 | 2030 } |
2194 | 2031 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2032 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
|
2033 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
|
2034 @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
|
2035 @deftypefnx {} {@var{old_val} =} save_header_format_string (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
2036 @deftypefnx {} {@var{old_val} =} 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
|
2037 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
|
2038 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
|
2039 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
|
2040 |
23557
00b11cee2100
doc: Improve documentation for Octave's save-related functions.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
2041 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
|
2042 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
|
2043 @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
|
2044 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
|
2045 @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
|
2046 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2047 @smallexample |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2048 "# 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
|
2049 @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
|
2050 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
2051 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
|
2052 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
|
2053 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
|
2054 @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
|
2055 @end deftypefn */) |
5794 | 2056 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2057 load_save_system& load_save_sys = interp.get_load_save_system (); |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2058 |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25697
diff
changeset
|
2059 return load_save_sys.save_header_format_string (args, nargout); |
2194 | 2060 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
2061 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
2062 OCTAVE_END_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2063 |
30000
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
2064 // DEPRECATED in Octave 7 |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
2065 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2066 void |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2067 dump_octave_core (void) |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2068 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30588
diff
changeset
|
2069 octave::load_save_system& load_save_sys = octave::__get_load_save_system__ (); |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2070 |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2071 load_save_sys.dump_octave_core (); |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2072 } |