From 3708669706516490ba9699d9d57d92d59fda1006 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 24 Nov 2016 10:54:23 -0700 Subject: utf8.c: Fix EBCDIC detection of above-31 bit code points This was failing on EBCDIC machines, and I couldn't figure out why. I didn't see any flaws in the logic. It required special debugging code to answer. It turns out it was a bad declaration, and not logic at all. The declaration should have been const U8 prefix[] = ... instead it was const U8 * const prefix = ... sizeof() the latter is 4, as it is looking at pointer size. What was intended was the size of the array this was initialized to, which was longer. What this led to was later in the routine, a comparison was stopping too early. --- utf8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utf8.c b/utf8.c index da575a9e4d..074f738806 100644 --- a/utf8.c +++ b/utf8.c @@ -383,8 +383,8 @@ S_is_utf8_cp_above_31_bits(const U8 * const s, const U8 * const e) #ifdef EBCDIC - /* [0] is start byte [1] [2] [3] [4] [5] [6] [7] */ - const U8 * const prefix = (U8 *) "\x41\x41\x41\x41\x41\x41\x42"; + /* [0] is start byte [1] [2] [3] [4] [5] [6] [7] */ + const U8 prefix[] = "\x41\x41\x41\x41\x41\x41\x42"; const STRLEN prefix_len = sizeof(prefix) - 1; const STRLEN len = e - s; const STRLEN cmp_len = MIN(prefix_len, len - 1); -- cgit v1.2.1