Skip to content

Commit 9efd3ac

Browse files
committed
utf8.c: Swap order of blocks
This makes things a bit simpler, but mainly leads to further simplifications in the next commits.
1 parent bff7ff5 commit 9efd3ac

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

utf8.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,27 +1601,13 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16011601
* the overflow handling code */
16021602
&& LIKELY(! (possible_problems & UTF8_GOT_OVERFLOW)))
16031603
{
1604-
/* If there were no malformations, or the only malformation is an
1605-
* overlong, 'uv' is valid */
1606-
if ( LIKELY(! (possible_problems & ~UTF8_GOT_LONG))
1607-
&& isUNICODE_POSSIBLY_PROBLEMATIC(uv))
1608-
{
1609-
if (UNLIKELY(UNICODE_IS_SURROGATE(uv))) {
1610-
possible_problems |= UTF8_GOT_SURROGATE;
1611-
}
1612-
else if (UNLIKELY(UNICODE_IS_SUPER(uv))) {
1613-
possible_problems |= UTF8_GOT_SUPER;
1614-
}
1615-
else if (UNLIKELY(UNICODE_IS_NONCHAR(uv))) {
1616-
possible_problems |= UTF8_GOT_NONCHAR;
1617-
}
1618-
}
1619-
else if ( UNLIKELY(possible_problems)
1620-
/* Otherwise, need to look at the source UTF-8,
1621-
* possibly adjusted to be non-overlong */
1622-
&& ( isUTF8_POSSIBLY_PROBLEMATIC(*adjusted_s0)
1623-
|| UNLIKELY(UTF8_IS_PERL_EXTENDED(s0))))
1624-
{
1604+
if (UNLIKELY(possible_problems & ~UTF8_GOT_LONG)) {
1605+
1606+
/* Here, there is a malformation other than overlong, we need to
1607+
look at the source UTF-8, possibly adjusted to be non-overlong */
1608+
if ( isUTF8_POSSIBLY_PROBLEMATIC(*adjusted_s0)
1609+
|| UNLIKELY(UTF8_IS_PERL_EXTENDED(s0)))
1610+
{
16251611
if (UNLIKELY(NATIVE_UTF8_TO_I8(*adjusted_s0)
16261612
> UTF_START_BYTE_110000_))
16271613
{
@@ -1642,7 +1628,24 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16421628

16431629
/* We need a complete well-formed UTF-8 character to discern
16441630
* non-characters, so can't look for them here */
1631+
}
16451632
}
1633+
else
1634+
1635+
/* Here there were no malformations, or the only malformation is an
1636+
* overlong, 'uv' is valid, and the 'if' above made sure that it
1637+
* could be problematic */
1638+
if (isUNICODE_POSSIBLY_PROBLEMATIC(uv)) {
1639+
if (UNLIKELY(UNICODE_IS_SURROGATE(uv))) {
1640+
possible_problems |= UTF8_GOT_SURROGATE;
1641+
}
1642+
else if (UNLIKELY(UNICODE_IS_SUPER(uv))) {
1643+
possible_problems |= UTF8_GOT_SUPER;
1644+
}
1645+
else if (UNLIKELY(UNICODE_IS_NONCHAR(uv))) {
1646+
possible_problems |= UTF8_GOT_NONCHAR;
1647+
}
1648+
}
16461649
}
16471650

16481651
ready_to_handle_errors:

0 commit comments

Comments
 (0)