From patchwork Wed Oct 26 10:00:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 686971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t3lsh17sFz9s3T for ; Wed, 26 Oct 2016 21:01:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=S0OhhUm/; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:cc:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=wdrl R7Ln2AdkNqcvrQN8tnJfAmQepW1rlllRP0Ah7mIimyBv0b95bsrrkcuN8Xk0BP+p drPheaDuALTqeVtRRkF9dQaEqQjBb0osDbBB0RA1oAXZ6a16t6714e//dikclWQj KX4R6uGHCKvPxRCLzUzQMo+VOzZIf42sRthsnUY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:cc:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=l/HwfIuv/c oZvkj2ruXSpRhyO8c=; b=S0OhhUm/YUdHyBbVBry6EEHJaSGSjzn/AlaLzovE4D r0PVLx4zNEiqPmEfkIKpf1Ip793xhDKvCVw1Tr0r5Ynpj/m3L1dDRcCK9BXC+5GD yJjKbxjK2XXHwI1VGeomobw37q4oB8470kXYdbk15MeQ9YLrD3ZWgm1dSlAw7ZpG k= Received: (qmail 43906 invoked by alias); 26 Oct 2016 10:00:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 43731 invoked by uid 89); 26 Oct 2016 10:00:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=x8d, xa4, xc8, x3a X-HELO: mx1.redhat.com Subject: Re: [PATCH] iconv: Avoid writable data and relocations in IBM charsets To: Andreas Schwab References: <20161026091538.A7628439942E0@oldenburg.str.redhat.com> Cc: libc-alpha@sourceware.org From: Florian Weimer Message-ID: <17924314-bb39-2c81-7faa-eefd58ebfa37@redhat.com> Date: Wed, 26 Oct 2016 12:00:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: On 10/26/2016 11:22 AM, Andreas Schwab wrote: >> -static const char * __ucs4_to_ibm930sb[] = >> +static const char __ucs4_to_ibm930sb[][2] = > > I think you can even make that [1]. Oh, right, I forgot. That was the reason why I had postponed the cleanup. :-/ This version removes the indirection completely and adjusts the .c files, too. Thanks, Florian iconv: Avoid writable data and relocations in IBM charsets The IBM930, IBM933, IBM935 and IBM939 converters defined lookup tables which were not constant. They also contained an unnecessary pointer indirection. 2016-10-26 Florian Weimer * iconvdata/ibm930.h (__ucs4_to_ibm930sb): Remove indirection and make const. * iconvdata/ibm933.h (__ucs4_to_ibm933sb): Likewise. * iconvdata/ibm935.h (__ucs4_to_ibm935sb): Likewise. * iconvdata/ibm939.h (__ucs4_to_ibm939sb): Likewise. * iconvdata/ibm930.c [TO_LOOP] (BODY): Store converted single-byte character in sbconv. * iconvdata/ibm933.c [TO_LOOP] (BODY): Likewise. * iconvdata/ibm935.c [TO_LOOP] (BODY): Likewise. * iconvdata/ibm939.c [TO_LOOP] (BODY): Likewise. diff --git a/iconvdata/ibm930.c b/iconvdata/ibm930.c index 9d35734..f632997 100644 --- a/iconvdata/ibm930.c +++ b/iconvdata/ibm930.c @@ -191,7 +191,6 @@ enum uint32_t ch = get32 (inptr); \ const struct gap *rp1 = __ucs4_to_ibm930sb_idx; \ const struct gap *rp2 = __ucs4_to_ibm930db_idx; \ - const char *cp; \ \ if (__glibc_unlikely (ch >= 0xffff)) \ { \ @@ -204,14 +203,16 @@ enum ++rp1; \ \ /* Use the UCS4 table for single byte. */ \ + unsigned char sbconv; \ if (__builtin_expect (ch < rp1->start, 0) \ - || (cp = __ucs4_to_ibm930sb[ch + rp1->idx], \ - __builtin_expect (cp[0], L'\1') == L'\0' && ch != '\0')) \ + || (sbconv = __ucs4_to_ibm930sb[ch + rp1->idx], \ + __builtin_expect (sbconv, L'\1') == L'\0' && ch != '\0')) \ { \ /* Use the UCS4 table for double byte. */ \ while (ch > rp2->end) \ ++rp2; \ \ + const char *cp; \ if (__builtin_expect (ch < rp2->start, 0) \ || (cp = __ucs4_to_ibm930db[ch + rp2->idx], \ __builtin_expect (cp[0], L'\1')== L'\0' && ch != '\0')) \ @@ -264,7 +265,7 @@ enum else if (ch == 0x5c) \ *outptr++ = 0x5b; \ else \ - *outptr++ = cp[0]; \ + *outptr++ = sbconv; \ } \ \ /* Now that we wrote the output increment the input pointer. */ \ diff --git a/iconvdata/ibm930.h b/iconvdata/ibm930.h index 1afda56..749623e 100644 --- a/iconvdata/ibm930.h +++ b/iconvdata/ibm930.h @@ -1499,46 +1499,46 @@ static const struct gap __ucs4_to_ibm930sb_idx[] = { .start = 0xffff, .end = 0xffff, .idx = 0 } }; -static const char * __ucs4_to_ibm930sb[] = +static const unsigned char __ucs4_to_ibm930sb[] = { - "\x00", "\x01", "\x02", "\x03", "\x37", "\x2d", "\x2e", "\x2f", "\x16", - "\x05", "\x25", "\x0b", "\x0c", "\x0d", "\x3f", "\x3f", "\x10", "\x11", - "\x12", "\x13", "\x3c", "\x3d", "\x32", "\x26", "\x18", "\x19", "\x3f", - "\x27", "\x1c", "\x1d", "\x1e", "\x1f", "\x40", "\x5a", "\x7f", "\x7b", - "\xe0", "\x6c", "\x50", "\x7d", "\x4d", "\x5d", "\x5c", "\x4e", "\x6b", - "\x60", "\x4b", "\x61", "\xf0", "\xf1", "\xf2", "\xf3", "\xf4", "\xf5", - "\xf6", "\xf7", "\xf8", "\xf9", "\x7a", "\x5e", "\x4c", "\x7e", "\x6e", - "\x6f", "\x7c", "\xc1", "\xc2", "\xc3", "\xc4", "\xc5", "\xc6", "\xc7", - "\xc8", "\xc9", "\xd1", "\xd2", "\xd3", "\xd4", "\xd5", "\xd6", "\xd7", - "\xd8", "\xd9", "\xe2", "\xe3", "\xe4", "\xe5", "\xe6", "\xe7", "\xe8", - "\xe9", "\x70", "\xb2", "\x80", "\xb0", "\x6d", "\x79", "\x62", "\x63", - "\x64", "\x65", "\x66", "\x67", "\x68", "\x69", "\x71", "\x72", "\x73", - "\x74", "\x75", "\x76", "\x77", "\x78", "\x8b", "\x9b", "\xab", "\xb3", - "\xb4", "\xb5", "\xb6", "\xb7", "\xb8", "\xb9", "\xc0", "\x4f", "\xd0", - "\xa0", "\x07", "\x20", "\x21", "\x22", "\x23", "\x24", "\x15", "\x06", - "\x17", "\x28", "\x29", "\x2a", "\x2b", "\x2c", "\x09", "\x0a", "\x1b", - "\x30", "\x31", "\x1a", "\x33", "\x34", "\x35", "\x36", "\x08", "\x38", - "\x39", "\x3a", "\x3b", "\x04", "\x14", "\x3e", "\xff", "\x3f", "\x3f", - "\xb1", "\x4a", "\x3f", "\x5b", "\x3f", "\x3f", "\x3f", "\x5f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\xa1", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x41", "\x42", "\x43", "\x44", "\x45", - "\x46", "\x47", "\x48", "\x49", "\x51", "\x52", "\x53", "\x54", "\x55", - "\x56", "\x58", "\x81", "\x82", "\x83", "\x84", "\x85", "\x86", "\x87", - "\x88", "\x89", "\x8a", "\x8c", "\x8d", "\x8e", "\x8f", "\x90", "\x91", - "\x92", "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\x9a", - "\x9d", "\x9e", "\x9f", "\xa2", "\xa3", "\xa4", "\xa5", "\xa6", "\xa7", - "\xa8", "\xa9", "\xaa", "\xac", "\xad", "\xae", "\xaf", "\xba", "\xbb", - "\xbc", "\xbd", "\xbe", "\xbf", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f" + '\x00', '\x01', '\x02', '\x03', '\x37', '\x2d', '\x2e', '\x2f', '\x16', + '\x05', '\x25', '\x0b', '\x0c', '\x0d', '\x3f', '\x3f', '\x10', '\x11', + '\x12', '\x13', '\x3c', '\x3d', '\x32', '\x26', '\x18', '\x19', '\x3f', + '\x27', '\x1c', '\x1d', '\x1e', '\x1f', '\x40', '\x5a', '\x7f', '\x7b', + '\xe0', '\x6c', '\x50', '\x7d', '\x4d', '\x5d', '\x5c', '\x4e', '\x6b', + '\x60', '\x4b', '\x61', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', + '\xf6', '\xf7', '\xf8', '\xf9', '\x7a', '\x5e', '\x4c', '\x7e', '\x6e', + '\x6f', '\x7c', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', + '\xc8', '\xc9', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', + '\xd8', '\xd9', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', + '\xe9', '\x70', '\xb2', '\x80', '\xb0', '\x6d', '\x79', '\x62', '\x63', + '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x71', '\x72', '\x73', + '\x74', '\x75', '\x76', '\x77', '\x78', '\x8b', '\x9b', '\xab', '\xb3', + '\xb4', '\xb5', '\xb6', '\xb7', '\xb8', '\xb9', '\xc0', '\x4f', '\xd0', + '\xa0', '\x07', '\x20', '\x21', '\x22', '\x23', '\x24', '\x15', '\x06', + '\x17', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x09', '\x0a', '\x1b', + '\x30', '\x31', '\x1a', '\x33', '\x34', '\x35', '\x36', '\x08', '\x38', + '\x39', '\x3a', '\x3b', '\x04', '\x14', '\x3e', '\xff', '\x3f', '\x3f', + '\xb1', '\x4a', '\x3f', '\x5b', '\x3f', '\x3f', '\x3f', '\x5f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\xa1', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x41', '\x42', '\x43', '\x44', '\x45', + '\x46', '\x47', '\x48', '\x49', '\x51', '\x52', '\x53', '\x54', '\x55', + '\x56', '\x58', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', + '\x88', '\x89', '\x8a', '\x8c', '\x8d', '\x8e', '\x8f', '\x90', '\x91', + '\x92', '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\x9a', + '\x9d', '\x9e', '\x9f', '\xa2', '\xa3', '\xa4', '\xa5', '\xa6', '\xa7', + '\xa8', '\xa9', '\xaa', '\xac', '\xad', '\xae', '\xaf', '\xba', '\xbb', + '\xbc', '\xbd', '\xbe', '\xbf', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f' }; static const struct gap __ucs4_to_ibm930db_idx[] = diff --git a/iconvdata/ibm933.c b/iconvdata/ibm933.c index 669e357..8abc05a 100644 --- a/iconvdata/ibm933.c +++ b/iconvdata/ibm933.c @@ -189,7 +189,6 @@ enum uint32_t ch = get32 (inptr); \ const struct gap *rp1 = __ucs4_to_ibm933sb_idx; \ const struct gap *rp2 = __ucs4_to_ibm933db_idx; \ - const char *cp; \ \ if (__glibc_unlikely (ch >= 0xffff)) \ { \ @@ -202,14 +201,16 @@ enum ++rp1; \ \ /* Use the UCS4 table for single byte. */ \ + unsigned char sbconv; \ if (__builtin_expect (ch < rp1->start, 0) \ - || (cp = __ucs4_to_ibm933sb[ch + rp1->idx], \ - __builtin_expect (cp[0], L'\1') == L'\0' && ch != '\0')) \ + || (sbconv = __ucs4_to_ibm933sb[ch + rp1->idx], \ + __builtin_expect (sbconv, L'\1') == L'\0' && ch != '\0')) \ { \ /* Use the UCS4 table for double byte. */ \ while (ch > rp2->end) \ ++rp2; \ \ + const char *cp; \ if (__builtin_expect (ch < rp2->start, 0) \ || (cp = __ucs4_to_ibm933db[ch + rp2->idx], \ __builtin_expect (cp[0], L'\1')==L'\0' && ch != '\0')) \ @@ -257,7 +258,7 @@ enum result = __GCONV_FULL_OUTPUT; \ break; \ } \ - *outptr++ = cp[0]; \ + *outptr++ = sbconv; \ } \ \ /* Now that we wrote the output increment the input pointer. */ \ diff --git a/iconvdata/ibm933.h b/iconvdata/ibm933.h index cb00137..1b69dd7 100644 --- a/iconvdata/ibm933.h +++ b/iconvdata/ibm933.h @@ -3371,39 +3371,39 @@ static const struct gap __ucs4_to_ibm933sb_idx[] = { .start = 0xffff, .end = 0xffff, .idx = 0 } }; -static const char *__ucs4_to_ibm933sb[] = +static const unsigned char __ucs4_to_ibm933sb[] = { - "\x00", "\x01", "\x02", "\x03", "\x37", "\x2d", "\x2e", "\x2f", "\x16", - "\x05", "\x25", "\x0b", "\x0c", "\x0d", "\x3f", "\x3f", "\x10", "\x11", - "\x12", "\x13", "\x3c", "\x3d", "\x32", "\x26", "\x18", "\x19", "\x3f", - "\x27", "\x1c", "\x1d", "\x1e", "\x1f", "\x40", "\x5a", "\x7f", "\x7b", - "\x5b", "\x6c", "\x50", "\x7d", "\x4d", "\x5d", "\x5c", "\x4e", "\x6b", - "\x60", "\x4b", "\x61", "\xf0", "\xf1", "\xf2", "\xf3", "\xf4", "\xf5", - "\xf6", "\xf7", "\xf8", "\xf9", "\x7a", "\x5e", "\x4c", "\x7e", "\x6e", - "\x6f", "\x7c", "\xc1", "\xc2", "\xc3", "\xc4", "\xc5", "\xc6", "\xc7", - "\xc8", "\xc9", "\xd1", "\xd2", "\xd3", "\xd4", "\xd5", "\xd6", "\xd7", - "\xd8", "\xd9", "\xe2", "\xe3", "\xe4", "\xe5", "\xe6", "\xe7", "\xe8", - "\xe9", "\x70", "\xb2", "\x80", "\xb0", "\x6d", "\x79", "\x81", "\x82", - "\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x91", "\x92", - "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\xa2", "\xa3", - "\xa4", "\xa5", "\xa6", "\xa7", "\xa8", "\xa9", "\xc0", "\x4f", "\xd0", - "\xa1", "\x07", "\x20", "\x21", "\x22", "\x23", "\x24", "\x15", "\x06", - "\x17", "\x28", "\x29", "\x2a", "\x2b", "\x2c", "\x09", "\x0a", "\x1b", - "\x30", "\x31", "\x1a", "\x33", "\x34", "\x35", "\x36", "\x08", "\x38", - "\x39", "\x3a", "\x3b", "\x04", "\x14", "\x3e", "\xff", "\x3f", "\x4a", - "\x3f", "\x3f", "\x6a", "\x3f", "\x3f", "\x5f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\xa0", "\xe0", "\x42", "\x43", "\x44", "\x45", "\x46", "\x47", "\x48", - "\x49", "\x52", "\x53", "\x54", "\x55", "\x56", "\x57", "\x58", "\x59", - "\x62", "\x63", "\x64", "\x65", "\x66", "\x67", "\x68", "\x69", "\x72", - "\x73", "\x74", "\x75", "\x76", "\x77", "\x78", "\x8a", "\x8b", "\x8c", - "\x8d", "\x8e", "\x8f", "\x9a", "\x9b", "\x9c", "\x9d", "\x9e", "\x9f", - "\xaa", "\xab", "\xac", "\xad", "\xae", "\xaf", "\xba", "\xbb", "\xbc" + '\x00', '\x01', '\x02', '\x03', '\x37', '\x2d', '\x2e', '\x2f', '\x16', + '\x05', '\x25', '\x0b', '\x0c', '\x0d', '\x3f', '\x3f', '\x10', '\x11', + '\x12', '\x13', '\x3c', '\x3d', '\x32', '\x26', '\x18', '\x19', '\x3f', + '\x27', '\x1c', '\x1d', '\x1e', '\x1f', '\x40', '\x5a', '\x7f', '\x7b', + '\x5b', '\x6c', '\x50', '\x7d', '\x4d', '\x5d', '\x5c', '\x4e', '\x6b', + '\x60', '\x4b', '\x61', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', + '\xf6', '\xf7', '\xf8', '\xf9', '\x7a', '\x5e', '\x4c', '\x7e', '\x6e', + '\x6f', '\x7c', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', + '\xc8', '\xc9', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', + '\xd8', '\xd9', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', + '\xe9', '\x70', '\xb2', '\x80', '\xb0', '\x6d', '\x79', '\x81', '\x82', + '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x91', '\x92', + '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\xa2', '\xa3', + '\xa4', '\xa5', '\xa6', '\xa7', '\xa8', '\xa9', '\xc0', '\x4f', '\xd0', + '\xa1', '\x07', '\x20', '\x21', '\x22', '\x23', '\x24', '\x15', '\x06', + '\x17', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x09', '\x0a', '\x1b', + '\x30', '\x31', '\x1a', '\x33', '\x34', '\x35', '\x36', '\x08', '\x38', + '\x39', '\x3a', '\x3b', '\x04', '\x14', '\x3e', '\xff', '\x3f', '\x4a', + '\x3f', '\x3f', '\x6a', '\x3f', '\x3f', '\x5f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\xa0', '\xe0', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', '\x48', + '\x49', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', '\x58', '\x59', + '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x72', + '\x73', '\x74', '\x75', '\x76', '\x77', '\x78', '\x8a', '\x8b', '\x8c', + '\x8d', '\x8e', '\x8f', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f', + '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf', '\xba', '\xbb', '\xbc' }; static const struct gap __ucs4_to_ibm933db_idx[] = diff --git a/iconvdata/ibm935.c b/iconvdata/ibm935.c index 2d3065e..d6574e8 100644 --- a/iconvdata/ibm935.c +++ b/iconvdata/ibm935.c @@ -190,7 +190,6 @@ enum uint32_t ch = get32 (inptr); \ const struct gap *rp1 = __ucs4_to_ibm935sb_idx; \ const struct gap *rp2 = __ucs4_to_ibm935db_idx; \ - const char *cp; \ \ if (__glibc_unlikely (ch >= 0xffff)) \ { \ @@ -203,14 +202,16 @@ enum ++rp1; \ \ /* Use the UCS4 table for single byte. */ \ + unsigned char sbconv; \ if (__builtin_expect (ch < rp1->start, 0) \ - || (cp = __ucs4_to_ibm935sb[ch + rp1->idx], \ - __builtin_expect (cp[0], L'\1') == L'\0' && ch != '\0')) \ + || (sbconv = __ucs4_to_ibm935sb[ch + rp1->idx], \ + __builtin_expect (sbconv, L'\1') == L'\0' && ch != '\0')) \ { \ /* Use the UCS4 table for double byte. */ \ while (ch > rp2->end) \ ++rp2; \ \ + const char *cp; \ if (__builtin_expect (ch < rp2->start, 0) \ || (cp = __ucs4_to_ibm935db[ch + rp2->idx], \ __builtin_expect (cp[0], L'\1')==L'\0' && ch != '\0')) \ @@ -258,7 +259,7 @@ enum result = __GCONV_FULL_OUTPUT; \ break; \ } \ - *outptr++ = cp[0]; \ + *outptr++ = sbconv; \ } \ \ /* Now that we wrote the output increment the input pointer. */ \ diff --git a/iconvdata/ibm935.h b/iconvdata/ibm935.h index f7a96e9..30b44ab 100644 --- a/iconvdata/ibm935.h +++ b/iconvdata/ibm935.h @@ -1282,35 +1282,35 @@ static const struct gap __ucs4_to_ibm935sb_idx[] = { .start = 0xffff, .end = 0xffff, .idx = 0 } }; -static const char *__ucs4_to_ibm935sb[] = +static const unsigned char __ucs4_to_ibm935sb[] = { - "\x00", "\x01", "\x02", "\x03", "\x37", "\x2d", "\x2e", "\x2f", "\x16", - "\x05", "\x25", "\x0b", "\x0c", "\x0d", "\x3f", "\x3f", "\x10", "\x11", - "\x12", "\x13", "\x3c", "\x3d", "\x32", "\x26", "\x18", "\x19", "\x3f", - "\x27", "\x1c", "\x1d", "\x1e", "\x1f", "\x40", "\x5a", "\x7f", "\x7b", - "\xe0", "\x6c", "\x50", "\x7d", "\x4d", "\x5d", "\x5c", "\x4e", "\x6b", - "\x60", "\x4b", "\x61", "\xf0", "\xf1", "\xf2", "\xf3", "\xf4", "\xf5", - "\xf6", "\xf7", "\xf8", "\xf9", "\x7a", "\x5e", "\x4c", "\x7e", "\x6e", - "\x6f", "\x7c", "\xc1", "\xc2", "\xc3", "\xc4", "\xc5", "\xc6", "\xc7", - "\xc8", "\xc9", "\xd1", "\xd2", "\xd3", "\xd4", "\xd5", "\xd6", "\xd7", - "\xd8", "\xd9", "\xe2", "\xe3", "\xe4", "\xe5", "\xe6", "\xe7", "\xe8", - "\xe9", "\xba", "\xb2", "\xbb", "\xb0", "\x6d", "\x79", "\x81", "\x82", - "\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x91", "\x92", - "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\xa2", "\xa3", - "\xa4", "\xa5", "\xa6", "\xa7", "\xa8", "\xa9", "\xc0", "\x4f", "\xd0", - "\xa0", "\x07", "\x20", "\x21", "\x22", "\x23", "\x24", "\x15", "\x06", - "\x17", "\x28", "\x29", "\x2a", "\x2b", "\x2c", "\x09", "\x0a", "\x1b", - "\x30", "\x31", "\x1a", "\x33", "\x34", "\x35", "\x36", "\x08", "\x38", - "\x39", "\x3a", "\x3b", "\x04", "\x14", "\x3e", "\xff", "\x3f", "\x3f", - "\x3f", "\x4a", "\x5b", "\x6a", "\x3f", "\x3f", "\x3f", "\x5f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\xa1" + '\x00', '\x01', '\x02', '\x03', '\x37', '\x2d', '\x2e', '\x2f', '\x16', + '\x05', '\x25', '\x0b', '\x0c', '\x0d', '\x3f', '\x3f', '\x10', '\x11', + '\x12', '\x13', '\x3c', '\x3d', '\x32', '\x26', '\x18', '\x19', '\x3f', + '\x27', '\x1c', '\x1d', '\x1e', '\x1f', '\x40', '\x5a', '\x7f', '\x7b', + '\xe0', '\x6c', '\x50', '\x7d', '\x4d', '\x5d', '\x5c', '\x4e', '\x6b', + '\x60', '\x4b', '\x61', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', + '\xf6', '\xf7', '\xf8', '\xf9', '\x7a', '\x5e', '\x4c', '\x7e', '\x6e', + '\x6f', '\x7c', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', + '\xc8', '\xc9', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', + '\xd8', '\xd9', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', + '\xe9', '\xba', '\xb2', '\xbb', '\xb0', '\x6d', '\x79', '\x81', '\x82', + '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x91', '\x92', + '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\xa2', '\xa3', + '\xa4', '\xa5', '\xa6', '\xa7', '\xa8', '\xa9', '\xc0', '\x4f', '\xd0', + '\xa0', '\x07', '\x20', '\x21', '\x22', '\x23', '\x24', '\x15', '\x06', + '\x17', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x09', '\x0a', '\x1b', + '\x30', '\x31', '\x1a', '\x33', '\x34', '\x35', '\x36', '\x08', '\x38', + '\x39', '\x3a', '\x3b', '\x04', '\x14', '\x3e', '\xff', '\x3f', '\x3f', + '\x3f', '\x4a', '\x5b', '\x6a', '\x3f', '\x3f', '\x3f', '\x5f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\xa1' }; static const struct gap __ucs4_to_ibm935db_idx[] = diff --git a/iconvdata/ibm939.c b/iconvdata/ibm939.c index c0a75f7..5122975 100644 --- a/iconvdata/ibm939.c +++ b/iconvdata/ibm939.c @@ -190,7 +190,6 @@ enum uint32_t ch = get32 (inptr); \ const struct gap *rp1 = __ucs4_to_ibm939sb_idx; \ const struct gap *rp2 = __ucs4_to_ibm939db_idx; \ - const char *cp; \ \ if (__glibc_unlikely (ch >= 0xffff)) \ { \ @@ -202,14 +201,16 @@ enum ++rp1; \ \ /* Use the UCS4 table for single byte. */ \ + unsigned char sbconv; \ if (__builtin_expect (ch < rp1->start, 0) \ - || (cp = __ucs4_to_ibm939sb[ch + rp1->idx], \ - __builtin_expect (cp[0], L'\1') == L'\0' && ch != '\0')) \ + || (sbconv = __ucs4_to_ibm939sb[ch + rp1->idx], \ + __builtin_expect (sbconv, L'\1') == L'\0' && ch != '\0')) \ { \ /* Use the UCS4 table for double byte. */ \ while (ch > rp2->end) \ ++rp2; \ \ + const char *cp; \ if (__builtin_expect (ch < rp2->start, 0) \ || (cp = __ucs4_to_ibm939db[ch + rp2->idx], \ __builtin_expect (cp[0], L'\1')==L'\0' && ch != '\0')) \ @@ -263,7 +264,7 @@ enum else if (ch == 0x5c) \ *outptr++ = 0xb2; \ else \ - *outptr++ = cp[0]; \ + *outptr++ = sbconv; \ } \ \ /* Now that we wrote the output increment the input pointer. */ \ diff --git a/iconvdata/ibm939.h b/iconvdata/ibm939.h index bb8a8de..9c0a657 100644 --- a/iconvdata/ibm939.h +++ b/iconvdata/ibm939.h @@ -1499,46 +1499,46 @@ static const struct gap __ucs4_to_ibm939sb_idx[] = { .start = 0xffff, .end = 0xffff, .idx = 0 } }; -static const char * __ucs4_to_ibm939sb[] = +static const unsigned char __ucs4_to_ibm939sb[] = { - "\x00", "\x01", "\x02", "\x03", "\x37", "\x2d", "\x2e", "\x2f", "\x16", - "\x05", "\x25", "\x0b", "\x0c", "\x0d", "\x3f", "\x3f", "\x10", "\x11", - "\x12", "\x13", "\x3c", "\x3d", "\x32", "\x26", "\x18", "\x19", "\x3f", - "\x27", "\x1c", "\x1d", "\x1e", "\x1f", "\x40", "\x5a", "\x7f", "\x7b", - "\x5b", "\x6c", "\x50", "\x7d", "\x4d", "\x5d", "\x5c", "\x4e", "\x6b", - "\x60", "\x4b", "\x61", "\xf0", "\xf1", "\xf2", "\xf3", "\xf4", "\xf5", - "\xf6", "\xf7", "\xf8", "\xf9", "\x7a", "\x5e", "\x4c", "\x7e", "\x6e", - "\x6f", "\x7c", "\xc1", "\xc2", "\xc3", "\xc4", "\xc5", "\xc6", "\xc7", - "\xc8", "\xc9", "\xd1", "\xd2", "\xd3", "\xd4", "\xd5", "\xd6", "\xd7", - "\xd8", "\xd9", "\xe2", "\xe3", "\xe4", "\xe5", "\xe6", "\xe7", "\xe8", - "\xe9", "\xad", "\xe0", "\xbd", "\xb0", "\x6d", "\x79", "\x81", "\x82", - "\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x91", "\x92", - "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\xa2", "\xa3", - "\xa4", "\xa5", "\xa6", "\xa7", "\xa8", "\xa9", "\xc0", "\x4f", "\xd0", - "\xa1", "\x07", "\x20", "\x21", "\x22", "\x23", "\x24", "\x15", "\x06", - "\x17", "\x28", "\x29", "\x2a", "\x2b", "\x2c", "\x09", "\x0a", "\x1b", - "\x30", "\x31", "\x1a", "\x33", "\x34", "\x35", "\x36", "\x08", "\x38", - "\x39", "\x3a", "\x3b", "\x04", "\x14", "\x3e", "\xff", "\x3f", "\x3f", - "\x4a", "\xb1", "\x3f", "\xb2", "\x3f", "\x3f", "\x3f", "\x5f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\xa0", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f", "\x3f", "\x3f", "\x42", "\x43", "\x44", "\x45", "\x46", - "\x47", "\x48", "\x49", "\x51", "\x52", "\x53", "\x54", "\x55", "\x56", - "\x57", "\x58", "\x59", "\x62", "\x63", "\x64", "\x65", "\x66", "\x67", - "\x68", "\x69", "\x70", "\x71", "\x72", "\x73", "\x74", "\x75", "\x76", - "\x77", "\x78", "\x8a", "\x8b", "\x8c", "\x8d", "\x8e", "\x8f", "\x9a", - "\x9b", "\x9c", "\x9d", "\x9e", "\x9f", "\xaa", "\xab", "\xac", "\xae", - "\xaf", "\xb3", "\xb4", "\xb5", "\xb6", "\xb7", "\xb8", "\xb9", "\xba", - "\xbb", "\xbc", "\xbe", "\xbf", "\x3f", "\x3f", "\x3f", "\x3f", "\x3f", - "\x3f", "\x3f" + '\x00', '\x01', '\x02', '\x03', '\x37', '\x2d', '\x2e', '\x2f', '\x16', + '\x05', '\x25', '\x0b', '\x0c', '\x0d', '\x3f', '\x3f', '\x10', '\x11', + '\x12', '\x13', '\x3c', '\x3d', '\x32', '\x26', '\x18', '\x19', '\x3f', + '\x27', '\x1c', '\x1d', '\x1e', '\x1f', '\x40', '\x5a', '\x7f', '\x7b', + '\x5b', '\x6c', '\x50', '\x7d', '\x4d', '\x5d', '\x5c', '\x4e', '\x6b', + '\x60', '\x4b', '\x61', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', + '\xf6', '\xf7', '\xf8', '\xf9', '\x7a', '\x5e', '\x4c', '\x7e', '\x6e', + '\x6f', '\x7c', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', + '\xc8', '\xc9', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', + '\xd8', '\xd9', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', + '\xe9', '\xad', '\xe0', '\xbd', '\xb0', '\x6d', '\x79', '\x81', '\x82', + '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x91', '\x92', + '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\xa2', '\xa3', + '\xa4', '\xa5', '\xa6', '\xa7', '\xa8', '\xa9', '\xc0', '\x4f', '\xd0', + '\xa1', '\x07', '\x20', '\x21', '\x22', '\x23', '\x24', '\x15', '\x06', + '\x17', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x09', '\x0a', '\x1b', + '\x30', '\x31', '\x1a', '\x33', '\x34', '\x35', '\x36', '\x08', '\x38', + '\x39', '\x3a', '\x3b', '\x04', '\x14', '\x3e', '\xff', '\x3f', '\x3f', + '\x4a', '\xb1', '\x3f', '\xb2', '\x3f', '\x3f', '\x3f', '\x5f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\xa0', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f', '\x3f', '\x3f', '\x42', '\x43', '\x44', '\x45', '\x46', + '\x47', '\x48', '\x49', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', + '\x57', '\x58', '\x59', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', + '\x68', '\x69', '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', + '\x77', '\x78', '\x8a', '\x8b', '\x8c', '\x8d', '\x8e', '\x8f', '\x9a', + '\x9b', '\x9c', '\x9d', '\x9e', '\x9f', '\xaa', '\xab', '\xac', '\xae', + '\xaf', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7', '\xb8', '\xb9', '\xba', + '\xbb', '\xbc', '\xbe', '\xbf', '\x3f', '\x3f', '\x3f', '\x3f', '\x3f', + '\x3f', '\x3f' }; static const struct gap __ucs4_to_ibm939db_idx[] =