Replace newSVpv(...,0) with newSVpvn where we know the length.
Nicholas Clark [Thu, 30 Jun 2005 11:40:37 +0000 (11:40 +0000)]
p4raw-id: //depot/perl@25022

perl.c
regcomp.c
sv.c

diff --git a/perl.c b/perl.c
index e573425..5689281 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -3061,8 +3061,10 @@ Perl_moreswitches(pTHX_ char *s)
            SV *sv;
            const char *use = "use ";
            /* -M-foo == 'no foo'       */
-           if (*s == '-') { use = "no "; ++s; }
-           sv = newSVpv(use,0);
+           /* Leading space on " no " is deliberate, to make both
+              possibilities the same length.  */
+           if (*s == '-') { use = " no "; ++s; }
+           sv = newSVpvn(use,4);
            start = s;
            /* We allow -M'Module qw(Foo Bar)'  */
            while(isALNUM(*s) || *s==':') ++s;
index 23bc9b9..d2526b7 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -765,7 +765,7 @@ and would end up looking like:
     DEBUG_TRIE_COMPILE_r({                                                 \
        SV *tmp;                                                           \
        if ( UTF ) {                                                       \
-           tmp = newSVpv( "", 0 );                                        \
+           tmp = newSVpvn( "", 0 );                                       \
            pv_uni_display( tmp, uc, len, 60, UNI_DISPLAY_REGEX );         \
        } else {                                                           \
            tmp = Perl_newSVpvf_nocontext( "%c", (int)uvc );               \
diff --git a/sv.c b/sv.c
index 2aa2b5a..101f8b6 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -988,7 +988,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match)
     case OP_SCHOMP:
     case OP_CHOMP:
        if (SvROK(PL_rs) && uninit_sv == SvRV(PL_rs))
-           return sv_2mortal(newSVpv("${$/}", 0));
+           return sv_2mortal(newSVpvn("${$/}", 5));
        /* FALL THROUGH */
 
     default:
@@ -1837,7 +1837,7 @@ S_not_a_number(pTHX_ SV *sv)
      const char *pv;
 
      if (DO_UTF8(sv)) {
-          dsv = sv_2mortal(newSVpv("", 0));
+          dsv = sv_2mortal(newSVpvn("", 0));
           pv = sv_uni_display(dsv, sv, 10, 0);
      } else {
          char *d = tmpbuf;