This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Can pass in a length here without introducing a bug. Might save
authorNicholas Clark <nick@ccl4.org>
Sun, 9 Jan 2005 19:42:30 +0000 (19:42 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 9 Jan 2005 19:42:30 +0000 (19:42 +0000)
a strlen()

p4raw-id: //depot/perl@23771

toke.c

diff --git a/toke.c b/toke.c
index 1fd7017..fcd143a 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -4144,8 +4144,12 @@ Perl_yylex(pTHX)
                    sv = newSVpvn("CORE::GLOBAL::",14);
                    sv_catpv(sv,PL_tokenbuf);
                }
-               else
-                   sv = newSVpv(PL_tokenbuf,0);
+               else {
+                   /* If len is 0, newSVpv does strlen(), which is correct.
+                      If len is non-zero, then it will be the true length,
+                      and so the scalar will be created correctly.  */
+                   sv = newSVpv(PL_tokenbuf,len);
+               }
 
                /* Presume this is going to be a bareword of some sort. */