Skip to content

Commit

Permalink
utf8_to_uv_msgs: Use a single bit flag
Browse files Browse the repository at this point in the history
This condition used a combination of two bits, which makes things a
little awkward, and isn't really needed
  • Loading branch information
khwilliamson committed Dec 4, 2024
1 parent f174f6e commit e6954d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,17 +2092,13 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
case UTF8_GOT_LONG:
*errors |= UTF8_GOT_LONG;

if (flags & UTF8_ALLOW_LONG) {

/* We don't allow the actual overlong value, unless the
* special extra bit is also set */
if (! (flags & ( UTF8_ALLOW_LONG_AND_ITS_VALUE
& ~UTF8_ALLOW_LONG)))
{
uv = UNICODE_REPLACEMENT;
}
if (! (flags & UTF8_ALLOW_LONG_AND_ITS_VALUE)) {
uv = UNICODE_REPLACEMENT;
}
else {

if (! (flags & ( UTF8_ALLOW_LONG
|UTF8_ALLOW_LONG_AND_ITS_VALUE)))
{
disallowed = TRUE;

if (NEED_MESSAGE(WARN_UTF8,,)) {
Expand Down
2 changes: 1 addition & 1 deletion utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ point's representation.
* First one will convert the overlong to the REPLACEMENT CHARACTER; second
* will return what the overlong evaluates to */
#define UTF8_ALLOW_LONG 0x2000
#define UTF8_ALLOW_LONG_AND_ITS_VALUE (UTF8_ALLOW_LONG|0x4000)
#define UTF8_ALLOW_LONG_AND_ITS_VALUE 0x4000
#define UTF8_GOT_LONG UTF8_ALLOW_LONG

/* For back compat, these old names are misleading for overlongs and
Expand Down

0 comments on commit e6954d8

Please sign in to comment.