if (PerlIOBase(f)->flags & PERLIO_F_RDBUF)
{
avail = (b->ptr - b->buf);
+ if (avail > (SSize_t) count)
+ avail = count;
}
else
{
avail = b->bufsiz;
+ /* Adjust this here to keep a subsequent tell() correct.
+ * (b->ptr - b->buf) *MUST* be an accurate reflection of the amount
+ * unread in this buffer. (See previous part of the if for an example,
+ * or try PERLIO=unix on t/io/tell.t.)
+ */
+ if (avail > (SSize_t) count)
+ avail = count;
b->end = b->buf + avail;
b->ptr = b->end;
PerlIOBase(f)->flags |= PERLIO_F_RDBUF;
- b->posn -= b->bufsiz;
+ b->posn -= avail;
}
- if (avail > (SSize_t) count)
- avail = count;
if (avail > 0)
{
b->ptr -= avail;
EXPECT
Odd number of elements in hash assignment at - line 3.
########
-# pp.c
+# pp_pack.c
use warnings 'pack' ;
use warnings 'unpack' ;
my @a = unpack ("A,A", "22") ;
EXPECT
Use of uninitialized value in scalar dereference at - line 4.
########
-# pp.c
+# pp_pack.c
use warnings 'pack' ;
sub foo { my $a = "a"; return $a . $a++ . $a++ }
my $a = pack("p", &foo) ;
reverse ;
EXPECT
########
-# pp.c
+# pp_pack.c
use warnings 'pack' ;
-print unpack("C", pack("C", -1)), "\n";
-print unpack("C", pack("C", 0)), "\n";
-print unpack("C", pack("C", 255)), "\n";
-print unpack("C", pack("C", 256)), "\n";
-print unpack("c", pack("c", -129)), "\n";
-print unpack("c", pack("c", -128)), "\n";
-print unpack("c", pack("c", 127)), "\n";
-print unpack("c", pack("c", 128)), "\n";
+print unpack("C", pack("C", -1)), "\n",
+ unpack("C", pack("C", 0)), "\n",
+ unpack("C", pack("C", 255)), "\n",
+ unpack("C", pack("C", 256)), "\n",
+ unpack("c", pack("c", -129)), "\n",
+ unpack("c", pack("c", -128)), "\n",
+ unpack("c", pack("c", 127)), "\n",
+ unpack("c", pack("c", 128)), "\n";
no warnings 'pack' ;
print unpack("C", pack("C", -1)), "\n";
print unpack("C", pack("C", 0)), "\n";
print unpack("c", pack("c", 128)), "\n";
EXPECT
Character in "C" format wrapped at - line 3.
-Character in "C" format wrapped at - line 6.
-Character in "c" format wrapped at - line 7.
-Character in "c" format wrapped at - line 10.
+Character in "C" format wrapped at - line 3.
+Character in "c" format wrapped at - line 3.
+Character in "c" format wrapped at - line 3.
255
0
255