From ebe124eacd7c3faa36ed358e7cc1d7c5b419e5f6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:18:09 +0200 Subject: Merging upstream version 15.6. Signed-off-by: Daniel Baumann --- src/include/mb/pg_wchar.h | 53 ----------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'src/include/mb/pg_wchar.h') diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index 31f5b39..4a0e6bf 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -699,57 +699,4 @@ extern int mic2latin_with_table(const unsigned char *mic, unsigned char *p, extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len); #endif - -/* - * Verify a chunk of bytes for valid ASCII. - * - * Returns false if the input contains any zero bytes or bytes with the - * high-bit set. Input len must be a multiple of 8. - */ -static inline bool -is_valid_ascii(const unsigned char *s, int len) -{ - uint64 chunk, - highbit_cum = UINT64CONST(0), - zero_cum = UINT64CONST(0x8080808080808080); - - Assert(len % sizeof(chunk) == 0); - - while (len > 0) - { - memcpy(&chunk, s, sizeof(chunk)); - - /* - * Capture any zero bytes in this chunk. - * - * First, add 0x7f to each byte. This sets the high bit in each byte, - * unless it was a zero. If any resulting high bits are zero, the - * corresponding high bits in the zero accumulator will be cleared. - * - * If none of the bytes in the chunk had the high bit set, the max - * value each byte can have after the addition is 0x7f + 0x7f = 0xfe, - * and we don't need to worry about carrying over to the next byte. If - * any input bytes did have the high bit set, it doesn't matter - * because we check for those separately. - */ - zero_cum &= (chunk + UINT64CONST(0x7f7f7f7f7f7f7f7f)); - - /* Capture any set bits in this chunk. */ - highbit_cum |= chunk; - - s += sizeof(chunk); - len -= sizeof(chunk); - } - - /* Check if any high bits in the high bit accumulator got set. */ - if (highbit_cum & UINT64CONST(0x8080808080808080)) - return false; - - /* Check if any high bits in the zero accumulator got cleared. */ - if (zero_cum != UINT64CONST(0x8080808080808080)) - return false; - - return true; -} - #endif /* PG_WCHAR_H */ -- cgit v1.2.3