majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Problem with windows-style line endings. #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build yaml-cpp r98 under Visual Studio.
2. Load a file with windows line endings.
3. Parse the file.  For me, YAML loads a lot of bunk data at the end of the
file that causes errors in ScanScalar.

I was able to fix the problem by changing line 15 of stream.cpp from

pBuf->sgetn(buffer, size);

to:

size = pBuf->sgetn(buffer, size);

I'm not 100% sure I understand the problem, but I think it has to do with
the way the VS CRT handles windows line endings.  I think pubseekoff()
returns the actual character number but sgetn() automatically converts
CRLFs to CRs under the hood, causing sgetn() to read fewer characters than
are in the file.

Original issue reported on code.google.com by devilj...@gmail.com on 6 Feb 2009 at 10:26

GoogleCodeExporter commented 9 years ago
Fixed, thanks!

Original comment by jbe...@gmail.com on 7 Feb 2009 at 7:57