Mercurial > hg > octave-lyh
changeset 11389:934ed3e07542
dlmread: simplify file name/id logic
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Dec 2010 03:27:46 -0500 |
parents | 027fbc389898 |
children | 7ca273af4309 |
files | src/ChangeLog src/DLD-FUNCTIONS/dlmread.cc |
diffstat | 2 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-12-18 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/dlmread.cc (Fdlmread): Simplify file name/id logic. + Bug #31910. + 2010-12-17 Rik <octave@nomad.inbox5.com> * oct-parse.yy (builtin): Remove seealso reference to deprecated
--- a/src/DLD-FUNCTIONS/dlmread.cc +++ b/src/DLD-FUNCTIONS/dlmread.cc @@ -206,8 +206,7 @@ } std::istream *input = 0; - std::auto_ptr<std::ifstream> input_file; - octave_stream input_fid; + std::ifstream input_file; if (args(0).is_string ()) { @@ -218,22 +217,25 @@ std::string tname = file_ops::tilde_expand (fname); - input_file = std::auto_ptr<std::ifstream> (new std::ifstream (tname.c_str ())); - if (input_file->bad ()) + input_file.open (tname.c_str (), std::ios::in); + + if (! input_file) { error ("dlmread: unable to open file `%s'", fname.c_str ()); return retval; } else - input = input_file.get (); + input = &input_file; } else if (args(0).is_scalar_type ()) { - input_fid = octave_stream_list::lookup (args(0), "dlmread"); + octave_stream is = octave_stream_list::lookup (args(0), "dlmread"); + if (error_state) return retval; - input = input_fid.input_stream (); + input = is.input_stream (); + if (! input) { error ("dlmread: stream not open for input");