diff options
author | Karl Williamson <khw@cpan.org> | 2021-06-28 12:53:13 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-08-07 05:14:44 -0600 |
commit | bc658500639af2d2587b6616c7a854049ea21972 (patch) | |
tree | d0a58c6a43e06f8c6169ac3efc3c2b18317db399 /utf8.c | |
parent | e932a5edb50acc7eadabb8b398bd071556b21ded (diff) | |
download | perl-bc658500639af2d2587b6616c7a854049ea21972.tar.gz |
Fix EBCDIC deficiency in uvoffuni_to_utf8_flags_msgs()
Simply by adjusting the case statement labels, and adding an extra case,
the code can avoid checking for a problem on EBCDIC boxes when it would
be impossible for the problem to exist.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -285,14 +285,14 @@ Perl_uvoffuni_to_utf8_flags_msgs(pTHX_ U8 *d, UV input_uv, const UV flags, HV** } p = d + utf8_skip - 1; - while (p >= d + 4) { + while (p >= d + 4 + ONE_IF_EBCDIC_ZERO_IF_NOT) { *p-- = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); shifted_uv >>= SHIFT; } /* FALLTHROUGH */ - case 4: + case 4 + ONE_IF_EBCDIC_ZERO_IF_NOT: if (UNLIKELY(UNICODE_IS_SUPER(input_uv))) { if ( (flags & UNICODE_WARN_SUPER) || ( (flags & UNICODE_WARN_PERL_EXTENDED) @@ -332,11 +332,12 @@ Perl_uvoffuni_to_utf8_flags_msgs(pTHX_ U8 *d, UV input_uv, const UV flags, HV** } } - d[3] = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); + d[3 + ONE_IF_EBCDIC_ZERO_IF_NOT] + = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); shifted_uv >>= SHIFT; /* FALLTHROUGH */ - case 3: + case 3 + ONE_IF_EBCDIC_ZERO_IF_NOT: if (input_uv >= UNICODE_SURROGATE_FIRST) { if (UNLIKELY(UNICODE_IS_NONCHAR(input_uv))) { HANDLE_UNICODE_NONCHAR(input_uv, flags, msgs); @@ -346,10 +347,21 @@ Perl_uvoffuni_to_utf8_flags_msgs(pTHX_ U8 *d, UV input_uv, const UV flags, HV** } } + d[2 + ONE_IF_EBCDIC_ZERO_IF_NOT] + = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); + shifted_uv >>= SHIFT; + /* FALLTHROUGH */ + +#ifdef EBCDIC + + case 3: d[2] = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); shifted_uv >>= SHIFT; /* FALLTHROUGH */ +#endif + + /* FALLTHROUGH */ case 2: d[1] = I8_TO_NATIVE_UTF8((shifted_uv & MASK) | MARK); shifted_uv >>= SHIFT; |