# HG changeset patch # User John W. Eaton # Date 1292660866 18000 # Node ID 934ed3e07542424c54b5faf4adcc69ed8e734aea # Parent 027fbc3898982bb9fac18d52f88c1c8f8cbe8423 dlmread: simplify file name/id logic diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-12-18 John W. Eaton + + * DLD-FUNCTIONS/dlmread.cc (Fdlmread): Simplify file name/id logic. + Bug #31910. + 2010-12-17 Rik * oct-parse.yy (builtin): Remove seealso reference to deprecated diff --git a/src/DLD-FUNCTIONS/dlmread.cc b/src/DLD-FUNCTIONS/dlmread.cc --- a/src/DLD-FUNCTIONS/dlmread.cc +++ b/src/DLD-FUNCTIONS/dlmread.cc @@ -206,8 +206,7 @@ } std::istream *input = 0; - std::auto_ptr 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 (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");