Skip to content

Commit 0bdef25

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 220f000 + 70bcd73 commit 0bdef25

File tree

12 files changed

+254
-110
lines changed

12 files changed

+254
-110
lines changed

src/eval.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,38 @@ static void list_one_var(dictitem_T *v, char_u *prefix, int *first);
242242
static void list_one_var_a(char_u *prefix, char_u *name, int type, char_u *string, int *first);
243243
static char_u *find_option_end(char_u **arg, int *opt_flags);
244244

245-
#ifdef EBCDIC
246-
static int compare_func_name(const void *s1, const void *s2);
247-
static void sortFunctions();
248-
#endif
249-
250245
/* for VIM_VERSION_ defines */
251246
#include "version.h"
252247

248+
249+
#if defined(EBCDIC) || defined(PROTO)
250+
/*
251+
* Compare struct fst by function name.
252+
*/
253+
static int
254+
compare_func_name(const void *s1, const void *s2)
255+
{
256+
struct fst *p1 = (struct fst *)s1;
257+
struct fst *p2 = (struct fst *)s2;
258+
259+
return STRCMP(p1->f_name, p2->f_name);
260+
}
261+
262+
/*
263+
* Sort the function table by function name.
264+
* The sorting of the table above is ASCII dependant.
265+
* On machines using EBCDIC we have to sort it.
266+
*/
267+
static void
268+
sortFunctions(void)
269+
{
270+
int funcCnt = (int)(sizeof(functions) / sizeof(struct fst)) - 1;
271+
272+
qsort(functions, (size_t)funcCnt, sizeof(struct fst), compare_func_name);
273+
}
274+
#endif
275+
276+
253277
/*
254278
* Initialize the global and v: variables.
255279
*/

src/evalfunc.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -923,34 +923,6 @@ get_expr_name(expand_T *xp, int idx)
923923

924924
#endif /* FEAT_CMDL_COMPL */
925925

926-
#if defined(EBCDIC) || defined(PROTO)
927-
/*
928-
* Compare struct fst by function name.
929-
*/
930-
static int
931-
compare_func_name(const void *s1, const void *s2)
932-
{
933-
struct fst *p1 = (struct fst *)s1;
934-
struct fst *p2 = (struct fst *)s2;
935-
936-
return STRCMP(p1->f_name, p2->f_name);
937-
}
938-
939-
/*
940-
* Sort the function table by function name.
941-
* The sorting of the table above is ASCII dependant.
942-
* On machines using EBCDIC we have to sort it.
943-
*/
944-
static void
945-
sortFunctions(void)
946-
{
947-
int funcCnt = (int)(sizeof(functions) / sizeof(struct fst)) - 1;
948-
949-
qsort(functions, (size_t)funcCnt, sizeof(struct fst), compare_func_name);
950-
}
951-
#endif
952-
953-
954926
/*
955927
* Find internal function in table above.
956928
* Return index, or -1 if not found

src/ex_cmds2.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5164,23 +5164,9 @@ ex_language(exarg_T *eap)
51645164
# if defined(FEAT_CMDL_COMPL) || defined(PROTO)
51655165

51665166
static char_u **locales = NULL; /* Array of all available locales */
5167-
static int did_init_locales = FALSE;
5168-
5169-
static void init_locales(void);
5170-
static char_u **find_locales(void);
51715167

5172-
/*
5173-
* Lazy initialization of all available locales.
5174-
*/
5175-
static void
5176-
init_locales(void)
5177-
{
5178-
if (!did_init_locales)
5179-
{
5180-
did_init_locales = TRUE;
5181-
locales = find_locales();
5182-
}
5183-
}
5168+
# ifndef WIN32
5169+
static int did_init_locales = FALSE;
51845170

51855171
/* Return an array of strings for all available locales + NULL for the
51865172
* last element. Return NULL in case of error. */
@@ -5222,6 +5208,22 @@ find_locales(void)
52225208
((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
52235209
return (char_u **)locales_ga.ga_data;
52245210
}
5211+
# endif
5212+
5213+
/*
5214+
* Lazy initialization of all available locales.
5215+
*/
5216+
static void
5217+
init_locales(void)
5218+
{
5219+
# ifndef WIN32
5220+
if (!did_init_locales)
5221+
{
5222+
did_init_locales = TRUE;
5223+
locales = find_locales();
5224+
}
5225+
# endif
5226+
}
52255227

52265228
# if defined(EXITFREE) || defined(PROTO)
52275229
void

src/mbyte.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4583,47 +4583,6 @@ static HINSTANCE hMsvcrtDLL = 0;
45834583
# define DYNAMIC_MSVCRT_DLL "msvcrt.dll"
45844584
# endif
45854585

4586-
/*
4587-
* Get the address of 'funcname' which is imported by 'hInst' DLL.
4588-
*/
4589-
static void *
4590-
get_iconv_import_func(HINSTANCE hInst, const char *funcname)
4591-
{
4592-
PBYTE pImage = (PBYTE)hInst;
4593-
PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hInst;
4594-
PIMAGE_NT_HEADERS pPE;
4595-
PIMAGE_IMPORT_DESCRIPTOR pImpDesc;
4596-
PIMAGE_THUNK_DATA pIAT; /* Import Address Table */
4597-
PIMAGE_THUNK_DATA pINT; /* Import Name Table */
4598-
PIMAGE_IMPORT_BY_NAME pImpName;
4599-
4600-
if (pDOS->e_magic != IMAGE_DOS_SIGNATURE)
4601-
return NULL;
4602-
pPE = (PIMAGE_NT_HEADERS)(pImage + pDOS->e_lfanew);
4603-
if (pPE->Signature != IMAGE_NT_SIGNATURE)
4604-
return NULL;
4605-
pImpDesc = (PIMAGE_IMPORT_DESCRIPTOR)(pImage
4606-
+ pPE->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
4607-
.VirtualAddress);
4608-
for (; pImpDesc->FirstThunk; ++pImpDesc)
4609-
{
4610-
if (!pImpDesc->OriginalFirstThunk)
4611-
continue;
4612-
pIAT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->FirstThunk);
4613-
pINT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->OriginalFirstThunk);
4614-
for (; pIAT->u1.Function; ++pIAT, ++pINT)
4615-
{
4616-
if (IMAGE_SNAP_BY_ORDINAL(pINT->u1.Ordinal))
4617-
continue;
4618-
pImpName = (PIMAGE_IMPORT_BY_NAME)(pImage
4619-
+ (UINT_PTR)(pINT->u1.AddressOfData));
4620-
if (strcmp((char *)pImpName->Name, funcname) == 0)
4621-
return (void *)pIAT->u1.Function;
4622-
}
4623-
}
4624-
return NULL;
4625-
}
4626-
46274586
/*
46284587
* Try opening the iconv.dll and return TRUE if iconv() can be used.
46294588
*/
@@ -4671,7 +4630,7 @@ iconv_enabled(int verbose)
46714630
iconv_open = (void *)GetProcAddress(hIconvDLL, "libiconv_open");
46724631
iconv_close = (void *)GetProcAddress(hIconvDLL, "libiconv_close");
46734632
iconvctl = (void *)GetProcAddress(hIconvDLL, "libiconvctl");
4674-
iconv_errno = get_iconv_import_func(hIconvDLL, "_errno");
4633+
iconv_errno = get_dll_import_func(hIconvDLL, "_errno");
46754634
if (iconv_errno == NULL)
46764635
iconv_errno = (void *)GetProcAddress(hMsvcrtDLL, "_errno");
46774636
if (iconv == NULL || iconv_open == NULL || iconv_close == NULL

src/misc1.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,6 +4461,9 @@ vim_setenv(char_u *name, char_u *val)
44614461
{
44624462
sprintf((char *)envbuf, "%s=%s", name, val);
44634463
putenv((char *)envbuf);
4464+
# ifdef libintl_putenv
4465+
libintl_putenv((char *)envbuf);
4466+
# endif
44644467
}
44654468
#endif
44664469
#ifdef FEAT_GETTEXT

src/os_unixx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
/* shared library access */
115115
#if defined(HAVE_DLFCN_H) && defined(USE_DLOPEN)
116-
# ifdef __MVS__
116+
# if defined(__MVS__) && !defined (__SUSV3)
117117
/* needed to define RTLD_LAZY (Anthony Giorgio) */
118118
# define __SUSV3
119119
# endif

src/os_win32.c

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,84 @@ vimLoadLib(char *name)
425425
return dll;
426426
}
427427

428+
#if defined(DYNAMIC_ICONV) || defined(DYNAMIC_GETTEXT) || defined(PROTO)
429+
/*
430+
* Get related information about 'funcname' which is imported by 'hInst'.
431+
* If 'info' is 0, return the function address.
432+
* If 'info' is 1, return the module name which the function is imported from.
433+
*/
434+
static void *
435+
get_imported_func_info(HINSTANCE hInst, const char *funcname, int info)
436+
{
437+
PBYTE pImage = (PBYTE)hInst;
438+
PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hInst;
439+
PIMAGE_NT_HEADERS pPE;
440+
PIMAGE_IMPORT_DESCRIPTOR pImpDesc;
441+
PIMAGE_THUNK_DATA pIAT; /* Import Address Table */
442+
PIMAGE_THUNK_DATA pINT; /* Import Name Table */
443+
PIMAGE_IMPORT_BY_NAME pImpName;
444+
445+
if (pDOS->e_magic != IMAGE_DOS_SIGNATURE)
446+
return NULL;
447+
pPE = (PIMAGE_NT_HEADERS)(pImage + pDOS->e_lfanew);
448+
if (pPE->Signature != IMAGE_NT_SIGNATURE)
449+
return NULL;
450+
pImpDesc = (PIMAGE_IMPORT_DESCRIPTOR)(pImage
451+
+ pPE->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
452+
.VirtualAddress);
453+
for (; pImpDesc->FirstThunk; ++pImpDesc)
454+
{
455+
if (!pImpDesc->OriginalFirstThunk)
456+
continue;
457+
pIAT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->FirstThunk);
458+
pINT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->OriginalFirstThunk);
459+
for (; pIAT->u1.Function; ++pIAT, ++pINT)
460+
{
461+
if (IMAGE_SNAP_BY_ORDINAL(pINT->u1.Ordinal))
462+
continue;
463+
pImpName = (PIMAGE_IMPORT_BY_NAME)(pImage
464+
+ (UINT_PTR)(pINT->u1.AddressOfData));
465+
if (strcmp((char *)pImpName->Name, funcname) == 0)
466+
{
467+
switch (info)
468+
{
469+
case 0:
470+
return (void *)pIAT->u1.Function;
471+
case 1:
472+
return (void *)(pImage + pImpDesc->Name);
473+
default:
474+
return NULL;
475+
}
476+
}
477+
}
478+
}
479+
return NULL;
480+
}
481+
482+
/*
483+
* Get the module handle which 'funcname' in 'hInst' is imported from.
484+
*/
485+
HINSTANCE
486+
find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname)
487+
{
488+
char *modulename;
489+
490+
modulename = (char *)get_imported_func_info(hInst, funcname, 1);
491+
if (modulename != NULL)
492+
return GetModuleHandleA(modulename);
493+
return NULL;
494+
}
495+
496+
/*
497+
* Get the address of 'funcname' which is imported by 'hInst' DLL.
498+
*/
499+
void *
500+
get_dll_import_func(HINSTANCE hInst, const char *funcname)
501+
{
502+
return get_imported_func_info(hInst, funcname, 0);
503+
}
504+
#endif
505+
428506
#if defined(DYNAMIC_GETTEXT) || defined(PROTO)
429507
# ifndef GETTEXT_DLL
430508
# define GETTEXT_DLL "libintl.dll"
@@ -436,6 +514,7 @@ static char *null_libintl_ngettext(const char *, const char *, unsigned long n);
436514
static char *null_libintl_textdomain(const char *);
437515
static char *null_libintl_bindtextdomain(const char *, const char *);
438516
static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
517+
static int null_libintl_putenv(const char *);
439518

440519
static HINSTANCE hLibintlDLL = NULL;
441520
char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
@@ -446,6 +525,7 @@ char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
446525
= null_libintl_bindtextdomain;
447526
char *(*dyn_libintl_bind_textdomain_codeset)(const char *, const char *)
448527
= null_libintl_bind_textdomain_codeset;
528+
int (*dyn_libintl_putenv)(const char *) = null_libintl_putenv;
449529

450530
int
451531
dyn_libintl_init(void)
@@ -463,6 +543,7 @@ dyn_libintl_init(void)
463543
{"bindtextdomain", (FARPROC*)&dyn_libintl_bindtextdomain},
464544
{NULL, NULL}
465545
};
546+
HINSTANCE hmsvcrt;
466547

467548
/* No need to initialize twice. */
468549
if (hLibintlDLL)
@@ -507,6 +588,13 @@ dyn_libintl_init(void)
507588
dyn_libintl_bind_textdomain_codeset =
508589
null_libintl_bind_textdomain_codeset;
509590

591+
/* _putenv() function for the libintl.dll is optional. */
592+
hmsvcrt = find_imported_module_by_funcname(hLibintlDLL, "getenv");
593+
if (hmsvcrt != NULL)
594+
dyn_libintl_putenv = (void *)GetProcAddress(hmsvcrt, "_putenv");
595+
if (dyn_libintl_putenv == NULL || dyn_libintl_putenv == putenv)
596+
dyn_libintl_putenv = null_libintl_putenv;
597+
510598
return 1;
511599
}
512600

@@ -521,6 +609,7 @@ dyn_libintl_end(void)
521609
dyn_libintl_textdomain = null_libintl_textdomain;
522610
dyn_libintl_bindtextdomain = null_libintl_bindtextdomain;
523611
dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset;
612+
dyn_libintl_putenv = null_libintl_putenv;
524613
}
525614

526615
/*ARGSUSED*/
@@ -562,6 +651,13 @@ null_libintl_textdomain(const char *domainname)
562651
return NULL;
563652
}
564653

654+
/*ARGSUSED*/
655+
int
656+
null_libintl_putenv(const char *envstring)
657+
{
658+
return 0;
659+
}
660+
565661
#endif /* DYNAMIC_GETTEXT */
566662

567663
/* This symbol is not defined in older versions of the SDK or Visual C++ */
@@ -4781,32 +4877,32 @@ mch_call_shell(
47814877
#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
47824878
static HANDLE
47834879
job_io_file_open(
4784-
char_u *fname,
4785-
DWORD dwDesiredAccess,
4786-
DWORD dwShareMode,
4787-
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
4788-
DWORD dwCreationDisposition,
4789-
DWORD dwFlagsAndAttributes)
4880+
char_u *fname,
4881+
DWORD dwDesiredAccess,
4882+
DWORD dwShareMode,
4883+
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
4884+
DWORD dwCreationDisposition,
4885+
DWORD dwFlagsAndAttributes)
47904886
{
47914887
HANDLE h;
47924888
# ifdef FEAT_MBYTE
47934889
WCHAR *wn = NULL;
47944890
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
47954891
{
4796-
wn = enc_to_utf16(fname, NULL);
4797-
if (wn != NULL)
4798-
{
4799-
h = CreateFileW(wn, dwDesiredAccess, dwShareMode,
4800-
lpSecurityAttributes, dwCreationDisposition,
4801-
dwFlagsAndAttributes, NULL);
4802-
vim_free(wn);
4803-
}
4892+
wn = enc_to_utf16(fname, NULL);
4893+
if (wn != NULL)
4894+
{
4895+
h = CreateFileW(wn, dwDesiredAccess, dwShareMode,
4896+
lpSecurityAttributes, dwCreationDisposition,
4897+
dwFlagsAndAttributes, NULL);
4898+
vim_free(wn);
4899+
}
48044900
}
48054901
if (wn == NULL)
48064902
# endif
4807-
h = CreateFile((LPCSTR)fname, dwDesiredAccess, dwShareMode,
4808-
lpSecurityAttributes, dwCreationDisposition,
4809-
dwFlagsAndAttributes, NULL);
4903+
h = CreateFile((LPCSTR)fname, dwDesiredAccess, dwShareMode,
4904+
lpSecurityAttributes, dwCreationDisposition,
4905+
dwFlagsAndAttributes, NULL);
48104906
return h;
48114907
}
48124908

0 commit comments

Comments
 (0)