Skip to content

Commit 418f81b

Browse files
committed
patch 7.4.1339
Problem: Warnings when building the GUI with MingW. (Cesar Romani) Solution: Add type cats. (Yasuhiro Matsumoto)
1 parent 0c2c96e commit 418f81b

6 files changed

Lines changed: 68 additions & 57 deletions

File tree

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ edit(
328328
{
329329
int c = 0;
330330
char_u *ptr;
331-
int lastc;
331+
int lastc = 0;
332332
int mincol;
333333
static linenr_T o_lnum = 0;
334334
int i;

src/gui_w32.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ _WndProc(
11311131

11321132
if (STRLEN(str) < sizeof(lpdi->szText)
11331133
|| ((tt_text = vim_strsave(str)) == NULL))
1134-
vim_strncpy(lpdi->szText, str,
1134+
vim_strncpy((char_u *)lpdi->szText, str,
11351135
sizeof(lpdi->szText) - 1);
11361136
else
11371137
lpdi->lpszText = tt_text;
@@ -1747,9 +1747,9 @@ gui_mch_init(void)
17471747

17481748
/* Initialise the struct */
17491749
s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
1750-
s_findrep_struct.lpstrFindWhat = alloc(MSWIN_FR_BUFSIZE);
1750+
s_findrep_struct.lpstrFindWhat = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
17511751
s_findrep_struct.lpstrFindWhat[0] = NUL;
1752-
s_findrep_struct.lpstrReplaceWith = alloc(MSWIN_FR_BUFSIZE);
1752+
s_findrep_struct.lpstrReplaceWith = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
17531753
s_findrep_struct.lpstrReplaceWith[0] = NUL;
17541754
s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
17551755
s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
@@ -2099,7 +2099,7 @@ GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *lenp)
20992099
pImmGetCompositionStringA(hIMC, GCS, buf, ret);
21002100

21012101
/* convert from codepage to UCS-2 */
2102-
MultiByteToWideChar_alloc(GetACP(), 0, buf, ret, &wbuf, lenp);
2102+
MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp);
21032103
vim_free(buf);
21042104

21052105
return (short_u *)wbuf;
@@ -3028,7 +3028,7 @@ rebuild_tearoff(vimmenu_T *menu)
30283028

30293029
HWND thwnd = menu->tearoff_handle;
30303030

3031-
GetWindowText(thwnd, tbuf, 127);
3031+
GetWindowText(thwnd, (LPSTR)tbuf, 127);
30323032
if (GetWindowRect(thwnd, &trect)
30333033
&& GetWindowRect(s_hwnd, &rct)
30343034
&& GetClientRect(s_hwnd, &roct))
@@ -3174,7 +3174,7 @@ dialog_callback(
31743174
else
31753175
# endif
31763176
GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
3177-
s_textfield, IOSIZE);
3177+
(LPSTR)s_textfield, IOSIZE);
31783178
}
31793179

31803180
/*
@@ -3216,7 +3216,7 @@ dialog_callback(
32163216
* If stubbing out this fn, return 1.
32173217
*/
32183218

3219-
static const char_u *dlg_icons[] = /* must match names in resource file */
3219+
static const char *dlg_icons[] = /* must match names in resource file */
32203220
{
32213221
"IDR_VIM",
32223222
"IDR_VIM_ERROR",
@@ -3353,7 +3353,7 @@ gui_mch_dialog(
33533353
fontHeight = fontInfo.tmHeight;
33543354

33553355
/* Minimum width for horizontal button */
3356-
minButtonWidth = GetTextWidth(hdc, "Cancel", 6);
3356+
minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6);
33573357

33583358
/* Maximum width of a dialog, if possible */
33593359
if (s_hwnd == NULL)
@@ -3617,7 +3617,7 @@ gui_mch_dialog(
36173617
+ 2 * fontHeight * i),
36183618
PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
36193619
(WORD)(PixelToDialogY(2 * fontHeight) - 1),
3620-
(WORD)(IDCANCEL + 1 + i), (WORD)0x0080, pstart);
3620+
(WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
36213621
}
36223622
else
36233623
{
@@ -3628,7 +3628,7 @@ gui_mch_dialog(
36283628
PixelToDialogY(buttonYpos), /* TBK */
36293629
PixelToDialogX(buttonWidths[i]),
36303630
(WORD)(PixelToDialogY(2 * fontHeight) - 1),
3631-
(WORD)(IDCANCEL + 1 + i), (WORD)0x0080, pstart);
3631+
(WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
36323632
}
36333633
pstart = pend + 1; /*next button*/
36343634
}
@@ -3649,7 +3649,7 @@ gui_mch_dialog(
36493649
PixelToDialogY(dlgPaddingY),
36503650
(WORD)(PixelToDialogX(messageWidth) + 1),
36513651
PixelToDialogY(msgheight),
3652-
DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, message);
3652+
DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message);
36533653

36543654
/* Edit box */
36553655
if (textfield != NULL)
@@ -3659,7 +3659,7 @@ gui_mch_dialog(
36593659
PixelToDialogY(2 * dlgPaddingY + msgheight),
36603660
PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
36613661
PixelToDialogY(fontHeight + dlgPaddingY),
3662-
DLG_NONBUTTON_CONTROL + 2, (WORD)0x0081, textfield);
3662+
DLG_NONBUTTON_CONTROL + 2, (WORD)0x0081, (char *)textfield);
36633663
*pnumitems += 1;
36643664
}
36653665

@@ -3798,7 +3798,7 @@ nCopyAnsiToWideChar(
37983798
if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
37993799
{
38003800
/* Not a codepage, use our own conversion function. */
3801-
wn = enc_to_utf16(lpAnsiIn, NULL);
3801+
wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
38023802
if (wn != NULL)
38033803
{
38043804
wcscpy(lpWCStr, wn);
@@ -4043,7 +4043,7 @@ gui_mch_tearoff(
40434043

40444044
/* Calculate width of a single space. Used for padding columns to the
40454045
* right width. */
4046-
spaceWidth = GetTextWidth(hdc, " ", 1);
4046+
spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1);
40474047

40484048
/* Figure out max width of the text column, the accelerator column and the
40494049
* optional submenu column. */
@@ -4086,7 +4086,7 @@ gui_mch_tearoff(
40864086
textWidth = columnWidths[0] + columnWidths[1];
40874087
if (submenuWidth != 0)
40884088
{
4089-
submenuWidth = GetTextWidth(hdc, TEAROFF_SUBMENU_LABEL,
4089+
submenuWidth = GetTextWidth(hdc, (char_u *)TEAROFF_SUBMENU_LABEL,
40904090
(int)STRLEN(TEAROFF_SUBMENU_LABEL));
40914091
textWidth += submenuWidth;
40924092
}
@@ -4262,7 +4262,7 @@ gui_mch_tearoff(
42624262
(WORD)(sepPadding + 1 + 13 * (*pnumitems)),
42634263
(WORD)PixelToDialogX(dlgwidth - 2 * TEAROFF_PADDING_X),
42644264
(WORD)12,
4265-
menuID, (WORD)0x0080, label);
4265+
menuID, (WORD)0x0080, (char *)label);
42664266
vim_free(label);
42674267
(*pnumitems)++;
42684268
}
@@ -4360,7 +4360,7 @@ get_toolbar_bitmap(vimmenu_T *menu)
43604360
gui_find_iconfile(menu->iconfile, fname, "bmp");
43614361
hbitmap = LoadImage(
43624362
NULL,
4363-
fname,
4363+
(LPCSTR)fname,
43644364
IMAGE_BITMAP,
43654365
TOOLBAR_BUTTON_WIDTH,
43664366
TOOLBAR_BUTTON_HEIGHT,
@@ -4381,7 +4381,7 @@ get_toolbar_bitmap(vimmenu_T *menu)
43814381
menu->dname, fname, "bmp") == OK))
43824382
hbitmap = LoadImage(
43834383
NULL,
4384-
fname,
4384+
(LPCSTR)fname,
43854385
IMAGE_BITMAP,
43864386
TOOLBAR_BUTTON_WIDTH,
43874387
TOOLBAR_BUTTON_HEIGHT,
@@ -4629,14 +4629,15 @@ gui_mch_register_sign(char_u *signfile)
46294629
do_load = 0;
46304630

46314631
if (do_load)
4632-
sign.hImage = (HANDLE)LoadImage(NULL, signfile, sign.uType,
4632+
sign.hImage = (HANDLE)LoadImage(NULL, (LPCSTR)signfile, sign.uType,
46334633
gui.char_width * 2, gui.char_height,
46344634
LR_LOADFROMFILE | LR_CREATEDIBSECTION);
46354635
#ifdef FEAT_XPM_W32
46364636
if (!STRICMP(ext, ".xpm"))
46374637
{
46384638
sign.uType = IMAGE_XPM;
4639-
LoadXpmImage(signfile, (HBITMAP *)&sign.hImage, (HBITMAP *)&sign.hShape);
4639+
LoadXpmImage((char *)signfile, (HBITMAP *)&sign.hImage,
4640+
(HBITMAP *)&sign.hShape);
46404641
}
46414642
#endif
46424643
}
@@ -4740,13 +4741,13 @@ multiline_balloon_available(void)
47404741
UINT vlen = 0;
47414742
void *data = alloc(len);
47424743

4743-
if (data != NULL
4744+
if ((data != NULL
47444745
&& GetFileVersionInfo(comctl_dll, 0, len, data)
47454746
&& VerQueryValue(data, "\\", (void **)&ver, &vlen)
47464747
&& vlen
4747-
&& HIWORD(ver->dwFileVersionMS) > 4
4748-
|| (HIWORD(ver->dwFileVersionMS) == 4
4749-
&& LOWORD(ver->dwFileVersionMS) >= 70))
4748+
&& HIWORD(ver->dwFileVersionMS) > 4)
4749+
|| ((HIWORD(ver->dwFileVersionMS) == 4
4750+
&& LOWORD(ver->dwFileVersionMS) >= 70)))
47504751
{
47514752
vim_free(data);
47524753
multiline_tip = TRUE;
@@ -4908,7 +4909,7 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
49084909
{
49094910
gui_mch_disable_beval_area(cur_beval);
49104911
beval->showState = ShS_SHOWING;
4911-
make_tooltip(beval, mesg, pt);
4912+
make_tooltip(beval, (char *)mesg, pt);
49124913
}
49134914
// TRACE0("gui_mch_post_balloon }}}");
49144915
}

src/gui_w48.c

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
534534
else
535535
{
536536
string[0] = ch;
537-
len = MultiByteToWideChar(GetACP(), 0, string, 1, wstring, 2);
537+
len = MultiByteToWideChar(GetACP(), 0, (LPCSTR)string,
538+
1, wstring, 2);
538539
}
539540
}
540541
else
@@ -551,7 +552,7 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
551552
if (enc_codepage > 0)
552553
{
553554
len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
554-
string, slen, 0, NULL);
555+
(LPSTR)string, slen, 0, NULL);
555556
/* If we had included the ALT key into the character but now the
556557
* upper bit is no longer set, that probably means the conversion
557558
* failed. Convert the original character and set the upper bit
@@ -560,7 +561,7 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
560561
{
561562
wstring[0] = ch & 0x7f;
562563
len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
563-
string, slen, 0, NULL);
564+
(LPSTR)string, slen, 0, NULL);
564565
if (len == 1) /* safety check */
565566
string[0] |= 0x80;
566567
}
@@ -921,7 +922,7 @@ findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
921922
lpfrw->hwndOwner = lpfr->hwndOwner;
922923
lpfrw->Flags = lpfr->Flags;
923924

924-
wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL);
925+
wp = enc_to_utf16((char_u *)lpfr->lpstrFindWhat, NULL);
925926
wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
926927
vim_free(wp);
927928

@@ -938,12 +939,12 @@ findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
938939

939940
lpfr->Flags = lpfrw->Flags;
940941

941-
p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL);
942-
vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
942+
p = utf16_to_enc((short_u*)lpfrw->lpstrFindWhat, NULL);
943+
vim_strncpy((char_u *)lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
943944
vim_free(p);
944945

945-
p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL);
946-
vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
946+
p = utf16_to_enc((short_u*)lpfrw->lpstrReplaceWith, NULL);
947+
vim_strncpy((char_u *)lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
947948
vim_free(p);
948949
}
949950
# endif
@@ -1000,8 +1001,8 @@ _OnFindRepl(void)
10001001
if (s_findrep_struct.Flags & FR_MATCHCASE)
10011002
flags |= FRD_MATCH_CASE;
10021003
down = (s_findrep_struct.Flags & FR_DOWN) != 0;
1003-
gui_do_findrepl(flags, s_findrep_struct.lpstrFindWhat,
1004-
s_findrep_struct.lpstrReplaceWith, down);
1004+
gui_do_findrepl(flags, (char_u *)s_findrep_struct.lpstrFindWhat,
1005+
(char_u *)s_findrep_struct.lpstrReplaceWith, down);
10051006
}
10061007
}
10071008
#endif
@@ -1530,7 +1531,7 @@ gui_mch_get_color(char_u *name)
15301531
int r, g, b;
15311532
int i;
15321533

1533-
if (name[0] == '#' && strlen(name) == 7)
1534+
if (name[0] == '#' && STRLEN(name) == 7)
15341535
{
15351536
/* Name is in "#rrggbb" format */
15361537
r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
@@ -2268,7 +2269,7 @@ GetTextWidth(HDC hdc, char_u *str, int len)
22682269
{
22692270
SIZE size;
22702271

2271-
GetTextExtentPoint(hdc, str, len, &size);
2272+
GetTextExtentPoint(hdc, (LPCSTR)str, len, &size);
22722273
return size.cx;
22732274
}
22742275

@@ -2468,10 +2469,11 @@ show_tabline_popup_menu(void)
24682469

24692470
if (first_tabpage->tp_next != NULL)
24702471
add_tabline_popup_menu_entry(tab_pmenu,
2471-
TABLINE_MENU_CLOSE, _("Close tab"));
2472-
add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_NEW, _("New tab"));
2473-
add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_OPEN,
2474-
_("Open tab..."));
2472+
TABLINE_MENU_CLOSE, (char_u *)_("Close tab"));
2473+
add_tabline_popup_menu_entry(tab_pmenu,
2474+
TABLINE_MENU_NEW, (char_u *)_("New tab"));
2475+
add_tabline_popup_menu_entry(tab_pmenu,
2476+
TABLINE_MENU_OPEN, (char_u *)_("Open tab..."));
24752477

24762478
GetCursorPos(&pt);
24772479
rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
@@ -2583,7 +2585,7 @@ gui_mch_update_tabline(void)
25832585
}
25842586

25852587
get_tabline_label(tp, FALSE);
2586-
tie.pszText = NameBuff;
2588+
tie.pszText = (LPSTR)NameBuff;
25872589
#ifdef FEAT_MBYTE
25882590
wstr = NULL;
25892591
if (use_unicode)
@@ -2680,7 +2682,7 @@ initialise_findrep(char_u *initial_string)
26802682
if (wword)
26812683
s_findrep_struct.Flags |= FR_WHOLEWORD;
26822684
if (entry_text != NULL && *entry_text != NUL)
2683-
vim_strncpy(s_findrep_struct.lpstrFindWhat, entry_text,
2685+
vim_strncpy((char_u *)s_findrep_struct.lpstrFindWhat, entry_text,
26842686
s_findrep_struct.wFindWhatLen - 1);
26852687
vim_free(entry_text);
26862688
}
@@ -3194,11 +3196,11 @@ logfont2name(LOGFONT lf)
31943196
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
31953197
{
31963198
int len;
3197-
acp_to_enc(lf.lfFaceName, (int)strlen(lf.lfFaceName),
3199+
acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName),
31983200
(char_u **)&font_name, &len);
31993201
}
32003202
#endif
3201-
res = alloc((unsigned)(strlen(font_name) + 20
3203+
res = (char *)alloc((unsigned)(strlen(font_name) + 20
32023204
+ (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
32033205
if (res != NULL)
32043206
{
@@ -3233,7 +3235,7 @@ logfont2name(LOGFONT lf)
32333235
if (font_name != lf.lfFaceName)
32343236
vim_free(font_name);
32353237
#endif
3236-
return res;
3238+
return (char_u *)res;
32373239
}
32383240

32393241

@@ -3323,7 +3325,7 @@ gui_mch_init_font(char_u *font_name, int fontset)
33233325
return FAIL;
33243326

33253327
if (font_name == NULL)
3326-
font_name = lf.lfFaceName;
3328+
font_name = (char_u *)lf.lfFaceName;
33273329
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
33283330
norm_logfont = lf;
33293331
sub_logfont = lf;
@@ -3753,12 +3755,12 @@ gui_mch_browse(
37533755
fileStruct.lStructSize = sizeof(fileStruct);
37543756
#endif
37553757

3756-
fileStruct.lpstrTitle = title;
3757-
fileStruct.lpstrDefExt = ext;
3758+
fileStruct.lpstrTitle = (LPSTR)title;
3759+
fileStruct.lpstrDefExt = (LPSTR)ext;
37583760

3759-
fileStruct.lpstrFile = fileBuf;
3761+
fileStruct.lpstrFile = (LPSTR)fileBuf;
37603762
fileStruct.nMaxFile = MAXPATHL;
3761-
fileStruct.lpstrFilter = filterp;
3763+
fileStruct.lpstrFilter = (LPSTR)filterp;
37623764
fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/
37633765
/* has an initial dir been specified? */
37643766
if (initdir != NULL && *initdir != NUL)
@@ -3769,7 +3771,7 @@ gui_mch_browse(
37693771
for (p = initdirp; *p != NUL; ++p)
37703772
if (*p == '/')
37713773
*p = '\\';
3772-
fileStruct.lpstrInitialDir = initdirp;
3774+
fileStruct.lpstrInitialDir = (LPSTR)initdirp;
37733775
}
37743776

37753777
/*
@@ -3851,7 +3853,7 @@ _OnDropFiles(
38513853
#endif
38523854
{
38533855
DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
3854-
fnames[i] = vim_strsave(szFile);
3856+
fnames[i] = vim_strsave((char_u *)szFile);
38553857
}
38563858
}
38573859

0 commit comments

Comments
 (0)