-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-17068: Add pack()/unpack() format for signed integer endianness #19368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
28d0948
to
bc83418
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes on a big endian system
bc83418
to
a2858ac
Compare
a2858ac
to
21bb22e
Compare
Friendly ping @php/release-managers, would you prefer to wait or are you comfortable with this change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RM approval, technical review not performed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this looks okay.
I didn't understand the reasoning behind picking the letters for the format, and the original issue description didn't help me understand it either. The original issue comment talks about "to match the other formats" but I didn't understand this. Can you please explain?
I followed the current convention where lowercase is little endian, and uppercase is big endian. About the letters themselves, I'm not sure there's a technical justification other than "these letters are not already used in pack/unpack". Maybe I miss something and the letters may actually have a deeper meaning? |
You didn't follow this. |
Indeed, I've got it all mixed up. It's no good as it is. |
Possibly, but honestly the more I look at the table the less the naming scheme makes sense, I just don't get it. Someone else will have to judge what the right letters are... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should match Perl: https://perldoc.perl.org/functions/pack
> sSiIlLqQ Force big-endian byte-order on the type.
jJfFdDpP (The "big end" touches the construct.)
< sSiIlLqQ Force little-endian byte-order on the type.
jJfFdDpP (The "little end" touches the construct.)
Hmmm... PERL uses |
In my opinion, it's better to pursue the RFC process here, instead of adding some arbitrary characters which might later interfere with further additions. |
Looks like the best thing to do here. Let's pause this PR for now |
Fix #17068
Adds signed integer endianness support to pack()/unpack() functions. There are 2 new format codes (from the original issue): m/y for signed 2-byte (little/big endian), M/Y for signed 4-byte (little/big endian), and p/j for signed 8-byte (little/big endian). It follows the existing pattern where lowercase matches uppercase endianness.
I also moved pack tests in a dedicated folder.