@@ -2592,71 +2592,15 @@ after-call value of C<*lenp> from it.
25922592
25932593=cut
25942594
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+ */
25972596
25982597U8 *
25992598Perl_bytes_from_utf8 (pTHX_ const U8 * s , STRLEN * lenp , bool * is_utf8p )
26002599{
26012600 PERL_ARGS_ASSERT_BYTES_FROM_UTF8 ;
26022601 PERL_UNUSED_CONTEXT ;
26032602
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-
26552603 if (! * is_utf8p ) {
2656- if (first_unconverted ) {
2657- * first_unconverted = NULL ;
2658- }
2659-
26602604 return (U8 * ) s ;
26612605 }
26622606
@@ -2685,14 +2629,8 @@ Perl_bytes_from_utf8_loc(const U8 *s, STRLEN *lenp, bool *is_utf8p, const U8** f
26852629 /* Then it is multi-byte encoded. If the code point is above 0xFF,
26862630 * have to stop now */
26872631 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 {
26932632 Safefree (converted_start );
26942633 return (U8 * ) s0 ;
2695- }
26962634 }
26972635
26982636 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
27032641
27042642 /* Here, converted the whole of the input */
27052643 * is_utf8p = FALSE;
2706- if (first_unconverted ) {
2707- * first_unconverted = NULL ;
2708- }
27092644
2710- finish_and_return :
27112645 * d = '\0' ;
27122646 * lenp = d - converted_start ;
27132647
0 commit comments