Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 89e6c11

Browse files
committed
PerlIO-scalar-0.29
1 parent 09df855 commit 89e6c11

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17295,7 +17295,7 @@ our %delta = (
1729517295
'mro' => '1.21_01',
1729617296
'Net::Ping' => '2.70',
1729717297
'perlfaq' => '5.20180605',
17298-
'PerlIO::scalar' => '0.29_01',
17298+
'PerlIO::scalar' => '0.29',
1729917299
'PerlIO::via' => '0.17_01',
1730017300
'Pod::Checker' => '1.73_01',
1730117301
'Pod::Man' => '4.11',
@@ -17556,6 +17556,7 @@ our %delta = (
1755617556
'IPC::Cmd' => '1.02',
1755717557
'Net::Ping' => '2.70',
1755817558
'NEXT' => '0.67_01',
17559+
'PerlIO::scalar' => '0.29',
1755917560
'List::Util' => '1.50_11',
1756017561
'List::Util::XS' => '1.50_11',
1756117562
'Scalar::Util' => '1.50_11',

ext/PerlIO-scalar/scalar.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package PerlIO::scalar;
2-
our $VERSION = '0.24';
2+
our $VERSION = '0.29';
33
require XSLoader;
44
XSLoader::load();
55
1;

ext/PerlIO-scalar/scalar.xs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ typedef struct {
1515
Off_t posn;
1616
} PerlIOScalar;
1717

18+
IV
19+
PerlIOScalar_eof(pTHX_ PerlIO * f)
20+
{
21+
if (PerlIOBase(f)->flags & PERLIO_F_CANREAD) {
22+
PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar);
23+
STRLEN len;
24+
(void)SvPV(s->var, len);
25+
return len - (STRLEN)(s->posn) <= 0;
26+
}
27+
return 1;
28+
}
29+
1830
static IV
1931
PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
2032
PerlIO_funcs * tab)
@@ -31,7 +43,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
3143
&& mode && *mode != 'r') {
3244
if (ckWARN(WARN_LAYER))
3345
Perl_warner(aTHX_ packWARN(WARN_LAYER), "%s", PL_no_modify);
34-
SETERRNO(EINVAL, SS_IVCHAN);
46+
SETERRNO(EACCES, RMS_PRV);
3547
return -1;
3648
}
3749
s->var = SvREFCNT_inc(SvRV(arg));
@@ -174,8 +186,8 @@ PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
174186
* seems safe) and that the size of the buffer in our SV is
175187
* always less than half the size of the address space
176188
*/
177-
assert(sizeof(Off_t) >= sizeof(len));
178-
assert((Off_t)len >= 0); /* unsigned with 32bit */
189+
STATIC_ASSERT_STMT(sizeof(Off_t) >= sizeof(len));
190+
assert(len < ((~(STRLEN)0) >> 1)); /* unsigned with 32bit */
179191
if ((Off_t)len <= s->posn)
180192
return 0;
181193
got = len - (STRLEN)(s->posn);
@@ -406,7 +418,7 @@ static PERLIO_FUNCS_DECL(PerlIO_scalar) = {
406418
PerlIOScalar_close,
407419
PerlIOScalar_flush,
408420
PerlIOScalar_fill,
409-
PerlIOBase_eof,
421+
PerlIOScalar_eof,
410422
PerlIOBase_error,
411423
PerlIOBase_clearerr,
412424
PerlIOBase_setlinebuf,

ext/PerlIO-scalar/t/scalar.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ BEGIN {
1313
}
1414

1515
use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere.
16+
use Errno qw(EACCES);
1617

1718
$| = 1;
1819

19-
use Test::More tests => 122;
20+
use Test::More tests => 123;
2021

2122
my $fh;
2223
my $var = "aaa\n";
@@ -185,6 +186,7 @@ EOF
185186

186187
my $ro = \43;
187188
ok(!(defined open(F, '>', $ro)), $!);
189+
is($!+0, EACCES, "check we get a read-onlyish error code");
188190
close F;
189191
# but we can read from it
190192
ok(open(F, '<', $ro), $!);

pod/perlcdelta.pod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ better icmpv6 support.
430430

431431
Fix for GLOB stubs [cpan #123002].
432432

433+
=item L<PerlIO::scalar> 0.29
434+
435+
check invariant at compile time.
436+
437+
return EACCES on writing to a read-only scalar
438+
433439
=item Scalar-List-Util 1.50_11
434440

435441
fix C<find_rundefsvoffset> logic.

0 commit comments

Comments
 (0)