-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add bindings for POSIX regexes #1719
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I've got a couple questions to maintainers. regex.h provides a struct, Now, there are two problems:
Regarding problem 1: is it okay if I hide some stuff like this? As far as I understand, turning an array into a struct later would be an API change. Regarding problem 2: should I only add definitions for targets for which I know the size for sure, or can I add blanket definitions and hope that people run tests on their platforms and will fix any inconsistencies? I'm not willing to chase the source for all OSes, and not willing to spin up VMs to find out the size experimentally. |
☔ The latest upstream changes (presumably #1699) made this pull request unmergeable. Please resolve the merge conflicts. |
I rebased onto current master, but I'll wait for maintainer's reply before pushing it. No point wasting CI resources when I already know what the result would be. |
Sorry for the delay!
If it's an opaque struct, I think an empty enum is suitable, like: libc/src/unix/linux_like/linux/mod.rs Lines 39 to 40 in 9782b7f
If it's unsure, I'd favor the former, small PR is better anyway :) |
Thanks for the feedback! I pushed some changes as a separate commit, so it's easier to see what changed.
Unfortunately, The |
Arrays don't work nearly as well as I hoped. By moving I'll try to do this "the proper way" and provide structure definitions (for musl, glibc, and BSDs). |
Doing this the "proper" way turned out way easier than I anticipated! Thank you for the guidance, @JohnTitor. There is no need to review individual commits — I expect this will be squashed into a single one upon merge. If that's not how things are done around here, tell me and I'll force-push the squashed version. Don't want to do it proactively because that'd be a waste of CI time IMHO. |
Looks good! Then I'll wait for fixups. |
Headers I used: Oh, for reference, here are the headers I used while working on this: - musl: https://git.musl-libc.org/cgit/musl/tree/include/regex.h?id=8327ae0cb23b799bc55a45e0d4bd95f5a2b1cdf1 - glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/regex.h;h=87cce7f5cb8cc3b678467329b479bd511e250e61;hb=HEAD - macOS: https://opensource.apple.com/source/Libc/Libc-997.90.3/include/regex.h.auto.html - FreeBSD: https://github.com/freebsd/freebsd/blob/8103b0ddb041617b7cd161528f0ff93ff32970a2/include/regex.h - NetBSD: https://github.com/NetBSD/src/blob/61c8f6fbb7e38b20e862d5cb3ed2203312963283/include/regex.h
Force-pushed a squashed commit. |
Um, GitHub says the checks are successful, but SemVer jobs actually failed, both on Linux and on macOS. The only difference I see relative to the previous build is that today's build use Nightly 3712e11a8 2020-04-12, whereas yesterday's used e82734e56 2020-04-11. |
Semver check depends on nightly rustc API and the failure is unlrelated to this PR, I'll fix it later :) |
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.
Great, thanks!
FYI, it broke the build on OpenBSD. |
regex.h is part of POSIX, so I believe it's in the scope of this crate.
Function definitions are the same for BSDs and Linux-lilkes, but I can't put them in src/unix/mod.rs since I believe not all Unix systems adhere to POSIX.
This is a draft because I want to see and fix test failures caused by wrong structure sizes. I only tested this on Linux locally.