diff --git a/sv.c b/sv.c index 0b3d142e85e4e..4460d4bf8b270 100644 --- a/sv.c +++ b/sv.c @@ -11185,29 +11185,79 @@ Perl_sv_catpvf_mg_nocontext(SV *const sv, const char *const pat, ...) /* =for apidoc sv_catpvf +=for apidoc_item sv_catpvf_nocontext =for apidoc_item sv_catpvf_mg =for apidoc_item sv_catpvf_mg_nocontext -=for apidoc_item sv_catpvf_nocontext +=for apidoc_item sv_vcatpvf +=for apidoc_item sv_vcatpvf_mg +=for apidoc_item sv_vcatpvfn +=for apidoc_item sv_vcatpvfn_flags + +These each append to C the result of formatting their arguments using +C as the C-like pattern. They assume that C has the same +UTF8ness as C. It's the caller's responsibility to ensure that this is +so. + +If the destination C isn't already in UTF-8, but the appended data contains +"wide" characters, C will be converted to be UTF-8. An example is the +C<%c> format with the code point > 255. (This is an enhancement to what libc +C would do in this situation.) Other examples are given below. + +The forms differ in how their arguments are specified and in the handling of +magic. + +C is the most general, and all the other forms are +implemented by eventually calling it. + +It has two sets of argument lists, only one of which is used in any given call. +The first set, C, is an encapsulated argument list of pointers to C +strings. If it is NULL, the other list is used, C, which is an array +of pointers to SV's. C gives how many there are in the list. + +See L> for details on how the formatting is done. Some +platforms support extensions to the standard C99 definition of this function. +None of those are supported by Perl. For example, neither C<'> (to get digit +grouping), nor C (to get alternate digits) are supported. -These process their arguments like C, and append the formatted -output to an SV. As with C, argument reordering is not supporte -when called with a non-null C-style variable argument list. +Also, argument reordering (using format specifiers like C<%2$d> or C<%*2$d>) is +supported only when using the C array of SVs; an exception is raised if +C is not NULL and C contains the C<$> reordering specifier. -If the appended data contains "wide" characters -(including, but not limited to, SVs with a UTF-8 PV formatted with C<%s>, -and characters >255 formatted with C<%c>), the original SV might get -upgraded to UTF-8. +S> is supposed to be set when running with taint checks +enabled if the results are untrustworthy (often due to the use of locales). +However, this is not currently implemented. This argument is not used. -If the original SV was UTF-8, the pattern should be -valid UTF-8; if the original SV was bytes, the pattern should be too. +C gives the length in bytes of C. Currently, the pattern must be +NUL-terminated anyway. -All perform 'get' magic, but only C and C -perform 'set' magic. +C is used to specify which magic to handle or to skip, by setting or +clearing the C and/or S flags. -C and C do not take a thread +Plain C just calls C setting both the +C and S flags, so it always handles both set and get +magic. + +All the remaining forms handle 'get' magic; the forms whose name contains +C<_mg> additionally handle 'set' magic. + +When using the C array, if any of the SVs in it have their UTF-8 flag +set, C will be converted to be so too, as necessary. + +None of the remaining forms use the C array, meaning argument +reordering is not possible with them. The arguments are generally considered +to be the same UTF8ness as the destination C, though certain Perl +extensions to the standard set of %formats can override this (see +L and adjacent sections). + +The forms whose name contains C<_no_context> do not take a thread context (C) parameter, so are used in situations where the caller doesn't already have the thread context. +The forms whose name contains C use an encapsulated argument list, the +other forms use C-style arguments. + +There are no other differences between the forms. + =cut */ @@ -11223,24 +11273,6 @@ Perl_sv_catpvf(pTHX_ SV *const sv, const char *const pat, ...) va_end(args); } -/* -=for apidoc sv_vcatpvf -=for apidoc_item sv_vcatpvf_mg - -These process their arguments like C called with a non-null -C-style variable argument list, and append the formatted output to C. - -They differ only in that C performs 'set' magic; -C skips 'set' magic. - -Both perform 'get' magic. - -They are usually accessed via their frontends C> and -C>. - -=cut -*/ - void Perl_sv_vcatpvf(pTHX_ SV *const sv, const char *const pat, va_list *const args) { @@ -12161,34 +12193,6 @@ S_format_hexfp(pTHX_ char * const buf, const STRLEN bufsize, const char c, return elen; } -/* -=for apidoc sv_vcatpvfn -=for apidoc_item sv_vcatpvfn_flags - -These process their arguments like C> and append the formatted output -to an SV. They use an array of SVs if the C-style variable argument list is -missing (C). Argument reordering (using format specifiers like C<%2$d> or -C<%*2$d>) is supported only when using an array of SVs; using a C-style -C argument list with a format string that uses argument reordering -will yield an exception. - -When running with taint checks enabled, they indicate via C if -results are untrustworthy (often due to the use of locales). - -They assume that C has the same utf8-ness as C. It's the caller's -responsibility to ensure that this is so. - -They differ in that C has a C parameter in which you -can set or clear the C and/or S flags, to specify which -magic to handle or not handle; whereas plain C always specifies -both 'get' and 'set' magic. - -They are usually used via one of the frontends L> and -L>. - -=cut -*/ - void Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,