@@ -81,7 +81,7 @@ Features Features::strictMode() {
81
81
// Implementation of class Reader
82
82
// ////////////////////////////////
83
83
84
- static bool containsNewLine (Reader::Location begin, Reader::Location end) {
84
+ bool Reader:: containsNewLine (Reader::Location begin, Reader::Location end) {
85
85
for (; begin < end; ++begin)
86
86
if (*begin == ' \n ' || *begin == ' \r ' )
87
87
return true ;
@@ -370,7 +370,7 @@ bool Reader::readComment() {
370
370
return true ;
371
371
}
372
372
373
- static JSONCPP_STRING normalizeEOL (Reader::Location begin, Reader::Location end) {
373
+ JSONCPP_STRING Reader:: normalizeEOL (Reader::Location begin, Reader::Location end) {
374
374
JSONCPP_STRING normalized;
375
375
normalized.reserve (static_cast <size_t >(end - begin));
376
376
Reader::Location current = begin;
@@ -1019,6 +1019,9 @@ class OurReader {
1019
1019
void addComment (Location begin, Location end, CommentPlacement placement);
1020
1020
void skipCommentTokens (Token& token);
1021
1021
1022
+ static JSONCPP_STRING normalizeEOL (Location begin, Location end);
1023
+ static bool containsNewLine (Location begin, Location end);
1024
+
1022
1025
typedef std::stack<Value*> Nodes;
1023
1026
Nodes nodes_;
1024
1027
Errors errors_;
@@ -1036,6 +1039,13 @@ class OurReader {
1036
1039
1037
1040
// complete copy of Read impl, for OurReader
1038
1041
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
+
1039
1049
OurReader::OurReader (OurFeatures const & features)
1040
1050
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
1041
1051
lastValue_(), commentsBefore_(),
@@ -1345,6 +1355,25 @@ bool OurReader::readComment() {
1345
1355
return true ;
1346
1356
}
1347
1357
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
+
1348
1377
void
1349
1378
OurReader::addComment (Location begin, Location end, CommentPlacement placement) {
1350
1379
assert (collectComments_);
0 commit comments