From 6b986090d954dbac91bbb3c43ce7c3328c91a780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 20 Apr 2020 20:33:51 +0200 Subject: New upstream version 6.9.5 --- src/iso8859_1.c | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'src/iso8859_1.c') diff --git a/src/iso8859_1.c b/src/iso8859_1.c index e681c2a..d75509e 100644 --- a/src/iso8859_1.c +++ b/src/iso8859_1.c @@ -29,6 +29,9 @@ #include "regenc.h" +#define LARGE_S 0x53 +#define SMALL_S 0x73 + #define ENC_IS_ISO_8859_1_CTYPE(code,ctype) \ ((EncISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) @@ -115,33 +118,48 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) { + static OnigUChar sa[] = { LARGE_S, SMALL_S }; + int i, j, n; + if (0x41 <= *p && *p <= 0x5a) { + if (*p == LARGE_S && end > p + 1 + && (*(p+1) == LARGE_S || *(p+1) == SMALL_S)) { /* SS */ + ss_combination: + items[0].byte_len = 2; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )0xdf; + + n = 1; + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + if (sa[i] == *p && sa[j] == *(p+1)) + continue; + + items[n].byte_len = 2; + items[n].code_len = 2; + items[n].code[0] = (OnigCodePoint )sa[i]; + items[n].code[1] = (OnigCodePoint )sa[j]; + n++; + } + } + return 4; + } + items[0].byte_len = 1; items[0].code_len = 1; items[0].code[0] = (OnigCodePoint )(*p + 0x20); - if (*p == 0x53 && end > p + 1 - && (*(p+1) == 0x53 || *(p+1) == 0x73)) { /* SS */ - items[1].byte_len = 2; - items[1].code_len = 1; - items[1].code[0] = (OnigCodePoint )0xdf; - return 2; - } - else - return 1; + return 1; } else if (0x61 <= *p && *p <= 0x7a) { + if (*p == SMALL_S && end > p + 1 + && (*(p+1) == SMALL_S || *(p+1) == LARGE_S)) { /* ss */ + goto ss_combination; + } + items[0].byte_len = 1; items[0].code_len = 1; items[0].code[0] = (OnigCodePoint )(*p - 0x20); - if (*p == 0x73 && end > p + 1 - && (*(p+1) == 0x73 || *(p+1) == 0x53)) { /* ss */ - items[1].byte_len = 2; - items[1].code_len = 1; - items[1].code[0] = (OnigCodePoint )0xdf; - return 2; - } - else - return 1; + return 1; } else if (0xc0 <= *p && *p <= 0xcf) { items[0].byte_len = 1; -- cgit v1.2.3