| author | |
| committer | |
| log | 102d3f30c406e2818c6320a48f2405fa7e1e4237 |
| tree | 975dd34f14528cff0bd57fa2fc8e08479a11ccff |
| parent | f15ec9a59b777a2b7998518858f11f5da0dfcb2d |
4 files changed, 13 insertions(+), 9 deletions(-)
src/os.cpp+4-4| ... | ... | @@ -1130,7 +1130,7 @@ Error os_get_cwd(Buf *out_cwd) { |
| 1130 | 1130 | bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) { |
| 1131 | 1131 | #if defined(ZIG_OS_WINDOWS) |
| 1132 | 1132 | HANDLE handle = (HANDLE)_get_osfhandle(fd); |
| 1133 | ||
| 1133 | ||
| 1134 | 1134 | // Cygwin/msys's pty is a pipe. |
| 1135 | 1135 | if (handle == INVALID_HANDLE_VALUE || GetFileType(handle) != FILE_TYPE_PIPE) { |
| 1136 | 1136 | return false; |
| ... | ... | @@ -1138,7 +1138,7 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) { |
| 1138 | 1138 | |
| 1139 | 1139 | int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * MAX_PATH; |
| 1140 | 1140 | WCHAR *p = NULL; |
| 1141 | ||
| 1141 | ||
| 1142 | 1142 | FILE_NAME_INFO *nameinfo = (FILE_NAME_INFO *)allocate<char>(size); |
| 1143 | 1143 | if (nameinfo == NULL) { |
| 1144 | 1144 | return false; |
| ... | ... | @@ -1179,13 +1179,13 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) { |
| 1179 | 1179 | free(nameinfo); |
| 1180 | 1180 | return (p != NULL); |
| 1181 | 1181 | #else |
| 1182 | return false | |
| 1182 | return false; | |
| 1183 | 1183 | #endif |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | bool os_stderr_tty(void) { |
| 1187 | 1187 | #if defined(ZIG_OS_WINDOWS) |
| 1188 | return _isatty(_fileno(stderr)) != 0 || os_is_cygwin_pty(_fileno(stderr)); | |
| 1188 | return _isatty(fileno(stderr)) != 0 || os_is_cygwin_pty(fileno(stderr)); | |
| 1189 | 1189 | #elif defined(ZIG_OS_POSIX) |
| 1190 | 1190 | return isatty(STDERR_FILENO) != 0; |
| 1191 | 1191 | #else |
src/os.hpp+5| ... | ... | @@ -89,6 +89,11 @@ struct Termination { |
| 89 | 89 | #define OsFile int |
| 90 | 90 | #endif |
| 91 | 91 | |
| 92 | #if defined(ZIG_OS_WINDOWS) | |
| 93 | #undef fileno | |
| 94 | #define fileno _fileno | |
| 95 | #endif | |
| 96 | ||
| 92 | 97 | struct OsTimeStamp { |
| 93 | 98 | uint64_t sec; |
| 94 | 99 | uint64_t nsec; |
src/target.cpp+1-1| ... | ... | @@ -1507,7 +1507,7 @@ bool target_is_single_threaded(const ZigTarget *target) { |
| 1507 | 1507 | static ZigLLVM_EnvironmentType target_get_win32_abi() { |
| 1508 | 1508 | FILE* files[] = { stdin, stdout, stderr, nullptr }; |
| 1509 | 1509 | for (int i = 0; files[i] != nullptr; i++) { |
| 1510 | if (os_is_cygwin_pty(_fileno(files[i]))) { | |
| 1510 | if (os_is_cygwin_pty(fileno(files[i]))) { | |
| 1511 | 1511 | return ZigLLVM_GNU; |
| 1512 | 1512 | } |
| 1513 | 1513 | } |
std/os/windows.zig+3-4| ... | ... | @@ -65,7 +65,7 @@ pub const CreateFileError = error{ |
| 65 | 65 | InvalidUtf8, |
| 66 | 66 | |
| 67 | 67 | /// On Windows, file paths cannot contain these characters: |
| 68 | /// '/', '*', '?', '"', '<', '>', '|' | |
| 68 | /// '*', '?', '"', '<', '>', '|', and '/' (when the ABI is not GNU) | |
| 69 | 69 | BadPathName, |
| 70 | 70 | |
| 71 | 71 | Unexpected, |
| ... | ... | @@ -831,8 +831,8 @@ pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16) |
| 831 | 831 | // disallow forward slashes in zig std lib file functions on Windows. |
| 832 | 832 | for (s) |byte| { |
| 833 | 833 | switch (byte) { |
| 834 | '/', '*', '?', '"', '<', '>', '|' => return error.BadPathName, | |
| 835 | else => {}, | |
| 834 | '*', '?', '"', '<', '>', '|' => return error.BadPathName, | |
| 835 | else => if (builtin.abi == .msvc and byte == '/') return error.BadPathName, | |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | const start_index = if (mem.startsWith(u8, s, "\\\\") or !std.fs.path.isAbsolute(s)) 0 else blk: { |
| ... | ... | @@ -866,7 +866,6 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError { |
| 866 | 866 | return error.Unexpected; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | ||
| 870 | 869 | /// Call this when you made a windows NtDll call |
| 871 | 870 | /// and you get an unexpected status. |
| 872 | 871 | pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { |