Commit a1e0a029 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

oleaut32: Use the ARRAY_SIZE() macro.

parent 56b3304a
...@@ -122,9 +122,7 @@ static inline bstr_t *bstr_from_str(BSTR str) ...@@ -122,9 +122,7 @@ static inline bstr_t *bstr_from_str(BSTR str)
static inline bstr_cache_entry_t *get_cache_entry_from_idx(unsigned cache_idx) static inline bstr_cache_entry_t *get_cache_entry_from_idx(unsigned cache_idx)
{ {
return bstr_cache_enabled && cache_idx < sizeof(bstr_cache)/sizeof(*bstr_cache) return bstr_cache_enabled && cache_idx < ARRAY_SIZE(bstr_cache) ? bstr_cache + cache_idx : NULL;
? bstr_cache + cache_idx
: NULL;
} }
static inline bstr_cache_entry_t *get_cache_entry(size_t size) static inline bstr_cache_entry_t *get_cache_entry(size_t size)
...@@ -304,7 +302,7 @@ void WINAPI SysFreeString(BSTR str) ...@@ -304,7 +302,7 @@ void WINAPI SysFreeString(BSTR str)
} }
} }
if(cache_entry->cnt < sizeof(cache_entry->buf)/sizeof(*cache_entry->buf)) { if(cache_entry->cnt < ARRAY_SIZE(cache_entry->buf)) {
cache_entry->buf[(cache_entry->head+cache_entry->cnt) % BUCKET_BUFFER_SIZE] = bstr; cache_entry->buf[(cache_entry->head+cache_entry->cnt) % BUCKET_BUFFER_SIZE] = bstr;
cache_entry->cnt++; cache_entry->cnt++;
......
...@@ -591,7 +591,7 @@ static void realize_font(OLEFontImpl *This) ...@@ -591,7 +591,7 @@ static void realize_font(OLEFontImpl *This)
if(This->gdiFont) if(This->gdiFont)
{ {
old_font = SelectObject(hdc, This->gdiFont); old_font = SelectObject(hdc, This->gdiFont);
GetTextFaceW(hdc, sizeof(text_face) / sizeof(text_face[0]), text_face); GetTextFaceW(hdc, ARRAY_SIZE(text_face), text_face);
SelectObject(hdc, old_font); SelectObject(hdc, old_font);
dec_int_ref(This->gdiFont); dec_int_ref(This->gdiFont);
This->gdiFont = 0; This->gdiFont = 0;
...@@ -645,7 +645,7 @@ static void realize_font(OLEFontImpl *This) ...@@ -645,7 +645,7 @@ static void realize_font(OLEFontImpl *This)
/* Fixup the name and charset properties so that they match the /* Fixup the name and charset properties so that they match the
selected font */ selected font */
old_font = SelectObject(get_dc(), This->gdiFont); old_font = SelectObject(get_dc(), This->gdiFont);
GetTextFaceW(hdc, sizeof(text_face) / sizeof(text_face[0]), text_face); GetTextFaceW(hdc, ARRAY_SIZE(text_face), text_face);
if(lstrcmpiW(text_face, This->description.lpstrName)) if(lstrcmpiW(text_face, This->description.lpstrName))
{ {
HeapFree(GetProcessHeap(), 0, This->description.lpstrName); HeapFree(GetProcessHeap(), 0, This->description.lpstrName);
......
...@@ -2395,7 +2395,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller, ...@@ -2395,7 +2395,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
if (strncmpW(szURLorPath, file, 5) == 0) { if (strncmpW(szURLorPath, file, 5) == 0) {
DWORD size; DWORD size;
hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf, hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf,
sizeof(path_buf)/sizeof(WCHAR), &size, 0); ARRAY_SIZE(path_buf), &size, 0);
if (FAILED(hRes)) if (FAILED(hRes))
return hRes; return hRes;
......
...@@ -387,8 +387,8 @@ _get_typeinfo_for_iid(REFIID riid, ITypeInfo **typeinfo) ...@@ -387,8 +387,8 @@ _get_typeinfo_for_iid(REFIID riid, ITypeInfo **typeinfo)
*typeinfo = NULL; *typeinfo = NULL;
moduleW[0] = 0; moduleW[0] = 0;
if (!actctx_get_typelib_module(riid, moduleW, sizeof(moduleW)/sizeof(moduleW[0]))) { if (!actctx_get_typelib_module(riid, moduleW, ARRAY_SIZE(moduleW))) {
hres = reg_get_typelib_module(riid, moduleW, sizeof(moduleW)/sizeof(moduleW[0])); hres = reg_get_typelib_module(riid, moduleW, ARRAY_SIZE(moduleW));
if (FAILED(hres)) if (FAILED(hres))
return hres; return hres;
} }
...@@ -1470,9 +1470,9 @@ static DWORD WINAPI xCall(int method, void **args) ...@@ -1470,9 +1470,9 @@ static DWORD WINAPI xCall(int method, void **args)
/* Need them for hack below */ /* Need them for hack below */
memset(names,0,sizeof(names)); memset(names,0,sizeof(names));
if (ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames)) if (ITypeInfo_GetNames(tinfo,fdesc->memid,names,ARRAY_SIZE(names),&nrofnames))
nrofnames = 0; nrofnames = 0;
if (nrofnames > sizeof(names)/sizeof(names[0])) if (nrofnames > ARRAY_SIZE(names))
ERR("Need more names!\n"); ERR("Need more names!\n");
xargs = (DWORD *)(args + 1); xargs = (DWORD *)(args + 1);
...@@ -2125,8 +2125,8 @@ TMStubImpl_Invoke( ...@@ -2125,8 +2125,8 @@ TMStubImpl_Invoke(
/* Need them for hack below */ /* Need them for hack below */
memset(names,0,sizeof(names)); memset(names,0,sizeof(names));
ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames); ITypeInfo_GetNames(tinfo,fdesc->memid,names,ARRAY_SIZE(names),&nrofnames);
if (nrofnames > sizeof(names)/sizeof(names[0])) { if (nrofnames > ARRAY_SIZE(names)) {
ERR("Need more names!\n"); ERR("Need more names!\n");
} }
......
...@@ -328,7 +328,7 @@ static HRESULT query_typelib_path( REFGUID guid, WORD wMaj, WORD wMin, ...@@ -328,7 +328,7 @@ static HRESULT query_typelib_path( REFGUID guid, WORD wMaj, WORD wMin,
return TYPE_E_LIBNOTREGISTERED; return TYPE_E_LIBNOTREGISTERED;
nameW = (WCHAR*)((BYTE*)data.lpSectionBase + tlib->name_offset); nameW = (WCHAR*)((BYTE*)data.lpSectionBase + tlib->name_offset);
len = SearchPathW( NULL, nameW, NULL, sizeof(Path)/sizeof(WCHAR), Path, NULL ); len = SearchPathW( NULL, nameW, NULL, ARRAY_SIZE( Path ), Path, NULL );
if (!len) return TYPE_E_LIBNOTREGISTERED; if (!len) return TYPE_E_LIBNOTREGISTERED;
TRACE_(typelib)("got path from context %s\n", debugstr_w(Path)); TRACE_(typelib)("got path from context %s\n", debugstr_w(Path));
...@@ -969,11 +969,11 @@ enddeleteloop: ...@@ -969,11 +969,11 @@ enddeleteloop:
/* check if there is anything besides the FLAGS/HELPDIR keys. /* check if there is anything besides the FLAGS/HELPDIR keys.
If there is, we don't delete them */ If there is, we don't delete them */
tmpLength = sizeof(subKeyName)/sizeof(WCHAR); tmpLength = ARRAY_SIZE(subKeyName);
deleteOtherStuff = TRUE; deleteOtherStuff = TRUE;
i = 0; i = 0;
while(RegEnumKeyExW(key, i++, subKeyName, &tmpLength, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { while(RegEnumKeyExW(key, i++, subKeyName, &tmpLength, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
tmpLength = sizeof(subKeyName)/sizeof(WCHAR); tmpLength = ARRAY_SIZE(subKeyName);
/* if its not FLAGS or HELPDIR, then we must keep the rest of the key */ /* if its not FLAGS or HELPDIR, then we must keep the rest of the key */
if (!strcmpW(subKeyName, FLAGSW)) continue; if (!strcmpW(subKeyName, FLAGSW)) continue;
...@@ -7751,7 +7751,7 @@ static BOOL CALLBACK search_res_tlb(HMODULE hModule, LPCWSTR lpszType, LPWSTR lp ...@@ -7751,7 +7751,7 @@ static BOOL CALLBACK search_res_tlb(HMODULE hModule, LPCWSTR lpszType, LPWSTR lp
if (!(len = GetModuleFileNameW(hModule, szPath, MAX_PATH))) if (!(len = GetModuleFileNameW(hModule, szPath, MAX_PATH)))
return TRUE; return TRUE;
if (snprintfW(szPath + len, sizeof(szPath)/sizeof(WCHAR) - len, formatW, LOWORD(lpszName)) < 0) if (snprintfW(szPath + len, ARRAY_SIZE(szPath) - len, formatW, LOWORD(lpszName)) < 0)
return TRUE; return TRUE;
ret = LoadTypeLibEx(szPath, REGKIND_NONE, &pTLib); ret = LoadTypeLibEx(szPath, REGKIND_NONE, &pTLib);
......
...@@ -449,8 +449,7 @@ static inline const BYTE *VARIANT_GetNamedFormat(LPCWSTR lpszFormat) ...@@ -449,8 +449,7 @@ static inline const BYTE *VARIANT_GetNamedFormat(LPCWSTR lpszFormat)
LPCNAMED_FORMAT fmt; LPCNAMED_FORMAT fmt;
key.name = lpszFormat; key.name = lpszFormat;
fmt = bsearch(&key, VARIANT_NamedFormats, fmt = bsearch(&key, VARIANT_NamedFormats, ARRAY_SIZE(VARIANT_NamedFormats),
sizeof(VARIANT_NamedFormats)/sizeof(NAMED_FORMAT),
sizeof(NAMED_FORMAT), FormatCompareFn); sizeof(NAMED_FORMAT), FormatCompareFn);
return fmt ? fmt->format : NULL; return fmt ? fmt->format : NULL;
} }
...@@ -764,7 +763,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -764,7 +763,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
TRACE("time sep\n"); TRACE("time sep\n");
} }
else if ((*pFormat == 'a' || *pFormat == 'A') && else if ((*pFormat == 'a' || *pFormat == 'A') &&
!strncmpiW(pFormat, szAMPM, sizeof(szAMPM)/sizeof(WCHAR))) !strncmpiW(pFormat, szAMPM, ARRAY_SIZE(szAMPM)))
{ {
/* Date formats: System AM/PM designation /* Date formats: System AM/PM designation
* Other formats: Literal * Other formats: Literal
...@@ -772,8 +771,8 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -772,8 +771,8 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/ */
header->type = FMT_TYPE_DATE; header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE)); NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMPM)/sizeof(WCHAR); pFormat += ARRAY_SIZE(szAMPM);
if (!strncmpW(pFormat, szampm, sizeof(szampm)/sizeof(WCHAR))) if (!strncmpW(pFormat, szampm, ARRAY_SIZE(szampm)))
*pOut++ = FMT_DATE_AMPM_SYS2; *pOut++ = FMT_DATE_AMPM_SYS2;
else else
*pOut++ = FMT_DATE_AMPM_SYS1; *pOut++ = FMT_DATE_AMPM_SYS1;
...@@ -811,8 +810,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -811,8 +810,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*pLastHours = *pLastHours + 2; *pLastHours = *pLastHours + 2;
TRACE("A/P\n"); TRACE("A/P\n");
} }
else if (*pFormat == 'a' && else if (*pFormat == 'a' && !strncmpW(pFormat, szamSlashpm, ARRAY_SIZE(szamSlashpm)))
!strncmpW(pFormat, szamSlashpm, sizeof(szamSlashpm)/sizeof(WCHAR)))
{ {
/* Date formats: lowercase AM or PM designation /* Date formats: lowercase AM or PM designation
* Other formats: Literal * Other formats: Literal
...@@ -820,14 +818,13 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -820,14 +818,13 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/ */
header->type = FMT_TYPE_DATE; header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE)); NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szamSlashpm)/sizeof(WCHAR); pFormat += ARRAY_SIZE(szamSlashpm);
*pOut++ = FMT_DATE_AMPM_LOWER; *pOut++ = FMT_DATE_AMPM_LOWER;
if (pLastHours) if (pLastHours)
*pLastHours = *pLastHours + 2; *pLastHours = *pLastHours + 2;
TRACE("AM/PM\n"); TRACE("AM/PM\n");
} }
else if (*pFormat == 'A' && else if (*pFormat == 'A' && !strncmpW(pFormat, szAMSlashPM, ARRAY_SIZE(szAMSlashPM)))
!strncmpW(pFormat, szAMSlashPM, sizeof(szAMSlashPM)/sizeof(WCHAR)))
{ {
/* Date formats: Uppercase AM or PM designation /* Date formats: Uppercase AM or PM designation
* Other formats: Literal * Other formats: Literal
...@@ -835,7 +832,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -835,7 +832,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/ */
header->type = FMT_TYPE_DATE; header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE)); NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMSlashPM)/sizeof(WCHAR); pFormat += ARRAY_SIZE(szAMSlashPM);
*pOut++ = FMT_DATE_AMPM_UPPER; *pOut++ = FMT_DATE_AMPM_UPPER;
TRACE("AM/PM\n"); TRACE("AM/PM\n");
} }
...@@ -847,7 +844,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -847,7 +844,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/ */
header->type = FMT_TYPE_DATE; header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE)); NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMSlashPM)/sizeof(WCHAR); pFormat += ARRAY_SIZE(szAMSlashPM);
*pOut++ = FMT_DATE_GENERAL; *pOut++ = FMT_DATE_GENERAL;
TRACE("gen date\n"); TRACE("gen date\n");
} }
...@@ -989,14 +986,14 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok, ...@@ -989,14 +986,14 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
fmt_state &= ~FMT_STATE_OPEN_COPY; fmt_state &= ~FMT_STATE_OPEN_COPY;
} }
else if ((*pFormat == 't' || *pFormat == 'T') && else if ((*pFormat == 't' || *pFormat == 'T') &&
!strncmpiW(pFormat, szTTTTT, sizeof(szTTTTT)/sizeof(WCHAR))) !strncmpiW(pFormat, szTTTTT, ARRAY_SIZE(szTTTTT)))
{ {
/* Date formats: System time specifier /* Date formats: System time specifier
* Other formats: Literal * Other formats: Literal
* Types the format if found * Types the format if found
*/ */
header->type = FMT_TYPE_DATE; header->type = FMT_TYPE_DATE;
pFormat += sizeof(szTTTTT)/sizeof(WCHAR); pFormat += ARRAY_SIZE(szTTTTT);
NEED_SPACE(sizeof(BYTE)); NEED_SPACE(sizeof(BYTE));
*pOut++ = FMT_DATE_TIME_SYS; *pOut++ = FMT_DATE_TIME_SYS;
fmt_state &= ~FMT_STATE_OPEN_COPY; fmt_state &= ~FMT_STATE_OPEN_COPY;
...@@ -1316,8 +1313,7 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat, ...@@ -1316,8 +1313,7 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
if (numHeader->flags & FMT_FLAG_THOUSANDS) if (numHeader->flags & FMT_FLAG_THOUSANDS)
{ {
if (!GetLocaleInfoW(lcid, LOCALE_STHOUSAND, thousandSeparator, if (!GetLocaleInfoW(lcid, LOCALE_STHOUSAND, thousandSeparator, ARRAY_SIZE(thousandSeparator)))
sizeof(thousandSeparator)/sizeof(WCHAR)))
{ {
thousandSeparator[0] = ','; thousandSeparator[0] = ',';
thousandSeparator[1] = 0; thousandSeparator[1] = 0;
...@@ -1555,8 +1551,7 @@ VARIANT_FormatNumber_Bool: ...@@ -1555,8 +1551,7 @@ VARIANT_FormatNumber_Bool:
} }
if (localeValue) if (localeValue)
{ {
if (GetLocaleInfoW(lcid, localeValue, pBuff, if (GetLocaleInfoW(lcid, localeValue, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
{ {
TRACE("added %s\n", debugstr_w(pBuff)); TRACE("added %s\n", debugstr_w(pBuff));
while (*pBuff) while (*pBuff)
...@@ -1875,8 +1870,7 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat, ...@@ -1875,8 +1870,7 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
if (localeValue) if (localeValue)
{ {
*pBuff = '\0'; *pBuff = '\0';
if (GetLocaleInfoW(lcid, localeValue, pBuff, if (GetLocaleInfoW(lcid, localeValue, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
{ {
TRACE("added %s\n", debugstr_w(pBuff)); TRACE("added %s\n", debugstr_w(pBuff));
while (*pBuff) while (*pBuff)
...@@ -1892,9 +1886,8 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat, ...@@ -1892,9 +1886,8 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
{ {
WCHAR fmt_buff[80]; WCHAR fmt_buff[80];
if (!GetLocaleInfoW(lcid, dwFmt, fmt_buff, sizeof(fmt_buff)/sizeof(WCHAR)) || if (!GetLocaleInfoW(lcid, dwFmt, fmt_buff, ARRAY_SIZE(fmt_buff)) ||
!get_date_format(lcid, 0, &udate.st, fmt_buff, pBuff, !get_date_format(lcid, 0, &udate.st, fmt_buff, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
{ {
hRes = E_INVALIDARG; hRes = E_INVALIDARG;
goto VARIANT_FormatDate_Exit; goto VARIANT_FormatDate_Exit;
...@@ -2293,8 +2286,7 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT ...@@ -2293,8 +2286,7 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
{ {
WCHAR grouping[16]; WCHAR grouping[16];
grouping[2] = '\0'; grouping[2] = '\0';
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, ARRAY_SIZE(grouping));
sizeof(grouping)/sizeof(WCHAR));
numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0'; numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0';
} }
else if (nGrouping == -1) else if (nGrouping == -1)
...@@ -2310,14 +2302,11 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT ...@@ -2310,14 +2302,11 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
numfmt.NegativeOrder = 1; /* 1 = "-xxx" */ numfmt.NegativeOrder = 1; /* 1 = "-xxx" */
numfmt.lpDecimalSep = decimal; numfmt.lpDecimalSep = decimal;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, ARRAY_SIZE(decimal));
sizeof(decimal)/sizeof(WCHAR));
numfmt.lpThousandSep = thousands; numfmt.lpThousandSep = thousands;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousands, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousands, ARRAY_SIZE(thousands));
sizeof(thousands)/sizeof(WCHAR));
if (GetNumberFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, if (GetNumberFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, buff, ARRAY_SIZE(buff)))
buff, sizeof(buff)/sizeof(WCHAR)))
{ {
*pbstrOut = SysAllocString(buff); *pbstrOut = SysAllocString(buff);
if (!*pbstrOut) if (!*pbstrOut)
...@@ -2473,8 +2462,7 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading, ...@@ -2473,8 +2462,7 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading,
{ {
WCHAR grouping[16]; WCHAR grouping[16];
grouping[2] = '\0'; grouping[2] = '\0';
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, ARRAY_SIZE(grouping));
sizeof(grouping)/sizeof(WCHAR));
numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0'; numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0';
} }
else if (nGrouping == -1) else if (nGrouping == -1)
...@@ -2492,18 +2480,14 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading, ...@@ -2492,18 +2480,14 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading,
GETLOCALENUMBER(LOCALE_ICURRENCY, PositiveOrder); GETLOCALENUMBER(LOCALE_ICURRENCY, PositiveOrder);
numfmt.lpDecimalSep = decimal; numfmt.lpDecimalSep = decimal;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, ARRAY_SIZE(decimal));
sizeof(decimal)/sizeof(WCHAR));
numfmt.lpThousandSep = thousands; numfmt.lpThousandSep = thousands;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, thousands, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, thousands, ARRAY_SIZE(thousands));
sizeof(thousands)/sizeof(WCHAR));
numfmt.lpCurrencySymbol = currency; numfmt.lpCurrencySymbol = currency;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, currency, GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, currency, ARRAY_SIZE(currency));
sizeof(currency)/sizeof(WCHAR));
/* use NLS as per VarFormatNumber() */ /* use NLS as per VarFormatNumber() */
if (GetCurrencyFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, if (GetCurrencyFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, buff, ARRAY_SIZE(buff)))
buff, sizeof(buff)/sizeof(WCHAR)))
{ {
*pbstrOut = SysAllocString(buff); *pbstrOut = SysAllocString(buff);
if (!*pbstrOut) if (!*pbstrOut)
......
...@@ -1549,7 +1549,7 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID ...@@ -1549,7 +1549,7 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID
/* Local currency symbols are often 2 characters */ /* Local currency symbols are often 2 characters */
lpChars->cCurrencyLocal2 = '\0'; lpChars->cCurrencyLocal2 = '\0';
switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, sizeof(buff)/sizeof(WCHAR))) switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, ARRAY_SIZE(buff)))
{ {
case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */ case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */
case 2: lpChars->cCurrencyLocal = buff[0]; case 2: lpChars->cCurrencyLocal = buff[0];
...@@ -1610,7 +1610,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags, ...@@ -1610,7 +1610,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
VARIANT_NUMBER_CHARS chars; VARIANT_NUMBER_CHARS chars;
BYTE rgbTmp[1024]; BYTE rgbTmp[1024];
DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS; DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
int iMaxDigits = sizeof(rgbTmp) / sizeof(BYTE); int iMaxDigits = ARRAY_SIZE(rgbTmp);
int cchUsed = 0; int cchUsed = 0;
TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig); TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig);
......
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