summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-12-18 18:42:34 +0100
committerYves Orton <demerphq@gmail.com>2022-12-22 15:41:12 +0100
commit332af2278b8db03a0735d24a17bbaae7f7e20112 (patch)
tree18170096c3ea3401104a2cacb76ddcad52b11151 /sv.c
parent81620fbedd5f5cb87f240d7809dc669cd60d0139 (diff)
downloadperl-332af2278b8db03a0735d24a17bbaae7f7e20112.tar.gz
sv.c - add support for HvNAMEf and HvNAMEf_QUOTEDPREFIX formats
They are similar to SVf and SVf_QUOTEDPREFIX but take an HV * argument and use HvNAME() and related macros to extract the string. This is helpful as it makes constructing error messages from a stash (HV *) easier. It is the callers responsibility to ensure that the HV is actually a stash.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index ca8992b49a..7b495589cf 100644
--- a/sv.c
+++ b/sv.c
@@ -12651,6 +12651,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
* rather than here.
* %d%lu%9p (UTF8f_QUOTEDPREFIX) .. but escaped and quoted.
*
+ * %6p (HvNAMEf) Like %s, but using the HvNAME() and HvNAMELEN()
+ * %10p (HvNAMEf_QUOTEDPREFIX) ... but escaped and quoted
*
* %<num>p where num is > 9: reserved for future
* extensions. Warns, but then is treated as a
@@ -12709,6 +12711,17 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
width = 0;
goto string;
}
+ else if (width == 6 || width == 10) {
+ HV *hv = va_arg(*args, HV *);
+ eptr = HvNAME(hv);
+ elen = HvNAMELEN(hv);
+ if (HvNAMEUTF8(hv))
+ is_utf8 = TRUE;
+ if (width == 10)
+ escape_it = TRUE;
+ width = 0;
+ goto string;
+ }
else if (width) {
/* note width=4 or width=9 is handled under %d */
Perl_ck_warner_d(aTHX_ packWARN(WARN_INTERNAL),