Mercurial > octave-nkf
diff src/file-io.cc @ 8773:9e3111d203c0
disallow reading from stdin while running interactively
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Feb 2009 01:33:10 -0500 |
parents | 0611b48a2b61 |
children | bbb3fa6778f3 |
line wrap: on
line diff
--- a/src/file-io.cc Tue Feb 17 00:43:13 2009 -0500 +++ b/src/file-io.cc Tue Feb 17 01:33:10 2009 -0500 @@ -335,7 +335,7 @@ std::string tmp = os.getl (len_arg, err, who); - if (! err) + if (! (error_state || err)) { retval(1) = tmp.length (); retval(0) = tmp; @@ -383,7 +383,7 @@ std::string tmp = os.gets (len_arg, err, who); - if (! err) + if (! (error_state || err)) { retval(1) = tmp.length (); retval(0) = tmp; @@ -1118,8 +1118,11 @@ { octave_value tmp = os.scanf (args(1), size, count, who); - retval(1) = count; - retval(0) = tmp; + if (! error_state) + { + retval(1) = count; + retval(0) = tmp; + } } } else @@ -1198,15 +1201,18 @@ octave_value tmp = os.scanf (args(1), size, count, who); - // FIXME -- is this the right thing to do? - // Extract error message first, because getting - // position will clear it. - std::string errmsg = os.error (); + if (! error_state) + { + // FIXME -- is this the right thing to do? + // Extract error message first, because getting + // position will clear it. + std::string errmsg = os.error (); - retval(3) = os.tell () + 1; - retval(2) = errmsg; - retval(1) = count; - retval(0) = tmp; + retval(3) = os.tell () + 1; + retval(2) = errmsg; + retval(1) = count; + retval(0) = tmp; + } } else ::error ("%s: format must be a string", who.c_str ());