@@ -1603,8 +1603,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
1603
1603
UV uv ;
1604
1604
SSize_t expectlen ; /* How long should this sequence be? */
1605
1605
SSize_t avail_len ; /* When input is too short, gives what that is */
1606
- U32 discard_errors ; /* Used to save branches when 'errors' is NULL; this
1607
- gets set and discarded */
1608
1606
1609
1607
dTHX ;
1610
1608
@@ -1650,14 +1648,10 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
1650
1648
possible_problems = 0 ;
1651
1649
expectlen = 0 ;
1652
1650
avail_len = 0 ;
1653
- discard_errors = 0 ;
1654
1651
1655
1652
if (errors ) {
1656
1653
* errors = 0 ;
1657
1654
}
1658
- else {
1659
- errors = & discard_errors ;
1660
- }
1661
1655
1662
1656
/* Accumulate the code point translation of the input byte sequence
1663
1657
* s0 .. e-1, looking for malformations.
@@ -1986,6 +1980,7 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
1986
1980
1987
1981
bool disallowed = FALSE;
1988
1982
const U32 orig_problems = possible_problems ;
1983
+ U32 error_flags_return = 0 ;
1989
1984
1990
1985
/* The following macro returns 0 if no message needs to be generated
1991
1986
* for this problem even if everything else says to. Otherwise returns
@@ -2034,6 +2029,11 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2034
2029
2035
2030
U32 this_flag_bit = this_problem ;
2036
2031
2032
+ /* All cases but these two set this; it makes the cases simpler
2033
+ * to do it here */
2034
+ error_flags_return |= this_problem & ~( UTF8_GOT_PERL_EXTENDED
2035
+ |UTF8_GOT_SUPER );
2036
+
2037
2037
/* Turn off so next iteration doesn't retry this */
2038
2038
possible_problems &= ~this_problem ;
2039
2039
@@ -2056,8 +2056,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2056
2056
break ;
2057
2057
2058
2058
case UTF8_GOT_EMPTY :
2059
- * errors |= UTF8_GOT_EMPTY ;
2060
-
2061
2059
if (! (flags & UTF8_ALLOW_EMPTY )) {
2062
2060
2063
2061
/* This so-called malformation is now treated as a bug in
@@ -2075,8 +2073,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2075
2073
break ;
2076
2074
2077
2075
case UTF8_GOT_CONTINUATION :
2078
- * errors |= UTF8_GOT_CONTINUATION ;
2079
-
2080
2076
if (! (flags & UTF8_ALLOW_CONTINUATION )) {
2081
2077
disallowed = TRUE;
2082
2078
if (NEED_MESSAGE (WARN_UTF8 ,,)) {
@@ -2091,7 +2087,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2091
2087
break ;
2092
2088
2093
2089
case UTF8_GOT_SHORT :
2094
- * errors |= UTF8_GOT_SHORT ;
2095
2090
uv = UNICODE_REPLACEMENT ;
2096
2091
2097
2092
if (! (flags & UTF8_ALLOW_SHORT )) {
@@ -2110,7 +2105,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2110
2105
break ;
2111
2106
2112
2107
case UTF8_GOT_NON_CONTINUATION :
2113
- * errors |= UTF8_GOT_NON_CONTINUATION ;
2114
2108
uv = UNICODE_REPLACEMENT ;
2115
2109
2116
2110
if (! (flags & UTF8_ALLOW_NON_CONTINUATION )) {
@@ -2140,8 +2134,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2140
2134
* this case are true */
2141
2135
2142
2136
if (flags & UTF8_WARN_SURROGATE ) {
2143
- * errors |= UTF8_GOT_SURROGATE ;
2144
-
2145
2137
if (NEED_MESSAGE (WARN_SURROGATE ,,)) {
2146
2138
pack_warn = packWARN (WARN_SURROGATE );
2147
2139
@@ -2161,7 +2153,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2161
2153
2162
2154
if (flags & UTF8_DISALLOW_SURROGATE ) {
2163
2155
disallowed = TRUE;
2164
- * errors |= UTF8_GOT_SURROGATE ;
2165
2156
}
2166
2157
2167
2158
break ;
@@ -2173,8 +2164,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2173
2164
* this case are true */
2174
2165
2175
2166
if (flags & UTF8_WARN_NONCHAR ) {
2176
- * errors |= UTF8_GOT_NONCHAR ;
2177
-
2178
2167
if (NEED_MESSAGE (WARN_NONCHAR ,,)) {
2179
2168
/* The code above should have guaranteed that we don't
2180
2169
* get here with errors other than overlong */
@@ -2188,13 +2177,11 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2188
2177
2189
2178
if (flags & UTF8_DISALLOW_NONCHAR ) {
2190
2179
disallowed = TRUE;
2191
- * errors |= UTF8_GOT_NONCHAR ;
2192
2180
}
2193
2181
2194
2182
break ;
2195
2183
2196
2184
case UTF8_GOT_LONG :
2197
- * errors |= UTF8_GOT_LONG ;
2198
2185
2199
2186
if (! (flags & UTF8_ALLOW_LONG_AND_ITS_VALUE )) {
2200
2187
uv = UNICODE_REPLACEMENT ;
@@ -2256,17 +2243,16 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2256
2243
/* Overflow means also got a super and are using Perl's
2257
2244
* extended UTF-8, but we handle all three cases here */
2258
2245
possible_problems &= ~(UTF8_GOT_SUPER |UTF8_GOT_PERL_EXTENDED );
2259
- * errors |= UTF8_GOT_OVERFLOW ;
2260
2246
uv = UNICODE_REPLACEMENT ;
2261
2247
2262
2248
/* But the API says we flag all errors found */
2263
2249
if (flags & (UTF8_WARN_SUPER |UTF8_DISALLOW_SUPER )) {
2264
- * errors |= UTF8_GOT_SUPER ;
2250
+ error_flags_return |= UTF8_GOT_SUPER ;
2265
2251
}
2266
2252
if (flags
2267
2253
& (UTF8_WARN_PERL_EXTENDED |UTF8_DISALLOW_PERL_EXTENDED ))
2268
2254
{
2269
- * errors |= UTF8_GOT_PERL_EXTENDED ;
2255
+ error_flags_return |= UTF8_GOT_PERL_EXTENDED ;
2270
2256
}
2271
2257
2272
2258
/* Disallow if any of the three categories say to */
@@ -2312,7 +2298,7 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2312
2298
* warned about */
2313
2299
2314
2300
if (flags & UTF8_WARN_SUPER ) {
2315
- * errors |= UTF8_GOT_SUPER ;
2301
+ error_flags_return |= UTF8_GOT_SUPER ;
2316
2302
2317
2303
if (NEED_MESSAGE (WARN_NON_UNICODE ,,)) {
2318
2304
pack_warn = packWARN (WARN_NON_UNICODE );
@@ -2365,7 +2351,7 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2365
2351
if (flags & ( UTF8_WARN_PERL_EXTENDED
2366
2352
|UTF8_DISALLOW_PERL_EXTENDED ))
2367
2353
{
2368
- * errors |= UTF8_GOT_PERL_EXTENDED ;
2354
+ error_flags_return |= UTF8_GOT_PERL_EXTENDED ;
2369
2355
2370
2356
if (flags & UTF8_DISALLOW_PERL_EXTENDED ) {
2371
2357
disallowed = TRUE;
@@ -2374,7 +2360,7 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2374
2360
}
2375
2361
2376
2362
if (flags & UTF8_DISALLOW_SUPER ) {
2377
- * errors |= UTF8_GOT_SUPER ;
2363
+ error_flags_return |= UTF8_GOT_SUPER ;
2378
2364
disallowed = TRUE;
2379
2365
}
2380
2366
@@ -2409,6 +2395,10 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
2409
2395
* advance_p = curlen ;
2410
2396
}
2411
2397
2398
+ if (errors ) {
2399
+ * errors = error_flags_return ;
2400
+ }
2401
+
2412
2402
if (disallowed ) {
2413
2403
success = false;
2414
2404
uv = UNICODE_REPLACEMENT ;
0 commit comments