@@ -2592,71 +2592,15 @@ after-call value of C<*lenp> from it.
2592
2592
2593
2593
=cut
2594
2594
2595
- There is a macro that avoids this function call, but this is retained for
2596
- anyone who calls it with the Perl_ prefix */
2595
+ */
2597
2596
2598
2597
U8 *
2599
2598
Perl_bytes_from_utf8 (pTHX_ const U8 * s , STRLEN * lenp , bool * is_utf8p )
2600
2599
{
2601
2600
PERL_ARGS_ASSERT_BYTES_FROM_UTF8 ;
2602
2601
PERL_UNUSED_CONTEXT ;
2603
2602
2604
- return bytes_from_utf8_loc (s , lenp , is_utf8p , NULL );
2605
- }
2606
-
2607
- /*
2608
- =for apidoc bytes_from_utf8_loc
2609
-
2610
- Like C<L<perlapi/bytes_from_utf8>()>, but takes an extra parameter, a pointer
2611
- to where to store the location of the first character in C<"s"> that cannot be
2612
- converted to non-UTF8.
2613
-
2614
- If that parameter is C<NULL>, this function behaves identically to
2615
- C<bytes_from_utf8>.
2616
-
2617
- Otherwise if C<*is_utf8p> is 0 on input, the function behaves identically to
2618
- C<bytes_from_utf8>, except it also sets C<*first_non_downgradable> to C<NULL>.
2619
-
2620
- Otherwise, the function returns a newly created C<NUL>-terminated string
2621
- containing the non-UTF8 equivalent of the convertible first portion of
2622
- C<"s">. C<*lenp> is set to its length, not including the terminating C<NUL>.
2623
- If the entire input string was converted, C<*is_utf8p> is set to a FALSE value,
2624
- and C<*first_non_downgradable> is set to C<NULL>.
2625
-
2626
- Otherwise, C<*first_non_downgradable> is set to point to the first byte of the
2627
- first character in the original string that wasn't converted. C<*is_utf8p> is
2628
- unchanged. Note that the new string may have length 0.
2629
-
2630
- Another way to look at it is, if C<*first_non_downgradable> is non-C<NULL> and
2631
- C<*is_utf8p> is TRUE, this function starts at the beginning of C<"s"> and
2632
- converts as many characters in it as possible stopping at the first one it
2633
- finds that can't be converted to non-UTF-8. C<*first_non_downgradable> is
2634
- set to point to that. The function returns the portion that could be converted
2635
- in a newly created C<NUL>-terminated string, and C<*lenp> is set to its length,
2636
- not including the terminating C<NUL>. If the very first character in the
2637
- original could not be converted, C<*lenp> will be 0, and the new string will
2638
- contain just a single C<NUL>. If the entire input string was converted,
2639
- C<*is_utf8p> is set to FALSE and C<*first_non_downgradable> is set to C<NULL>.
2640
-
2641
- Upon successful return, the number of variants in the converted portion of the
2642
- string can be computed by having saved the value of C<*lenp> before the call,
2643
- and subtracting the after-call value of C<*lenp> from it.
2644
-
2645
- =cut
2646
-
2647
-
2648
- */
2649
-
2650
- U8 *
2651
- Perl_bytes_from_utf8_loc (const U8 * s , STRLEN * lenp , bool * is_utf8p , const U8 * * first_unconverted )
2652
- {
2653
- PERL_ARGS_ASSERT_BYTES_FROM_UTF8_LOC ;
2654
-
2655
2603
if (! * is_utf8p ) {
2656
- if (first_unconverted ) {
2657
- * first_unconverted = NULL ;
2658
- }
2659
-
2660
2604
return (U8 * ) s ;
2661
2605
}
2662
2606
@@ -2685,14 +2629,8 @@ Perl_bytes_from_utf8_loc(const U8 *s, STRLEN *lenp, bool *is_utf8p, const U8** f
2685
2629
/* Then it is multi-byte encoded. If the code point is above 0xFF,
2686
2630
* have to stop now */
2687
2631
if (UNLIKELY (! UTF8_IS_NEXT_CHAR_DOWNGRADEABLE (s - 1 , send ))) {
2688
- if (first_unconverted ) {
2689
- * first_unconverted = s - 1 ;
2690
- goto finish_and_return ;
2691
- }
2692
- else {
2693
2632
Safefree (converted_start );
2694
2633
return (U8 * ) s0 ;
2695
- }
2696
2634
}
2697
2635
2698
2636
c = EIGHT_BIT_UTF8_TO_NATIVE (c , * s );
@@ -2703,11 +2641,7 @@ Perl_bytes_from_utf8_loc(const U8 *s, STRLEN *lenp, bool *is_utf8p, const U8** f
2703
2641
2704
2642
/* Here, converted the whole of the input */
2705
2643
* is_utf8p = FALSE;
2706
- if (first_unconverted ) {
2707
- * first_unconverted = NULL ;
2708
- }
2709
2644
2710
- finish_and_return :
2711
2645
* d = '\0' ;
2712
2646
* lenp = d - converted_start ;
2713
2647
0 commit comments