@@ -81,7 +81,7 @@ Features Features::strictMode() {
8181// Implementation of class Reader
8282// ////////////////////////////////
8383
84- static bool containsNewLine (Reader::Location begin, Reader::Location end) {
84+ bool Reader:: containsNewLine (Reader::Location begin, Reader::Location end) {
8585 for (; begin < end; ++begin)
8686 if (*begin == ' \n ' || *begin == ' \r ' )
8787 return true ;
@@ -370,7 +370,7 @@ bool Reader::readComment() {
370370 return true ;
371371}
372372
373- static JSONCPP_STRING normalizeEOL (Reader::Location begin, Reader::Location end) {
373+ JSONCPP_STRING Reader:: normalizeEOL (Reader::Location begin, Reader::Location end) {
374374 JSONCPP_STRING normalized;
375375 normalized.reserve (static_cast <size_t >(end - begin));
376376 Reader::Location current = begin;
@@ -1019,6 +1019,9 @@ class OurReader {
10191019 void addComment (Location begin, Location end, CommentPlacement placement);
10201020 void skipCommentTokens (Token& token);
10211021
1022+ static JSONCPP_STRING normalizeEOL (Location begin, Location end);
1023+ static bool containsNewLine (Location begin, Location end);
1024+
10221025 typedef std::stack<Value*> Nodes;
10231026 Nodes nodes_;
10241027 Errors errors_;
@@ -1036,6 +1039,13 @@ class OurReader {
10361039
10371040// complete copy of Read impl, for OurReader
10381041
1042+ bool OurReader::containsNewLine (OurReader::Location begin, OurReader::Location end) {
1043+ for (; begin < end; ++begin)
1044+ if (*begin == ' \n ' || *begin == ' \r ' )
1045+ return true ;
1046+ return false ;
1047+ }
1048+
10391049OurReader::OurReader (OurFeatures const & features)
10401050 : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
10411051 lastValue_(), commentsBefore_(),
@@ -1345,6 +1355,25 @@ bool OurReader::readComment() {
13451355 return true ;
13461356}
13471357
1358+ JSONCPP_STRING OurReader::normalizeEOL (OurReader::Location begin, OurReader::Location end) {
1359+ JSONCPP_STRING normalized;
1360+ normalized.reserve (static_cast <size_t >(end - begin));
1361+ OurReader::Location current = begin;
1362+ while (current != end) {
1363+ char c = *current++;
1364+ if (c == ' \r ' ) {
1365+ if (current != end && *current == ' \n ' )
1366+ // convert dos EOL
1367+ ++current;
1368+ // convert Mac EOL
1369+ normalized += ' \n ' ;
1370+ } else {
1371+ normalized += c;
1372+ }
1373+ }
1374+ return normalized;
1375+ }
1376+
13481377void
13491378OurReader::addComment (Location begin, Location end, CommentPlacement placement) {
13501379 assert (collectComments_);
0 commit comments