comparison src/iscygpty.c @ 18933:82c732e8d23d v8.2.0027

patch 8.2.0027: still some /* */ comments Commit: https://github.com/vim/vim/commit/aa2f0ee639d3b59e4402261ebee27bf545a62d8b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 21 18:47:26 2019 +0100 patch 8.2.0027: still some /* */ comments Problem: Still some /* */ comments. Solution: Convert to // comments.
author Bram Moolenaar <Bram@vim.org>
date Sat, 21 Dec 2019 19:00:03 +0100
parents 8412df1479a3
children faf7fcd1c8d5
comparison
equal deleted inserted replaced
18932:ec2cc19cacf6 18933:82c732e8d23d
33 #include <io.h> 33 #include <io.h>
34 #include <wchar.h> 34 #include <wchar.h>
35 #include <windows.h> 35 #include <windows.h>
36 36
37 #ifdef USE_FILEEXTD 37 #ifdef USE_FILEEXTD
38 /* VC 7.1 or earlier doesn't support SAL. */ 38 // VC 7.1 or earlier doesn't support SAL.
39 # if !defined(_MSC_VER) || (_MSC_VER < 1400) 39 # if !defined(_MSC_VER) || (_MSC_VER < 1400)
40 # define __out 40 # define __out
41 # define __in 41 # define __in
42 # define __in_opt 42 # define __in_opt
43 # endif 43 # endif
44 /* Win32 FileID API Library: 44 // Win32 FileID API Library:
45 * http://www.microsoft.com/en-us/download/details.aspx?id=22599 45 // http://www.microsoft.com/en-us/download/details.aspx?id=22599
46 * Needed for WinXP. */ 46 // Needed for WinXP.
47 # include <fileextd.h> 47 # include <fileextd.h>
48 #else /* USE_FILEEXTD */ 48 #else // USE_FILEEXTD
49 /* VC 8 or earlier. */ 49 // VC 8 or earlier.
50 # if defined(_MSC_VER) && (_MSC_VER < 1500) 50 # if defined(_MSC_VER) && (_MSC_VER < 1500)
51 # ifdef ENABLE_STUB_IMPL 51 # ifdef ENABLE_STUB_IMPL
52 # define STUB_IMPL 52 # define STUB_IMPL
53 # else 53 # else
54 # error "Win32 FileID API Library is required for VC2005 or earlier." 54 # error "Win32 FileID API Library is required for VC2005 or earlier."
55 # endif 55 # endif
56 # endif 56 # endif
57 #endif /* USE_FILEEXTD */ 57 #endif // USE_FILEEXTD
58 58
59 59
60 #include "iscygpty.h" 60 #include "iscygpty.h"
61 61
62 //#define USE_DYNFILEID 62 //#define USE_DYNFILEID
102 102
103 103
104 #define is_wprefix(s, prefix) \ 104 #define is_wprefix(s, prefix) \
105 (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0) 105 (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0)
106 106
107 /* Check if the fd is a cygwin/msys's pty. */ 107 // Check if the fd is a cygwin/msys's pty.
108 int is_cygpty(int fd) 108 int is_cygpty(int fd)
109 { 109 {
110 #ifdef STUB_IMPL 110 #ifdef STUB_IMPL
111 return 0; 111 return 0;
112 #else 112 #else
119 119
120 h = (HANDLE) _get_osfhandle(fd); 120 h = (HANDLE) _get_osfhandle(fd);
121 if (h == INVALID_HANDLE_VALUE) { 121 if (h == INVALID_HANDLE_VALUE) {
122 return 0; 122 return 0;
123 } 123 }
124 /* Cygwin/msys's pty is a pipe. */ 124 // Cygwin/msys's pty is a pipe.
125 if (GetFileType(h) != FILE_TYPE_PIPE) { 125 if (GetFileType(h) != FILE_TYPE_PIPE) {
126 return 0; 126 return 0;
127 } 127 }
128 nameinfo = malloc(size + sizeof(WCHAR)); 128 nameinfo = malloc(size + sizeof(WCHAR));
129 if (nameinfo == NULL) { 129 if (nameinfo == NULL) {
130 return 0; 130 return 0;
131 } 131 }
132 /* Check the name of the pipe: 132 // Check the name of the pipe:
133 * '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */ 133 // '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master'
134 if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) { 134 if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) {
135 nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0'; 135 nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0';
136 p = nameinfo->FileName; 136 p = nameinfo->FileName;
137 if (is_wprefix(p, L"\\cygwin-")) { /* Cygwin */ 137 if (is_wprefix(p, L"\\cygwin-")) { // Cygwin
138 p += 8; 138 p += 8;
139 } else if (is_wprefix(p, L"\\msys-")) { /* MSYS and MSYS2 */ 139 } else if (is_wprefix(p, L"\\msys-")) { // MSYS and MSYS2
140 p += 6; 140 p += 6;
141 } else { 141 } else {
142 p = NULL; 142 p = NULL;
143 } 143 }
144 if (p != NULL) { 144 if (p != NULL) {
145 while (*p && isxdigit(*p)) /* Skip 16-digit hexadecimal. */ 145 while (*p && isxdigit(*p)) // Skip 16-digit hexadecimal.
146 ++p; 146 ++p;
147 if (is_wprefix(p, L"-pty")) { 147 if (is_wprefix(p, L"-pty")) {
148 p += 4; 148 p += 4;
149 } else { 149 } else {
150 p = NULL; 150 p = NULL;
151 } 151 }
152 } 152 }
153 if (p != NULL) { 153 if (p != NULL) {
154 while (*p && isdigit(*p)) /* Skip pty number. */ 154 while (*p && isdigit(*p)) // Skip pty number.
155 ++p; 155 ++p;
156 if (is_wprefix(p, L"-from-master")) { 156 if (is_wprefix(p, L"-from-master")) {
157 //p += 12; 157 //p += 12;
158 } else if (is_wprefix(p, L"-to-master")) { 158 } else if (is_wprefix(p, L"-to-master")) {
159 //p += 10; 159 //p += 10;
162 } 162 }
163 } 163 }
164 } 164 }
165 free(nameinfo); 165 free(nameinfo);
166 return (p != NULL); 166 return (p != NULL);
167 #endif /* STUB_IMPL */ 167 #endif // STUB_IMPL
168 } 168 }
169 169
170 /* Check if at least one cygwin/msys pty is used. */ 170 // Check if at least one cygwin/msys pty is used.
171 int is_cygpty_used(void) 171 int is_cygpty_used(void)
172 { 172 {
173 int fd, ret = 0; 173 int fd, ret = 0;
174 174
175 for (fd = 0; fd < 3; fd++) { 175 for (fd = 0; fd < 3; fd++) {
176 ret |= is_cygpty(fd); 176 ret |= is_cygpty(fd);
177 } 177 }
178 return ret; 178 return ret;
179 } 179 }
180 180
181 #endif /* _WIN32 */ 181 #endif // _WIN32
182 182
183 /* vim: set ts=4 sw=4: */ 183 // vim: set ts=4 sw=4: