Ticket #4340: property_tree_xml_i18n_fix.patch

File property_tree_xml_i18n_fix.patch, 3.9 KB (added by zhuo.qiang@…, 12 years ago)

Fix for the property_tree xml parser parse i18n stream bug against svn revision 62903

  • boost/property_tree/detail/rapidxml.hpp

     
    309309            }
    310310            return true;
    311311        }
     312
     313        template<class Ch>
     314        inline size_t get_index(const Ch c)
     315        {
     316            // If not ASCII char, its sematic is same as plain 'z'
     317            if (c > 255)
     318            {
     319                return 'z';
     320            }
     321            return c;
     322        }
    312323    }
    313324    //! \endcond
    314325
     
    13991410        {
    14001411            static unsigned char test(Ch ch)
    14011412            {
    1402                 return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];
     1413                return internal::lookup_tables<0>::lookup_whitespace[internal::get_index(ch)];
    14031414            }
    14041415        };
    14051416
     
    14081419        {
    14091420            static unsigned char test(Ch ch)
    14101421            {
    1411                 return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];
     1422                return internal::lookup_tables<0>::lookup_node_name[internal::get_index(ch)];
    14121423            }
    14131424        };
    14141425
     
    14171428        {
    14181429            static unsigned char test(Ch ch)
    14191430            {
    1420                 return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];
     1431                return internal::lookup_tables<0>::lookup_attribute_name[internal::get_index(ch)];
    14211432            }
    14221433        };
    14231434
     
    14261437        {
    14271438            static unsigned char test(Ch ch)
    14281439            {
    1429                 return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];
     1440                return internal::lookup_tables<0>::lookup_text[internal::get_index(ch)];
    14301441            }
    14311442        };
    14321443
     
    14351446        {
    14361447            static unsigned char test(Ch ch)
    14371448            {
    1438                 return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];
     1449                return internal::lookup_tables<0>::lookup_text_pure_no_ws[internal::get_index(ch)];
    14391450            }
    14401451        };
    14411452
     
    14441455        {
    14451456            static unsigned char test(Ch ch)
    14461457            {
    1447                 return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];
     1458                return internal::lookup_tables<0>::lookup_text_pure_with_ws[internal::get_index(ch)];
    14481459            }
    14491460        };
    14501461
     
    14551466            static unsigned char test(Ch ch)
    14561467            {
    14571468                if (Quote == Ch('\''))
    1458                     return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];
     1469                    return internal::lookup_tables<0>::lookup_attribute_data_1[internal::get_index(ch)];
    14591470                if (Quote == Ch('\"'))
    1460                     return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];
     1471                    return internal::lookup_tables<0>::lookup_attribute_data_2[internal::get_index(ch)];
    14611472                return 0;       // Should never be executed, to avoid warnings on Comeau
    14621473            }
    14631474        };
     
    14691480            static unsigned char test(Ch ch)
    14701481            {
    14711482                if (Quote == Ch('\''))
    1472                     return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];
     1483                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[internal::get_index(ch)];
    14731484                if (Quote == Ch('\"'))
    1474                     return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];
     1485                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[internal::get_index(ch)];
    14751486                return 0;       // Should never be executed, to avoid warnings on Comeau
    14761487            }
    14771488        };