nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

localizing record separator is not honored #314

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$ perlcc -r -e 'open FOO, ">", "test.file"; print FOO "abc"; close FOO; open 
FOO, "<", "test.file"; { local $/='b'; $in=<FOO>; print "separator: -$/-\n" }; 
print "\$/ is -$/-\n"; print $in eq "ab" ? "OK\n" : "FAIL: -$in-\n"'
separator: -b-
$/ is -
-
FAIL: -abc-

If you remove the "local" on "$/", this works as expected.

Working version:
$ perlcc -r -e 'open FOO, ">", "test.file"; print FOO "abc"; close FOO; open 
FOO, "<", "test.file"; {  $/='b'; $in=<FOO>; print "separator: -$/-\n" }; print 
"\$/ is -$/-\n"; print $in eq "ab" ? "OK\n" : "FAIL: -$in-\n"'
separator: -b-
$/ is -b-
OK

Original issue reported on code.google.com by chro...@gmail.com on 6 May 2014 at 11:10

GoogleCodeExporter commented 9 years ago
Note that the working version has no local in front of $/

Original comment by chro...@gmail.com on 6 May 2014 at 11:11

GoogleCodeExporter commented 9 years ago
This happened on master (0cc94a5cc082fadd77206404585e8f9e12e3712a)

Original comment by todd.e.rinaldo on 6 May 2014 at 11:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I suspect issue 306 caused this regression.

Original comment by todd.e.rinaldo on 6 May 2014 at 11:59

GoogleCodeExporter commented 9 years ago
The same happens if you localize $\ 
see t/C-COMPILED/CORE--op--tiehandle.t and the other failing core tests.

local $\ = 'something'
::is( $ors, "\n",        'say sets $\ to \n in PRINT' );

Original comment by reini.urban on 7 May 2014 at 1:09

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 7 May 2014 at 2:15

GoogleCodeExporter commented 9 years ago
Needs to be fixed by adding the missing GvSV sv magic from the SV back to the 
GV.
i.e. PL_rs -> gv_list[1]

Otherwise Perl_pp_gvsv will go into save_scalar_at but will miss the 
if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) part 
there, i.e mg_localize. 
So sv (i.e. PL_rs) will be totally empty (*sptr = newSV(0))

Original comment by reini.urban on 7 May 2014 at 5:26

GoogleCodeExporter commented 9 years ago
Fixed with commit d394cb05071ee01529f445e2e7d242ebfb8fc2a5
Author: Reini Urban <rurban@cpanel.net>
Date:   Wed May 7 13:00:20 2014 -0500

    C: Support local $/ = "somestring" (only used empty values before) #314

    A regression from 1.43
    added testcases to t/issue256.t
    Also inc the refcnt of PL_rs if used as such
      for t/C-COMPILED/CORE--base--rs.t

    Note that PL_ors_sv not, since this is NULL (not even PL_sv_undef) as default.

Original comment by reini.urban on 7 May 2014 at 7:01

GoogleCodeExporter commented 9 years ago

Original comment by nicolas....@gmail.com on 8 May 2014 at 8:27