# HG changeset patch # User Christian Brabandt # Date 1455632106 -3600 # Node ID b6cb94ad97a47b4e0fcfea46e666b3a9e394d8e9 # Parent 6dac7e594219817d8c11e86be50c5ade80afb660 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c Author: Bram Moolenaar Date: Tue Feb 16 15:06:59 2016 +0100 patch 7.4.1334 Problem: Many compiler warnings with MingW. Solution: Add type casts. (Yasuhiro Matsumoto) diff --git a/src/channel.c b/src/channel.c --- a/src/channel.c +++ b/src/channel.c @@ -58,7 +58,7 @@ extern HWND s_hwnd; /* Gvim's Window h #ifdef WIN32 static int -fd_read(sock_T fd, char_u *buf, size_t len) +fd_read(sock_T fd, char *buf, size_t len) { HANDLE h = (HANDLE)fd; DWORD nread; @@ -69,7 +69,7 @@ fd_read(sock_T fd, char_u *buf, size_t l } static int -fd_write(sock_T fd, char_u *buf, size_t len) +fd_write(sock_T fd, char *buf, size_t len) { HANDLE h = (HANDLE)fd; DWORD nwrite; @@ -1393,7 +1393,7 @@ channel_wait(channel_T *channel, sock_T /* reading from a pipe, not a socket */ while (TRUE) { - if (PeekNamedPipe(fd, NULL, 0, NULL, &nread, NULL) && nread > 0) + if (PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL) && nread > 0) return OK; diff = deadline - GetTickCount(); if (diff < 0) @@ -1509,9 +1509,9 @@ channel_read(channel_T *channel, int whi if (channel_wait(channel, fd, 0) == FAIL) break; if (use_socket) - len = sock_read(fd, buf, MAXMSGSIZE); + len = sock_read(fd, (char *)buf, MAXMSGSIZE); else - len = fd_read(fd, buf, MAXMSGSIZE); + len = fd_read(fd, (char *)buf, MAXMSGSIZE); if (len <= 0) break; /* error or nothing more to read */ @@ -1713,9 +1713,9 @@ channel_send(channel_T *channel, char_u } if (use_socket) - res = sock_write(fd, buf, len); + res = sock_write(fd, (char *)buf, len); else - res = fd_write(fd, buf, len); + res = fd_write(fd, (char *)buf, len); if (res != len) { if (!channel->ch_error && fun != NULL) diff --git a/src/dosinst.h b/src/dosinst.h --- a/src/dosinst.h +++ b/src/dosinst.h @@ -452,7 +452,7 @@ run_command(char *cmd) /* * Append a backslash to "name" if there isn't one yet. */ - static void + void add_pathsep(char *name) { int len = strlen(name); diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -14554,7 +14554,7 @@ f_job_start(typval_T *argvars UNUSED, ty #ifdef USE_ARGV mch_start_job(argv, job); #else - mch_start_job(cmd, job); + mch_start_job((char *)cmd, job); #endif theend: @@ -16410,7 +16410,7 @@ f_remote_peek(typval_T *argvars UNUSED, return; /* type error; errmsg already given */ } # ifdef WIN32 - sscanf(serverid, SCANF_HEX_LONG_U, &n); + sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n); if (n == 0) rettv->vval.v_number = -1; else @@ -16456,7 +16456,7 @@ f_remote_read(typval_T *argvars UNUSED, /* The server's HWND is encoded in the 'id' parameter */ long_u n = 0; - sscanf(serverid, SCANF_HEX_LONG_U, &n); + sscanf((char *)serverid, SCANF_HEX_LONG_U, &n); if (n != 0) r = serverGetReply((HWND)n, FALSE, TRUE, TRUE); if (r == NULL) @@ -25415,7 +25415,7 @@ get_short_pathname(char_u **fnamep, char char_u *newbuf; len = *fnamelen; - l = GetShortPathName(*fnamep, *fnamep, len); + l = GetShortPathName((LPSTR)*fnamep, (LPSTR)*fnamep, len); if (l > len - 1) { /* If that doesn't work (not enough space), then save the string @@ -25428,7 +25428,7 @@ get_short_pathname(char_u **fnamep, char *fnamep = *bufp = newbuf; /* Really should always succeed, as the buffer is big enough. */ - l = GetShortPathName(*fnamep, *fnamep, l+1); + l = GetShortPathName((LPSTR)*fnamep, (LPSTR)*fnamep, l+1); } *fnamelen = l; @@ -25720,7 +25720,7 @@ repeat: p = alloc(_MAX_PATH + 1); if (p != NULL) { - if (GetLongPathName(*fnamep, p, _MAX_PATH)) + if (GetLongPathName((LPSTR)*fnamep, (LPSTR)p, _MAX_PATH)) { vim_free(*bufp); *bufp = *fnamep = p; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -4149,16 +4149,16 @@ ex_checktime(exarg_T *eap) #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ && (defined(FEAT_EVAL) || defined(FEAT_MULTI_LANG)) # define HAVE_GET_LOCALE_VAL -static char *get_locale_val(int what); - - static char * +static char_u *get_locale_val(int what); + + static char_u * get_locale_val(int what) { - char *loc; + char_u *loc; /* Obtain the locale value from the libraries. For DJGPP this is * redefined and it doesn't use the arguments. */ - loc = setlocale(what, NULL); + loc = (char_u *)setlocale(what, NULL); # ifdef WIN32 if (loc != NULL) @@ -4222,7 +4222,7 @@ gettext_lang(char_u *name) for (i = 0; mtable[i] != NULL; i += 2) if (STRNICMP(mtable[i], name, STRLEN(mtable[i])) == 0) - return mtable[i + 1]; + return (char_u *)mtable[i + 1]; return name; } #endif @@ -4239,13 +4239,13 @@ get_mess_lang(void) # ifdef HAVE_GET_LOCALE_VAL # if defined(LC_MESSAGES) - p = (char_u *)get_locale_val(LC_MESSAGES); + p = get_locale_val(LC_MESSAGES); # else /* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG * may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME * and LC_MONETARY may be set differently for a Japanese working in the * US. */ - p = (char_u *)get_locale_val(LC_COLLATE); + p = get_locale_val(LC_COLLATE); # endif # else p = mch_getenv((char_u *)"LC_ALL"); @@ -4290,7 +4290,7 @@ get_mess_env(void) p = NULL; /* ignore something like "1043" */ # ifdef HAVE_GET_LOCALE_VAL if (p == NULL || *p == NUL) - p = (char_u *)get_locale_val(LC_CTYPE); + p = get_locale_val(LC_CTYPE); # endif } } @@ -4310,7 +4310,7 @@ set_lang_var(void) char_u *loc; # ifdef HAVE_GET_LOCALE_VAL - loc = (char_u *)get_locale_val(LC_CTYPE); + loc = get_locale_val(LC_CTYPE); # else /* setlocale() not supported: use the default value */ loc = (char_u *)"C"; @@ -4320,14 +4320,14 @@ set_lang_var(void) /* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall * back to LC_CTYPE if it's empty. */ # if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES) - loc = (char_u *)get_locale_val(LC_MESSAGES); + loc = get_locale_val(LC_MESSAGES); # else loc = get_mess_env(); # endif set_vim_var_string(VV_LANG, loc, -1); # ifdef HAVE_GET_LOCALE_VAL - loc = (char_u *)get_locale_val(LC_TIME); + loc = get_locale_val(LC_TIME); # endif set_vim_var_string(VV_LC_TIME, loc, -1); } diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -626,8 +626,8 @@ getcmdline( #endif if (vim_ispathsep(ccline.cmdbuff[j]) #ifdef BACKSLASH_IN_FILENAME - && vim_strchr(" *?[{`$%#", ccline.cmdbuff[j + 1]) - == NULL + && vim_strchr((char_u *)" *?[{`$%#", + ccline.cmdbuff[j + 1]) == NULL #endif ) { diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -7480,11 +7480,11 @@ vim_tempname( } strcpy(buf4, "VIM"); buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */ - if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0) + if (GetTempFileName(szTempFile, buf4, 0, (LPSTR)itmp) == 0) return NULL; if (!keep) /* GetTempFileName() will create the file, we don't want that */ - (void)DeleteFile(itmp); + (void)DeleteFile((LPSTR)itmp); /* Backslashes in a temp file name cause problems when filtering with * "sh". NOTE: This also checks 'shellcmdflag' to help those people who diff --git a/src/if_cscope.c b/src/if_cscope.c --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -839,7 +839,7 @@ cs_create_connection(int i) # ifdef __BORLANDC__ # define OPEN_OH_ARGTYPE long # else -# if (_MSC_VER >= 1300) +# if (_MSC_VER >= 1300) || defined(__MINGW32__) # define OPEN_OH_ARGTYPE intptr_t # else # define OPEN_OH_ARGTYPE long @@ -1423,7 +1423,7 @@ cs_insert_filelist( /* On windows 9x GetFileInformationByHandle doesn't work, so skip it */ if (!mch_windows95()) { - switch (win32_fileinfo(fname, &bhfi)) + switch (win32_fileinfo((char_u *)fname, &bhfi)) { case FILEINFO_ENC_FAIL: /* enc_to_utf16() failed */ case FILEINFO_READ_FAIL: /* CreateFile() failed */ @@ -1459,7 +1459,8 @@ cs_insert_filelist( && csinfo[j].st_dev == sb->st_dev && csinfo[j].st_ino == sb->st_ino #else /* compare pathnames first */ - && ((fullpathcmp(csinfo[j].fname, fname, FALSE) & FPC_SAME) + && ((fullpathcmp((char_u *)csinfo[j].fname, + (char_u *)fname, FALSE) & FPC_SAME) /* if not Windows 9x, test index file attributes too */ || (!mch_windows95() && csinfo[j].nVolume == bhfi.dwVolumeSerialNumber diff --git a/src/if_perl.xs b/src/if_perl.xs --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -49,6 +49,12 @@ # define __inline__ __inline #endif +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + #include #include #include @@ -1730,3 +1736,6 @@ Append(vimbuf, ...) } } +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif diff --git a/src/if_python.c b/src/if_python.c --- a/src/if_python.c +++ b/src/if_python.c @@ -43,6 +43,15 @@ # undef _DEBUG #endif +#ifdef HAVE_STRFTIME +# undef HAVE_STRFTIME +#endif +#ifdef HAVE_STRING_H +# undef HAVE_STRING_H +#endif +#ifdef HAVE_PUTENV +# undef HAVE_PUTENV +#endif #ifdef HAVE_STDARG_H # undef HAVE_STDARG_H /* Python's config.h defines it as well. */ #endif diff --git a/src/if_python3.c b/src/if_python3.c --- a/src/if_python3.c +++ b/src/if_python3.c @@ -51,6 +51,15 @@ # undef F_BLANK #endif +#ifdef HAVE_STRFTIME +# undef HAVE_STRFTIME +#endif +#ifdef HAVE_STRING_H +# undef HAVE_STRING_H +#endif +#ifdef HAVE_PUTENV +# undef HAVE_PUTENV +#endif #ifdef HAVE_STDARG_H # undef HAVE_STDARG_H /* Python's config.h defines it as well. */ #endif diff --git a/src/if_ruby.c b/src/if_ruby.c --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -158,6 +158,10 @@ # define RSTRING_PTR(s) RSTRING(s)->ptr #endif +#ifdef HAVE_DUP +# undef HAVE_DUP +#endif + #include "vim.h" #include "version.h" @@ -253,6 +257,7 @@ static void ruby_vim_init(void); # define rb_raise dll_rb_raise # define rb_str_cat dll_rb_str_cat # define rb_str_concat dll_rb_str_concat +# undef rb_str_new # define rb_str_new dll_rb_str_new # ifdef rb_str_new2 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ @@ -300,7 +305,8 @@ static void ruby_vim_init(void); # define ruby_script dll_ruby_script # define rb_enc_find_index dll_rb_enc_find_index # define rb_enc_find dll_rb_enc_find -# define rb_enc_str_new dll_rb_enc_str_new +# undef rb_enc_str_new +# define rb_enc_str_new dll_rb_enc_str_new # define rb_sprintf dll_rb_sprintf # define rb_require dll_rb_require # define ruby_options dll_ruby_options diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -3940,7 +3940,7 @@ build_drop_cmd( } cdp = vim_strsave_escaped_ext(cwd, #ifdef BACKSLASH_IN_FILENAME - "", /* rem_backslash() will tell what chars to escape */ + (char_u *)"", /* rem_backslash() will tell what chars to escape */ #else PATH_ESC_CHARS, #endif diff --git a/src/mbyte.c b/src/mbyte.c --- a/src/mbyte.c +++ b/src/mbyte.c @@ -473,7 +473,7 @@ enc_canon_props(char_u *name) CPINFO cpinfo; /* Get info on this codepage to find out what it is. */ - if (GetCPInfo(atoi(name + 2), &cpinfo) != 0) + if (GetCPInfo(atoi((char *)name + 2), &cpinfo) != 0) { if (cpinfo.MaxCharSize == 1) /* some single-byte encoding */ return ENC_8BIT; @@ -535,7 +535,7 @@ mb_init(void) CPINFO cpinfo; /* Get info on this codepage to find out what it is. */ - if (GetCPInfo(atoi(p_enc + 2), &cpinfo) != 0) + if (GetCPInfo(atoi((char *)p_enc + 2), &cpinfo) != 0) { if (cpinfo.MaxCharSize == 1) { @@ -547,7 +547,7 @@ mb_init(void) && (cpinfo.LeadByte[0] != 0 || cpinfo.LeadByte[1] != 0)) { /* must be a DBCS encoding, check below */ - enc_dbcs_new = atoi(p_enc + 2); + enc_dbcs_new = atoi((char *)p_enc + 2); } else goto codepage_invalid; @@ -571,7 +571,7 @@ codepage_invalid: #ifdef WIN3264 /* Windows: accept only valid codepage numbers, check below. */ if (p_enc[6] != 'c' || p_enc[7] != 'p' - || (enc_dbcs_new = atoi(p_enc + 8)) == 0) + || (enc_dbcs_new = atoi((char *)p_enc + 8)) == 0) return e_invarg; #else /* Unix: accept any "2byte-" name, assume current locale. */ @@ -4338,7 +4338,7 @@ get_iconv_import_func(HINSTANCE hInst, c continue; pImpName = (PIMAGE_IMPORT_BY_NAME)(pImage + (UINT_PTR)(pINT->u1.AddressOfData)); - if (strcmp(pImpName->Name, funcname) == 0) + if (strcmp((char *)pImpName->Name, funcname) == 0) return (void *)pIAT->u1.Function; } } @@ -6268,7 +6268,7 @@ string_convert_ext( { tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, unconvlenp ? MB_ERR_INVALID_CHARS : 0, - ptr, len, 0, 0); + (char *)ptr, len, 0, 0); if (tmp_len == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION) { @@ -6288,7 +6288,8 @@ string_convert_ext( if (vcp->vc_cpfrom == 0) utf8_to_utf16(ptr, len, tmp, unconvlenp); else - MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len); + MultiByteToWideChar(vcp->vc_cpfrom, 0, + (char *)ptr, len, tmp, tmp_len); /* 2. ucs-2 -> codepage/UTF-8. */ if (vcp->vc_cpto == 0) @@ -6303,7 +6304,8 @@ string_convert_ext( utf16_to_utf8(tmp, tmp_len, retval); else WideCharToMultiByte(vcp->vc_cpto, 0, - tmp, tmp_len, retval, retlen, 0, 0); + tmp, tmp_len, + (char *)retval, retlen, 0, 0); retval[retlen] = NUL; if (lenp != NULL) *lenp = retlen; diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -3779,7 +3779,7 @@ init_homedir(void) homedrive = mch_getenv((char_u *)"HOMEDRIVE"); homepath = mch_getenv((char_u *)"HOMEPATH"); if (homepath == NULL || *homepath == NUL) - homepath = "\\"; + homepath = (char_u *)"\\"; if (homedrive != NULL && STRLEN(homedrive) + STRLEN(homepath) < MAXPATHL) { @@ -3817,7 +3817,7 @@ init_homedir(void) * Best assumption we can make in such a situation. */ if (var == NULL) - var = "C:/"; + var = (char_u *)"C:/"; #endif if (var != NULL) { @@ -9944,7 +9944,7 @@ dos_expandpath( if (wn == NULL) # endif - hFind = FindFirstFile(buf, &fb); + hFind = FindFirstFile((LPCSTR)buf, &fb); ok = (hFind != INVALID_HANDLE_VALUE); #else /* If we are expanding wildcards we try both files and directories */ @@ -10042,7 +10042,7 @@ dos_expandpath( } if (wn == NULL) # endif - hFind = FindFirstFile(buf, &fb); + hFind = FindFirstFile((LPCSTR)buf, &fb); ok = (hFind != INVALID_HANDLE_VALUE); #else ok = (findfirst((char *)buf, &fb, diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -3196,7 +3196,7 @@ set_init_1(void) # endif || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) # ifdef WIN3264 - || ((p = default_shell()) != NULL && *p != NUL) + || ((p = (char_u *)default_shell()) != NULL && *p != NUL) # endif #endif ) @@ -3479,7 +3479,7 @@ set_init_1(void) STRCPY(buf, "ja"); else buf[2] = NUL; /* truncate to two-letter code */ - vim_setenv("LANG", buf); + vim_setenv((char_u *)"LANG", (char_u *)buf); } } # else diff --git a/src/os_mswin.c b/src/os_mswin.c --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -273,11 +273,11 @@ mch_early_init(void) for (i = 0; i < 256; ++i) toupper_tab[i] = tolower_tab[i] = i; #ifdef WIN3264 - CharUpperBuff(toupper_tab, 256); - CharLowerBuff(tolower_tab, 256); + CharUpperBuff((LPSTR)toupper_tab, 256); + CharLowerBuff((LPSTR)tolower_tab, 256); #else - AnsiUpperBuff(toupper_tab, 256); - AnsiLowerBuff(tolower_tab, 256); + AnsiUpperBuff((LPSTR)toupper_tab, 256); + AnsiLowerBuff((LPSTR)tolower_tab, 256); #endif } @@ -327,7 +327,7 @@ mch_settitle( } } # endif - SetConsoleTitle(title); + SetConsoleTitle((LPCSTR)title); } # endif } @@ -428,7 +428,7 @@ mch_FullName( if (nResult == FAIL) /* fall back to non-wide function */ #endif { - if (_fullpath(buf, fname, len - 1) == NULL) + if (_fullpath((char *)buf, (const char *)fname, len - 1) == NULL) { /* failed, use relative path name */ vim_strncpy(buf, fname, len - 1); @@ -469,10 +469,10 @@ mch_isFullName(char_u *fname) return TRUE; /* A name that can't be made absolute probably isn't absolute. */ - if (mch_FullName(fname, szName, sizeof(szName) - 1, FALSE) == FAIL) + if (mch_FullName(fname, (char_u *)szName, sizeof(szName) - 1, FALSE) == FAIL) return FALSE; - return pathcmp(fname, szName, -1) == 0; + return pathcmp((const char *)fname, (const char *)szName, -1) == 0; } /* @@ -619,14 +619,14 @@ vim_stat(const char *name, struct stat * /* WinNT and later can use _MAX_PATH wide characters for a pathname, which * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is * UTF-8. */ - char buf[_MAX_PATH * 3 + 1]; + char_u buf[_MAX_PATH * 3 + 1]; #else - char buf[_MAX_PATH + 1]; + char_u buf[_MAX_PATH + 1]; #endif - char *p; + char_u *p; vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1); - p = buf + strlen(buf); + p = buf + STRLEN(buf); if (p > buf) mb_ptr_back(buf, p); @@ -637,10 +637,10 @@ vim_stat(const char *name, struct stat * if ((buf[0] == '\\' && buf[1] == '\\') || (buf[0] == '/' && buf[1] == '/')) { /* UNC root path must be followed by '\\'. */ - p = vim_strpbrk(buf + 2, "\\/"); + p = vim_strpbrk(buf + 2, (char_u *)"\\/"); if (p != NULL) { - p = vim_strpbrk(p + 1, "\\/"); + p = vim_strpbrk(p + 1, (char_u *)"\\/"); if (p == NULL) STRCAT(buf, "\\"); } @@ -668,7 +668,7 @@ vim_stat(const char *name, struct stat * } } #endif - return stat_symlink_aware(buf, stp); + return stat_symlink_aware((char *)buf, stp); } #if defined(FEAT_GUI_MSWIN) || defined(PROTO) @@ -820,7 +820,7 @@ mch_chdir(char *path) #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_utf16(path, NULL); + WCHAR *p = enc_to_utf16((char_u *)path, NULL); int n; if (p != NULL) @@ -853,7 +853,8 @@ can_end_termcap_mode( if (g_PlatformId == VER_PLATFORM_WIN32_NT || Columns == 80) return TRUE; if (give_msg) - msg(_("'columns' is not 80, cannot execute external commands")); + msg((char_u *) + _("'columns' is not 80, cannot execute external commands")); return FALSE; #endif } @@ -915,7 +916,7 @@ check_str_len(char_u *str) MEMORY_BASIC_INFORMATION mbi; size_t length = 0; size_t i; - const char *p; + const char_u *p; /* get page size */ GetSystemInfo(&si); @@ -953,7 +954,7 @@ mch_icon_load_cb(char_u *fname, void *co HANDLE *h = (HANDLE *)cookie; *h = LoadImage(NULL, - fname, + (LPSTR)fname, IMAGE_ICON, 64, 64, @@ -992,7 +993,7 @@ mch_libcall( # ifdef WIN16 hinstLib = LoadLibrary(libname); # else - hinstLib = vimLoadLib(libname); + hinstLib = vimLoadLib((char *)libname); # endif // If the handle is valid, try to get the function address. @@ -1005,25 +1006,25 @@ mch_libcall( if (argstring != NULL) { /* Call with string argument */ - ProcAdd = (MYSTRPROCSTR) GetProcAddress(hinstLib, funcname); + ProcAdd = (MYSTRPROCSTR)GetProcAddress(hinstLib, (LPCSTR)funcname); if ((fRunTimeLinkSuccess = (ProcAdd != NULL)) != 0) { if (string_result == NULL) - retval_int = ((MYSTRPROCINT)ProcAdd)(argstring); + retval_int = ((MYSTRPROCINT)ProcAdd)((LPSTR)argstring); else - retval_str = (ProcAdd)(argstring); + retval_str = (char_u *)(ProcAdd)((LPSTR)argstring); } } else { /* Call with number argument */ - ProcAddI = (MYINTPROCSTR) GetProcAddress(hinstLib, funcname); + ProcAddI = (MYINTPROCSTR) GetProcAddress(hinstLib, (LPCSTR)funcname); if ((fRunTimeLinkSuccess = (ProcAddI != NULL)) != 0) { if (string_result == NULL) retval_int = ((MYINTPROCINT)ProcAddI)(argint); else - retval_str = (ProcAddI)(argint); + retval_str = (char_u *)(ProcAddI)(argint); } } @@ -1228,7 +1229,7 @@ vimSetDlgItemText(HWND hDlg, int nIDDlgI vim_free(wp); return ret; } - return SetDlgItemText(hDlg, nIDDlgItem, s); + return SetDlgItemText(hDlg, nIDDlgItem, (LPCSTR)s); } #endif @@ -1283,18 +1284,18 @@ PrintDlgProc(HWND hDlg, UINT message, WP { SendDlgItemMessage(hDlg, i, WM_SETFONT, (WPARAM)hfont, 1); if (GetDlgItemText(hDlg,i, buff, sizeof(buff))) - vimSetDlgItemText(hDlg,i, _(buff)); + vimSetDlgItemText(hDlg,i, (char_u *)_(buff)); } SendDlgItemMessage(hDlg, IDCANCEL, WM_SETFONT, (WPARAM)hfont, 1); if (GetDlgItemText(hDlg,IDCANCEL, buff, sizeof(buff))) - vimSetDlgItemText(hDlg,IDCANCEL, _(buff)); + vimSetDlgItemText(hDlg,IDCANCEL, (char_u *)_(buff)); } #endif - SetWindowText(hDlg, szAppName); + SetWindowText(hDlg, (LPCSTR)szAppName); if (prt_name != NULL) { - vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (LPSTR)prt_name); + vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (char_u *)prt_name); vim_free(prt_name); prt_name = NULL; } @@ -1585,7 +1586,7 @@ mch_print_init(prt_settings_T *psettings * NT, but NULL appears to work just as well. */ if (*p_pdev != NUL) - prt_dlg.hDC = CreateDC(NULL, p_pdev, NULL, NULL); + prt_dlg.hDC = CreateDC(NULL, (LPCSTR)p_pdev, NULL, NULL); else #endif { @@ -1649,7 +1650,7 @@ mch_print_init(prt_settings_T *psettings { char_u *printer_name = (char_u *)devname + devname->wDeviceOffset; char_u *port_name = (char_u *)devname +devname->wOutputOffset; - char_u *text = _("to %s on %s"); + char_u *text = (char_u *)_("to %s on %s"); #ifdef FEAT_MBYTE char_u *printer_name_orig = printer_name; char_u *port_name_orig = port_name; @@ -1671,7 +1672,8 @@ mch_print_init(prt_settings_T *psettings prt_name = alloc((unsigned)(STRLEN(printer_name) + STRLEN(port_name) + STRLEN(text))); if (prt_name != NULL) - wsprintf(prt_name, text, printer_name, port_name); + wsprintf((char *)prt_name, (const char *)text, + printer_name, port_name); #ifdef FEAT_MBYTE if (printer_name != printer_name_orig) vim_free(printer_name); @@ -1781,11 +1783,11 @@ mch_print_begin(prt_settings_T *psetting SetAbortProc(prt_dlg.hDC, AbortProc); #endif wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname)); - vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer); + vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer); vim_memset(&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); - di.lpszDocName = psettings->jobname; + di.lpszDocName = (LPCSTR)psettings->jobname; ret = StartDoc(prt_dlg.hDC, &di); #ifdef FEAT_GUI @@ -1815,7 +1817,7 @@ mch_print_end_page(void) mch_print_begin_page(char_u *msg) { if (msg != NULL) - vimSetDlgItemText(hDlgPrint, IDC_PROGRESS, (LPSTR)msg); + vimSetDlgItemText(hDlgPrint, IDC_PROGRESS, msg); return (StartPage(prt_dlg.hDC) > 0); } @@ -1878,16 +1880,17 @@ mch_print_text_out(char_u *p, int len) } #endif TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin, - prt_pos_y + prt_top_margin, p, len); + prt_pos_y + prt_top_margin, + (LPCSTR)p, len); #ifndef FEAT_PROPORTIONAL_FONTS prt_pos_x += len * prt_tm.tmAveCharWidth; return (prt_pos_x + prt_left_margin + prt_tm.tmAveCharWidth + prt_tm.tmOverhang > prt_right_margin); #else # ifdef WIN16 - GetTextExtentPoint(prt_dlg.hDC, p, len, &sz); + GetTextExtentPoint(prt_dlg.hDC, (LPCSTR)p, len, &sz); # else - GetTextExtentPoint32(prt_dlg.hDC, p, len, &sz); + GetTextExtentPoint32(prt_dlg.hDC, (LPCSTR)p, len, &sz); # endif prt_pos_x += (sz.cx - prt_tm.tmOverhang); /* This is wrong when printing spaces for a TAB. */ @@ -2027,7 +2030,7 @@ shortcut_errorw: goto shortcut_end; // full path string must be in Unicode. - MultiByteToWideChar(CP_ACP, 0, fname, -1, wsz, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)fname, -1, wsz, MAX_PATH); // "load" the name and resolve the link hr = ppf->lpVtbl->Load(ppf, wsz, STGM_READ); @@ -2043,7 +2046,7 @@ shortcut_errorw: ZeroMemory(buf, MAX_PATH); hr = psl->lpVtbl->GetPath(psl, buf, MAX_PATH, &ffd, 0); if (hr == S_OK && buf[0] != NUL) - rfname = vim_strsave(buf); + rfname = vim_strsave((char_u *)buf); shortcut_end: // Release all interface pointers (both belong to the same object) @@ -2234,7 +2237,7 @@ Messaging_WndProc(HWND hwnd, UINT msg, W if (res == NULL) { - res = vim_strsave(_(e_invexprmsg)); + res = vim_strsave((char_u *)_(e_invexprmsg)); reply.dwData = COPYDATA_ERROR_RESULT; } else @@ -2399,8 +2402,8 @@ enumWindowsGetNames(HWND hwnd, LPARAM lp return TRUE; /* Add the name to the list */ - ga_concat(ga, server); - ga_concat(ga, "\n"); + ga_concat(ga, (char_u *)server); + ga_concat(ga, (char_u *)"\n"); return TRUE; } @@ -2459,7 +2462,7 @@ serverSetName(char_u *name) #endif /* Update the message window title */ - SetWindowText(message_window, ok_name); + SetWindowText(message_window, (LPCSTR)ok_name); #ifdef FEAT_EVAL /* Set the servername variable */ @@ -2948,7 +2951,7 @@ get_logfont( if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { int len; - enc_to_acp(name, (int)strlen(name), &acpname, &len); + enc_to_acp(name, (int)strlen((char *)name), &acpname, &len); name = acpname; } #endif diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -91,7 +91,6 @@ FILE* fdDump = NULL; */ #ifdef PROTO #define WINAPI -#define WINBASEAPI typedef char * LPCSTR; typedef char * LPWSTR; typedef int ACCESS_MASK; @@ -148,14 +147,14 @@ typedef int PROCESS_INFORMATION; * and Michael Dietrich for helping me figure out this workaround. */ -/* WINBASEAPI BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR); */ -#ifndef WINBASEAPI -# define WINBASEAPI __stdcall +/* WINAPI BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR); */ +#ifndef WINAPI +# define WINAPI __stdcall #endif #if defined(__BORLANDC__) typedef BOOL (__stdcall *PFNGCKLN)(LPSTR); #else -typedef WINBASEAPI BOOL (WINAPI *PFNGCKLN)(LPSTR); +typedef BOOL (WINAPI *PFNGCKLN)(LPSTR); #endif static PFNGCKLN s_pfnGetConsoleKeyboardLayoutName = NULL; #endif @@ -340,6 +339,7 @@ msg_wait_for_multiple_objects( dwMilliseconds, dwWakeMask); } +#ifndef FEAT_CLIENTSERVER static DWORD wait_for_single_object( HANDLE hHandle, @@ -349,6 +349,7 @@ wait_for_single_object( return WAIT_OBJECT_0; return WaitForSingleObject(hHandle, dwMilliseconds); } +#endif static void get_exe_name(void) @@ -388,7 +389,7 @@ get_exe_name(void) STRCAT(temp, ";"); } STRCAT(temp, exe_path); - vim_setenv((char_u *)"PATH", temp); + vim_setenv((char_u *)"PATH", (char_u *)temp); } } } @@ -440,7 +441,7 @@ vimLoadLib(char *name) /* Change directory to where the executable is, both to make * sure we find a .dll there and to avoid looking for a .dll * in the current directory. */ - SetCurrentDirectory(exe_path); + SetCurrentDirectory((LPCSTR)exe_path); dll = LoadLibrary(name); SetCurrentDirectoryW(old_dirw); return dll; @@ -453,7 +454,7 @@ vimLoadLib(char *name) /* Change directory to where the executable is, both to make * sure we find a .dll there and to avoid looking for a .dll * in the current directory. */ - SetCurrentDirectory(exe_path); + SetCurrentDirectory((LPCSTR)exe_path); dll = LoadLibrary(name); SetCurrentDirectory(old_dir); } @@ -1961,7 +1962,7 @@ executable_exists(char *name, char_u **p #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_utf16(name, NULL); + WCHAR *p = enc_to_utf16((char_u *)name, NULL); WCHAR fnamew[_MAX_PATH]; WCHAR *dumw; WCHAR *wcurpath, *wnewpath; @@ -2003,10 +2004,10 @@ executable_exists(char *name, char_u **p vim_free(newpath); if (n == 0) return FALSE; - if (mch_isdir(fname)) + if (mch_isdir((char_u *)fname)) return FALSE; if (path != NULL) - *path = vim_strsave(fname); + *path = vim_strsave((char_u *)fname); return TRUE; } @@ -2383,7 +2384,7 @@ static ConsoleBuffer g_cbTermcap = { 0 } #ifdef __BORLANDC__ typedef HWND (__stdcall *GETCONSOLEWINDOWPROC)(VOID); #else -typedef WINBASEAPI HWND (WINAPI *GETCONSOLEWINDOWPROC)(VOID); +typedef HWND (WINAPI *GETCONSOLEWINDOWPROC)(VOID); #endif char g_szOrigTitle[256] = { 0 }; HWND g_hWnd = NULL; /* also used in os_mswin.c */ @@ -2439,18 +2440,15 @@ SetConsoleIcon( HICON hIconSmall, HICON hIcon) { - HICON hPrevIconSmall; - HICON hPrevIcon; - if (hWnd == NULL) return FALSE; if (hIconSmall != NULL) - hPrevIconSmall = (HICON)SendMessage(hWnd, WM_SETICON, - (WPARAM)ICON_SMALL, (LPARAM)hIconSmall); + SendMessage(hWnd, WM_SETICON, + (WPARAM)ICON_SMALL, (LPARAM)hIconSmall); if (hIcon != NULL) - hPrevIcon = (HICON)SendMessage(hWnd, WM_SETICON, - (WPARAM)ICON_BIG,(LPARAM) hIcon); + SendMessage(hWnd, WM_SETICON, + (WPARAM)ICON_BIG, (LPARAM) hIcon); return TRUE; } @@ -2496,7 +2494,7 @@ SaveConsoleTitleAndIcon(void) /* Extract the first icon contained in the Vim executable. */ if (mch_icon_load((HANDLE *)&g_hVimIcon) == FAIL || g_hVimIcon == NULL) - g_hVimIcon = ExtractIcon(NULL, exe_name, 0); + g_hVimIcon = ExtractIcon(NULL, (LPCSTR)exe_name, 0); if (g_hVimIcon != NULL) g_fCanChangeIcon = TRUE; } @@ -2851,7 +2849,7 @@ fname_case( return; /* Build the new name in szTrueName[] one component at a time. */ - porig = name; + porig = (char *)name; ptrue = szTrueName; if (isalpha(porig[0]) && porig[1] == ':') @@ -2877,7 +2875,7 @@ fname_case( if (enc_dbcs) { - l = (*mb_ptr2len)(porig); + l = (*mb_ptr2len)((char_u *)porig); while (--l >= 0) *ptrue++ = *porig++; } @@ -2978,7 +2976,7 @@ mch_get_user_name( #endif if (GetUserName(szUserName, &cch)) { - vim_strncpy(s, szUserName, len - 1); + vim_strncpy(s, (char_u *)szUserName, len - 1); return OK; } s[0] = NUL; @@ -3018,8 +3016,8 @@ mch_get_host_name( /* Retry with non-wide function (for Windows 98). */ } #endif - if (!GetComputerName(s, &cch)) - vim_strncpy(s, "PC (Win32 Vim)", len - 1); + if (!GetComputerName((LPSTR)s, &cch)) + vim_strncpy(s, (char_u *)"PC (Win32 Vim)", len - 1); } @@ -3069,7 +3067,7 @@ mch_dirname( /* Retry with non-wide function (for Windows 98). */ } #endif - return (GetCurrentDirectory(len, buf) != 0 ? OK : FAIL); + return (GetCurrentDirectory(len, (LPSTR)buf) != 0 ? OK : FAIL); } /* @@ -3082,7 +3080,7 @@ mch_getperm(char_u *name) struct stat st; int n; - n = mch_stat(name, &st); + n = mch_stat((char *)name, &st); return n == 0 ? (long)(unsigned short)st.st_mode : -1L; } @@ -3113,7 +3111,7 @@ mch_setperm(char_u *name, long perm) } if (n == -1) #endif - n = _chmod(name, perm); + n = _chmod((const char *)name, perm); if (n == -1) return FAIL; @@ -3197,7 +3195,7 @@ mch_mkdir(char_u *name) return retval; } #endif - return _mkdir(name); + return _mkdir((const char *)name); } /* @@ -3221,7 +3219,7 @@ mch_rmdir(char_u *name) return retval; } #endif - return _rmdir(name); + return _rmdir((const char *)name); } /* @@ -3260,7 +3258,7 @@ mch_is_symbolic_link(char_u *name) && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { /* Retry with non-wide function (for Windows 98). */ - hFind = FindFirstFile(name, &findDataA); + hFind = FindFirstFile((LPCSTR)name, &findDataA); if (hFind != INVALID_HANDLE_VALUE) { fileFlags = findDataA.dwFileAttributes; @@ -3276,7 +3274,7 @@ mch_is_symbolic_link(char_u *name) else #endif { - hFind = FindFirstFile(name, &findDataA); + hFind = FindFirstFile((LPCSTR)name, &findDataA); if (hFind != INVALID_HANDLE_VALUE) { fileFlags = findDataA.dwFileAttributes; @@ -3347,8 +3345,8 @@ win32_fileinfo(char_u *fname, BY_HANDLE_ } if (wn == NULL) #endif - hFile = CreateFile(fname, /* file name */ - GENERIC_READ, /* access mode */ + hFile = CreateFile((LPCSTR)fname, /* file name */ + GENERIC_READ, /* access mode */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ NULL, /* security descriptor */ OPEN_EXISTING, /* creation disposition */ @@ -3566,13 +3564,13 @@ mch_nodetype(char_u *name) } if (wn == NULL) #endif - hFile = CreateFile(name, /* file name */ - GENERIC_WRITE, /* access mode */ - 0, /* share mode */ - NULL, /* security descriptor */ - OPEN_EXISTING, /* creation disposition */ - 0, /* file attributes */ - NULL); /* handle to template file */ + hFile = CreateFile((LPCSTR)name, /* file name */ + GENERIC_WRITE, /* access mode */ + 0, /* share mode */ + NULL, /* security descriptor */ + OPEN_EXISTING, /* creation disposition */ + 0, /* file attributes */ + NULL); /* handle to template file */ #ifdef FEAT_MBYTE vim_free(wn); @@ -4084,7 +4082,7 @@ vim_create_process( # ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *wcmd = enc_to_utf16(cmd, NULL); + WCHAR *wcmd = enc_to_utf16((char_u *)cmd, NULL); if (wcmd != NULL) { @@ -4725,7 +4723,7 @@ mch_system(char *cmd, int options) { if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *wcmd = enc_to_utf16(cmd, NULL); + WCHAR *wcmd = enc_to_utf16((char_u *)cmd, NULL); if (wcmd != NULL) { int ret = _wsystem(wcmd); @@ -4768,7 +4766,7 @@ mch_call_shell( wcscat(szShellTitle, L" :sh"); else { - WCHAR *wn = enc_to_utf16(cmd, NULL); + WCHAR *wn = enc_to_utf16((char_u *)cmd, NULL); if (wn != NULL) { @@ -4793,8 +4791,9 @@ mch_call_shell( else { strcat(szShellTitle, " - !"); - if ((strlen(szShellTitle) + strlen(cmd) < sizeof(szShellTitle))) - strcat(szShellTitle, cmd); + if ((strlen(szShellTitle) + strlen((char *)cmd) + < sizeof(szShellTitle))) + strcat(szShellTitle, (char *)cmd); } SetConsoleTitle(szShellTitle); } @@ -4831,7 +4830,7 @@ mch_call_shell( if (cmd == NULL) { - x = mch_system(p_sh, options); + x = mch_system((char *)p_sh, options); } else { @@ -4915,9 +4914,10 @@ mch_call_shell( char_u *cmd_shell = mch_getenv("COMSPEC"); if (cmd_shell == NULL || *cmd_shell == NUL) - cmd_shell = default_shell(); - - subcmd = vim_strsave_escaped_ext(cmdbase, "|", '^', FALSE); + cmd_shell = (char_u *)default_shell(); + + subcmd = vim_strsave_escaped_ext(cmdbase, + (char_u *)"|", '^', FALSE); if (subcmd != NULL) { /* make "cmd.exe /c arguments" */ @@ -4937,7 +4937,7 @@ mch_call_shell( * inherit our handles which causes unpleasant dangling swap * files if we exit before the spawned process */ - if (vim_create_process(newcmd, FALSE, flags, &si, &pi)) + if (vim_create_process((char *)newcmd, FALSE, flags, &si, &pi)) x = 0; else { @@ -5010,7 +5010,7 @@ mch_call_shell( #endif ) { - smsg(_("shell returned %d"), x); + smsg((char_u *)_("shell returned %d"), x); msg_putchar('\n'); } #ifdef FEAT_TITLE @@ -5745,7 +5745,7 @@ mch_write( { /* optimization: use one single write_chars for runs of text, * rather than once per character It ain't curses, but it helps. */ - DWORD prefix = (DWORD)strcspn(s, "\n\r\b\a\033"); + DWORD prefix = (DWORD)strcspn((char *)s, "\n\r\b\a\033"); if (p_wd) { @@ -6083,7 +6083,7 @@ mch_remove(char_u *name) } } #endif - return DeleteFile(name) ? 0 : -1; + return DeleteFile((LPCSTR)name) ? 0 : -1; } @@ -6368,10 +6368,10 @@ mch_access(char *n, int p) WCHAR *wn = NULL; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) - wn = enc_to_utf16(n, NULL); -#endif - - if (mch_isdir(n)) + wn = enc_to_utf16((char_u *)n, NULL); +#endif + + if (mch_isdir((char_u *)n)) { char TempName[_MAX_PATH + 16] = ""; #ifdef FEAT_MBYTE @@ -6414,7 +6414,7 @@ mch_access(char *n, int p) char *pch; WIN32_FIND_DATA d; - vim_strncpy(TempName, n, _MAX_PATH); + vim_strncpy((char_u *)TempName, (char_u *)n, _MAX_PATH); pch = TempName + STRLEN(TempName) - 1; if (*pch != '\\' && *pch != '/') *++pch = '\\'; @@ -6506,7 +6506,7 @@ mch_open(char *name, int flags, int mode if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - wn = enc_to_utf16(name, NULL); + wn = enc_to_utf16((char_u *)name, NULL); if (wn != NULL) { f = _wopen(wn, flags, mode); @@ -6558,8 +6558,8 @@ mch_fopen(char *name, char *mode) else if (newMode == 'b') _set_fmode(_O_BINARY); # endif - wn = enc_to_utf16(name, NULL); - wm = enc_to_utf16(mode, NULL); + wn = enc_to_utf16((char_u *)name, NULL); + wm = enc_to_utf16((char_u *)mode, NULL); if (wn != NULL && wm != NULL) f = _wfopen(wn, wm); vim_free(wn); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1334, +/**/ 1333, /**/ 1332,