Commit 90aea35b authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

riched20: Use the ARRAY_SIZE() macro.

parent 3d67641d
...@@ -518,8 +518,8 @@ void ME_RTFCharAttrHook(RTF_Info *info) ...@@ -518,8 +518,8 @@ void ME_RTFCharAttrHook(RTF_Info *info)
RTFFont *f = RTFGetFont(info, info->rtfParam); RTFFont *f = RTFGetFont(info, info->rtfParam);
if (f) if (f)
{ {
MultiByteToWideChar(CP_ACP, 0, f->rtfFName, -1, fmt.szFaceName, sizeof(fmt.szFaceName)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, f->rtfFName, -1, fmt.szFaceName, ARRAY_SIZE(fmt.szFaceName));
fmt.szFaceName[sizeof(fmt.szFaceName)/sizeof(WCHAR)-1] = '\0'; fmt.szFaceName[ARRAY_SIZE(fmt.szFaceName)-1] = '\0';
fmt.bCharSet = f->rtfFCharSet; fmt.bCharSet = f->rtfFCharSet;
fmt.dwMask = CFM_FACE | CFM_CHARSET; fmt.dwMask = CFM_FACE | CFM_CHARSET;
fmt.bPitchAndFamily = f->rtfFPitch | (f->rtfFFamily << 4); fmt.bPitchAndFamily = f->rtfFPitch | (f->rtfFFamily << 4);
...@@ -5272,10 +5272,9 @@ static BOOL isurlneutral( WCHAR c ) ...@@ -5272,10 +5272,9 @@ static BOOL isurlneutral( WCHAR c )
/* Some shortcuts */ /* Some shortcuts */
if (isalnum( c )) return FALSE; if (isalnum( c )) return FALSE;
if (c > neutral_chars[sizeof(neutral_chars) / sizeof(neutral_chars[0]) - 1]) return FALSE; if (c > neutral_chars[ARRAY_SIZE( neutral_chars ) - 1]) return FALSE;
return !!bsearch( &c, neutral_chars, sizeof(neutral_chars) / sizeof(neutral_chars[0]), return !!bsearch( &c, neutral_chars, ARRAY_SIZE( neutral_chars ), sizeof(c), wchar_comp );
sizeof(c), wchar_comp );
} }
/** /**
...@@ -5408,7 +5407,7 @@ static BOOL ME_IsCandidateAnURL(ME_TextEditor *editor, const ME_Cursor *start, i ...@@ -5408,7 +5407,7 @@ static BOOL ME_IsCandidateAnURL(ME_TextEditor *editor, const ME_Cursor *start, i
unsigned int i; unsigned int i;
ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE); ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE);
for (i = 0; i < sizeof(prefixes) / sizeof(*prefixes); i++) for (i = 0; i < ARRAY_SIZE(prefixes); i++)
{ {
if (nChars < prefixes[i].length) continue; if (nChars < prefixes[i].length) continue;
if (!memcmp(prefixes[i].text, bufferW, prefixes[i].length * sizeof(WCHAR))) if (!memcmp(prefixes[i].text, bufferW, prefixes[i].length * sizeof(WCHAR)))
......
...@@ -536,7 +536,7 @@ int ME_GetParaBorderWidth(const ME_Context* c, int flags) ...@@ -536,7 +536,7 @@ int ME_GetParaBorderWidth(const ME_Context* c, int flags)
int idx = (flags >> 8) & 0xF; int idx = (flags >> 8) & 0xF;
int width; int width;
if (idx >= sizeof(border_details) / sizeof(border_details[0])) if (idx >= ARRAY_SIZE(border_details))
{ {
FIXME("Unsupported border value %d\n", idx); FIXME("Unsupported border value %d\n", idx);
return 0; return 0;
......
...@@ -206,7 +206,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num ) ...@@ -206,7 +206,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num )
/* This is not base-26 (or 27) as zeros don't count unless they are leading zeros. /* This is not base-26 (or 27) as zeros don't count unless they are leading zeros.
It's simplest to start with the least significant letter, so first calculate how many letters are needed. */ It's simplest to start with the least significant letter, so first calculate how many letters are needed. */
for (i = 0, total = 0; i < sizeof(letter_base) / sizeof(letter_base[0]); i++) for (i = 0, total = 0; i < ARRAY_SIZE( letter_base ); i++)
{ {
total += letter_base[i]; total += letter_base[i];
if (num < total) break; if (num < total) break;
...@@ -228,7 +228,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num ) ...@@ -228,7 +228,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num )
case PFN_UCROMAN: case PFN_UCROMAN:
if (!num) num = 1; if (!num) num = 1;
for (i = 0; i < sizeof(roman_base) / sizeof(roman_base[0]); i++) for (i = 0; i < ARRAY_SIZE( roman_base ); i++)
{ {
if (i > 0) if (i > 0)
{ {
......
...@@ -2596,13 +2596,13 @@ RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length) ...@@ -2596,13 +2596,13 @@ RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
RTFFlushCPOutputBuffer(info); RTFFlushCPOutputBuffer(info);
while (length) while (length)
{ {
int fit = min(length, sizeof(info->OutputBuffer) / sizeof(WCHAR) - info->dwOutputCount); int fit = min(length, ARRAY_SIZE(info->OutputBuffer) - info->dwOutputCount);
memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR)); memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
info->dwOutputCount += fit; info->dwOutputCount += fit;
length -= fit; length -= fit;
string += fit; string += fit;
if (sizeof(info->OutputBuffer) / sizeof(WCHAR) == info->dwOutputCount) if (ARRAY_SIZE(info->OutputBuffer) == info->dwOutputCount)
RTFFlushUnicodeOutputBuffer(info); RTFFlushUnicodeOutputBuffer(info);
} }
} }
......
...@@ -97,7 +97,7 @@ void release_typelib(void) ...@@ -97,7 +97,7 @@ void release_typelib(void)
if (!typelib) if (!typelib)
return; return;
for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++) for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
if (typeinfos[i]) if (typeinfos[i])
ITypeInfo_Release(typeinfos[i]); ITypeInfo_Release(typeinfos[i]);
...@@ -633,7 +633,7 @@ static void textrange_set_font(ITextRange *range, ITextFont *font) ...@@ -633,7 +633,7 @@ static void textrange_set_font(ITextRange *range, ITextFont *font)
if (ITextFont_GetName(font, &str) == S_OK) { if (ITextFont_GetName(font, &str) == S_OK) {
fmt.dwMask |= CFM_FACE; fmt.dwMask |= CFM_FACE;
lstrcpynW(fmt.szFaceName, str, sizeof(fmt.szFaceName)/sizeof(WCHAR)); lstrcpynW(fmt.szFaceName, str, ARRAY_SIZE(fmt.szFaceName));
SysFreeString(str); SysFreeString(str);
} }
...@@ -817,7 +817,7 @@ static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id prop ...@@ -817,7 +817,7 @@ static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id prop
fmt.wWeight = value->l; fmt.wWeight = value->l;
break; break;
case FONT_NAME: case FONT_NAME:
lstrcpynW(fmt.szFaceName, value->str, sizeof(fmt.szFaceName)/sizeof(WCHAR)); lstrcpynW(fmt.szFaceName, value->str, ARRAY_SIZE(fmt.szFaceName));
break; break;
default: default:
FIXME("unhandled font property %d\n", propid); FIXME("unhandled font property %d\n", propid);
......
...@@ -41,7 +41,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from) ...@@ -41,7 +41,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName)); CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
to->cbSize = sizeof(CHARFORMAT2W); to->cbSize = sizeof(CHARFORMAT2W);
if (f->dwMask & CFM_FACE) { if (f->dwMask & CFM_FACE) {
MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, sizeof(to->szFaceName)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, ARRAY_SIZE(to->szFaceName));
} }
return TRUE; return TRUE;
} }
...@@ -61,7 +61,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from) ...@@ -61,7 +61,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName)); CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
/* convert face name */ /* convert face name */
if (f->dwMask & CFM_FACE) if (f->dwMask & CFM_FACE)
MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, sizeof(to->szFaceName)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, ARRAY_SIZE(to->szFaceName));
/* copy the rest of the 2A structure to 2W */ /* copy the rest of the 2A structure to 2W */
CopyMemory(&to->wWeight, &f->wWeight, sizeof(CHARFORMAT2A)-FIELD_OFFSET(CHARFORMAT2A, wWeight)); CopyMemory(&to->wWeight, &f->wWeight, sizeof(CHARFORMAT2A)-FIELD_OFFSET(CHARFORMAT2A, wWeight));
to->cbSize = sizeof(CHARFORMAT2W); to->cbSize = sizeof(CHARFORMAT2W);
......
...@@ -260,7 +260,7 @@ static void layout_row( ME_DisplayItem *start, const ME_DisplayItem *end ) ...@@ -260,7 +260,7 @@ static void layout_row( ME_DisplayItem *start, const ME_DisplayItem *end )
TRACE("%d runs\n", num_runs); TRACE("%d runs\n", num_runs);
if (!num_runs) return; if (!num_runs) return;
if (num_runs > sizeof(buf) / (sizeof(buf[0]) * 5)) if (num_runs > ARRAY_SIZE( buf ) / 5)
vis_to_log = heap_alloc( num_runs * sizeof(int) * 5 ); vis_to_log = heap_alloc( num_runs * sizeof(int) * 5 );
log_to_vis = vis_to_log + num_runs; log_to_vis = vis_to_log + num_runs;
...@@ -766,7 +766,7 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p ) ...@@ -766,7 +766,7 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
ME_Run *run; ME_Run *run;
ME_DisplayItem *di; ME_DisplayItem *di;
SCRIPT_ITEM buf[16], *items = buf; SCRIPT_ITEM buf[16], *items = buf;
int items_passed = sizeof( buf ) / sizeof( buf[0] ), num_items, cur_item; int items_passed = ARRAY_SIZE( buf ), num_items, cur_item;
SCRIPT_CONTROL control = { LANG_USER_DEFAULT, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, SCRIPT_CONTROL control = { LANG_USER_DEFAULT, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, 0 }; FALSE, FALSE, 0 };
SCRIPT_STATE state = { 0, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0 }; SCRIPT_STATE state = { 0, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0 };
......
...@@ -760,7 +760,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt) ...@@ -760,7 +760,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt)
{ CFE_STRIKEOUT, "\\strike", "\\strike0" }, { CFE_STRIKEOUT, "\\strike", "\\strike0" },
}; };
for (i = 0; i < sizeof(effects) / sizeof(effects[0]); i++) for (i = 0; i < ARRAY_SIZE( effects ); i++)
{ {
if ((old_fmt->dwEffects ^ fmt->dwEffects) & effects[i].effect) if ((old_fmt->dwEffects ^ fmt->dwEffects) & effects[i].effect)
strcat( props, fmt->dwEffects & effects[i].effect ? effects[i].on : effects[i].off ); strcat( props, fmt->dwEffects & effects[i].effect ? effects[i].on : effects[i].off );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment