Long-standing "defined but not used" SvPVbyte*() are about to get used
Nick Ing-Simmons [Mon, 5 Mar 2001 15:56:35 +0000 (15:56 +0000)]
for auto-downgrade hooks in gethostbyaddr() etc. (as per Camel-III).

Make SvPVbyte*() symmetric with respect to SvPVutf8*() in that:
 - it does a sv_utf8_downgrade (c.f. SvPVutf8's sv_utf8_upgrade())
 - uses SvPV() rather than sv_2pv() in case it isn't a string.

p4raw-id: //depot/perlio@9037

sv.c

diff --git a/sv.c b/sv.c
index 4e75506..d47a2f5 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2884,7 +2884,8 @@ Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
 char *
 Perl_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
 {
-    return sv_2pv(sv,lp);
+    sv_utf8_downgrade(sv,0);
+    return SvPV(sv,*lp);
 }
 
 char *