diff options
author | chpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-16 15:56:26 +0000 |
---|---|---|
committer | chpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-16 15:56:26 +0000 |
commit | 191822033558082f127991f947ff50efa6aeefdc (patch) | |
tree | e0d0ae30da066f1dcc0e647dab8f3fc31ec0fb8b /pcre_string_utils.c | |
parent | f4551b3ba82aff87a520b041b9e1dc1fe1ec5533 (diff) | |
download | pcre-191822033558082f127991f947ff50efa6aeefdc.tar.gz |
pcre32: exec: Mask bits > 21 in 32-bit UTF mode
Allow passing characters with high bits set in UTF-32 mode.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1100 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_string_utils.c')
-rw-r--r-- | pcre_string_utils.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/pcre_string_utils.c b/pcre_string_utils.c index 54a75f6..94a5126 100644 --- a/pcre_string_utils.c +++ b/pcre_string_utils.c @@ -81,6 +81,27 @@ while (*str1 != '\0' || *str2 != '\0') return 0; } +#ifdef COMPILE_PCRE32 + +int +PRIV(strcmp_uc_uc_utf)(const pcre_uchar *str1, const pcre_uchar *str2) +{ +pcre_uchar c1; +pcre_uchar c2; + +while (*str1 != '\0' || *str2 != '\0') + { + c1 = RAWUCHARINC(str1); + c2 = RAWUCHARINC(str2); + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +#endif /* COMPILE_PCRE32 */ + int PRIV(strcmp_uc_c8)(const pcre_uchar *str1, const char *str2) { @@ -99,6 +120,28 @@ while (*str1 != '\0' || *ustr2 != '\0') return 0; } +#ifdef COMPILE_PCRE32 + +int +PRIV(strcmp_uc_c8_utf)(const pcre_uchar *str1, const char *str2) +{ +const pcre_uint8 *ustr2 = (pcre_uint8 *)str2; +pcre_uchar c1; +pcre_uchar c2; + +while (*str1 != '\0' || *ustr2 != '\0') + { + c1 = RAWUCHARINC(str1); + c2 = (pcre_uchar)*ustr2++; + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +#endif /* COMPILE_PCRE32 */ + /* The following two functions compares two, fixed length strings. Basically an strncmp for non 8 bit characters. @@ -163,6 +206,6 @@ while (*str++ != 0) return len; } -#endif /* COMPILE_PCRE8 */ +#endif /* !COMPILE_PCRE8 */ /* End of pcre_string_utils.c */ |