K.Takata's patch queue for Vim
Revision | 9f749a7e9cb1ce042687db43695ea3a16dbcd5e1 (tree) |
---|---|
Zeit | 2022-02-12 21:04:03 |
Autor | K.Takata <kentkt@csc....> |
Commiter | K.Takata |
Update for 8.2.4354
Remove a merged patch. Fix conflicts.
@@ -30,5 +30,4 @@ | ||
30 | 30 | wip-win32-vimdir-encoding.patch #+wip |
31 | 31 | win32-directwrite-ambiwidth-auto.patch |
32 | 32 | suppress-warnings.patch |
33 | -win32-fix-dynamic-sodium.patch | |
34 | 33 | fix-config_cache-removal.patch #+rejected |
@@ -1,264 +0,0 @@ | ||
1 | -# HG changeset patch | |
2 | -# Parent 7604cf51c3c613a91b80861d8434819e7e802f06 | |
3 | - | |
4 | -diff --git a/src/crypt.c b/src/crypt.c | |
5 | ---- a/src/crypt.c | |
6 | -+++ b/src/crypt.c | |
7 | -@@ -162,6 +162,22 @@ typedef struct { | |
8 | - | |
9 | - | |
10 | - # ifdef DYNAMIC_SODIUM | |
11 | -+# ifdef MSWIN | |
12 | -+# define SODIUM_PROC FARPROC | |
13 | -+# define load_dll vimLoadLib | |
14 | -+# define symbol_from_dll GetProcAddress | |
15 | -+# define close_dll FreeLibrary | |
16 | -+# define load_dll_error GetWin32Error | |
17 | -+# else | |
18 | -+# error Dynamic loading of libsodium is not supported for now. | |
19 | -+//# define HINSTANCE void* | |
20 | -+//# define SODIUM_PROC void* | |
21 | -+//# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) | |
22 | -+//# define symbol_from_dll dlsym | |
23 | -+//# define close_dll dlclose | |
24 | -+//# define load_dll_error dlerror | |
25 | -+# endif | |
26 | -+ | |
27 | - # define sodium_init load_sodium | |
28 | - # define sodium_free dll_sodium_free | |
29 | - # define sodium_malloc dll_sodium_malloc | |
30 | -@@ -214,51 +230,70 @@ static void (*dll_randombytes_buf)(void | |
31 | - | |
32 | - static struct { | |
33 | - const char *name; | |
34 | -- FARPROC *ptr; | |
35 | -+ SODIUM_PROC *ptr; | |
36 | - } sodium_funcname_table[] = { | |
37 | -- {"sodium_init", (FARPROC*)&dll_sodium_init}, | |
38 | -- {"sodium_free", (FARPROC*)&dll_sodium_free}, | |
39 | -- {"sodium_malloc", (FARPROC*)&dll_sodium_malloc}, | |
40 | -- {"sodium_memzero", (FARPROC*)&dll_sodium_memzero}, | |
41 | -- {"sodium_mlock", (FARPROC*)&dll_sodium_mlock}, | |
42 | -- {"sodium_munlock", (FARPROC*)&dll_sodium_munlock}, | |
43 | -- {"crypto_secretstream_xchacha20poly1305_init_push", (FARPROC*)&dll_crypto_secretstream_xchacha20poly1305_init_push}, | |
44 | -- {"crypto_secretstream_xchacha20poly1305_push", (FARPROC*)&dll_crypto_secretstream_xchacha20poly1305_push}, | |
45 | -- {"crypto_secretstream_xchacha20poly1305_init_pull", (FARPROC*)&dll_crypto_secretstream_xchacha20poly1305_init_pull}, | |
46 | -- {"crypto_secretstream_xchacha20poly1305_pull", (FARPROC*)&dll_crypto_secretstream_xchacha20poly1305_pull}, | |
47 | -- {"crypto_pwhash", (FARPROC*)&dll_crypto_pwhash}, | |
48 | -- {"randombytes_buf", (FARPROC*)&dll_randombytes_buf}, | |
49 | -+ {"sodium_init", (SODIUM_PROC*)&dll_sodium_init}, | |
50 | -+ {"sodium_free", (SODIUM_PROC*)&dll_sodium_free}, | |
51 | -+ {"sodium_malloc", (SODIUM_PROC*)&dll_sodium_malloc}, | |
52 | -+ {"sodium_memzero", (SODIUM_PROC*)&dll_sodium_memzero}, | |
53 | -+ {"sodium_mlock", (SODIUM_PROC*)&dll_sodium_mlock}, | |
54 | -+ {"sodium_munlock", (SODIUM_PROC*)&dll_sodium_munlock}, | |
55 | -+ {"crypto_secretstream_xchacha20poly1305_init_push", (SODIUM_PROC*)&dll_crypto_secretstream_xchacha20poly1305_init_push}, | |
56 | -+ {"crypto_secretstream_xchacha20poly1305_push", (SODIUM_PROC*)&dll_crypto_secretstream_xchacha20poly1305_push}, | |
57 | -+ {"crypto_secretstream_xchacha20poly1305_init_pull", (SODIUM_PROC*)&dll_crypto_secretstream_xchacha20poly1305_init_pull}, | |
58 | -+ {"crypto_secretstream_xchacha20poly1305_pull", (SODIUM_PROC*)&dll_crypto_secretstream_xchacha20poly1305_pull}, | |
59 | -+ {"crypto_pwhash", (SODIUM_PROC*)&dll_crypto_pwhash}, | |
60 | -+ {"randombytes_buf", (SODIUM_PROC*)&dll_randombytes_buf}, | |
61 | - {NULL, NULL} | |
62 | - }; | |
63 | - | |
64 | - static int | |
65 | -+sodium_runtime_link_init(int verbose) | |
66 | -+{ | |
67 | -+ static HINSTANCE hsodium = NULL; | |
68 | -+ const char *libname = "libsodium.dll"; | |
69 | -+ int i; | |
70 | -+ | |
71 | -+ if (hsodium != NULL) | |
72 | -+ return OK; | |
73 | -+ | |
74 | -+ hsodium = load_dll(libname); | |
75 | -+ if (hsodium == NULL) | |
76 | -+ { | |
77 | -+ if (verbose) | |
78 | -+ semsg(_(e_could_not_load_library_str_str), libname, load_dll_error()); | |
79 | -+ return FAIL; | |
80 | -+ } | |
81 | -+ | |
82 | -+ for (i = 0; sodium_funcname_table[i].ptr; ++i) | |
83 | -+ { | |
84 | -+ if ((*sodium_funcname_table[i].ptr = symbol_from_dll(hsodium, | |
85 | -+ sodium_funcname_table[i].name)) == NULL) | |
86 | -+ { | |
87 | -+ FreeLibrary(hsodium); | |
88 | -+ hsodium = NULL; | |
89 | -+ if (verbose) | |
90 | -+ semsg(_(e_could_not_load_library_function_str), sodium_funcname_table[i].name); | |
91 | -+ return FAIL; | |
92 | -+ } | |
93 | -+ } | |
94 | -+ return OK; | |
95 | -+} | |
96 | -+ | |
97 | -+ static int | |
98 | - load_sodium(void) | |
99 | - { | |
100 | -- static HANDLE hsodium = NULL; | |
101 | -- int i; | |
102 | -- | |
103 | -- if (hsodium != NULL) | |
104 | -- return 0; | |
105 | -- | |
106 | -- hsodium = vimLoadLib("libsodium.dll"); | |
107 | -- if (hsodium == NULL) | |
108 | -- { | |
109 | -- // TODO: Show error message. | |
110 | -+ if (sodium_runtime_link_init(TRUE) == FAIL) | |
111 | - return -1; | |
112 | -- } | |
113 | -+ return dll_sodium_init(); | |
114 | -+} | |
115 | -+# endif | |
116 | - | |
117 | -- for (i = 0; sodium_funcname_table[i].ptr; ++i) | |
118 | -- { | |
119 | -- if ((*sodium_funcname_table[i].ptr = GetProcAddress(hsodium, | |
120 | -- sodium_funcname_table[i].name)) == NULL) | |
121 | -- { | |
122 | -- FreeLibrary(hsodium); | |
123 | -- hsodium = NULL; | |
124 | -- // TODO: Show error message. | |
125 | -- return -1; | |
126 | -- } | |
127 | -- } | |
128 | -- return dll_sodium_init(); | |
129 | -+# if defined(DYNAMIC_SODIUM) || defined(PROTO) | |
130 | -+ int | |
131 | -+sodium_enabled(int verbose) | |
132 | -+{ | |
133 | -+ return sodium_runtime_link_init(verbose) == OK; | |
134 | - } | |
135 | - # endif | |
136 | - #endif | |
137 | -diff --git a/src/evalfunc.c b/src/evalfunc.c | |
138 | ---- a/src/evalfunc.c | |
139 | -+++ b/src/evalfunc.c | |
140 | -@@ -5997,7 +5997,7 @@ f_has(typval_T *argvars, typval_T *rettv | |
141 | - #endif | |
142 | - }, | |
143 | - {"sodium", | |
144 | --#ifdef FEAT_SODIUM | |
145 | -+#if defined(FEAT_SODIUM) && !defined(DYNAMIC_SODIUM) | |
146 | - 1 | |
147 | - #else | |
148 | - 0 | |
149 | -@@ -6318,6 +6318,10 @@ f_has(typval_T *argvars, typval_T *rettv | |
150 | - else if (STRICMP(name, "tcl") == 0) | |
151 | - n = tcl_enabled(FALSE); | |
152 | - #endif | |
153 | -+#ifdef DYNAMIC_SODIUM | |
154 | -+ else if (STRICMP(name, "sodium") == 0) | |
155 | -+ n = sodium_enabled(FALSE); | |
156 | -+#endif | |
157 | - #if defined(FEAT_TERMINAL) && defined(MSWIN) | |
158 | - else if (STRICMP(name, "terminal") == 0) | |
159 | - n = terminal_enabled(); | |
160 | -diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp | |
161 | ---- a/src/gui_dwrite.cpp | |
162 | -+++ b/src/gui_dwrite.cpp | |
163 | -@@ -59,7 +59,7 @@ | |
164 | - #endif | |
165 | - | |
166 | - #ifdef DYNAMIC_DIRECTX | |
167 | --extern "C" HINSTANCE vimLoadLib(char *name); | |
168 | -+extern "C" HINSTANCE vimLoadLib(const char *name); | |
169 | - | |
170 | - typedef int (WINAPI *PGETUSERDEFAULTLOCALENAME)(LPWSTR, int); | |
171 | - typedef HRESULT (WINAPI *PD2D1CREATEFACTORY)(D2D1_FACTORY_TYPE, | |
172 | -@@ -1270,8 +1270,8 @@ DWrite_Init(void) | |
173 | - { | |
174 | - #ifdef DYNAMIC_DIRECTX | |
175 | - // Load libraries. | |
176 | -- hD2D1DLL = vimLoadLib(const_cast<char*>("d2d1.dll")); | |
177 | -- hDWriteDLL = vimLoadLib(const_cast<char*>("dwrite.dll")); | |
178 | -+ hD2D1DLL = vimLoadLib("d2d1.dll"); | |
179 | -+ hDWriteDLL = vimLoadLib("dwrite.dll"); | |
180 | - if (hD2D1DLL == NULL || hDWriteDLL == NULL) | |
181 | - { | |
182 | - DWrite_Final(); | |
183 | -diff --git a/src/if_cscope.c b/src/if_cscope.c | |
184 | ---- a/src/if_cscope.c | |
185 | -+++ b/src/if_cscope.c | |
186 | -@@ -1371,10 +1371,7 @@ cs_insert_filelist( | |
187 | - char *winmsg = GetWin32Error(); | |
188 | - | |
189 | - if (winmsg != NULL) | |
190 | -- { | |
191 | - (void)semsg(cant_msg, winmsg); | |
192 | -- LocalFree(winmsg); | |
193 | -- } | |
194 | - else | |
195 | - // subst filename if can't get error text | |
196 | - (void)semsg(cant_msg, fname); | |
197 | -diff --git a/src/os_win32.c b/src/os_win32.c | |
198 | ---- a/src/os_win32.c | |
199 | -+++ b/src/os_win32.c | |
200 | -@@ -521,7 +521,7 @@ unescape_shellxquote(char_u *p, char_u * | |
201 | - * Load library "name". | |
202 | - */ | |
203 | - HINSTANCE | |
204 | --vimLoadLib(char *name) | |
205 | -+vimLoadLib(const char *name) | |
206 | - { | |
207 | - HINSTANCE dll = NULL; | |
208 | - | |
209 | -@@ -8257,15 +8257,20 @@ resize_console_buf(void) | |
210 | - char * | |
211 | - GetWin32Error(void) | |
212 | - { | |
213 | -+ static char *oldmsg = NULL; | |
214 | - char *msg = NULL; | |
215 | -+ | |
216 | - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, | |
217 | - NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); | |
218 | -+ if (oldmsg != NULL) | |
219 | -+ LocalFree(oldmsg); | |
220 | - if (msg != NULL) | |
221 | - { | |
222 | - // remove trailing \r\n | |
223 | - char *pcrlf = strstr(msg, "\r\n"); | |
224 | - if (pcrlf != NULL) | |
225 | - *pcrlf = '\0'; | |
226 | -+ oldmsg = msg; | |
227 | - } | |
228 | - return msg; | |
229 | - } | |
230 | -diff --git a/src/proto/crypt.pro b/src/proto/crypt.pro | |
231 | ---- a/src/proto/crypt.pro | |
232 | -+++ b/src/proto/crypt.pro | |
233 | -@@ -1,4 +1,5 @@ | |
234 | - /* crypt.c */ | |
235 | -+int sodium_enabled(int verbose); | |
236 | - int crypt_method_nr_from_name(char_u *name); | |
237 | - int crypt_method_nr_from_magic(char *ptr, int len); | |
238 | - int crypt_works_inplace(cryptstate_T *state); | |
239 | -diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro | |
240 | ---- a/src/proto/os_win32.pro | |
241 | -+++ b/src/proto/os_win32.pro | |
242 | -@@ -1,6 +1,6 @@ | |
243 | - /* os_win32.c */ | |
244 | - void mch_get_exe_name(void); | |
245 | --HINSTANCE vimLoadLib(char *name); | |
246 | -+HINSTANCE vimLoadLib(const char *name); | |
247 | - int mch_is_gui_executable(void); | |
248 | - HINSTANCE find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname); | |
249 | - void *get_dll_import_func(HINSTANCE hInst, const char *funcname); | |
250 | -diff --git a/src/version.c b/src/version.c | |
251 | ---- a/src/version.c | |
252 | -+++ b/src/version.c | |
253 | -@@ -548,7 +548,11 @@ static char *(features[]) = | |
254 | - "-smartindent", | |
255 | - #endif | |
256 | - #ifdef FEAT_SODIUM | |
257 | -+# ifdef DYNAMIC_SODIUM | |
258 | -+ "+sodium/dyn", | |
259 | -+# else | |
260 | - "+sodium", | |
261 | -+# endif | |
262 | - #else | |
263 | - "-sodium", | |
264 | - #endif |
@@ -1,5 +1,5 @@ | ||
1 | 1 | # HG changeset patch |
2 | -# Parent 966a55f59e8255979ed20950b33a89fe3ac9fa22 | |
2 | +# Parent 75d764289e9e44b75f1e3705270582f539a048f0 | |
3 | 3 | |
4 | 4 | diff --git a/src/locale.c b/src/locale.c |
5 | 5 | --- a/src/locale.c |
@@ -15,7 +15,7 @@ | ||
15 | 15 | diff --git a/src/misc1.c b/src/misc1.c |
16 | 16 | --- a/src/misc1.c |
17 | 17 | +++ b/src/misc1.c |
18 | -@@ -1261,6 +1261,32 @@ free_users(void) | |
18 | +@@ -1283,6 +1283,32 @@ free_users(void) | |
19 | 19 | } |
20 | 20 | #endif |
21 | 21 |
@@ -48,7 +48,7 @@ | ||
48 | 48 | /* |
49 | 49 | * Call expand_env() and store the result in an allocated string. |
50 | 50 | * This is not very memory efficient, this expects the result to be freed |
51 | -@@ -1406,7 +1432,9 @@ expand_env_esc( | |
51 | +@@ -1428,7 +1454,9 @@ expand_env_esc( | |
52 | 52 | ++tail; |
53 | 53 | #endif |
54 | 54 | *var = NUL; |
@@ -58,7 +58,7 @@ | ||
58 | 58 | #if defined(MSWIN) || defined(UNIX) |
59 | 59 | } |
60 | 60 | #endif |
61 | -@@ -1693,6 +1721,7 @@ vim_getenv(char_u *name, int *mustfree) | |
61 | +@@ -1715,6 +1743,7 @@ vim_getenv(char_u *name, int *mustfree) | |
62 | 62 | if (!vimruntime && STRCMP(name, "VIM") != 0) |
63 | 63 | return NULL; |
64 | 64 |
@@ -66,7 +66,7 @@ | ||
66 | 66 | /* |
67 | 67 | * When expanding $VIMRUNTIME fails, try using $VIM/vim<version> or $VIM. |
68 | 68 | * Don't do this when default_vimruntime_dir is non-empty. |
69 | -@@ -1750,10 +1779,12 @@ vim_getenv(char_u *name, int *mustfree) | |
69 | +@@ -1772,10 +1801,12 @@ vim_getenv(char_u *name, int *mustfree) | |
70 | 70 | else |
71 | 71 | p = exe_name; |
72 | 72 | #endif |
@@ -79,7 +79,7 @@ | ||
79 | 79 | |
80 | 80 | // remove "doc/" from 'helpfile', if present |
81 | 81 | if (p == p_hf) |
82 | -@@ -1792,6 +1823,7 @@ vim_getenv(char_u *name, int *mustfree) | |
82 | +@@ -1814,6 +1845,7 @@ vim_getenv(char_u *name, int *mustfree) | |
83 | 83 | pend = remove_tail(p, pend, (char_u *)RUNTIME_DIRNAME); |
84 | 84 | pend = remove_tail(p, pend, (char_u *)VIM_VERSION_NODOT); |
85 | 85 | } |
@@ -87,7 +87,7 @@ | ||
87 | 87 | |
88 | 88 | // remove trailing path separator |
89 | 89 | if (pend > p && after_pathsep(p, pend)) |
90 | -@@ -1853,14 +1885,17 @@ vim_getenv(char_u *name, int *mustfree) | |
90 | +@@ -1875,14 +1907,17 @@ vim_getenv(char_u *name, int *mustfree) | |
91 | 91 | if (vimruntime) |
92 | 92 | { |
93 | 93 | vim_setenv((char_u *)"VIMRUNTIME", p); |
@@ -108,7 +108,7 @@ | ||
108 | 108 | diff --git a/src/option.c b/src/option.c |
109 | 109 | --- a/src/option.c |
110 | 110 | +++ b/src/option.c |
111 | -@@ -2302,6 +2302,7 @@ option_expand(int opt_idx, char_u *val) | |
111 | +@@ -2400,6 +2400,7 @@ option_expand(int opt_idx, char_u *val) | |
112 | 112 | (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
113 | 113 | #endif |
114 | 114 | NULL); |
@@ -119,7 +119,7 @@ | ||
119 | 119 | diff --git a/src/optionstr.c b/src/optionstr.c |
120 | 120 | --- a/src/optionstr.c |
121 | 121 | +++ b/src/optionstr.c |
122 | -@@ -1037,9 +1037,13 @@ ambw_end: | |
122 | +@@ -1042,9 +1042,13 @@ ambw_end: | |
123 | 123 | } |
124 | 124 | |
125 | 125 | #if defined(MSWIN) |
@@ -146,7 +146,7 @@ | ||
146 | 146 | |
147 | 147 | static BOOL win8_or_later = FALSE; |
148 | 148 | |
149 | -@@ -438,26 +438,47 @@ wait_for_single_object( | |
149 | +@@ -433,26 +433,47 @@ wait_for_single_object( | |
150 | 150 | # endif |
151 | 151 | #endif |
152 | 152 |
@@ -206,7 +206,7 @@ | ||
206 | 206 | if (exe_path != NULL) |
207 | 207 | { |
208 | 208 | // Append our starting directory to $PATH, so that when doing |
209 | -@@ -477,6 +498,7 @@ get_exe_name(void) | |
209 | +@@ -472,6 +493,7 @@ get_exe_name(void) | |
210 | 210 | STRCAT(temp, exe_path); |
211 | 211 | vim_setenv((char_u *)"PATH", (char_u *)temp); |
212 | 212 | } |
@@ -214,7 +214,7 @@ | ||
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
217 | -@@ -514,9 +536,9 @@ vimLoadLib(char *name) | |
217 | +@@ -509,9 +531,9 @@ vimLoadLib(const char *name) | |
218 | 218 | |
219 | 219 | // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call |
220 | 220 | // vimLoadLib() recursively, which causes a stack overflow. |
@@ -227,7 +227,7 @@ | ||
227 | 227 | { |
228 | 228 | WCHAR old_dirw[MAXPATHL]; |
229 | 229 | |
230 | -@@ -525,7 +547,7 @@ vimLoadLib(char *name) | |
230 | +@@ -520,7 +542,7 @@ vimLoadLib(const char *name) | |
231 | 231 | // Change directory to where the executable is, both to make |
232 | 232 | // sure we find a .dll there and to avoid looking for a .dll |
233 | 233 | // in the current directory. |
@@ -236,7 +236,7 @@ | ||
236 | 236 | dll = LoadLibrary(name); |
237 | 237 | SetCurrentDirectoryW(old_dirw); |
238 | 238 | return dll; |
239 | -@@ -2962,7 +2984,7 @@ mch_check_win( | |
239 | +@@ -2974,7 +2996,7 @@ mch_check_win( | |
240 | 240 | int argc UNUSED, |
241 | 241 | char **argv UNUSED) |
242 | 242 | { |
@@ -262,6 +262,6 @@ | ||
262 | 262 | @@ -1,4 +1,5 @@ |
263 | 263 | /* os_win32.c */ |
264 | 264 | +void mch_get_exe_name(void); |
265 | - HINSTANCE vimLoadLib(char *name); | |
265 | + HINSTANCE vimLoadLib(const char *name); | |
266 | 266 | int mch_is_gui_executable(void); |
267 | 267 | HINSTANCE find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname); |