FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Properly pass `wchar *` type to giterr_set by bokic · Pull Request #4014 · libgit2/libgit2 · GitHub

Repository navigation

Properly pass wchar * type to giterr_set - #4014

Merged
ethomson merged 2 commits into
libgit2:masterfrom
bokic:patch-1
Dec 7, 2016
Merged

ethomson merged 2 commits into
libgit2:masterfrom
bokic:patch-1

Conversation

bokic commented Nov 20, 2016

Copy link
Copy Markdown
Contributor

Ensure correct type is passed, no garbage text is sent, and mute compiler warning.

Comment thread src/win32/w32_util.h Outdated
* not counting the NULL terminator */
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
giterr_set(GITERR_OS, "Could not convert reparse point name for '%s'", path);
giterr_set(GITERR_OS, "Could not convert reparse point name for '%S'", path);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good catch.

IIRC, %S means that the argument should have the opposite size of the format string. So for the narrow printf family of functions, %S is a wchar_t * and for the Unicode/wide wprintf family of functions, %S is a narrow char *. Is my memory correct here?

If so, can we change this to %ls which (again, IIRC) indicates a wide string always, regardless of whether you're feeding it to printf or wprintf.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just checked with MinGW 5.3.0, and, you are right. %S seem to reverse the character width.

So, yes %ls format is better for this case.

ethomson commented Dec 7, 2016

Copy link
Copy Markdown
Member

Thanks! 😀

ethomson merged commit 1576973 into libgit2:master Dec 7, 2016
carlosmn mentioned this pull request Dec 10, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL