allow $\ to work right when set to a string with embedded nulls
Gurusamy Sarathy [Fri, 5 Nov 1999 04:35:30 +0000 (04:35 +0000)]
p4raw-id: //depot/perl@4521

mg.c
t/io/print.t

diff --git a/mg.c b/mg.c
index aed978a..bb69f5c 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1699,8 +1699,10 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
     case '\\':
        if (PL_ors)
            Safefree(PL_ors);
-       if (SvOK(sv) || SvGMAGICAL(sv))
-           PL_ors = savepv(SvPV(sv,PL_orslen));
+       if (SvOK(sv) || SvGMAGICAL(sv)) {
+           s = SvPV(sv,PL_orslen);
+           PL_ors = savepvn(s,PL_orslen);
+       }
        else {
            PL_ors = Nullch;
            PL_orslen = 0;
index 180b1e8..0578ee6 100755 (executable)
@@ -1,8 +1,6 @@
 #!./perl
 
-# $RCSfile: print.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:32 $
-
-print "1..16\n";
+print "1..18\n";
 
 $foo = 'STDOUT';
 print $foo "ok 1\n";
@@ -30,3 +28,7 @@ print "ok","11";
 @x = ("ok","12\nok","13\nok");
 @y = ("15\nok","16");
 print @x,"14\nok",@y;
+{
+    local $\ = "ok 17\n# null =>[\000]\nok 18\n";
+    print "";
+}