Mercurial > vim
annotate src/iscygpty.c @ 20170:0612c64a2b87 v8.2.0640
patch 8.2.0640: Vim9: expanding does not work
Commit: https://github.com/vim/vim/commit/cfe435d7feacf123ac060747b885f7c4328062ea
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 25 20:02:55 2020 +0200
patch 8.2.0640: Vim9: expanding does not work
Problem: Vim9: expanding does not work.
Solution: Find wildcards in not compiled commands. Reorganize test files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Apr 2020 20:15:03 +0200 |
parents | 82c732e8d23d |
children | faf7fcd1c8d5 |
rev | line source |
---|---|
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 /* |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * iscygpty.c -- part of ptycheck |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * https://github.com/k-takata/ptycheck |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * |
12301
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5 * Copyright (c) 2015-2017 K.Takata |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 * You can redistribute it and/or modify it under the terms of either |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 * the MIT license (as described below) or the Vim license. |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 * |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 * Permission is hereby granted, free of charge, to any person obtaining |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 * a copy of this software and associated documentation files (the |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 * "Software"), to deal in the Software without restriction, including |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 * without limitation the rights to use, copy, modify, merge, publish, |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 * distribute, sublicense, and/or sell copies of the Software, and to |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 * permit persons to whom the Software is furnished to do so, subject to |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 * the following conditions: |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 * |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 * The above copyright notice and this permission notice shall be |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 * included in all copies or substantial portions of the Software. |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 * |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 */ |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
12301
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
30 #ifdef _WIN32 |
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
31 |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 #include <ctype.h> |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 #include <io.h> |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 #include <wchar.h> |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 #include <windows.h> |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 #ifdef USE_FILEEXTD |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
38 // VC 7.1 or earlier doesn't support SAL. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 # if !defined(_MSC_VER) || (_MSC_VER < 1400) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 # define __out |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 # define __in |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 # define __in_opt |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 # endif |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
44 // Win32 FileID API Library: |
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
45 // http://www.microsoft.com/en-us/download/details.aspx?id=22599 |
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
46 // Needed for WinXP. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 # include <fileextd.h> |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
48 #else // USE_FILEEXTD |
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
49 // VC 8 or earlier. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 # if defined(_MSC_VER) && (_MSC_VER < 1500) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 # ifdef ENABLE_STUB_IMPL |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 # define STUB_IMPL |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 # else |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 # error "Win32 FileID API Library is required for VC2005 or earlier." |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 # endif |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 # endif |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
57 #endif // USE_FILEEXTD |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 #include "iscygpty.h" |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 //#define USE_DYNFILEID |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 #ifdef USE_DYNFILEID |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)( |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
65 HANDLE hFile, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
66 FILE_INFO_BY_HANDLE_CLASS FileInformationClass, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
67 LPVOID lpFileInformation, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
68 DWORD dwBufferSize); |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 # ifndef USE_FILEEXTD |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 static BOOL WINAPI stub_GetFileInformationByHandleEx( |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
73 HANDLE hFile, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
74 FILE_INFO_BY_HANDLE_CLASS FileInformationClass, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
75 LPVOID lpFileInformation, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12301
diff
changeset
|
76 DWORD dwBufferSize) |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 return FALSE; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 # endif |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 static void setup_fileid_api(void) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 if (pGetFileInformationByHandleEx != NULL) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 return; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 "GetFileInformationByHandleEx"); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 if (pGetFileInformationByHandleEx == NULL) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 # ifdef USE_FILEEXTD |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 pGetFileInformationByHandleEx = GetFileInformationByHandleEx; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 # else |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 pGetFileInformationByHandleEx = stub_GetFileInformationByHandleEx; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 # endif |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 #else |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 # define pGetFileInformationByHandleEx GetFileInformationByHandleEx |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 # define setup_fileid_api() |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 #endif |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 #define is_wprefix(s, prefix) \ |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
107 // Check if the fd is a cygwin/msys's pty. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 int is_cygpty(int fd) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 #ifdef STUB_IMPL |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 return 0; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 #else |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 HANDLE h; |
12301
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
114 int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1); |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 FILE_NAME_INFO *nameinfo; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 WCHAR *p = NULL; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 setup_fileid_api(); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 h = (HANDLE) _get_osfhandle(fd); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 if (h == INVALID_HANDLE_VALUE) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 return 0; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 } |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
124 // Cygwin/msys's pty is a pipe. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 if (GetFileType(h) != FILE_TYPE_PIPE) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 return 0; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 } |
12301
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
128 nameinfo = malloc(size + sizeof(WCHAR)); |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 if (nameinfo == NULL) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 return 0; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 } |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
132 // Check the name of the pipe: |
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
133 // '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0'; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 p = nameinfo->FileName; |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
137 if (is_wprefix(p, L"\\cygwin-")) { // Cygwin |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 p += 8; |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
139 } else if (is_wprefix(p, L"\\msys-")) { // MSYS and MSYS2 |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 p += 6; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 } else { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 p = NULL; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 if (p != NULL) { |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
145 while (*p && isxdigit(*p)) // Skip 16-digit hexadecimal. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 ++p; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 if (is_wprefix(p, L"-pty")) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 p += 4; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 } else { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 p = NULL; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 if (p != NULL) { |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
154 while (*p && isdigit(*p)) // Skip pty number. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 ++p; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 if (is_wprefix(p, L"-from-master")) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 //p += 12; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 } else if (is_wprefix(p, L"-to-master")) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 //p += 10; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 } else { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 p = NULL; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 free(nameinfo); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 return (p != NULL); |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
167 #endif // STUB_IMPL |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
170 // Check if at least one cygwin/msys pty is used. |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 int is_cygpty_used(void) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 int fd, ret = 0; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 for (fd = 0; fd < 3; fd++) { |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 ret |= is_cygpty(fd); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 return ret; |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
181 #endif // _WIN32 |
12301
93155ae168fb
patch 8.0.1030: MS-Windows: wrong size computation in is_cygpty()
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
182 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
13353
diff
changeset
|
183 // vim: set ts=4 sw=4: |