diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-14 11:31:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-15 08:24:33 +0200 |
commit | ec8c98f59869bee0e327d32f39480a0e4b1330bc (patch) | |
tree | ee68d29cd51c60a8a939fd454955410e66e3b66c /i18npool | |
parent | 11503e99be09b4e8faa465559fbdacb06e8896cc (diff) |
use more SAL_N_ELEMENTS part 3
Change-Id: I82e366fefd2e31928b99840fe76649cc3521e623
Reviewed-on: https://gerrit.libreoffice.org/38789
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
4 files changed, 12 insertions, 18 deletions
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx index 102b54b8df77..cab75e6f32ac 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -947,7 +947,7 @@ static const Supported_NumberingType aSupportedTypes[] = {style::NumberingType::CHARS_GREEK_UPPER_LETTER, C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL}, {style::NumberingType::CHARS_GREEK_LOWER_LETTER, S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL}, }; -static const sal_Int32 nSupported_NumberingTypes = sizeof(aSupportedTypes) / sizeof(Supported_NumberingType); +static const sal_Int32 nSupported_NumberingTypes = SAL_N_ELEMENTS(aSupportedTypes); OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index) { diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx index 43c81b5123a6..4418fc287c45 100644 --- a/i18npool/source/nativenumber/nativenumbersupplier.cxx +++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx @@ -841,13 +841,11 @@ struct HebrewNumberChar { { 0x05d0, 1 } }; -static sal_Int16 nbOfHebrewNumberChar = sizeof(HebrewNumberCharArray)/sizeof(HebrewNumberChar); - -static sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0}; -static sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0}; -static sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0}; -static sal_Unicode geresh = 0x05f3; -static sal_Unicode gershayim = 0x05f4; +static const sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0}; +static const sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0}; +static const sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0}; +static const sal_Unicode geresh = 0x05f3; +static const sal_Unicode gershayim = 0x05f4; void makeHebrewNumber(sal_Int64 value, OUStringBuffer& output, bool isLast, bool useGeresh) { @@ -861,7 +859,7 @@ void makeHebrewNumber(sal_Int64 value, OUStringBuffer& output, bool isLast, bool output.append(value == 1000 ? thousand : isLast ? thousands_last : thousands); } else { sal_Int16 nbOfChar = 0; - for (sal_Int32 j = 0; num > 0 && j < nbOfHebrewNumberChar; j++) { + for (sal_Int32 j = 0; num > 0 && j < sal_Int32(SAL_N_ELEMENTS(HebrewNumberCharArray)); j++) { if (num - HebrewNumberCharArray[j].value >= 0) { nbOfChar++; if (num == 15 || num == 16) // substitution for 15 and 16 @@ -952,8 +950,6 @@ struct CyrillicNumberChar { { 0x0430, 1 } }; -static sal_Int16 nbOfCyrillicNumberChar = sizeof(CyrillicNumberCharArray)/sizeof(CyrillicNumberChar); - void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo) { sal_Int16 num = sal::static_int_cast<sal_Int16>(value % 1000); @@ -967,7 +963,7 @@ void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo) addTitlo = false; } - for (sal_Int32 j = 0; num > 0 && j < nbOfCyrillicNumberChar; j++) { + for (sal_Int32 j = 0; num > 0 && j < sal_Int32(SAL_N_ELEMENTS(CyrillicNumberCharArray)); j++) { if (num < 20 && num > 10) { num -= 10; makeCyrillicNumber(num, output, false); diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx index 07a4151bc873..e9a788f5a461 100644 --- a/i18npool/source/textconversion/textconversion_ko.cxx +++ b/i18npool/source/textconversion/textconversion_ko.cxx @@ -87,7 +87,7 @@ sal_Int16 SAL_CALL checkScriptType(sal_Unicode c) sal_Int16 script; } UBlock2Script; - static UBlock2Script scriptList[] = { + static const UBlock2Script scriptList[] = { {UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, SCRIPT_HANGUL}, {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_BOPOMOFO, SCRIPT_HANJA}, {UBLOCK_HANGUL_COMPATIBILITY_JAMO, UBLOCK_HANGUL_COMPATIBILITY_JAMO, SCRIPT_HANGUL}, @@ -98,14 +98,12 @@ sal_Int16 SAL_CALL checkScriptType(sal_Unicode c) {UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, SCRIPT_HANJA}, }; -#define scriptListCount sizeof (scriptList) / sizeof (UBlock2Script) - UBlockCode block=ublock_getCode((sal_uInt32) c); sal_uInt16 i; - for ( i = 0; i < scriptListCount; i++) { + for ( i = 0; i < SAL_N_ELEMENTS(scriptList); i++) { if (block <= scriptList[i].to) break; } - return (i < scriptListCount && block >= scriptList[i].from) ? scriptList[i].script : SCRIPT_OTHERS; + return (i < SAL_N_ELEMENTS(scriptList) && block >= scriptList[i].from) ? scriptList[i].script : SCRIPT_OTHERS; } #ifdef DISABLE_DYNLOADING diff --git a/i18npool/source/transliteration/numtotext_cjk.cxx b/i18npool/source/transliteration/numtotext_cjk.cxx index f1d15d268afd..af633d0c1997 100644 --- a/i18npool/source/transliteration/numtotext_cjk.cxx +++ b/i18npool/source/transliteration/numtotext_cjk.cxx @@ -60,7 +60,7 @@ TRANSLITERATION_NUMTOTEXT( KanjiShortModern_ja_JP, NATNUM7) NumToText##name::NumToText##name() \ { \ table = _table;\ - tableSize = sizeof(_table) / sizeof(sal_Unicode); \ + tableSize = SAL_N_ELEMENTS(_table); \ recycleSymbol = recycle; \ transliterationName = "NumToText"#name; \ implementationName = "com.sun.star.i18n.Transliteration.NumToText"#name; \ |