-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
file: Support unicode urls on windows #6501
Conversation
That is because open takes 2 or 3 arguments. To fix it you could do |
lib/curl_setup.h
Outdated
@@ -356,9 +358,11 @@ | |||
# define fstat(fdes,stp) _fstat(fdes, stp) | |||
# define stat(fname,stp) curlx_win32_stat(fname, stp) | |||
# define struct_stat struct _stat | |||
# define open(fname,oflag) curlx_win32_open(fname, oflag) |
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.
Please don't redfine a POSIX syscall
lib/curl_multibyte.c
Outdated
return result; | ||
#endif | ||
|
||
return (open)(filename, oflag); |
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.
Why even define the function on non Windows platforms?
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.
It's not, this is in a #if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
block.
lib/curl_multibyte.c
Outdated
int curlx_win32_open(const char *filename, int oflag) | ||
{ | ||
#ifdef _UNICODE | ||
int result = 0; |
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 error value is defined as -1 and 0 might be a valid result: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-160#return-value
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.
Thanks, totally missed it (and the later check as mentioned below).
63585f8
to
1106ff3
Compare
lib/curl_multibyte.c
Outdated
@@ -82,6 +82,29 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) | |||
|
|||
#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES) | |||
|
|||
int curlx_win32_open(const char *filename, int oflag, ...) | |||
{ | |||
int pmode = 0; |
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.
Indentation is wrong here.
lib/curl_multibyte.c
Outdated
if(filename_w) | ||
result = _wopen(filename_w, oflag, pmode); | ||
free(filename_w); | ||
if(result) |
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.
This should be if(result != -1)
now.
1106ff3
to
6dc311a
Compare
lib/curl_setup.h
Outdated
@@ -356,9 +359,12 @@ | |||
# define fstat(fdes,stp) _fstat(fdes, stp) | |||
# define stat(fname,stp) curlx_win32_stat(fname, stp) | |||
# define struct_stat struct _stat | |||
# define open(fname,oflag,...) curlx_win32_open(fname, oflag \ | |||
, ## __VA_ARGS__) |
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.
I would do away with __VA_ARGS__
I don't think all compilers support it
9a9a4fc
to
cf951b5
Compare
cf951b5
to
2f71f51
Compare
Thanks |
Support file: urls with utf-8 filenames on Windows when _UNICODE is defined.