Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
eb92bed5
Commit
eb92bed5
authored
Nov 01, 2012
by
Mukund Sivaraman
Browse files
[2369] Distinguish between EOF and failures in getChar()
parent
5ac6e8b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/master_lexer_inputsource.cc
View file @
eb92bed5
...
...
@@ -70,10 +70,16 @@ InputSource::getChar() {
// Have we reached EOF now? If so, set at_eof_ and return early,
// but don't modify buffer_pos_ (which should still be equal to
// the size of buffer_).
if
(
!
input_
.
good
())
{
if
(
input_
.
eof
())
{
at_eof_
=
true
;
return
(
END_OF_STREAM
);
}
// This has to come after the .eof() check as some
// implementations seem to check the eofbit also in .fail().
if
(
input_
.
fail
())
{
isc_throw
(
ReadError
,
"Error reading from the input stream: "
<<
getName
());
}
buffer_
.
push_back
(
c
);
}
...
...
src/lib/dns/master_lexer_inputsource.h
View file @
eb92bed5
...
...
@@ -79,11 +79,22 @@ public:
{}
};
/// \brief Exception thrown when we fail to read from the input
/// stream or file.
struct
ReadError
:
public
Unexpected
{
ReadError
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
Unexpected
(
file
,
line
,
what
)
{}
};
/// \brief Returned by getChar() when end of stream is reached.
static
const
int
END_OF_STREAM
;
/// \brief Returns a single character from the input source. If end
/// of file is reached, \c END_OF_STREAM is returned.
///
/// \throws ReadError when reading from the input stream or file
/// fails.
int
getChar
();
/// \brief Skips backward a single character in the input
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment