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)
RTFFont *f = RTFGetFont(info, info->rtfParam);
if (f)
{
MultiByteToWideChar(CP_ACP, 0, f->rtfFName, -1, fmt.szFaceName, sizeof(fmt.szFaceName)/sizeof(WCHAR));
fmt.szFaceName[sizeof(fmt.szFaceName)/sizeof(WCHAR)-1] = '\0';
MultiByteToWideChar(CP_ACP, 0, f->rtfFName, -1, fmt.szFaceName, ARRAY_SIZE(fmt.szFaceName));
fmt.szFaceName[ARRAY_SIZE(fmt.szFaceName)-1] = '\0';
fmt.bCharSet = f->rtfFCharSet;
fmt.dwMask = CFM_FACE | CFM_CHARSET;
fmt.bPitchAndFamily = f->rtfFPitch | (f->rtfFFamily << 4);
......@@ -5272,10 +5272,9 @@ static BOOL isurlneutral( WCHAR c )
/* Some shortcuts */
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]),
sizeof(c), wchar_comp );
return !!bsearch( &c, neutral_chars, ARRAY_SIZE( neutral_chars ), sizeof(c), wchar_comp );
}
/**
......@@ -5408,7 +5407,7 @@ static BOOL ME_IsCandidateAnURL(ME_TextEditor *editor, const ME_Cursor *start, i
unsigned int i;
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 (!memcmp(prefixes[i].text, bufferW, prefixes[i].length * sizeof(WCHAR)))
......
......@@ -536,7 +536,7 @@ int ME_GetParaBorderWidth(const ME_Context* c, int flags)
int idx = (flags >> 8) & 0xF;
int width;
if (idx >= sizeof(border_details) / sizeof(border_details[0]))
if (idx >= ARRAY_SIZE(border_details))
{
FIXME("Unsupported border value %d\n", idx);
return 0;
......
......@@ -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.
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];
if (num < total) break;
......@@ -228,7 +228,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num )
case PFN_UCROMAN:
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)
{
......
......@@ -2596,13 +2596,13 @@ RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
RTFFlushCPOutputBuffer(info);
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));
info->dwOutputCount += fit;
length -= fit;
string += fit;
if (sizeof(info->OutputBuffer) / sizeof(WCHAR) == info->dwOutputCount)
if (ARRAY_SIZE(info->OutputBuffer) == info->dwOutputCount)
RTFFlushUnicodeOutputBuffer(info);
}
}
......
......@@ -97,7 +97,7 @@ void release_typelib(void)
if (!typelib)
return;
for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
if (typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
......@@ -633,7 +633,7 @@ static void textrange_set_font(ITextRange *range, ITextFont *font)
if (ITextFont_GetName(font, &str) == S_OK) {
fmt.dwMask |= CFM_FACE;
lstrcpynW(fmt.szFaceName, str, sizeof(fmt.szFaceName)/sizeof(WCHAR));
lstrcpynW(fmt.szFaceName, str, ARRAY_SIZE(fmt.szFaceName));
SysFreeString(str);
}
......@@ -817,7 +817,7 @@ static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id prop
fmt.wWeight = value->l;
break;
case FONT_NAME:
lstrcpynW(fmt.szFaceName, value->str, sizeof(fmt.szFaceName)/sizeof(WCHAR));
lstrcpynW(fmt.szFaceName, value->str, ARRAY_SIZE(fmt.szFaceName));
break;
default:
FIXME("unhandled font property %d\n", propid);
......
......@@ -41,7 +41,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
to->cbSize = sizeof(CHARFORMAT2W);
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;
}
......@@ -61,7 +61,7 @@ BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
/* convert face name */
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 */
CopyMemory(&to->wWeight, &f->wWeight, sizeof(CHARFORMAT2A)-FIELD_OFFSET(CHARFORMAT2A, wWeight));
to->cbSize = sizeof(CHARFORMAT2W);
......
......@@ -260,7 +260,7 @@ static void layout_row( ME_DisplayItem *start, const ME_DisplayItem *end )
TRACE("%d runs\n", num_runs);
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 );
log_to_vis = vis_to_log + num_runs;
......@@ -766,7 +766,7 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
ME_Run *run;
ME_DisplayItem *di;
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,
FALSE, FALSE, 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)
{ 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)
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