@@ -871,7 +871,7 @@ class OurFeatures {
871871 bool failIfExtra_;
872872 bool rejectDupKeys_;
873873 bool allowSpecialFloats_;
874- bool allowBom_ ;
874+ bool skipBom_ ;
875875 size_t stackLimit_;
876876}; // OurFeatures
877877
@@ -940,7 +940,7 @@ class OurReader {
940940
941941 bool readToken (Token& token);
942942 void skipSpaces ();
943- void skipBom (bool allowBom );
943+ void skipBom (bool skipBom );
944944 bool match (const Char* pattern, int patternLength);
945945 bool readComment ();
946946 bool readCStyleComment (bool * containsNewLineResult);
@@ -1025,7 +1025,7 @@ bool OurReader::parse(const char* beginDoc, const char* endDoc, Value& root,
10251025 nodes_.push (&root);
10261026
10271027 // skip byte order mark if it exists at the beginning of the UTF-8 text.
1028- skipBom (features_.allowBom_ );
1028+ skipBom (features_.skipBom_ );
10291029 bool successful = readValue ();
10301030 nodes_.pop ();
10311031 Token token;
@@ -1272,10 +1272,9 @@ void OurReader::skipSpaces() {
12721272 }
12731273}
12741274
1275- void OurReader::skipBom (bool allowBom) {
1276- // If BOM is not allowed, then skip it.
1277- // The default value is: false
1278- if (!allowBom) {
1275+ void OurReader::skipBom (bool skipBom) {
1276+ // The default behavior is to skip BOM.
1277+ if (skipBom) {
12791278 if (strncmp (begin_, " \xEF\xBB\xBF " , 3 ) == 0 ) {
12801279 begin_ += 3 ;
12811280 current_ = begin_;
@@ -1900,7 +1899,7 @@ CharReader* CharReaderBuilder::newCharReader() const {
19001899 features.failIfExtra_ = settings_[" failIfExtra" ].asBool ();
19011900 features.rejectDupKeys_ = settings_[" rejectDupKeys" ].asBool ();
19021901 features.allowSpecialFloats_ = settings_[" allowSpecialFloats" ].asBool ();
1903- features.allowBom_ = settings_[" allowBom " ].asBool ();
1902+ features.skipBom_ = settings_[" skipBom " ].asBool ();
19041903 return new OurCharReader (collectComments, features);
19051904}
19061905static void getValidReaderKeys (std::set<String>* valid_keys) {
@@ -1916,7 +1915,7 @@ static void getValidReaderKeys(std::set<String>* valid_keys) {
19161915 valid_keys->insert (" failIfExtra" );
19171916 valid_keys->insert (" rejectDupKeys" );
19181917 valid_keys->insert (" allowSpecialFloats" );
1919- valid_keys->insert (" allowBom " );
1918+ valid_keys->insert (" skipBom " );
19201919}
19211920bool CharReaderBuilder::validate (Json::Value* invalid) const {
19221921 Json::Value my_invalid;
@@ -1951,7 +1950,7 @@ void CharReaderBuilder::strictMode(Json::Value* settings) {
19511950 (*settings)[" failIfExtra" ] = true ;
19521951 (*settings)[" rejectDupKeys" ] = true ;
19531952 (*settings)[" allowSpecialFloats" ] = false ;
1954- (*settings)[" allowBom " ] = false ;
1953+ (*settings)[" skipBom " ] = true ;
19551954 // ! [CharReaderBuilderStrictMode]
19561955}
19571956// static
@@ -1968,7 +1967,7 @@ void CharReaderBuilder::setDefaults(Json::Value* settings) {
19681967 (*settings)[" failIfExtra" ] = false ;
19691968 (*settings)[" rejectDupKeys" ] = false ;
19701969 (*settings)[" allowSpecialFloats" ] = false ;
1971- (*settings)[" allowBom " ] = false ;
1970+ (*settings)[" skipBom " ] = true ;
19721971 // ! [CharReaderBuilderDefaults]
19731972}
19741973
0 commit comments