wineconsole: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-07-13 19:01:25 +02:00 committed by Alexandre Julliard
parent d7fb7dfb46
commit 8969cf98cf
4 changed files with 20 additions and 25 deletions

View File

@ -340,7 +340,7 @@ static void WCCURSES_SetTitle(const struct inner_data* data)
{ {
WCHAR wbuf[256]; WCHAR wbuf[256];
if (WINECON_GetConsoleTitle(data->hConIn, wbuf, sizeof(wbuf)/sizeof(WCHAR))) if (WINECON_GetConsoleTitle(data->hConIn, wbuf, ARRAY_SIZE(wbuf)))
{ {
char buffer[256]; char buffer[256];

View File

@ -208,12 +208,10 @@ static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam,
FillRect(ps.hdc, &ps.rcPaint, CreateSolidBrush(bkcolor)); FillRect(ps.hdc, &ps.rcPaint, CreateSolidBrush(bkcolor));
SetBkColor(ps.hdc, bkcolor); SetBkColor(ps.hdc, bkcolor);
SetTextColor(ps.hdc, get_color(di, IDC_FNT_COLOR_FG)); SetTextColor(ps.hdc, get_color(di, IDC_FNT_COLOR_FG));
len = LoadStringW(GetModuleHandleW(NULL), IDS_FNT_PREVIEW, len = LoadStringW(GetModuleHandleW(NULL), IDS_FNT_PREVIEW, buf, ARRAY_SIZE(buf));
buf, sizeof(buf) / sizeof(buf[0]));
if (len) if (len)
TextOutW(ps.hdc, 0, 0, buf, len); TextOutW(ps.hdc, 0, 0, buf, len);
TextOutW(ps.hdc, 0, di->font[size_idx].height, ascii, TextOutW(ps.hdc, 0, di->font[size_idx].height, ascii, ARRAY_SIZE(ascii) - 1);
sizeof(ascii)/sizeof(ascii[0]) - 1);
SelectObject(ps.hdc, hOldFont); SelectObject(ps.hdc, hOldFont);
} }
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
@ -366,7 +364,7 @@ static int CALLBACK font_enum_size(const LOGFONTW* lf, const TEXTMETRICW* tm,
static const int sizes[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72}; static const int sizes[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
int i; int i;
di->nFont = sizeof(sizes) / sizeof(sizes[0]); di->nFont = ARRAY_SIZE(sizes);
di->font = HeapAlloc(GetProcessHeap(), 0, di->nFont * sizeof(di->font[0])); di->font = HeapAlloc(GetProcessHeap(), 0, di->nFont * sizeof(di->font[0]));
for (i = 0; i < di->nFont; i++) for (i = 0; i < di->nFont; i++)
{ {
@ -459,11 +457,11 @@ static BOOL select_font(struct dialog_info* di)
SendDlgItemMessageW(di->hDlg, IDC_FNT_PREVIEW, WM_SETFONT, (WPARAM)hFont, TRUE); SendDlgItemMessageW(di->hDlg, IDC_FNT_PREVIEW, WM_SETFONT, (WPARAM)hFont, TRUE);
if (hOldFont) DeleteObject(hOldFont); if (hOldFont) DeleteObject(hOldFont);
LoadStringW(GetModuleHandleW(NULL), IDS_FNT_DISPLAY, fmt, sizeof(fmt) / sizeof(fmt[0])); LoadStringW(GetModuleHandleW(NULL), IDS_FNT_DISPLAY, fmt, ARRAY_SIZE(fmt));
args[0] = config.cell_width; args[0] = config.cell_width;
args[1] = config.cell_height; args[1] = config.cell_height;
FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
fmt, 0, 0, buf, sizeof(buf)/sizeof(*buf), (__ms_va_list*)args); fmt, 0, 0, buf, ARRAY_SIZE(buf), (__ms_va_list*)args);
SendDlgItemMessageW(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf); SendDlgItemMessageW(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf);
@ -687,10 +685,8 @@ static INT_PTR WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, L
WCHAR cap[256]; WCHAR cap[256];
WCHAR txt[256]; WCHAR txt[256];
LoadStringW(GetModuleHandleW(NULL), IDS_DLG_TIT_ERROR, LoadStringW(GetModuleHandleW(NULL), IDS_DLG_TIT_ERROR, cap, ARRAY_SIZE(cap));
cap, sizeof(cap) / sizeof(cap[0])); LoadStringW(GetModuleHandleW(NULL), IDS_DLG_ERR_SBWINSIZE, txt, ARRAY_SIZE(txt));
LoadStringW(GetModuleHandleW(NULL), IDS_DLG_ERR_SBWINSIZE,
txt, sizeof(txt) / sizeof(cap[0]));
MessageBoxW(hDlg, txt, cap, MB_OK); MessageBoxW(hDlg, txt, cap, MB_OK);
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_INVALID); SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_INVALID);
@ -831,9 +827,8 @@ BOOL WCUSER_GetProperties(struct inner_data* data, BOOL current)
memset(&psHead, 0, sizeof(psHead)); memset(&psHead, 0, sizeof(psHead));
psHead.dwSize = sizeof(psHead); psHead.dwSize = sizeof(psHead);
if (!LoadStringW(GetModuleHandleW(NULL), if (!LoadStringW(GetModuleHandleW(NULL), (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT,
(current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT, buff, ARRAY_SIZE(buff)))
buff, sizeof(buff) / sizeof(buff[0])))
{ {
buff[0] = 'S'; buff[0] = 'S';
buff[1] = 'e'; buff[1] = 'e';

View File

@ -823,25 +823,25 @@ static BOOL WCUSER_FillMenu(HMENU hMenu, BOOL sep)
hSubMenu = CreateMenu(); hSubMenu = CreateMenu();
if (!hSubMenu) return FALSE; if (!hSubMenu) return FALSE;
LoadStringW(hInstance, IDS_MARK, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_MARK, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_MARK, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_MARK, buff);
LoadStringW(hInstance, IDS_COPY, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_COPY, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_COPY, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_COPY, buff);
LoadStringW(hInstance, IDS_PASTE, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_PASTE, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PASTE, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PASTE, buff);
LoadStringW(hInstance, IDS_SELECTALL, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_SELECTALL, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SELECTALL, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SELECTALL, buff);
LoadStringW(hInstance, IDS_SCROLL, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_SCROLL, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SCROLL, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SCROLL, buff);
LoadStringW(hInstance, IDS_SEARCH, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_SEARCH, buff, ARRAY_SIZE(buff));
InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SEARCH, buff); InsertMenuW(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SEARCH, buff);
if (sep) InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL); if (sep) InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);
LoadStringW(hInstance, IDS_EDIT, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_EDIT, buff, ARRAY_SIZE(buff));
InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, buff); InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, buff);
LoadStringW(hInstance, IDS_DEFAULT, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_DEFAULT, buff, ARRAY_SIZE(buff));
InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_DEFAULT, buff); InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_DEFAULT, buff);
LoadStringW(hInstance, IDS_PROPERTIES, buff, sizeof(buff) / sizeof(buff[0])); LoadStringW(hInstance, IDS_PROPERTIES, buff, ARRAY_SIZE(buff));
InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PROPERTIES, buff); InsertMenuW(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PROPERTIES, buff);
return TRUE; return TRUE;

View File

@ -45,7 +45,7 @@ static void printf_res(UINT uResId, ...)
va_list args; va_list args;
va_start(args, uResId); va_start(args, uResId);
LoadStringW(GetModuleHandleW(NULL), uResId, buffer, sizeof(buffer)/sizeof(buffer[0])); LoadStringW(GetModuleHandleW(NULL), uResId, buffer, ARRAY_SIZE(buffer));
WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, ansi, sizeof(ansi), NULL, NULL); WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, ansi, sizeof(ansi), NULL, NULL);
vprintf(ansi, args); vprintf(ansi, args);
va_end(args); va_end(args);