| OLD | NEW |
| 1 /* | 1 /* |
| 2 * string.c : an XML string utilities module | 2 * string.c : an XML string utilities module |
| 3 * | 3 * |
| 4 * This module provides various utility functions for manipulating | 4 * This module provides various utility functions for manipulating |
| 5 * the xmlChar* type. All functions named xmlStr* have been moved here | 5 * the xmlChar* type. All functions named xmlStr* have been moved here |
| 6 * from the parser.c file (their original home). | 6 * from the parser.c file (their original home). |
| 7 * | 7 * |
| 8 * See Copyright for the status of this software. | 8 * See Copyright for the status of this software. |
| 9 * | 9 * |
| 10 * UTF8 string routines from: | 10 * UTF8 string routines from: |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 * @utf: a sequence of UTF-8 encoded bytes | 814 * @utf: a sequence of UTF-8 encoded bytes |
| 815 * @len: the number of characters in the array | 815 * @len: the number of characters in the array |
| 816 * | 816 * |
| 817 * storage size of an UTF8 string | 817 * storage size of an UTF8 string |
| 818 * the behaviour is not garanteed if the input string is not UTF-8 | 818 * the behaviour is not garanteed if the input string is not UTF-8 |
| 819 * | 819 * |
| 820 * Returns the storage size of | 820 * Returns the storage size of |
| 821 * the first 'len' characters of ARRAY | 821 * the first 'len' characters of ARRAY |
| 822 */ | 822 */ |
| 823 | 823 |
| 824 #if _MSC_FULL_VER && _MSC_FULL_VER == 190023918 | |
| 825 // Workaround for a /O1 ("s") optimization bug in VS 2015 Update 2, remove once | |
| 826 // the fix is released. crbug.com/599427 | |
| 827 // https://connect.microsoft.com/VisualStudio/feedback/details/2582138 | |
| 828 #pragma optimize("t", on) | |
| 829 #endif | |
| 830 | |
| 831 int | 824 int |
| 832 xmlUTF8Strsize(const xmlChar *utf, int len) { | 825 xmlUTF8Strsize(const xmlChar *utf, int len) { |
| 833 const xmlChar *ptr=utf; | 826 const xmlChar *ptr=utf; |
| 834 xmlChar ch; | 827 xmlChar ch; |
| 835 | 828 |
| 836 if (utf == NULL) | 829 if (utf == NULL) |
| 837 return(0); | 830 return(0); |
| 838 | 831 |
| 839 if (len <= 0) | 832 if (len <= 0) |
| 840 return(0); | 833 return(0); |
| 841 | 834 |
| 842 while ( len-- > 0) { | 835 while ( len-- > 0) { |
| 843 if ( !*ptr ) | 836 if ( !*ptr ) |
| 844 break; | 837 break; |
| 845 if ( (ch = *ptr++) & 0x80) | 838 if ( (ch = *ptr++) & 0x80) { |
| 846 while ((ch<<=1) & 0x80 ) { | 839 // Workaround for an optimization bug in VS 2015 Update 2, remove |
| 840 // once the fix is released. crbug.com/599427 |
| 841 // https://connect.microsoft.com/VisualStudio/feedback/details/25821
38 |
| 842 xmlChar ch2 = ch; |
| 843 while ((ch2<<=1) & 0x80 ) { |
| 847 ptr++; | 844 ptr++; |
| 848 » » if (*ptr == 0) break; | 845 if (*ptr == 0) break; |
| 849 » } | 846 } |
| 847 } |
| 850 } | 848 } |
| 851 return (ptr - utf); | 849 return (ptr - utf); |
| 852 } | 850 } |
| 853 | 851 |
| 854 #if _MSC_FULL_VER && _MSC_FULL_VER == 190023918 | |
| 855 // Restore the original optimization settings. | |
| 856 #pragma optimize("", on) | |
| 857 #endif | |
| 858 | |
| 859 /** | 852 /** |
| 860 * xmlUTF8Strndup: | 853 * xmlUTF8Strndup: |
| 861 * @utf: the input UTF8 * | 854 * @utf: the input UTF8 * |
| 862 * @len: the len of @utf (in chars) | 855 * @len: the len of @utf (in chars) |
| 863 * | 856 * |
| 864 * a strndup for array of UTF8's | 857 * a strndup for array of UTF8's |
| 865 * | 858 * |
| 866 * Returns a new UTF8 * or NULL | 859 * Returns a new UTF8 * or NULL |
| 867 */ | 860 */ |
| 868 xmlChar * | 861 xmlChar * |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 if ( (*utf++ & 0xc0) != 0x80 ) | 979 if ( (*utf++ & 0xc0) != 0x80 ) |
| 987 return(NULL); | 980 return(NULL); |
| 988 } | 981 } |
| 989 } | 982 } |
| 990 | 983 |
| 991 return(xmlUTF8Strndup(utf, len)); | 984 return(xmlUTF8Strndup(utf, len)); |
| 992 } | 985 } |
| 993 | 986 |
| 994 #define bottom_xmlstring | 987 #define bottom_xmlstring |
| 995 #include "elfgcchack.h" | 988 #include "elfgcchack.h" |
| OLD | NEW |