Skip to content

Commit 41e43bc

Browse files
committed
utf8.c: Extract out common statement
Each case: in the switch has this statement which can be handled outside it, once.
1 parent a9374ce commit 41e43bc

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

utf8.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,13 +1700,14 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
17001700
* it changes 'uv' looked at by the others */
17011701

17021702
U32 this_problem = 1U << lsbit_pos32(possible_problems);
1703+
possible_problems &= ~this_problem;
1704+
17031705
switch (this_problem) {
17041706
case UTF8_GOT_OVERFLOW:
17051707

17061708
/* Overflow means also got a super and are using Perl's
17071709
* extended UTF-8, but we handle all three cases here */
1708-
possible_problems
1709-
&= ~(UTF8_GOT_OVERFLOW|UTF8_GOT_SUPER|UTF8_GOT_PERL_EXTENDED);
1710+
possible_problems &= ~(UTF8_GOT_SUPER|UTF8_GOT_PERL_EXTENDED);
17101711
*errors |= UTF8_GOT_OVERFLOW;
17111712

17121713
/* But the API says we flag all errors found */
@@ -1757,7 +1758,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
17571758
break;
17581759

17591760
case UTF8_GOT_EMPTY:
1760-
possible_problems &= ~UTF8_GOT_EMPTY;
17611761
*errors |= UTF8_GOT_EMPTY;
17621762

17631763
if (! (flags & UTF8_ALLOW_EMPTY)) {
@@ -1781,7 +1781,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
17811781
break;
17821782

17831783
case UTF8_GOT_CONTINUATION:
1784-
possible_problems &= ~UTF8_GOT_CONTINUATION;
17851784
*errors |= UTF8_GOT_CONTINUATION;
17861785

17871786
if (! (flags & UTF8_ALLOW_CONTINUATION)) {
@@ -1802,7 +1801,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
18021801
break;
18031802

18041803
case UTF8_GOT_SHORT:
1805-
possible_problems &= ~UTF8_GOT_SHORT;
18061804
*errors |= UTF8_GOT_SHORT;
18071805

18081806
if (! (flags & UTF8_ALLOW_SHORT)) {
@@ -1825,7 +1823,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
18251823
break;
18261824

18271825
case UTF8_GOT_NON_CONTINUATION:
1828-
possible_problems &= ~UTF8_GOT_NON_CONTINUATION;
18291826
*errors |= UTF8_GOT_NON_CONTINUATION;
18301827

18311828
if (! (flags & UTF8_ALLOW_NON_CONTINUATION)) {
@@ -1853,7 +1850,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
18531850
break;
18541851

18551852
case UTF8_GOT_SURROGATE:
1856-
possible_problems &= ~UTF8_GOT_SURROGATE;
18571853

18581854
if (flags & UTF8_WARN_SURROGATE) {
18591855
*errors |= UTF8_GOT_SURROGATE;
@@ -1886,7 +1882,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
18861882
break;
18871883

18881884
case UTF8_GOT_SUPER:
1889-
possible_problems &= ~UTF8_GOT_SUPER;
18901885

18911886
if (flags & UTF8_WARN_SUPER) {
18921887
*errors |= UTF8_GOT_SUPER;
@@ -1963,7 +1958,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
19631958
break;
19641959

19651960
case UTF8_GOT_NONCHAR:
1966-
possible_problems &= ~UTF8_GOT_NONCHAR;
19671961

19681962
if (flags & UTF8_WARN_NONCHAR) {
19691963
*errors |= UTF8_GOT_NONCHAR;
@@ -1990,7 +1984,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
19901984
break;
19911985

19921986
case UTF8_GOT_LONG:
1993-
possible_problems &= ~UTF8_GOT_LONG;
19941987
*errors |= UTF8_GOT_LONG;
19951988

19961989
if (flags & UTF8_ALLOW_LONG) {

0 commit comments

Comments
 (0)