From 8969cf98cf3801df31428342394ac4ba4eee6854 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Fri, 13 Jul 2018 19:01:25 +0200 Subject: [PATCH] wineconsole: Use the ARRAY_SIZE() macro. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- programs/wineconsole/curses.c | 2 +- programs/wineconsole/dialog.c | 23 +++++++++-------------- programs/wineconsole/user.c | 18 +++++++++--------- programs/wineconsole/wineconsole.c | 2 +- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c index 7413c8f00f5..6c35554d84f 100644 --- a/programs/wineconsole/curses.c +++ b/programs/wineconsole/curses.c @@ -340,7 +340,7 @@ static void WCCURSES_SetTitle(const struct inner_data* data) { 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]; diff --git a/programs/wineconsole/dialog.c b/programs/wineconsole/dialog.c index 9a14184ba48..898812553a7 100644 --- a/programs/wineconsole/dialog.c +++ b/programs/wineconsole/dialog.c @@ -208,12 +208,10 @@ static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, FillRect(ps.hdc, &ps.rcPaint, CreateSolidBrush(bkcolor)); SetBkColor(ps.hdc, bkcolor); SetTextColor(ps.hdc, get_color(di, IDC_FNT_COLOR_FG)); - len = LoadStringW(GetModuleHandleW(NULL), IDS_FNT_PREVIEW, - buf, sizeof(buf) / sizeof(buf[0])); + len = LoadStringW(GetModuleHandleW(NULL), IDS_FNT_PREVIEW, buf, ARRAY_SIZE(buf)); if (len) TextOutW(ps.hdc, 0, 0, buf, len); - TextOutW(ps.hdc, 0, di->font[size_idx].height, ascii, - sizeof(ascii)/sizeof(ascii[0]) - 1); + TextOutW(ps.hdc, 0, di->font[size_idx].height, ascii, ARRAY_SIZE(ascii) - 1); SelectObject(ps.hdc, hOldFont); } 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}; 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])); 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); 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[1] = config.cell_height; 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); @@ -687,10 +685,8 @@ static INT_PTR WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, L WCHAR cap[256]; WCHAR txt[256]; - LoadStringW(GetModuleHandleW(NULL), IDS_DLG_TIT_ERROR, - cap, sizeof(cap) / sizeof(cap[0])); - LoadStringW(GetModuleHandleW(NULL), IDS_DLG_ERR_SBWINSIZE, - txt, sizeof(txt) / sizeof(cap[0])); + LoadStringW(GetModuleHandleW(NULL), IDS_DLG_TIT_ERROR, cap, ARRAY_SIZE(cap)); + LoadStringW(GetModuleHandleW(NULL), IDS_DLG_ERR_SBWINSIZE, txt, ARRAY_SIZE(txt)); MessageBoxW(hDlg, txt, cap, MB_OK); SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_INVALID); @@ -831,9 +827,8 @@ BOOL WCUSER_GetProperties(struct inner_data* data, BOOL current) memset(&psHead, 0, sizeof(psHead)); psHead.dwSize = sizeof(psHead); - if (!LoadStringW(GetModuleHandleW(NULL), - (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT, - buff, sizeof(buff) / sizeof(buff[0]))) + if (!LoadStringW(GetModuleHandleW(NULL), (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT, + buff, ARRAY_SIZE(buff))) { buff[0] = 'S'; buff[1] = 'e'; diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index 03d0ea18e66..0b29157ef9d 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -823,25 +823,25 @@ static BOOL WCUSER_FillMenu(HMENU hMenu, BOOL sep) hSubMenu = CreateMenu(); 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); - 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); - 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); - 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); - 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); - 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); 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); - 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); - 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); return TRUE; diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 9e3afb19c2b..439099c37a6 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -45,7 +45,7 @@ static void printf_res(UINT uResId, ...) va_list args; 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); vprintf(ansi, args); va_end(args);