-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix realpath on Windows #13582
Fix realpath on Windows #13582
Conversation
if (p < buflength) | ||
resize!(buf, p+1) | ||
return utf8(UTF16String(buf)) | ||
if (p > length(buf)) |
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.
Should be p+1 > length(buf)
, I think. According to the documentation, the return value is:
If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpBuffer, not including the terminating null character.
If the lpBuffer buffer is too small to contain the path, the return value is the size, in TCHARs, of the buffer that is required to hold the path and the terminating null character.
In particular, note the inconsistency regarding whether the return value includes the terminating null codeunit.
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.
The same correction is needed for longpath
, since the docs for GetLongPathName are similar.
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.
Yes.
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.
Actually, I don't think it's possible for p==length(buf)
, which would be the only affected case by this change.
In fact, I see a lot of |
I'm not sure it's a great idea for |
@malmaud, |
Ok, I'm convinced. I'll make a PR for that. On Tue, Oct 13, 2015 at 2:12 PM Steven G. Johnson notifications@github.com
|
however, it's best to stick with |
If you recall, I'd already tried to add more of these conversions, and was made to remove them. |
superseded by #12819? |
yes -- i was thinking of this PR as I made those changes, I just couldn't remember where I had seen this. |
There was a small inefficiency that would usually cause the call to
GetFullPathName
to be made twice. See #13542 (diff).