| author | |
| committer | |
| log | 7b73c7fe12e96de1be92b27474048566244f98c4 |
| tree | ca5d8811921d113bfbfeb88721e4635d904d0762 |
| parent | e2e9be5deac75e102bc5faaa94aa17308224f9f6 |
| parent | 2662e50d27006396a4b6c776dc757e883b836fcc |
| signature | Commit is signed but in an unrecognized format. |
13 files changed, 53 insertions(+), 64 deletions(-)
lib/std/child_process.zig+2-4| ... | ... | @@ -582,9 +582,7 @@ pub const ChildProcess = struct { |
| 582 | 582 | }; |
| 583 | 583 | var piProcInfo: windows.PROCESS_INFORMATION = undefined; |
| 584 | 584 | |
| 585 | const cwd_slice = if (self.cwd) |cwd| try cstr.addNullByte(self.allocator, cwd) else null; | |
| 586 | defer if (cwd_slice) |cwd| self.allocator.free(cwd); | |
| 587 | const cwd_w = if (cwd_slice) |cwd| try unicode.utf8ToUtf16LeWithNull(self.allocator, cwd) else null; | |
| 585 | const cwd_w = if (self.cwd) |cwd| try unicode.utf8ToUtf16LeWithNull(self.allocator, cwd) else null; | |
| 588 | 586 | defer if (cwd_w) |cwd| self.allocator.free(cwd); |
| 589 | 587 | const cwd_w_ptr = if (cwd_w) |cwd| cwd.ptr else null; |
| 590 | 588 | |
| ... | ... | @@ -701,7 +699,7 @@ pub const ChildProcess = struct { |
| 701 | 699 | } |
| 702 | 700 | }; |
| 703 | 701 | |
| 704 | fn windowsCreateProcess(app_name: [*]u16, cmd_line: [*]u16, envp_ptr: ?[*]u16, cwd_ptr: ?[*]u16, lpStartupInfo: *windows.STARTUPINFOW, lpProcessInformation: *windows.PROCESS_INFORMATION) !void { | |
| 702 | fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u16, cwd_ptr: ?[*:0]u16, lpStartupInfo: *windows.STARTUPINFOW, lpProcessInformation: *windows.PROCESS_INFORMATION) !void { | |
| 705 | 703 | // TODO the docs for environment pointer say: |
| 706 | 704 | // > A pointer to the environment block for the new process. If this parameter |
| 707 | 705 | // > is NULL, the new process uses the environment of the calling process. |
lib/std/fs/file.zig+1-1| ... | ... | @@ -60,7 +60,7 @@ pub const File = struct { |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// Deprecated; call `std.fs.Dir.openFileW` directly. |
| 63 | pub fn openReadW(path_w: [*]const u16) OpenError!File { | |
| 63 | pub fn openReadW(path_w: [*:0]const u16) OpenError!File { | |
| 64 | 64 | return std.fs.cwd().openFileW(path_w, .{}); |
| 65 | 65 | } |
| 66 | 66 |
lib/std/fs/get_app_data_dir.zig+2-8| ... | ... | @@ -15,7 +15,7 @@ pub const GetAppDataDirError = error{ |
| 15 | 15 | pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataDirError![]u8 { |
| 16 | 16 | switch (builtin.os) { |
| 17 | 17 | .windows => { |
| 18 | var dir_path_ptr: [*]u16 = undefined; | |
| 18 | var dir_path_ptr: [*:0]u16 = undefined; | |
| 19 | 19 | switch (os.windows.shell32.SHGetKnownFolderPath( |
| 20 | 20 | &os.windows.FOLDERID_LocalAppData, |
| 21 | 21 | os.windows.KF_FLAG_CREATE, |
| ... | ... | @@ -24,7 +24,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 24 | 24 | )) { |
| 25 | 25 | os.windows.S_OK => { |
| 26 | 26 | defer os.windows.ole32.CoTaskMemFree(@ptrCast(*c_void, dir_path_ptr)); |
| 27 | const global_dir = unicode.utf16leToUtf8Alloc(allocator, utf16lePtrSlice(dir_path_ptr)) catch |err| switch (err) { | |
| 27 | const global_dir = unicode.utf16leToUtf8Alloc(allocator, mem.toSliceConst(u16, dir_path_ptr)) catch |err| switch (err) { | |
| 28 | 28 | error.UnexpectedSecondSurrogateHalf => return error.AppDataDirUnavailable, |
| 29 | 29 | error.ExpectedSecondSurrogateHalf => return error.AppDataDirUnavailable, |
| 30 | 30 | error.DanglingSurrogateHalf => return error.AppDataDirUnavailable, |
| ... | ... | @@ -55,12 +55,6 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | fn utf16lePtrSlice(ptr: [*]const u16) []const u16 { | |
| 59 | var index: usize = 0; | |
| 60 | while (ptr[index] != 0) : (index += 1) {} | |
| 61 | return ptr[0..index]; | |
| 62 | } | |
| 63 | ||
| 64 | 58 | test "getAppDataDir" { |
| 65 | 59 | var buf: [512]u8 = undefined; |
| 66 | 60 | const allocator = &std.heap.FixedBufferAllocator.init(buf[0..]).allocator; |
lib/std/os.zig+1-3| ... | ... | @@ -2632,9 +2632,7 @@ pub fn realpathW(pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BYTES]u8) Real |
| 2632 | 2632 | defer windows.CloseHandle(h_file); |
| 2633 | 2633 | |
| 2634 | 2634 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; |
| 2635 | const wide_len = try windows.GetFinalPathNameByHandleW(h_file, &wide_buf, wide_buf.len, windows.VOLUME_NAME_DOS); | |
| 2636 | assert(wide_len <= wide_buf.len); | |
| 2637 | const wide_slice = wide_buf[0..wide_len]; | |
| 2635 | const wide_slice = try windows.GetFinalPathNameByHandleW(h_file, &wide_buf, wide_buf.len, windows.VOLUME_NAME_DOS); | |
| 2638 | 2636 | |
| 2639 | 2637 | // Windows returns \\?\ prepended to the path. |
| 2640 | 2638 | // We strip it to make this function consistent across platforms. |
lib/std/os/uefi/protocols/simple_text_output_protocol.zig+4-4| ... | ... | @@ -4,8 +4,8 @@ const Guid = uefi.Guid; |
| 4 | 4 | /// Character output devices |
| 5 | 5 | pub const SimpleTextOutputProtocol = extern struct { |
| 6 | 6 | _reset: extern fn (*const SimpleTextOutputProtocol, bool) usize, |
| 7 | _output_string: extern fn (*const SimpleTextOutputProtocol, [*]const u16) usize, | |
| 8 | _test_string: extern fn (*const SimpleTextOutputProtocol, [*]const u16) usize, | |
| 7 | _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) usize, | |
| 8 | _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) usize, | |
| 9 | 9 | _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) usize, |
| 10 | 10 | _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) usize, |
| 11 | 11 | _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) usize, |
| ... | ... | @@ -20,12 +20,12 @@ pub const SimpleTextOutputProtocol = extern struct { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /// Writes a string to the output device. |
| 23 | pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*]const u16) usize { | |
| 23 | pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) usize { | |
| 24 | 24 | return self._output_string(self, msg); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /// Verifies that all characters in a string can be output to the target device. |
| 28 | pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*]const u16) usize { | |
| 28 | pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) usize { | |
| 29 | 29 | return self._test_string(self, msg); |
| 30 | 30 | } |
| 31 | 31 |
lib/std/os/uefi/tables/runtime_services.zig+2-2| ... | ... | @@ -25,13 +25,13 @@ pub const RuntimeServices = extern struct { |
| 25 | 25 | convertPointer: usize, // TODO |
| 26 | 26 | |
| 27 | 27 | /// Returns the value of a variable. |
| 28 | getVariable: extern fn ([*]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize, | |
| 28 | getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize, | |
| 29 | 29 | |
| 30 | 30 | /// Enumerates the current variable names. |
| 31 | 31 | getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize, |
| 32 | 32 | |
| 33 | 33 | /// Sets the value of a variable. |
| 34 | setVariable: extern fn ([*]const u16, *align(8) const Guid, u32, usize, *c_void) usize, | |
| 34 | setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) usize, | |
| 35 | 35 | |
| 36 | 36 | getNextHighMonotonicCount: usize, // TODO |
| 37 | 37 |
lib/std/os/uefi/tables/system_table.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ pub const SystemTable = extern struct { |
| 19 | 19 | hdr: TableHeader, |
| 20 | 20 | |
| 21 | 21 | /// A null-terminated string that identifies the vendor that produces the system firmware of the platform. |
| 22 | firmware_vendor: [*]u16, | |
| 22 | firmware_vendor: [*:0]u16, | |
| 23 | 23 | firmware_revision: u32, |
| 24 | 24 | console_in_handle: ?Handle, |
| 25 | 25 | con_in: ?*SimpleTextInputProtocol, |
lib/std/os/windows.zig+16-16| ... | ... | @@ -60,7 +60,7 @@ pub fn CreateFile( |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | pub fn CreateFileW( |
| 63 | file_path_w: [*]const u16, | |
| 63 | file_path_w: [*:0]const u16, | |
| 64 | 64 | desired_access: DWORD, |
| 65 | 65 | share_mode: DWORD, |
| 66 | 66 | lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES, |
| ... | ... | @@ -425,8 +425,8 @@ pub fn CreateSymbolicLink( |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | pub fn CreateSymbolicLinkW( |
| 428 | sym_link_path: [*]const u16, | |
| 429 | target_path: [*]const u16, | |
| 428 | sym_link_path: [*:0]const u16, | |
| 429 | target_path: [*:0]const u16, | |
| 430 | 430 | flags: DWORD, |
| 431 | 431 | ) CreateSymbolicLinkError!void { |
| 432 | 432 | if (kernel32.CreateSymbolicLinkW(sym_link_path, target_path, flags) == 0) { |
| ... | ... | @@ -449,7 +449,7 @@ pub fn DeleteFile(filename: []const u8) DeleteFileError!void { |
| 449 | 449 | return DeleteFileW(&filename_w); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | pub fn DeleteFileW(filename: [*]const u16) DeleteFileError!void { | |
| 452 | pub fn DeleteFileW(filename: [*:0]const u16) DeleteFileError!void { | |
| 453 | 453 | if (kernel32.DeleteFileW(filename) == 0) { |
| 454 | 454 | switch (kernel32.GetLastError()) { |
| 455 | 455 | ERROR.FILE_NOT_FOUND => return error.FileNotFound, |
| ... | ... | @@ -471,7 +471,7 @@ pub fn MoveFileEx(old_path: []const u8, new_path: []const u8, flags: DWORD) Move |
| 471 | 471 | return MoveFileExW(&old_path_w, &new_path_w, flags); |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | pub fn MoveFileExW(old_path: [*]const u16, new_path: [*]const u16, flags: DWORD) MoveFileError!void { | |
| 474 | pub fn MoveFileExW(old_path: [*:0]const u16, new_path: [*:0]const u16, flags: DWORD) MoveFileError!void { | |
| 475 | 475 | if (kernel32.MoveFileExW(old_path, new_path, flags) == 0) { |
| 476 | 476 | switch (kernel32.GetLastError()) { |
| 477 | 477 | else => |err| return unexpectedError(err), |
| ... | ... | @@ -490,7 +490,7 @@ pub fn CreateDirectory(pathname: []const u8, attrs: ?*SECURITY_ATTRIBUTES) Creat |
| 490 | 490 | return CreateDirectoryW(&pathname_w, attrs); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | pub fn CreateDirectoryW(pathname: [*]const u16, attrs: ?*SECURITY_ATTRIBUTES) CreateDirectoryError!void { | |
| 493 | pub fn CreateDirectoryW(pathname: [*:0]const u16, attrs: ?*SECURITY_ATTRIBUTES) CreateDirectoryError!void { | |
| 494 | 494 | if (kernel32.CreateDirectoryW(pathname, attrs) == 0) { |
| 495 | 495 | switch (kernel32.GetLastError()) { |
| 496 | 496 | ERROR.ALREADY_EXISTS => return error.PathAlreadyExists, |
| ... | ... | @@ -511,7 +511,7 @@ pub fn RemoveDirectory(dir_path: []const u8) RemoveDirectoryError!void { |
| 511 | 511 | return RemoveDirectoryW(&dir_path_w); |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | pub fn RemoveDirectoryW(dir_path_w: [*]const u16) RemoveDirectoryError!void { | |
| 514 | pub fn RemoveDirectoryW(dir_path_w: [*:0]const u16) RemoveDirectoryError!void { | |
| 515 | 515 | if (kernel32.RemoveDirectoryW(dir_path_w) == 0) { |
| 516 | 516 | switch (kernel32.GetLastError()) { |
| 517 | 517 | ERROR.PATH_NOT_FOUND => return error.FileNotFound, |
| ... | ... | @@ -602,7 +602,7 @@ pub fn GetFinalPathNameByHandleW( |
| 602 | 602 | buf_ptr: [*]u16, |
| 603 | 603 | buf_len: DWORD, |
| 604 | 604 | flags: DWORD, |
| 605 | ) GetFinalPathNameByHandleError!DWORD { | |
| 605 | ) GetFinalPathNameByHandleError![:0]u16 { | |
| 606 | 606 | const rc = kernel32.GetFinalPathNameByHandleW(hFile, buf_ptr, buf_len, flags); |
| 607 | 607 | if (rc == 0) { |
| 608 | 608 | switch (kernel32.GetLastError()) { |
| ... | ... | @@ -614,7 +614,7 @@ pub fn GetFinalPathNameByHandleW( |
| 614 | 614 | else => |err| return unexpectedError(err), |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | return rc; | |
| 617 | return buf_ptr[0..rc :0]; | |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | pub const GetFileSizeError = error{Unexpected}; |
| ... | ... | @@ -640,7 +640,7 @@ pub fn GetFileAttributes(filename: []const u8) GetFileAttributesError!DWORD { |
| 640 | 640 | return GetFileAttributesW(&filename_w); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | pub fn GetFileAttributesW(lpFileName: [*]const u16) GetFileAttributesError!DWORD { | |
| 643 | pub fn GetFileAttributesW(lpFileName: [*:0]const u16) GetFileAttributesError!DWORD { | |
| 644 | 644 | const rc = kernel32.GetFileAttributesW(lpFileName); |
| 645 | 645 | if (rc == INVALID_FILE_ATTRIBUTES) { |
| 646 | 646 | switch (kernel32.GetLastError()) { |
| ... | ... | @@ -733,14 +733,14 @@ pub fn WSAIoctl( |
| 733 | 733 | |
| 734 | 734 | const GetModuleFileNameError = error{Unexpected}; |
| 735 | 735 | |
| 736 | pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) GetModuleFileNameError![]u16 { | |
| 736 | pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) GetModuleFileNameError![:0]u16 { | |
| 737 | 737 | const rc = kernel32.GetModuleFileNameW(hModule, buf_ptr, buf_len); |
| 738 | 738 | if (rc == 0) { |
| 739 | 739 | switch (kernel32.GetLastError()) { |
| 740 | 740 | else => |err| return unexpectedError(err), |
| 741 | 741 | } |
| 742 | 742 | } |
| 743 | return buf_ptr[0..rc]; | |
| 743 | return buf_ptr[0..rc :0]; | |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | pub const TerminateProcessError = error{Unexpected}; |
| ... | ... | @@ -779,11 +779,11 @@ pub fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) SetCon |
| 779 | 779 | |
| 780 | 780 | pub const GetEnvironmentStringsError = error{OutOfMemory}; |
| 781 | 781 | |
| 782 | pub fn GetEnvironmentStringsW() GetEnvironmentStringsError![*]u16 { | |
| 782 | pub fn GetEnvironmentStringsW() GetEnvironmentStringsError![*:0]u16 { | |
| 783 | 783 | return kernel32.GetEnvironmentStringsW() orelse return error.OutOfMemory; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | pub fn FreeEnvironmentStringsW(penv: [*]u16) void { | |
| 786 | pub fn FreeEnvironmentStringsW(penv: [*:0]u16) void { | |
| 787 | 787 | assert(kernel32.FreeEnvironmentStringsW(penv) != 0); |
| 788 | 788 | } |
| 789 | 789 | |
| ... | ... | @@ -792,7 +792,7 @@ pub const GetEnvironmentVariableError = error{ |
| 792 | 792 | Unexpected, |
| 793 | 793 | }; |
| 794 | 794 | |
| 795 | pub fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) GetEnvironmentVariableError!DWORD { | |
| 795 | pub fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) GetEnvironmentVariableError!DWORD { | |
| 796 | 796 | const rc = kernel32.GetEnvironmentVariableW(lpName, lpBuffer, nSize); |
| 797 | 797 | if (rc == 0) { |
| 798 | 798 | switch (kernel32.GetLastError()) { |
| ... | ... | @@ -850,7 +850,7 @@ pub const LoadLibraryError = error{ |
| 850 | 850 | Unexpected, |
| 851 | 851 | }; |
| 852 | 852 | |
| 853 | pub fn LoadLibraryW(lpLibFileName: [*]const u16) LoadLibraryError!HMODULE { | |
| 853 | pub fn LoadLibraryW(lpLibFileName: [*:0]const u16) LoadLibraryError!HMODULE { | |
| 854 | 854 | return kernel32.LoadLibraryW(lpLibFileName) orelse { |
| 855 | 855 | switch (kernel32.GetLastError()) { |
| 856 | 856 | ERROR.FILE_NOT_FOUND => return error.FileNotFound, |
lib/std/os/windows/bits.zig+6-6| ... | ... | @@ -33,17 +33,17 @@ pub const FARPROC = *@OpaqueType(); |
| 33 | 33 | pub const INT = c_int; |
| 34 | 34 | pub const LPBYTE = *BYTE; |
| 35 | 35 | pub const LPCH = *CHAR; |
| 36 | pub const LPCSTR = [*]const CHAR; | |
| 37 | pub const LPCTSTR = [*]const TCHAR; | |
| 36 | pub const LPCSTR = [*:0]const CHAR; | |
| 37 | pub const LPCTSTR = [*:0]const TCHAR; | |
| 38 | 38 | pub const LPCVOID = *const c_void; |
| 39 | 39 | pub const LPDWORD = *DWORD; |
| 40 | pub const LPSTR = [*]CHAR; | |
| 40 | pub const LPSTR = [*:0]CHAR; | |
| 41 | 41 | pub const LPTSTR = if (UNICODE) LPWSTR else LPSTR; |
| 42 | 42 | pub const LPVOID = *c_void; |
| 43 | pub const LPWSTR = [*]WCHAR; | |
| 44 | pub const LPCWSTR = [*]const WCHAR; | |
| 43 | pub const LPWSTR = [*:0]WCHAR; | |
| 44 | pub const LPCWSTR = [*:0]const WCHAR; | |
| 45 | 45 | pub const PVOID = *c_void; |
| 46 | pub const PWSTR = [*]WCHAR; | |
| 46 | pub const PWSTR = [*:0]WCHAR; | |
| 47 | 47 | pub const SIZE_T = usize; |
| 48 | 48 | pub const TCHAR = if (UNICODE) WCHAR else u8; |
| 49 | 49 | pub const UINT = c_uint; |
lib/std/os/windows/kernel32.zig+13-13| ... | ... | @@ -7,7 +7,7 @@ pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) c |
| 7 | 7 | |
| 8 | 8 | pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.Stdcall) BOOL; |
| 9 | 9 | |
| 10 | pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL; | |
| 10 | pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL; | |
| 11 | 11 | |
| 12 | 12 | pub extern "kernel32" fn CreateEventExW( |
| 13 | 13 | lpEventAttributes: ?*SECURITY_ATTRIBUTES, |
| ... | ... | @@ -17,7 +17,7 @@ pub extern "kernel32" fn CreateEventExW( |
| 17 | 17 | ) callconv(.Stdcall) ?HANDLE; |
| 18 | 18 | |
| 19 | 19 | pub extern "kernel32" fn CreateFileW( |
| 20 | lpFileName: [*]const u16, // TODO null terminated pointer type | |
| 20 | lpFileName: [*:0]const u16, | |
| 21 | 21 | dwDesiredAccess: DWORD, |
| 22 | 22 | dwShareMode: DWORD, |
| 23 | 23 | lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES, |
| ... | ... | @@ -46,7 +46,7 @@ pub extern "kernel32" fn CreateProcessW( |
| 46 | 46 | lpProcessInformation: *PROCESS_INFORMATION, |
| 47 | 47 | ) callconv(.Stdcall) BOOL; |
| 48 | 48 | |
| 49 | pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*]const u16, lpTargetFileName: [*]const u16, dwFlags: DWORD) callconv(.Stdcall) BOOLEAN; | |
| 49 | pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*:0]const u16, lpTargetFileName: [*:0]const u16, dwFlags: DWORD) callconv(.Stdcall) BOOLEAN; | |
| 50 | 50 | |
| 51 | 51 | pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(.Stdcall) ?HANDLE; |
| 52 | 52 | |
| ... | ... | @@ -63,19 +63,19 @@ pub extern "kernel32" fn DeviceIoControl( |
| 63 | 63 | lpOverlapped: ?*OVERLAPPED, |
| 64 | 64 | ) callconv(.Stdcall) BOOL; |
| 65 | 65 | |
| 66 | pub extern "kernel32" fn DeleteFileW(lpFileName: [*]const u16) callconv(.Stdcall) BOOL; | |
| 66 | pub extern "kernel32" fn DeleteFileW(lpFileName: [*:0]const u16) callconv(.Stdcall) BOOL; | |
| 67 | 67 | |
| 68 | 68 | pub extern "kernel32" fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) callconv(.Stdcall) BOOL; |
| 69 | 69 | |
| 70 | 70 | pub extern "kernel32" fn ExitProcess(exit_code: UINT) callconv(.Stdcall) noreturn; |
| 71 | 71 | |
| 72 | pub extern "kernel32" fn FindFirstFileW(lpFileName: [*]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) HANDLE; | |
| 72 | pub extern "kernel32" fn FindFirstFileW(lpFileName: [*:0]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) HANDLE; | |
| 73 | 73 | pub extern "kernel32" fn FindClose(hFindFile: HANDLE) callconv(.Stdcall) BOOL; |
| 74 | 74 | pub extern "kernel32" fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) BOOL; |
| 75 | 75 | |
| 76 | pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) callconv(.Stdcall) DWORD; | |
| 76 | pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: [*]u16, nSize: DWORD, Arguments: ?*va_list) callconv(.Stdcall) DWORD; | |
| 77 | 77 | |
| 78 | pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*]u16) callconv(.Stdcall) BOOL; | |
| 78 | pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*:0]u16) callconv(.Stdcall) BOOL; | |
| 79 | 79 | |
| 80 | 80 | pub extern "kernel32" fn GetCommandLineA() callconv(.Stdcall) LPSTR; |
| 81 | 81 | |
| ... | ... | @@ -88,9 +88,9 @@ pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[ |
| 88 | 88 | pub extern "kernel32" fn GetCurrentThread() callconv(.Stdcall) HANDLE; |
| 89 | 89 | pub extern "kernel32" fn GetCurrentThreadId() callconv(.Stdcall) DWORD; |
| 90 | 90 | |
| 91 | pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.Stdcall) ?[*]u16; | |
| 91 | pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.Stdcall) ?[*:0]u16; | |
| 92 | 92 | |
| 93 | pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD; | |
| 93 | pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) callconv(.Stdcall) DWORD; | |
| 94 | 94 | |
| 95 | 95 | pub extern "kernel32" fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) callconv(.Stdcall) BOOL; |
| 96 | 96 | |
| ... | ... | @@ -150,8 +150,8 @@ pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllo |
| 150 | 150 | pub extern "kernel32" fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) callconv(.Stdcall) BOOL; |
| 151 | 151 | |
| 152 | 152 | pub extern "kernel32" fn MoveFileExW( |
| 153 | lpExistingFileName: [*]const u16, | |
| 154 | lpNewFileName: [*]const u16, | |
| 153 | lpExistingFileName: [*:0]const u16, | |
| 154 | lpNewFileName: [*:0]const u16, | |
| 155 | 155 | dwFlags: DWORD, |
| 156 | 156 | ) callconv(.Stdcall) BOOL; |
| 157 | 157 | |
| ... | ... | @@ -180,7 +180,7 @@ pub extern "kernel32" fn ReadFile( |
| 180 | 180 | in_out_lpOverlapped: ?*OVERLAPPED, |
| 181 | 181 | ) callconv(.Stdcall) BOOL; |
| 182 | 182 | |
| 183 | pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*]const u16) callconv(.Stdcall) BOOL; | |
| 183 | pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*:0]const u16) callconv(.Stdcall) BOOL; | |
| 184 | 184 | |
| 185 | 185 | pub extern "kernel32" fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) callconv(.Stdcall) BOOL; |
| 186 | 186 | |
| ... | ... | @@ -234,7 +234,7 @@ pub extern "kernel32" fn WriteFile( |
| 234 | 234 | |
| 235 | 235 | pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(.Stdcall) BOOL; |
| 236 | 236 | |
| 237 | pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*]const u16) callconv(.Stdcall) ?HMODULE; | |
| 237 | pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*:0]const u16) callconv(.Stdcall) ?HMODULE; | |
| 238 | 238 | |
| 239 | 239 | pub extern "kernel32" fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) callconv(.Stdcall) ?FARPROC; |
| 240 | 240 |
lib/std/os/windows/ntdll.zig+2-2| ... | ... | @@ -35,9 +35,9 @@ pub extern "NtDll" fn NtDeviceIoControlFile( |
| 35 | 35 | ) callconv(.Stdcall) NTSTATUS; |
| 36 | 36 | pub extern "NtDll" fn NtClose(Handle: HANDLE) callconv(.Stdcall) NTSTATUS; |
| 37 | 37 | pub extern "NtDll" fn RtlDosPathNameToNtPathName_U( |
| 38 | DosPathName: [*]const u16, | |
| 38 | DosPathName: [*:0]const u16, | |
| 39 | 39 | NtPathName: *UNICODE_STRING, |
| 40 | NtFileNamePart: ?*?[*]const u16, | |
| 40 | NtFileNamePart: ?*?[*:0]const u16, | |
| 41 | 41 | DirectoryInfo: ?*CURDIR, |
| 42 | 42 | ) callconv(.Stdcall) BOOL; |
| 43 | 43 | pub extern "NtDll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.Stdcall) void; |
lib/std/os/windows/shell32.zig+1-1| ... | ... | @@ -1,3 +1,3 @@ |
| 1 | 1 | usingnamespace @import("bits.zig"); |
| 2 | 2 | |
| 3 | pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) callconv(.Stdcall) HRESULT; | |
| 3 | pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*:0]WCHAR) callconv(.Stdcall) HRESULT; |
lib/std/unicode.zig+2-3| ... | ... | @@ -544,8 +544,7 @@ test "utf16leToUtf8" { |
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | /// TODO type for null terminated pointer | |
| 548 | pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![]u16 { | |
| 547 | pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u16 { | |
| 549 | 548 | var result = std.ArrayList(u16).init(allocator); |
| 550 | 549 | // optimistically guess that it will not require surrogate pairs |
| 551 | 550 | try result.ensureCapacity(utf8.len + 1); |
| ... | ... | @@ -567,7 +566,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![]u16 |
| 567 | 566 | } |
| 568 | 567 | |
| 569 | 568 | try result.append(0); |
| 570 | return result.toOwnedSlice(); | |
| 569 | return result.toOwnedSlice()[0..:0]; | |
| 571 | 570 | } |
| 572 | 571 | |
| 573 | 572 | /// Returns index of next character. If exact fit, returned index equals output slice length. |