This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Simplify the implementation of SvPV*nolen functions
authorNicholas Clark <nick@ccl4.org>
Tue, 7 Jun 2005 15:10:38 +0000 (15:10 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 7 Jun 2005 15:10:38 +0000 (15:10 +0000)
p4raw-id: //depot/perl@24733

sv.c
sv.h

diff --git a/sv.c b/sv.c
index 81634de..4e9c3f9 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3328,8 +3328,7 @@ use the macro wrapper C<SvPV_nolen(sv)> instead.
 char *
 Perl_sv_2pv_nolen(pTHX_ register SV *sv)
 {
-    STRLEN n_a;
-    return sv_2pv(sv, &n_a);
+    return sv_2pv(sv, 0);
 }
 
 /* uiv_2buf(): private routine for use by sv_2pv_flags(): print an IV or
@@ -3394,6 +3393,12 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags)
     SV *tsv, *origsv;
     char tbuf[64];     /* Must fit sprintf/Gconvert of longest IV/NV */
     char *tmpbuf = tbuf;
+    STRLEN n_a;
+
+    if (!lp) {
+       /* Saves needing to do lots of if (!lp) checks below  */
+       lp = &n_a;
+    }
 
     if (!sv) {
        *lp = 0;
@@ -3728,8 +3733,7 @@ Usually accessed via the C<SvPVbyte_nolen> macro.
 char *
 Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
 {
-    STRLEN n_a;
-    return sv_2pvbyte(sv, &n_a);
+    return sv_2pvbyte(sv, 0);
 }
 
 /*
@@ -3765,8 +3769,7 @@ Usually accessed via the C<SvPVutf8_nolen> macro.
 char *
 Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
 {
-    STRLEN n_a;
-    return sv_2pvutf8(sv, &n_a);
+    return sv_2pvutf8(sv, 0);
 }
 
 /*
diff --git a/sv.h b/sv.h
index 19acb1a..377f9a3 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1222,7 +1222,7 @@ Like C<sv_catsv> but doesn't process magic.
 
 #define SvPV_nolen(sv) \
     ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
-     ? SvPVX(sv) : sv_2pv_nolen(sv))
+     ? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC))
 
 #define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0)
 
@@ -1239,7 +1239,7 @@ Like C<sv_catsv> but doesn't process magic.
 
 #define SvPVutf8_nolen(sv) \
     ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8)\
-     ? SvPVX(sv) : sv_2pvutf8_nolen(sv))
+     ? SvPVX(sv) : sv_2pvutf8(sv, 0))
 
 /* ----*/
 
@@ -1253,7 +1253,7 @@ Like C<sv_catsv> but doesn't process magic.
 
 #define SvPVbyte_nolen(sv) \
     ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)\
-     ? SvPVX(sv) : sv_2pvbyte_nolen(sv))
+     ? SvPVX(sv) : sv_2pvbyte(sv, 0))