mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Switched the utf bom checking to putback in the stream (instead of keeping a secondary buffer), which fixes a bug when there's only one ascii character
This commit is contained in:
@@ -178,7 +178,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
Stream::Stream(std::istream& input)
|
||||
: m_input(input), m_nPushedBack(0),
|
||||
: m_input(input),
|
||||
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
|
||||
m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0)
|
||||
{
|
||||
@@ -199,11 +199,10 @@ namespace YAML
|
||||
UtfIntroState newState = s_introTransitions[state][charType];
|
||||
int nUngets = s_introUngetCount[state][charType];
|
||||
if(nUngets > 0) {
|
||||
input.clear();
|
||||
for(; nUngets > 0; --nUngets) {
|
||||
if (char_traits::eof() != intro[--nIntroUsed]) {
|
||||
m_bufPushback[m_nPushedBack++] =
|
||||
char_traits::to_char_type(intro[nIntroUsed]);
|
||||
}
|
||||
if(char_traits::eof() != intro[--nIntroUsed])
|
||||
input.putback(char_traits::to_char_type(intro[nIntroUsed]));
|
||||
}
|
||||
}
|
||||
state = newState;
|
||||
@@ -398,11 +397,6 @@ namespace YAML
|
||||
|
||||
unsigned char Stream::GetNextByte() const
|
||||
{
|
||||
if (m_nPushedBack)
|
||||
{
|
||||
return m_bufPushback[--m_nPushedBack];
|
||||
}
|
||||
|
||||
if (m_nPrefetchedUsed >= m_nPrefetchedAvailable)
|
||||
{
|
||||
std::streambuf *pBuf = m_input.rdbuf();
|
||||
|
@@ -17,8 +17,6 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
static const size_t MAX_PARSER_PUSHBACK = 8;
|
||||
|
||||
class Stream: private noncopyable
|
||||
{
|
||||
public:
|
||||
@@ -50,8 +48,6 @@ namespace YAML
|
||||
Mark m_mark;
|
||||
|
||||
CharacterSet m_charSet;
|
||||
unsigned char m_bufPushback[MAX_PARSER_PUSHBACK];
|
||||
mutable size_t m_nPushedBack;
|
||||
mutable std::deque<char> m_readahead;
|
||||
unsigned char* const m_pPrefetched;
|
||||
mutable size_t m_nPrefetchedAvailable;
|
||||
|
Reference in New Issue
Block a user