develooper Front page | perl.perl5.porters | Postings from April 2000

Re: [ID 20000425.002] Minor bug fix and enhancement to to pp.c:pp_pack()

Thread Previous | Thread Next
From:
Ilya Zakharevich
Date:
April 25, 2000 19:58
Subject:
Re: [ID 20000425.002] Minor bug fix and enhancement to to pp.c:pp_pack()
Message ID:
200004260258.WAA15579@monk.mps.ohio-state.edu
John Holdsworth writes:
> Included is a bug fix to the decode of unpack 'N/Z*' which
> was not adding a byte to the encoded length as pack does.

Not clear.  unpack 'N/Z*' with N unpacking to 14 should be the same as
Z14.  Is it?

> There is also option to use 'N/a*4' to round the length of encoded
> strings to four bytes as required by SUN XDR RFC 1832.

I think a more general command is needed.  Say, 'x!8' which would add
0-bytes until the next position which is multiple of 8.  Then you
would write 'N/a*x!4'.

> More contentiously perhaps the code also supports a new length
> character '?' which steals the length from the next argument.
> This allows multiple arrays to be encoded and decoded viz.:
>  
> my @arr = (1,2,3,4);
> my $packed = pack "N/N?N/N?", scalar @arr, @arr, scalar @arr, @arr;

Again, something more general is needed.  Something like

  my $packed = pack "(N//N)(N//N)", scalar @arr, @arr, scalar @arr, @arr;

or similar.

Ilya

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About