File tree Expand file tree Collapse file tree 3 files changed +8
-13
lines changed Expand file tree Collapse file tree 3 files changed +8
-13
lines changed Original file line number Diff line number Diff line change 23
23
24
24
#include < wchar.h>
25
25
26
- namespace swift {
27
- namespace win32 {
28
-
29
26
// / Convert a wide string to UTF-8.
30
27
// /
31
28
// / @param str The string to convert.
@@ -35,7 +32,7 @@ namespace win32 {
35
32
// /
36
33
// / If @a str cannot be converted to UTF-8, @c nullptr is returned.
37
34
SWIFT_RUNTIME_STDLIB_INTERNAL
38
- char *copyUTF8FromWide (const wchar_t *str);
35
+ char *_swift_win32_copyUTF8FromWide (const wchar_t *str);
39
36
40
37
// / Convert a UTF-8 string to a wide string.
41
38
// /
@@ -46,10 +43,8 @@ char *copyUTF8FromWide(const wchar_t *str);
46
43
// /
47
44
// / If @a str cannot be converted to UTF-16, @c nullptr is returned.
48
45
SWIFT_RUNTIME_STDLIB_INTERNAL
49
- wchar_t *copyWideFromUTF8 (const char *str);
46
+ wchar_t *_swift_win32_copyWideFromUTF8 (const char *str);
50
47
51
- }
52
- }
53
48
#endif // defined(_WIN32)
54
49
55
50
#endif // SWIFT_RUNTIME_WIN32_H
Original file line number Diff line number Diff line change @@ -203,8 +203,10 @@ static void swift::enumerateUnsafeArgv(const F& body) {
203
203
int argc = 0 ;
204
204
if (LPWSTR *wargv = CommandLineToArgvW (GetCommandLineW (), &argc)) {
205
205
std::for_each (wargv, wargv + argc, [=] (wchar_t *warg) {
206
- auto arg = swift::win32::copyUTF8FromWide (warg);
207
- if (!arg) {
206
+ if (char *arg = _swift_win32_copyUTF8FromWide (warg)) {
207
+ body (argc, arg);
208
+ free (arg);
209
+ } else {
208
210
// Note that GetLastError() and errno may not be so useful here,
209
211
// as in the error case we may have called free(), which might reset
210
212
// either or both of them.
@@ -213,8 +215,6 @@ static void swift::enumerateUnsafeArgv(const F& body) {
213
215
" UTF-8: %lx, %d.\n " ,
214
216
warg, ::GetLastError (), errno);
215
217
}
216
- body (argc, arg);
217
- free (arg);
218
218
});
219
219
220
220
LocalFree (wargv);
Original file line number Diff line number Diff line change 22
22
#include < windows.h>
23
23
24
24
char *
25
- swift::win32::copyUTF8FromWide (const wchar_t *str) {
25
+ _swift_win32_copyUTF8FromWide (const wchar_t *str) {
26
26
char *result = nullptr ;
27
27
int len = ::WideCharToMultiByte (CP_UTF8, WC_ERR_INVALID_CHARS,
28
28
str, -1 ,
@@ -48,7 +48,7 @@ swift::win32::copyUTF8FromWide(const wchar_t *str) {
48
48
}
49
49
50
50
wchar_t *
51
- swift::win32::copyWideFromUTF8 (const char *str) {
51
+ _swift_win32_copyWideFromUTF8 (const char *str) {
52
52
wchar_t *result = nullptr ;
53
53
int len = ::MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
54
54
str, -1 ,
You can’t perform that action at this time.
0 commit comments