Mercurial > hg > octave-lyh
changeset 4638:9d8e84d710a5
[project @ 2003-11-20 04:55:21 by jwe]
author | jwe |
---|---|
date | Thu, 20 Nov 2003 04:55:21 +0000 |
parents | 2b4e706ff011 |
children | f70c9e90ac2d |
files | src/ls-mat5.cc |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -223,7 +223,6 @@ enum arrayclasstype arrayclass; FOUR_BYTE_INT junk; FOUR_BYTE_INT flags; - FOUR_BYTE_INT dimension_length; dim_vector dims; int len; int element_length; @@ -273,13 +272,15 @@ // dimensions array subelement { - if (read_mat5_tag (is, swap, type, dimension_length) || type != miINT32) + FOUR_BYTE_INT dim_len; + + if (read_mat5_tag (is, swap, type, dim_len) || type != miINT32) { error ("load: invalid dimensions array subelement"); goto early_read_error; } - int ndims = dimension_length / 4; + int ndims = dim_len / 4; dims.resize (ndims); for (int i = 0; i < ndims; i++) { @@ -290,7 +291,7 @@ re.resize (dims); std::streampos tmp_pos = is.tellg (); - is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (dimension_length) - dimension_length)); + is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (dim_len) - dim_len)); } if (read_mat5_tag (is, swap, type, len) || type != miINT8) @@ -768,14 +769,21 @@ { dim_vector dv = tc.dims (); int nd = tc.ndims (); + int dim_len = 4*nd; - write_mat5_tag (os, miINT32, 8); + write_mat5_tag (os, miINT32, dim_len); for (int i = 0; i < nd; i++) { - int n = dv(i); + FOUR_BYTE_INT n = dv(i); os.write ((char *)&n, 4); } + + if (PAD (dim_len) > dim_len) + { + static char buf[9]="\x00\x00\x00\x00\x00\x00\x00\x00"; + os.write (buf, PAD (dim_len) - dim_len); + } } // array name subelement