Re: Fw: unpack()

From: Date: Mon, 19 Dec 2016 08:15:53 +0000
Subject: Re: Fw: unpack()
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-97441@lists.php.net to get a copy of this message
Fixed. Thanks for catching and sorry for delay. Dmitry. ________________________________ From: Leigh <leight@gmail.com> Sent: Tuesday, December 13, 2016 6:36:00 PM To: Dmitry Stogov Cc: Nikita Popov; internals@lists.php.net; Hynek Bartoš Subject: Re: [PHP-DEV] Fw: unpack() On 29 February 2016 at 07:43, Dmitry Stogov <dmitry@zend.com> wrote: > I think the most clear way is to apply the new $offset argument and then the old way to skip > first bytes of input string. > So unpack("@$skip/N4", $message, $offset) will skip $offset+$skip. > Actually, this is the way how the proposed patch works. > > Thanks. Dmitry. > > > ________________________________________ > From: Leigh <leight@gmail.com> > Sent: Thursday, February 25, 2016 18:20 > To: Dmitry Stogov > Cc: Nikita Popov; internals@lists.php.net; Hynek Bartoš > Subject: Re: [PHP-DEV] Fw: unpack() > > On 25 February 2016 at 13:02, Dmitry Stogov <dmitry@zend.com> wrote: >> >> I've just got to know about possible usage of "@" in unpack(), but it seems >> doesn't work at all >> >> $ sapi/cli/php -r 'var_dump(unpack("@0l", "\x01\x00\x00\x00")); >> ' >> array(0) { >> } >> >> Do I use it properly? >> >> Thanks. Dmitry. >> > > As Nikita said, you need the "/". I use this operator when processing > streams of binary data. > > Trimmed down example: > > while ($blocks--) { > list(, $x0, $x1, $x2, $x3) = unpack("@$offset/N4", $message); > //... > $offset += 16; > } > > The dynamic format string is kind of nasty though, so no objections to > an additional parameter making things clearer, however, what is to be > done if an offset is specified in both the format string and the > additional parameter? Does one override the other? Are they additive? Hi Dmitry, I noticed this is half implemented. You have committed some changes to unpack to cater for the offset argument, but arginfo_unpack was never updated. What was the intention with this? Cheers, Leigh.

« previous php.internals (#97441) next »