Skip to content
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

make selfExePath() compile on OpenBSD #6788

Merged
merged 1 commit into from
Oct 25, 2020

Conversation

semarie
Copy link
Contributor

@semarie semarie commented Oct 24, 2020

readd original code from #6638. realpathZ() is expected to take a [*:0]const u8

@daurnimator daurnimator added the standard library This issue involves writing Zig code for the standard library. label Oct 24, 2020
@@ -2251,7 +2251,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
const PATH = std.os.getenvZ("PATH") orelse return error.FileNotFound;
var path_it = mem.tokenize(PATH, &[_]u8{path.delimiter});
while (path_it.next()) |a_path| {
var resolved_path_buf: [MAX_PATH_BYTES]u8 = undefined;
var resolved_path_buf: [MAX_PATH_BYTES-1:0]u8 = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, could this not be made into

var resolved_path_buf: [MAX_PATH_BYTES:0]u8 = undefined;

instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in #6638 (comment), I was told to use MAX_PATH_BYTES-1:0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I was just wondering why not MAX_PATH_BYTES + 1, but I guess it makes sense for it to be null-delimited, hence the null makes the last byte in MAX_PATH_BYTES. :-)

@semarie
Copy link
Contributor Author

semarie commented Oct 25, 2020

this PR is only to restore an already accepted change with was lost in the merge.

@kubkon kubkon merged commit 3115d2f into ziglang:master Oct 25, 2020
@semarie semarie deleted the openbsd-realpathZ branch November 11, 2020 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants