Skip to content

file: Support unicode urls on windows - #6501

Closed
foopoiuyt wants to merge 1 commit into
curl:masterfrom
foopoiuyt:windows_unicode_file
Closed

file: Support unicode urls on windows#6501
foopoiuyt wants to merge 1 commit into
curl:masterfrom
foopoiuyt:windows_unicode_file

Conversation

@foopoiuyt

Copy link
Copy Markdown
Contributor

Support file: urls with utf-8 filenames on Windows when _UNICODE is defined.

@jay jay added the Windows Windows-specific label Jan 21, 2021
@jay

jay commented Jan 21, 2021

Copy link
Copy Markdown
Member

https://dev.azure.com/daniel0244/5571c33c-81e1-43d7-93ee-d3d4152f27b2/_apis/build/builds/4396/logs/99

2021-01-21T00:23:08.4699191Z file.c: In function 'file_upload':
2021-01-21T00:23:08.4700646Z file.c:280:55: error: macro "open" passed 3 arguments, but takes just 2
2021-01-21T00:23:08.4701344Z    fd = open(file->path, mode, data->set.new_file_perms);
2021-01-21T00:23:08.4701886Z                                                        ^
2021-01-21T00:23:08.4704068Z file.c:280:6: error: assignment to 'int' from 'int (__attribute__((cdecl)) *)(const char *, int,  ...)' {aka 'int (*)(const char *, int,  ...)'} makes integer from pointer without a cast [-Wint-conversion]
2021-01-21T00:23:08.4705100Z    fd = open(file->path, mode, data->set.new_file_perms);
2021-01-21T00:23:08.4705770Z       ^

That is because open takes 2 or 3 arguments. To fix it you could do # define open curlx_win32_open and then make curlx_win32_open variadic. The alternative is a variadic macro but I don't think that's supported with all compilers.

Comment thread lib/curl_setup.h Outdated

Copy link
Copy Markdown
Contributor

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

Comment thread lib/curl_multibyte.c Outdated

Copy link
Copy Markdown
Contributor

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?

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.

It's not, this is in a #if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES) block.

Comment thread lib/curl_multibyte.c Outdated

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.

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.

Thanks, totally missed it (and the later check as mentioned below).

@foopoiuyt
foopoiuyt force-pushed the windows_unicode_file branch 3 times, most recently from 63585f8 to 1106ff3 Compare January 21, 2021 22:21
Comment thread lib/curl_multibyte.c Outdated

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.

Indentation is wrong here.

Comment thread lib/curl_multibyte.c Outdated

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.

This should be if(result != -1) now.

@foopoiuyt
foopoiuyt force-pushed the windows_unicode_file branch from 1106ff3 to 6dc311a Compare January 21, 2021 22:31
Comment thread lib/curl_setup.h Outdated

@jay jay Jan 22, 2021

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.

I would do away with __VA_ARGS__ I don't think all compilers support it

@foopoiuyt
foopoiuyt force-pushed the windows_unicode_file branch 5 times, most recently from 9a9a4fc to cf951b5 Compare January 22, 2021 21:17
@jay jay added the feature-window A merge of this requires an open feature window label Jan 24, 2021
@jay jay changed the title WIP: file: Support unicode urls on windows file: Support unicode urls on windows Jan 24, 2021
@jay
jay force-pushed the windows_unicode_file branch from cf951b5 to 2f71f51 Compare February 3, 2021 20:23
@jay jay closed this in 1269c80 Feb 9, 2021
@jay jay removed the feature-window A merge of this requires an open feature window label Feb 9, 2021
@jay

jay commented Feb 9, 2021

Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

5 participants