comparison libinterp/corefcn/ls-mat5.cc @ 17787:175b392e91fe

Use GNU style coding conventions for code in libinterp/ * libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc, libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc, libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc, libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h, libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h, libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc, libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc, libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc, libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc, libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h, libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc, libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc, libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h, libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/input.h, libinterp/corefcn/inv.cc, libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h, libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc, libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc, libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc, libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc, libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h, libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h, libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h, libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h, libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h, libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h, libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc, libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h, libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc, libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h, libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc, libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc, libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc, libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc, libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc, libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc, libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h, libinterp/octave-value/ov-base-scalar.cc, libinterp/octave-value/ov-base-scalar.h, libinterp/octave-value/ov-base-sparse.cc, libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc, libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc, libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc, libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc, libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h, libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h, libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-handle.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h, libinterp/octave-value/ov-flt-complex.cc, libinterp/octave-value/ov-flt-complex.h, libinterp/octave-value/ov-flt-cx-diag.cc, libinterp/octave-value/ov-flt-cx-diag.h, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.h, libinterp/octave-value/ov-flt-re-diag.cc, libinterp/octave-value/ov-flt-re-diag.h, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc, libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc, libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h, libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h, libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc, libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc, libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc, libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc, libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc, libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc, libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h, libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc, libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc, libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc, libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc, libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc, libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc, libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc, libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc, libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc, libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc, libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc, libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc, libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc, libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc, libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc, libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc, libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc, libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc, libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc, libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc, libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc, libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc, libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc, libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc, libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc, libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc, libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc, libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc, libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc, libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc, libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc, libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc, libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc, libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc, libinterp/operators/ops.h, libinterp/parse-tree/lex.h, libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc, libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc, libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc, libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h, libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc, libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc, libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc, libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h, libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc, libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc, libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/token.h, libinterp/version.cc: Use GNU style coding conventions for code in libinterp/
author Rik <rik@octave.org>
date Mon, 28 Oct 2013 19:51:46 -0700
parents d63878346099
children 97e49b588f5d 870f3e12e163
comparison
equal deleted inserted replaced
17786:34d9812a943b 17787:175b392e91fe
87 87
88 88
89 // The subsystem data block 89 // The subsystem data block
90 static octave_value subsys_ov; 90 static octave_value subsys_ov;
91 91
92 // FIXME -- the following enum values should be the same as the 92 // FIXME: the following enum values should be the same as the
93 // mxClassID values in mexproto.h, but it seems they have also changed 93 // mxClassID values in mexproto.h, but it seems they have also changed
94 // over time. What is the correct way to handle this and maintain 94 // over time. What is the correct way to handle this and maintain
95 // backward compatibility with old MAT files? For now, use 95 // backward compatibility with old MAT files? For now, use
96 // "MAT_FILE_" instead of "mx" as the prefix for these names to avoid 96 // "MAT_FILE_" instead of "mx" as the prefix for these names to avoid
97 // conflict with the mxClassID enum in mexproto.h. 97 // conflict with the mxClassID enum in mexproto.h.
98 98
99 enum arrayclasstype 99 enum arrayclasstype
100 { 100 {
101 MAT_FILE_CELL_CLASS=1, // cell array 101 MAT_FILE_CELL_CLASS=1, // cell array
102 MAT_FILE_STRUCT_CLASS, // structure 102 MAT_FILE_STRUCT_CLASS, // structure
103 MAT_FILE_OBJECT_CLASS, // object 103 MAT_FILE_OBJECT_CLASS, // object
104 MAT_FILE_CHAR_CLASS, // character array 104 MAT_FILE_CHAR_CLASS, // character array
105 MAT_FILE_SPARSE_CLASS, // sparse array 105 MAT_FILE_SPARSE_CLASS, // sparse array
106 MAT_FILE_DOUBLE_CLASS, // double precision array 106 MAT_FILE_DOUBLE_CLASS, // double precision array
107 MAT_FILE_SINGLE_CLASS, // single precision floating point 107 MAT_FILE_SINGLE_CLASS, // single precision floating point
108 MAT_FILE_INT8_CLASS, // 8 bit signed integer 108 MAT_FILE_INT8_CLASS, // 8 bit signed integer
109 MAT_FILE_UINT8_CLASS, // 8 bit unsigned integer 109 MAT_FILE_UINT8_CLASS, // 8 bit unsigned integer
110 MAT_FILE_INT16_CLASS, // 16 bit signed integer 110 MAT_FILE_INT16_CLASS, // 16 bit signed integer
111 MAT_FILE_UINT16_CLASS, // 16 bit unsigned integer 111 MAT_FILE_UINT16_CLASS, // 16 bit unsigned integer
112 MAT_FILE_INT32_CLASS, // 32 bit signed integer 112 MAT_FILE_INT32_CLASS, // 32 bit signed integer
113 MAT_FILE_UINT32_CLASS, // 32 bit unsigned integer 113 MAT_FILE_UINT32_CLASS, // 32 bit unsigned integer
114 MAT_FILE_INT64_CLASS, // 64 bit signed integer 114 MAT_FILE_INT64_CLASS, // 64 bit signed integer
115 MAT_FILE_UINT64_CLASS, // 64 bit unsigned integer 115 MAT_FILE_UINT64_CLASS, // 64 bit unsigned integer
116 MAT_FILE_FUNCTION_CLASS, // Function handle 116 MAT_FILE_FUNCTION_CLASS, // Function handle
117 MAT_FILE_WORKSPACE_CLASS // Workspace (undocumented) 117 MAT_FILE_WORKSPACE_CLASS // Workspace (undocumented)
118 }; 118 };
119 119
120 // Read COUNT elements of data from IS in the format specified by TYPE, 120 // Read COUNT elements of data from IS in the format specified by TYPE,
121 // placing the result in DATA. If SWAP is TRUE, swap the bytes of 121 // placing the result in DATA. If SWAP is TRUE, swap the bytes of
122 // each element before copying to DATA. FLT_FMT specifies the format 122 // each element before copying to DATA. FLT_FMT specifies the format
123 // of the data if we are reading floating point numbers. 123 // of the data if we are reading floating point numbers.
427 else \ 427 else \
428 tc = re; \ 428 tc = re; \
429 } 429 }
430 430
431 // Read one element tag from stream IS, 431 // Read one element tag from stream IS,
432 // place the type code in TYPE, the byte count in BYTES and true (false) to 432 // place the type code in TYPE, the byte count in BYTES and true (false) to
433 // IS_SMALL_DATA_ELEMENT if the tag is 4 (8) bytes long. 433 // IS_SMALL_DATA_ELEMENT if the tag is 4 (8) bytes long.
434 // return nonzero on error 434 // return nonzero on error
435 static int 435 static int
436 read_mat5_tag (std::istream& is, bool swap, int32_t& type, int32_t& bytes, 436 read_mat5_tag (std::istream& is, bool swap, int32_t& type, int32_t& bytes,
437 bool& is_small_data_element) 437 bool& is_small_data_element)
464 is_small_data_element = false; 464 is_small_data_element = false;
465 } 465 }
466 466
467 return 0; 467 return 0;
468 468
469 data_read_error: 469 data_read_error:
470 return 1; 470 return 1;
471 } 471 }
472 472
473 static void 473 static void
474 read_int (std::istream& is, bool swap, int32_t& val) 474 read_int (std::istream& is, bool swap, int32_t& val)
546 swap_bytes<4> (tmp, 2); 546 swap_bytes<4> (tmp, 2);
547 547
548 destLen = tmp[1] + 8; 548 destLen = tmp[1] + 8;
549 std::string outbuf (destLen, ' '); 549 std::string outbuf (destLen, ' ');
550 550
551 // FIXME -- find a way to avoid casting away const here! 551 // FIXME: find a way to avoid casting away const here!
552 552
553 int err = uncompress (reinterpret_cast<Bytef *> (const_cast<char *> (outbuf.c_str ())), 553 int err = uncompress (reinterpret_cast<Bytef *>
554 (const_cast<char *> (outbuf.c_str ())),
554 &destLen, reinterpret_cast<Bytef *> (inbuf), 555 &destLen, reinterpret_cast<Bytef *> (inbuf),
555 element_length); 556 element_length);
556 557
557 if (err != Z_OK) 558 if (err != Z_OK)
558 { 559 {
789 (READ_PAD (is_small_data_element, len))); 790 (READ_PAD (is_small_data_element, len)));
790 791
791 // col indices 792 // col indices
792 if (read_mat5_tag (is, swap, type, len, is_small_data_element)) 793 if (read_mat5_tag (is, swap, type, len, is_small_data_element))
793 { 794 {
794 error ("load: reading sparse column data for '%s'", retval.c_str ()); 795 error ("load: reading sparse column data for '%s'",
796 retval.c_str ());
795 goto data_read_error; 797 goto data_read_error;
796 } 798 }
797 799
798 tmp_pos = is.tellg (); 800 tmp_pos = is.tellg ();
799 801
800 read_mat5_integer_data (is, cidx, nc + 1, swap, 802 read_mat5_integer_data (is, cidx, nc + 1, swap,
801 static_cast<enum mat5_data_type> (type)); 803 static_cast<enum mat5_data_type> (type));
802 804
803 if (! is || error_state) 805 if (! is || error_state)
804 { 806 {
805 error ("load: reading sparse column data for '%s'", retval.c_str ()); 807 error ("load: reading sparse column data for '%s'",
808 retval.c_str ());
806 goto data_read_error; 809 goto data_read_error;
807 } 810 }
808 811
809 is.seekg (tmp_pos + static_cast<std::streamoff> 812 is.seekg (tmp_pos + static_cast<std::streamoff>
810 (READ_PAD (is_small_data_element, len))); 813 (READ_PAD (is_small_data_element, len)));
811 814
812 // real data subelement 815 // real data subelement
813 if (read_mat5_tag (is, swap, type, len, is_small_data_element)) 816 if (read_mat5_tag (is, swap, type, len, is_small_data_element))
814 { 817 {
815 error ("load: reading sparse matrix data for '%s'", retval.c_str ()); 818 error ("load: reading sparse matrix data for '%s'",
819 retval.c_str ());
816 goto data_read_error; 820 goto data_read_error;
817 } 821 }
818 822
819 octave_idx_type nnz = cidx[nc]; 823 octave_idx_type nnz = cidx[nc];
820 NDArray re; 824 NDArray re;
824 data = re.fortran_vec (); 828 data = re.fortran_vec ();
825 } 829 }
826 830
827 tmp_pos = is.tellg (); 831 tmp_pos = is.tellg ();
828 read_mat5_binary_data (is, data, nnz, swap, 832 read_mat5_binary_data (is, data, nnz, swap,
829 static_cast<enum mat5_data_type> (type), flt_fmt); 833 static_cast<enum mat5_data_type> (type),
834 flt_fmt);
830 835
831 if (! is || error_state) 836 if (! is || error_state)
832 { 837 {
833 error ("load: reading sparse matrix data for '%s'", retval.c_str ()); 838 error ("load: reading sparse matrix data for '%s'",
839 retval.c_str ());
834 goto data_read_error; 840 goto data_read_error;
835 } 841 }
836 842
837 is.seekg (tmp_pos + static_cast<std::streamoff> 843 is.seekg (tmp_pos + static_cast<std::streamoff>
838 (READ_PAD (is_small_data_element, len))); 844 (READ_PAD (is_small_data_element, len)));
842 { 848 {
843 NDArray im (dim_vector (static_cast<int> (nnz), 1)); 849 NDArray im (dim_vector (static_cast<int> (nnz), 1));
844 850
845 if (read_mat5_tag (is, swap, type, len, is_small_data_element)) 851 if (read_mat5_tag (is, swap, type, len, is_small_data_element))
846 { 852 {
847 error ("load: reading sparse matrix data for '%s'", retval.c_str ()); 853 error ("load: reading sparse matrix data for '%s'",
854 retval.c_str ());
848 goto data_read_error; 855 goto data_read_error;
849 } 856 }
850 857
851 read_mat5_binary_data (is, im.fortran_vec (), nnz, swap, 858 read_mat5_binary_data (is, im.fortran_vec (), nnz, swap,
852 static_cast<enum mat5_data_type> (type), flt_fmt); 859 static_cast<enum mat5_data_type> (type),
860 flt_fmt);
853 861
854 if (! is || error_state) 862 if (! is || error_state)
855 { 863 {
856 error ("load: reading imaginary sparse matrix data for '%s'", 864 error ("load: reading imaginary sparse matrix data for '%s'",
857 retval.c_str ()); 865 retval.c_str ());
879 887
880 // Octave can handle both "/" and "\" as a directory seperator 888 // Octave can handle both "/" and "\" as a directory seperator
881 // and so can ignore the separator field of m0. I think the 889 // and so can ignore the separator field of m0. I think the
882 // sentinel field is also save to ignore. 890 // sentinel field is also save to ignore.
883 octave_scalar_map m0 = tc2.scalar_map_value (); 891 octave_scalar_map m0 = tc2.scalar_map_value ();
884 octave_scalar_map m1 = m0.contents ("function_handle").scalar_map_value (); 892 octave_scalar_map m1
893 = m0.contents ("function_handle").scalar_map_value ();
885 std::string ftype = m1.contents ("type").string_value (); 894 std::string ftype = m1.contents ("type").string_value ();
886 std::string fname = m1.contents ("function").string_value (); 895 std::string fname = m1.contents ("function").string_value ();
887 std::string fpath = m1.contents ("file").string_value (); 896 std::string fpath = m1.contents ("file").string_value ();
888 897
889 if (ftype == "simple" || ftype == "scopedfunction") 898 if (ftype == "simple" || ftype == "scopedfunction")
907 // case we replace with the same function in the 916 // case we replace with the same function in the
908 // running version of Octave? 917 // running version of Octave?
909 918
910 // First check if just replacing matlabroot is enough 919 // First check if just replacing matlabroot is enough
911 std::string str = OCTAVE_EXEC_PREFIX + 920 std::string str = OCTAVE_EXEC_PREFIX +
912 fpath.substr (mroot.length ()); 921 fpath.substr (mroot.length ());
913 file_stat fs (str); 922 file_stat fs (str);
914 923
915 if (fs.exists ()) 924 if (fs.exists ())
916 { 925 {
917 size_t xpos 926 size_t xpos
924 933
925 if (fcn) 934 if (fcn)
926 { 935 {
927 octave_value tmp (fcn); 936 octave_value tmp (fcn);
928 937
929 tc = octave_value (new octave_fcn_handle (tmp, fname)); 938 tc = octave_value (new octave_fcn_handle (tmp,
939 fname));
930 } 940 }
931 } 941 }
932 else 942 else
933 { 943 {
934 // Next just search for it anywhere in the system path 944 // Next just search for it anywhere in the system path
937 names(1) = fname + ".mex"; 947 names(1) = fname + ".mex";
938 names(2) = fname + ".m"; 948 names(2) = fname + ".m";
939 949
940 dir_path p (load_path::system_path ()); 950 dir_path p (load_path::system_path ());
941 951
942 str = octave_env::make_absolute (p.find_first_of (names)); 952 str =
953 octave_env::make_absolute (p.find_first_of (names));
943 954
944 size_t xpos 955 size_t xpos
945 = str.find_last_of (file_ops::dir_sep_chars ()); 956 = str.find_last_of (file_ops::dir_sep_chars ());
946 957
947 std::string dir_name = str.substr (0, xpos); 958 std::string dir_name = str.substr (0, xpos);
951 962
952 if (fcn) 963 if (fcn)
953 { 964 {
954 octave_value tmp (fcn); 965 octave_value tmp (fcn);
955 966
956 tc = octave_value (new octave_fcn_handle (tmp, fname)); 967 tc = octave_value (new octave_fcn_handle (tmp,
968 fname));
957 } 969 }
958 else 970 else
959 { 971 {
960 warning ("load: can't find the file %s", 972 warning ("load: can't find the file %s",
961 fpath.c_str ()); 973 fpath.c_str ());
993 warning ("load: can't load nested function"); 1005 warning ("load: can't load nested function");
994 goto skip_ahead; 1006 goto skip_ahead;
995 } 1007 }
996 else if (ftype == "anonymous") 1008 else if (ftype == "anonymous")
997 { 1009 {
998 octave_scalar_map m2 = m1.contents ("workspace").scalar_map_value (); 1010 octave_scalar_map m2
1011 = m1.contents ("workspace").scalar_map_value ();
999 uint32NDArray MCOS = m2.contents ("MCOS").uint32_array_value (); 1012 uint32NDArray MCOS = m2.contents ("MCOS").uint32_array_value ();
1000 octave_idx_type off = static_cast<octave_idx_type>(MCOS(4).double_value ()); 1013 octave_idx_type off
1014 = static_cast<octave_idx_type>(MCOS(4).double_value ());
1001 m2 = subsys_ov.scalar_map_value (); 1015 m2 = subsys_ov.scalar_map_value ();
1002 m2 = m2.contents ("MCOS").scalar_map_value (); 1016 m2 = m2.contents ("MCOS").scalar_map_value ();
1003 tc2 = m2.contents ("MCOS").cell_value ()(1 + off).cell_value ()(1); 1017 tc2 = m2.contents ("MCOS").cell_value ()(1 + off).cell_value ()(1);
1004 m2 = tc2.scalar_map_value (); 1018 m2 = tc2.scalar_map_value ();
1005 1019
1344 } 1358 }
1345 1359
1346 octave_idx_type n = re.numel (); 1360 octave_idx_type n = re.numel ();
1347 tmp_pos = is.tellg (); 1361 tmp_pos = is.tellg ();
1348 read_mat5_binary_data (is, re.fortran_vec (), n, swap, 1362 read_mat5_binary_data (is, re.fortran_vec (), n, swap,
1349 static_cast<enum mat5_data_type> (type), flt_fmt); 1363 static_cast<enum mat5_data_type> (type),
1364 flt_fmt);
1350 1365
1351 if (! is || error_state) 1366 if (! is || error_state)
1352 { 1367 {
1353 error ("load: reading matrix data for '%s'", retval.c_str ()); 1368 error ("load: reading matrix data for '%s'", retval.c_str ());
1354 goto data_read_error; 1369 goto data_read_error;
1369 goto data_read_error; 1384 goto data_read_error;
1370 } 1385 }
1371 1386
1372 n = im.numel (); 1387 n = im.numel ();
1373 read_mat5_binary_data (is, im.fortran_vec (), n, swap, 1388 read_mat5_binary_data (is, im.fortran_vec (), n, swap,
1374 static_cast<enum mat5_data_type> (type), flt_fmt); 1389 static_cast<enum mat5_data_type> (type),
1390 flt_fmt);
1375 1391
1376 if (! is || error_state) 1392 if (! is || error_state)
1377 { 1393 {
1378 error ("load: reading imaginary matrix data for '%s'", 1394 error ("load: reading imaginary matrix data for '%s'",
1379 retval.c_str ()); 1395 retval.c_str ());
1411 } 1427 }
1412 1428
1413 octave_idx_type n = re.numel (); 1429 octave_idx_type n = re.numel ();
1414 tmp_pos = is.tellg (); 1430 tmp_pos = is.tellg ();
1415 read_mat5_binary_data (is, re.fortran_vec (), n, swap, 1431 read_mat5_binary_data (is, re.fortran_vec (), n, swap,
1416 static_cast<enum mat5_data_type> (type), flt_fmt); 1432 static_cast<enum mat5_data_type> (type),
1433 flt_fmt);
1417 1434
1418 if (! is || error_state) 1435 if (! is || error_state)
1419 { 1436 {
1420 error ("load: reading matrix data for '%s'", retval.c_str ()); 1437 error ("load: reading matrix data for '%s'", retval.c_str ());
1421 goto data_read_error; 1438 goto data_read_error;
1449 goto data_read_error; 1466 goto data_read_error;
1450 } 1467 }
1451 1468
1452 n = im.numel (); 1469 n = im.numel ();
1453 read_mat5_binary_data (is, im.fortran_vec (), n, swap, 1470 read_mat5_binary_data (is, im.fortran_vec (), n, swap,
1454 static_cast<enum mat5_data_type> (type), flt_fmt); 1471 static_cast<enum mat5_data_type> (type),
1472 flt_fmt);
1455 1473
1456 if (! is || error_state) 1474 if (! is || error_state)
1457 { 1475 {
1458 error ("load: reading imaginary matrix data for '%s'", 1476 error ("load: reading imaginary matrix data for '%s'",
1459 retval.c_str ()); 1477 retval.c_str ());
1474 if (type == miUTF16 || type == miUTF32) 1492 if (type == miUTF16 || type == miUTF32)
1475 { 1493 {
1476 bool found_big_char = false; 1494 bool found_big_char = false;
1477 for (octave_idx_type i = 0; i < n; i++) 1495 for (octave_idx_type i = 0; i < n; i++)
1478 { 1496 {
1479 if (re(i) > 127) { 1497 if (re(i) > 127)
1480 re(i) = '?'; 1498 {
1481 found_big_char = true; 1499 re(i) = '?';
1482 } 1500 found_big_char = true;
1501 }
1483 } 1502 }
1484 1503
1485 if (found_big_char) 1504 if (found_big_char)
1486 warning ("load: can not read non-ASCII portions of UTF characters; replacing unreadable characters with '?'"); 1505 warning ("load: can not read non-ASCII portions of UTF characters; replacing unreadable characters with '?'");
1487 } 1506 }
1501 if (utf8_multi_byte) 1520 if (utf8_multi_byte)
1502 { 1521 {
1503 warning ("load: can not read multi-byte encoded UTF8 characters; replacing unreadable characters with '?'"); 1522 warning ("load: can not read multi-byte encoded UTF8 characters; replacing unreadable characters with '?'");
1504 for (octave_idx_type i = 0; i < n; i++) 1523 for (octave_idx_type i = 0; i < n; i++)
1505 { 1524 {
1506 unsigned char a = static_cast<unsigned char> (re(i)); 1525 unsigned char a
1526 = static_cast<unsigned char> (re(i));
1507 if (a > 0x7f) 1527 if (a > 0x7f)
1508 re(i) = '?'; 1528 re(i) = '?';
1509 } 1529 }
1510 } 1530 }
1511 } 1531 }
1523 if (is.eof ()) 1543 if (is.eof ())
1524 is.clear (); 1544 is.clear ();
1525 1545
1526 return retval; 1546 return retval;
1527 1547
1528 data_read_error: 1548 data_read_error:
1529 early_read_error: 1549 early_read_error:
1530 error ("load: trouble reading binary file '%s'", filename.c_str ()); 1550 error ("load: trouble reading binary file '%s'", filename.c_str ());
1531 return std::string (); 1551 return std::string ();
1532 1552
1533 skip_ahead: 1553 skip_ahead:
1534 warning ("skipping over '%s'", retval.c_str ()); 1554 warning ("skipping over '%s'", retval.c_str ());
1535 is.seekg (pos + static_cast<std::streamoff> (element_length)); 1555 is.seekg (pos + static_cast<std::streamoff> (element_length));
1536 return read_mat5_binary_element (is, filename, swap, global, tc); 1556 return read_mat5_binary_element (is, filename, swap, global, tc);
1537 } 1557 }
1538 1558
1589 octave_idx_type ilen = itmp.numel (); 1609 octave_idx_type ilen = itmp.numel ();
1590 1610
1591 // Why should I have to initialize outbuf as just overwrite 1611 // Why should I have to initialize outbuf as just overwrite
1592 std::string outbuf (ilen - 7, ' '); 1612 std::string outbuf (ilen - 7, ' ');
1593 1613
1594 // FIXME -- find a way to avoid casting away const here 1614 // FIXME: find a way to avoid casting away const here
1595 char *ctmp = const_cast<char *> (outbuf.c_str ()); 1615 char *ctmp = const_cast<char *> (outbuf.c_str ());
1596 for (octave_idx_type j = 8; j < ilen; j++) 1616 for (octave_idx_type j = 8; j < ilen; j++)
1597 ctmp[j-8] = itmp(j).char_value (); 1617 ctmp[j-8] = itmp(j).char_value ();
1598 1618
1599 std::istringstream fh_ws (outbuf); 1619 std::istringstream fh_ws (outbuf);
1631 if (! is.write (reinterpret_cast<char *> (&temp), 4)) 1651 if (! is.write (reinterpret_cast<char *> (&temp), 4))
1632 goto data_write_error; 1652 goto data_write_error;
1633 1653
1634 return 0; 1654 return 0;
1635 1655
1636 data_write_error: 1656 data_write_error:
1637 return 1; 1657 return 1;
1638 } 1658 }
1639 1659
1640 // Have to use copy here to avoid writing over data accessed via 1660 // Have to use copy here to avoid writing over data accessed via
1641 // Matrix::data(). 1661 // Matrix::data().
1971 if (!too_large_for_float) 1991 if (!too_large_for_float)
1972 size = 4; 1992 size = 4;
1973 } 1993 }
1974 1994
1975 // The code below is disabled since get_save_type currently doesn't 1995 // The code below is disabled since get_save_type currently doesn't
1976 // deal with integer types. This will need to be activated if get_save_type 1996 // deal with integer types. This will need to be activated if
1977 // is changed. 1997 // get_save_type is changed.
1978 1998
1979 // double max_val = val[0]; 1999 // double max_val = val[0];
1980 // double min_val = val[0]; 2000 // double min_val = val[0];
1981 // bool all_integers = true; 2001 // bool all_integers = true;
1982 // 2002 //
2026 { 2046 {
2027 int size = 4; 2047 int size = 4;
2028 2048
2029 2049
2030 // The code below is disabled since get_save_type currently doesn't 2050 // The code below is disabled since get_save_type currently doesn't
2031 // deal with integer types. This will need to be activated if get_save_type 2051 // deal with integer types. This will need to be activated if
2032 // is changed. 2052 // get_save_type is changed.
2033 2053
2034 // float max_val = val[0]; 2054 // float max_val = val[0];
2035 // float min_val = val[0]; 2055 // float min_val = val[0];
2036 // bool all_integers = true; 2056 // bool all_integers = true;
2037 // 2057 //
2375 uLongf srcLen = buf_str.length (); 2395 uLongf srcLen = buf_str.length ();
2376 uLongf destLen = srcLen * 101 / 100 + 12; 2396 uLongf destLen = srcLen * 101 / 100 + 12;
2377 OCTAVE_LOCAL_BUFFER (char, out_buf, destLen); 2397 OCTAVE_LOCAL_BUFFER (char, out_buf, destLen);
2378 2398
2379 if (compress (reinterpret_cast<Bytef *> (out_buf), &destLen, 2399 if (compress (reinterpret_cast<Bytef *> (out_buf), &destLen,
2380 reinterpret_cast<const Bytef *> (buf_str.c_str ()), srcLen) == Z_OK) 2400 reinterpret_cast<const Bytef *> (buf_str.c_str ()),
2401 srcLen)
2402 == Z_OK)
2381 { 2403 {
2382 write_mat5_tag (os, miCOMPRESSED, 2404 write_mat5_tag (os, miCOMPRESSED,
2383 static_cast<octave_idx_type> (destLen)); 2405 static_cast<octave_idx_type> (destLen));
2384 2406
2385 os.write (out_buf, destLen); 2407 os.write (out_buf, destLen);
2665 os.write (paddedname, paddedlength); 2687 os.write (paddedname, paddedlength);
2666 } 2688 }
2667 2689
2668 octave_map m; 2690 octave_map m;
2669 2691
2670 if (tc.is_object () && 2692 if (tc.is_object ()
2671 load_path::find_method (tc.class_name (), "saveobj") != std::string ()) 2693 && load_path::find_method (tc.class_name (),
2694 "saveobj") != std::string ())
2672 { 2695 {
2673 octave_value_list tmp = feval ("saveobj", tc, 1); 2696 octave_value_list tmp = feval ("saveobj", tc, 1);
2674 if (! error_state) 2697 if (! error_state)
2675 m = tmp(0).map_value (); 2698 m = tmp(0).map_value ();
2676 else 2699 else
2733 } 2756 }
2734 } 2757 }
2735 else 2758 else
2736 gripe_wrong_type_arg ("save", tc, false); 2759 gripe_wrong_type_arg ("save", tc, false);
2737 2760
2738 skip_to_next: 2761 skip_to_next:
2739 return true; 2762 return true;
2740 2763
2741 error_cleanup: 2764 error_cleanup:
2742 error ("save: error while writing '%s' to MAT file", name.c_str ()); 2765 error ("save: error while writing '%s' to MAT file", name.c_str ());
2743 2766
2744 return false; 2767 return false;
2745 } 2768 }