Mercurial > octave
changeset 26458:9f090d811332 stable
ls-mat-ascii.cc: Fix static analyzer detected issues (bug #55347).
* ls-mat-ascii.cc (read_mat_ascii_data): Remove useless check on
"(nr < 1 || nc < 1)" and re-indent code.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 05 Jan 2019 11:02:45 -0800 |
parents | aced09cc1721 |
children | 1479694709ea |
files | libinterp/corefcn/ls-mat-ascii.cc |
diffstat | 1 files changed, 29 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/ls-mat-ascii.cc Sat Jan 05 17:41:53 2019 +0100 +++ b/libinterp/corefcn/ls-mat-ascii.cc Sat Jan 05 11:02:45 2019 -0800 @@ -270,58 +270,51 @@ Matrix tmp (nr, nc); - if (nr < 1 || nc < 1) - is.clear (std::ios::badbit); - else + double d; + for (octave_idx_type i = 0; i < nr; i++) { - double d; - for (octave_idx_type i = 0; i < nr; i++) - { - std::string buf = get_mat_data_input_line (is); + std::string buf = get_mat_data_input_line (is); + + std::istringstream tmp_stream (buf); - std::istringstream tmp_stream (buf); - - for (octave_idx_type j = 0; j < nc; j++) - { - octave_quit (); + for (octave_idx_type j = 0; j < nc; j++) + { + octave_quit (); - d = octave_read_value<double> (tmp_stream); + d = octave_read_value<double> (tmp_stream); - if (! tmp_stream && ! tmp_stream.eof ()) - error ("load: failed to read matrix from file '%s'", - filename.c_str ()); + if (! tmp_stream && ! tmp_stream.eof ()) + error ("load: failed to read matrix from file '%s'", + filename.c_str ()); - tmp.elem (i, j) = d; - total_count++; + tmp.elem (i, j) = d; + total_count++; - // Skip whitespace and commas. - char c; - while (1) - { - tmp_stream >> c; + // Skip whitespace and commas. + char c; + while (1) + { + tmp_stream >> c; - if (! tmp_stream) - break; + if (! tmp_stream) + break; - if (! (c == ' ' || c == '\t' || c == ',')) - { - tmp_stream.putback (c); - break; - } + if (! (c == ' ' || c == '\t' || c == ',')) + { + tmp_stream.putback (c); + break; } + } - if (tmp_stream.eof ()) - break; - } + if (tmp_stream.eof ()) + break; } } if (! is && ! is.eof ()) - error ("load: failed to read matrix from file '%s'", - filename.c_str ()); + error ("load: failed to read matrix from file '%s'", filename.c_str ()); // FIXME: not sure this is best, but it works. - if (is.eof ()) is.clear ();