This is a good point, so I checked my old source codes and I found a note in one of them, that: unpack('@2000000/'. 'aA', str_repeat(' ', 2000000). 'ABC') was returning 'B' instead of 'A'. It is some issue which probably was repaired years ago (because it works correctly now), but it allowed me to completely forgot that it should works this way... ;-)
Anyway, as I said in previous email, prepending some '@xxx' to the start of the constant $format exclude usage of another '@'s inside the $format unless updating them, so I'm still promoting additional $offset argument. People will still be able to use it old style... Regards, Hynek On Thu, Feb 25, 2016 at 2:02 PM, Dmitry Stogov <dmi...@zend.com> wrote: > > > On 02/25/2016 03:05 PM, Nikita Popov wrote: > > On Thu, Feb 25, 2016 at 8:08 AM, Dmitry Stogov <dmi...@zend.com> wrote: > >> >> >> >> ________________________________ >> From: Dmitry Stogov >> Sent: Wednesday, February 24, 2016 13:35 >> To: Hynek Bartoš; php-...@lists.php.net; php-general-h...@lists.php.net >> Subject: Re: unpack() >> >> >> Hi, >> >> >> I think the requested feature may be really useful. >> >> And the implementation is really simple >> <https://gist.github.com/dstogov/edbb1efcd1e9701e75ab> >> https://gist.github.com/dstogov/edbb1efcd1e9701e75ab >> >> I think, committing this into master doesn't require RFC and voting. >> >> Anyone objects? >> > > How should this interact with absolute position references? Your current > patch changes input and inputlen, so absolute offsets will be relative to > the "offset" parameter and not relative to the actual start of the string. > Is this supposed to be so? > > And on that note, isn't this already covered by prefixing the unpack with > @offset? (Not to say that an explicit offset argument wouldn't be more > elegant.) > > > 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. > >