Skip to content

zig fmt: Fix relative paths with . and .. on Windows as well as forward slashes #5187

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

Merged
merged 3 commits into from
Apr 27, 2020

Conversation

andrewrk
Copy link
Member

This is @squeek502's pull request #4655 with a couple of additional modifications.

@squeek502 does this look OK to you?

I also plan on looking into making "." and ".." work in the code that calls NtCreateFile but I agree with you that can be a separate issue.

squeek502 and others added 3 commits April 27, 2020 13:35
This is a band-aid fix due to NtCreateFile failing on paths with . or .. in them.
The previous commit made zig fmt print absolute paths; this commit keeps
the absolute path resolution but still prints the relative paths to
stdout.
@andrewrk andrewrk changed the title zig fmt: Fix relative paths with . and .. on Windows zig fmt: Fix relative paths with . and .. on Windows as well as forward slashes Apr 27, 2020
@squeek502
Copy link
Collaborator

Looks good to me. 👍

@andrewrk andrewrk merged commit ecdf75d into master Apr 27, 2020
@andrewrk andrewrk deleted the squeek502-windows-fmt-relative branch April 27, 2020 22:28

const max = std.math.maxInt(usize);
const source_code = fs.cwd().readFileAlloc(fmt.allocator, file_path, max) catch |err| switch (err) {
const source_code = fs.cwd().readFileAlloc(fmt.allocator, real_path, self_hosted_main.max_src_size) catch |err| switch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't real_path an absolute path? Why call fs.cwd()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants