# HG changeset patch # User John W. Eaton # Date 1450473773 18000 # Node ID aac911d8847bc75b19abaf09028dd317ac37ba57 # Parent 3b2cc6ef0624f65bd1855290e0f3ca77177a86e1 choose correct error function in stream classes * oct-fstrm.cc, oct-iostrm.cc, oct-stream.cc, oct-strstrm.cc: Use error or ::error as appropriate. diff -r 3b2cc6ef0624 -r aac911d8847b libinterp/corefcn/oct-fstrm.cc --- a/libinterp/corefcn/oct-fstrm.cc Fri Dec 18 15:55:36 2015 -0500 +++ b/libinterp/corefcn/oct-fstrm.cc Fri Dec 18 16:22:53 2015 -0500 @@ -56,7 +56,7 @@ #endif if (! fs) - // Note: error() is inherited from octave_base_stream, not ::error(). + // Note: error is inherited from octave_base_stream, not ::error. error (gnulib::strerror (errno)); } @@ -65,7 +65,7 @@ int octave_fstream::seek (off_t, int) { - // Note: error() is inherited from octave_base_stream, not ::error(). + // Note: error is inherited from octave_base_stream, not ::error. // This error function does not halt execution so "return ..." must exist. error ("fseek: invalid_operation"); return -1; @@ -76,7 +76,7 @@ off_t octave_fstream::tell (void) { - // Note: error() is inherited from octave_base_stream, not ::error(). + // Note: error is inherited from octave_base_stream, not ::error. // This error function does not halt execution so "return ..." must exist. error ("ftell: invalid_operation"); return -1; diff -r 3b2cc6ef0624 -r aac911d8847b libinterp/corefcn/oct-iostrm.cc --- a/libinterp/corefcn/oct-iostrm.cc Fri Dec 18 15:55:36 2015 -0500 +++ b/libinterp/corefcn/oct-iostrm.cc Fri Dec 18 16:22:53 2015 -0500 @@ -57,7 +57,7 @@ void octave_base_iostream::invalid_operation (void) const { - // Note: use '::error()' to get error from error.h which halts operation. + // Note: use ::error to get error from error.h which halts operation. ::error ("%s: invalid operation", stream_type ()); } diff -r 3b2cc6ef0624 -r aac911d8847b libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Fri Dec 18 15:55:36 2015 -0500 +++ b/libinterp/corefcn/oct-stream.cc Fri Dec 18 16:22:53 2015 -0500 @@ -53,16 +53,15 @@ #include "toplev.h" #include "utils.h" -//////////////////////////////////////////////////////////////////////////////// -// Programming Note: There are two very different error() functions used -// in the stream code. When invoked with "error (...)" the member function -// from octave_stream or octave_base_stream is called. This function sets the -// error state on the stream AND returns control to the caller. The caller -// must then return a value at the end of the function. When invoked with -// "::error (...)" the exception-based error function from error.h is used. -// This function will throw an exception and not return control to the caller. -// BE CAREFUL and invoke the correct error function! -//////////////////////////////////////////////////////////////////////////////// +// Programming Note: There are two very different error functions used +// in the stream code. When invoked with "error (...)" the member +// function from octave_stream or octave_base_stream is called. This +// function sets the error state on the stream AND returns control to +// the caller. The caller must then return a value at the end of the +// function. When invoked with "::error (...)" the exception-based +// error function from error.h is used. This function will throw an +// exception and not return control to the caller. BE CAREFUL and +// invoke the correct error function! // Possible values for conv_err: // @@ -2588,8 +2587,8 @@ break; default: - // Note: error() is member fcn from octave_base_stream, not ::error(). - // This error() does not halt execution so "return ..." must exist. + // Note: error is member fcn from octave_base_stream, not ::error. + // This error does not halt execution so "return ..." must exist. error ("%s: invalid format specifier", who.c_str ()); return -1; break; @@ -2698,13 +2697,7 @@ } } else - { - // FIXME: should this be member fcn "error"? - // Otherwise, retval and break are unnecessary. - ::error ("%s: internal error handling format", who.c_str ()); - retval = -1; - break; - } + ::error ("%s: internal error handling format", who.c_str ()); elt = fmt_list.next (nconv > 0 && ! val_cache.exhausted ()); @@ -2784,7 +2777,7 @@ void octave_base_stream::invalid_operation (const std::string& who, const char *rw) { - // Note: This calls the member fcn error(), not ::error() from error.h. + // Note: This calls the member fcn error, not ::error from error.h. error (who, std::string ("stream not open for ") + rw); } @@ -3056,12 +3049,11 @@ retval = seek (xoffset, origin); if (retval != 0) - // FIXME: Should this be ::error()? + // Note: error is member fcn from octave_stream, not ::error. error ("fseek: failed to seek to requested position"); } else - // FIXME: Should this be ::error()? - error ("fseek: invalid value for origin"); + ::error ("fseek: invalid value for origin"); return retval; } @@ -3284,10 +3276,7 @@ break; default: - retval = false; - // FIXME: Should this be ::error()? - error ("read: invalid type specification"); - break; + ::error ("read: invalid type specification"); } return retval; @@ -3649,10 +3638,7 @@ break; default: - retval = false; - // FIXME: Should this be ::error()? - error ("write: invalid type specification"); - break; + ::error ("write: invalid type specification"); } return retval; @@ -3851,7 +3837,7 @@ } else { - // Note: error() is member fcn from octave_stream, not ::error(). + // Note: error is member fcn from octave_stream, not ::error. error (who + ": format must be a string"); } @@ -3885,7 +3871,7 @@ } else { - // Note: error() is member fcn from octave_stream, not ::error(). + // Note: error is member fcn from octave_stream, not ::error. error (who + ": format must be a string"); } @@ -3921,7 +3907,7 @@ } else { - // Note: error() is member fcn from octave_stream, not ::error(). + // Note: error is member fcn from octave_stream, not ::error. error (who + ": format must be a string"); } @@ -3953,7 +3939,7 @@ } else { - // Note: error() is member fcn from octave_stream, not ::error(). + // Note: error is member fcn from octave_stream, not ::error. error (who + ": argument must be a string"); } @@ -4168,11 +4154,7 @@ if (list.size () < list.max_size ()) list[stream_number] = os; else - { - stream_number = -1; - // FIXME: Should this be ::error()? - error ("could not create file id"); - } + ::error ("could not create file id"); return stream_number; diff -r 3b2cc6ef0624 -r aac911d8847b libinterp/corefcn/oct-strstrm.cc --- a/libinterp/corefcn/oct-strstrm.cc Fri Dec 18 15:55:36 2015 -0500 +++ b/libinterp/corefcn/oct-strstrm.cc Fri Dec 18 16:22:53 2015 -0500 @@ -31,7 +31,7 @@ int octave_base_strstream::seek (off_t, int) { - // Note: error() is inherited from octave_base_stream, not ::error(). + // Note: error is inherited from octave_base_stream, not ::error. // This error function does not halt execution so "return ..." must exist. error ("fseek: invalid operation"); return -1; @@ -42,7 +42,7 @@ off_t octave_base_strstream::tell (void) { - // Note: error() is inherited from octave_base_stream, not ::error(). + // Note: error is inherited from octave_base_stream, not ::error. // This error function does not halt execution so "return ..." must exist. error ("ftell: invalid operation"); return -1;