HEKf256 format
authorFather Chrysostomos <sprout@cpan.org>
Fri, 7 Oct 2011 17:00:24 +0000 (10:00 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 7 Oct 2011 18:40:18 +0000 (11:40 -0700)
perl.h
sv.c
t/porting/diag.t

diff --git a/perl.h b/perl.h
index accb96b..8048b56 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3212,6 +3212,12 @@ typedef pthread_key_t    perl_key;
 #  define HEKf "2p"
 #endif
 
+/* Not ideal, but we cannot easily include a number in an already-numeric
+ * format sequence. */
+#ifndef HEKf256
+#  define HEKf256 "3p"
+#endif
+
 #define HEKfARG(p) ((void*)(p))
 
 #ifdef PERL_CORE
diff --git a/sv.c b/sv.c
index c8e3c02..158410d 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10175,7 +10175,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,
                %-p     (SVf)   include an SV (previously %_)
                %-<num>p        include an SV with precision <num>      
                %2p             include a HEK
-               %<num>p         (where num != 2) reserved for future
+               %3p             include a HEK with precision of 256
+               %<num>p         (where num != 2 or 3) reserved for future
                                extensions
 
        Robin Barker 2005-07-14 (but modified since)
@@ -10200,12 +10201,13 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,
                        is_utf8 = TRUE;
                    goto string;
                }
-               else if (n==2) {                /* HEKf */
+               else if (n==2 || n==3) {        /* HEKf */
                    HEK * const hek = va_arg(*args, HEK *);
                    eptr = HEK_KEY(hek);
                    elen = HEK_LEN(hek);
                    if (HEK_UTF8(hek)) is_utf8 = TRUE;
-                   goto string; /* no modifiers supported */
+                   if (n==3) precis = 256, has_precis = TRUE;
+                   goto string;
                }
                else if (n) {
                    Perl_ck_warner_d(aTHX_ packWARN(WARN_INTERNAL),
index 3a9dbab..331b356 100644 (file)
@@ -142,6 +142,7 @@ my %specialformats = (IVdf => 'd',
                      NVef => 'f',
                      NVff => 'f',
                      NVgf => 'f',
+                     HEKf256=>'s',
                      HEKf => 's',
                      SVf256=>'s',
                      SVf32=> 's',