[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62723] sscanf returns an error when there is
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #62723] sscanf returns an error when there is no error |
Date: |
Tue, 22 Nov 2022 11:38:51 -0500 (EST) |
Follow-up Comment #8, bug #62723 (project octave):
> Additionally, I stumbled across some probably older code (maybe from when
`error` didn't throw an exception immediately). I moved the clean-up code to
before throwing the exception here:
> https://hg.savannah.gnu.org/hgweb/octave/rev/2a12350f9410
This actually won't have any effect. I've never been happy with this, but the
octave_stream class has it's own error() function which is not the global
error function that Octave uses elsewhere. I made a comment about this at the
top of oct-stream.cc a long time ago because I too was very confused about
this. The comment is:
// Programming Note: There are two very different error functions used
// in the stream code. When invoked with "error (...)" the member
// function from stream or 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!
The change you made
+ is.clear (is.rdstate () & (~std::ios::failbit));
error (who, "format failed to match");
- is.clear (is.rdstate () & (~std::ios::failbit));
is still probably a good idea because anyone who is familiar with Octave is
likely to have the same confusion. Putting the is.clear call first works
whichever version of error() is called.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62723>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/