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>
This commit is contained in:
Noel Grandin 2017-06-14 11:31:15 +02:00
parent 11503e99be
commit ec8c98f598
25 changed files with 62 additions and 77 deletions

View File

@ -423,7 +423,7 @@ AnimationNode::AnimationNode( sal_Int16 nNodeType )
mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ), mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ),
mfIterateInterval(0.0) mfIterateInterval(0.0)
{ {
assert((sal_uInt32)nNodeType < sizeof(mpTypes)/sizeof(Sequence<Type>*)); assert(nNodeType < int(SAL_N_ELEMENTS(mpTypes)));
} }
AnimationNode::AnimationNode( const AnimationNode& rNode ) AnimationNode::AnimationNode( const AnimationNode& rNode )

View File

@ -39,7 +39,7 @@ private:
// cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java: // cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java:
void Test::testNothingLostFromLruList() { void Test::testNothingLostFromLruList() {
int a[8]; int a[8];
for (int i = 0; i != sizeof a / sizeof a[0]; ++i) { for (int i = 0; i != int(SAL_N_ELEMENTS(a)); ++i) {
for (int j = 0; j != i; ++j) { for (int j = 0; j != i; ++j) {
a[j] = 0; a[j] = 0;
} }

View File

@ -694,11 +694,11 @@ SyntaxHighlighter::SyntaxHighlighter(HighlighterLanguage language):
{ {
case HighlighterLanguage::Basic: case HighlighterLanguage::Basic:
m_tokenizer->setKeyWords( strListBasicKeyWords, m_tokenizer->setKeyWords( strListBasicKeyWords,
sizeof( strListBasicKeyWords ) / sizeof( char* )); SAL_N_ELEMENTS( strListBasicKeyWords ));
break; break;
case HighlighterLanguage::SQL: case HighlighterLanguage::SQL:
m_tokenizer->setKeyWords( strListSqlKeyWords, m_tokenizer->setKeyWords( strListSqlKeyWords,
sizeof( strListSqlKeyWords ) / sizeof( char* )); SAL_N_ELEMENTS( strListSqlKeyWords ));
break; break;
default: default:
assert(false); // this cannot happen assert(false); // this cannot happen

View File

@ -591,7 +591,7 @@ bool WriterThread::iteration() {
OUString("bloaters") }; OUString("bloaters") };
test_.setKey(path_, name_, css::uno::Any(options[index_])); test_.setKey(path_, name_, css::uno::Any(options[index_]));
index_ = (index_ + 1) % (sizeof options / sizeof (OUString)); index_ = (index_ + 1) % SAL_N_ELEMENTS(options);
return true; return true;
} }
@ -614,7 +614,7 @@ void Test::testThreads()
{ OUString("/org.openoffice.System"), { OUString("/org.openoffice.System"),
OUString("L10N/Locale") } OUString("L10N/Locale") }
}; };
std::size_t const numReaders = sizeof list / sizeof (Entry); std::size_t const numReaders = SAL_N_ELEMENTS(list);
std::size_t const numWriters = numReaders - 2; std::size_t const numWriters = numReaders - 2;
ReaderThread * readers[numReaders]; ReaderThread * readers[numReaders];
WriterThread * writers[numWriters]; WriterThread * writers[numWriters];

View File

@ -201,7 +201,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE , tString ) PropertyDef( statics.TYPE , tString )
}; };
ist.pProps = createPropertyArrayHelper( ist.pProps = createPropertyArrayHelper(
tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY ); tableDef, SAL_N_ELEMENTS(tableDef), READONLY );
statics.refl.tableDescriptor.implName = statics.refl.tableDescriptor.implName =
"org.openoffice.comp.pq.sdbcx.TableDescriptor"; "org.openoffice.comp.pq.sdbcx.TableDescriptor";
@ -240,7 +240,7 @@ Statics & getStatics()
PropertyDefEx( statics.TYPE_NAME , tString ,READONLY) PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
}; };
statics.refl.column.pProps = createPropertyArrayHelper( statics.refl.column.pProps = createPropertyArrayHelper(
columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) ); columnDef, SAL_N_ELEMENTS(columnDef) );
statics.refl.columnDescriptor.implName = statics.refl.columnDescriptor.implName =
"org.openoffice.comp.pq.sdbcx.ColumnDescriptor"; "org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
@ -282,7 +282,7 @@ Statics & getStatics()
PropertyDef( statics.UPDATE_RULE, tInt ) PropertyDef( statics.UPDATE_RULE, tInt )
}; };
statics.refl.key.pProps = createPropertyArrayHelper( statics.refl.key.pProps = createPropertyArrayHelper(
keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY ); keyDef, SAL_N_ELEMENTS(keyDef), READONLY );
// Key properties // Key properties
@ -324,7 +324,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE_NAME , tString ) PropertyDef( statics.TYPE_NAME , tString )
}; };
statics.refl.keycolumn.pProps = createPropertyArrayHelper( statics.refl.keycolumn.pProps = createPropertyArrayHelper(
keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY ); keycolumnDef, SAL_N_ELEMENTS(keycolumnDef), READONLY );
// KeyColumn props set // KeyColumn props set
statics.refl.keycolumnDescriptor.implName = statics.refl.keycolumnDescriptor.implName =
@ -353,7 +353,7 @@ Statics & getStatics()
PropertyDef( statics.SCHEMA_NAME , tString ) PropertyDef( statics.SCHEMA_NAME , tString )
}; };
statics.refl.view.pProps = createPropertyArrayHelper( statics.refl.view.pProps = createPropertyArrayHelper(
viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY ); viewDef, SAL_N_ELEMENTS(viewDef), READONLY );
// view props set // view props set
statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor"; statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
@ -370,7 +370,7 @@ Statics & getStatics()
PropertyDef( statics.NAME , tString ) PropertyDef( statics.NAME , tString )
}; };
statics.refl.user.pProps = createPropertyArrayHelper( statics.refl.user.pProps = createPropertyArrayHelper(
userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY ); userDefRO, SAL_N_ELEMENTS(userDefRO), READONLY );
// user props set // user props set
statics.refl.userDescriptor.implName = statics.refl.userDescriptor.implName =
@ -400,7 +400,7 @@ Statics & getStatics()
PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence ) PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
}; };
statics.refl.index.pProps = createPropertyArrayHelper( statics.refl.index.pProps = createPropertyArrayHelper(
indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY ); indexDef, SAL_N_ELEMENTS(indexDef), READONLY );
// index props set // index props set
statics.refl.indexDescriptor.implName = statics.refl.indexDescriptor.implName =
@ -432,7 +432,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE_NAME , tString ) PropertyDef( statics.TYPE_NAME , tString )
}; };
statics.refl.indexColumn.pProps = createPropertyArrayHelper( statics.refl.indexColumn.pProps = createPropertyArrayHelper(
indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY ); indexColumnDef, SAL_N_ELEMENTS(indexColumnDef), READONLY );
// indexColumn props set // indexColumn props set
statics.refl.indexColumnDescriptor.implName = statics.refl.indexColumnDescriptor.implName =

View File

@ -42,8 +42,6 @@
#include "macro_expander.hxx" #include "macro_expander.hxx"
#define ARLEN(x) sizeof (x) / sizeof *(x)
using namespace ::osl; using namespace ::osl;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
@ -138,7 +136,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
if ( hPool == nullptr ) if ( hPool == nullptr )
throw BootstrapException( "cannot create random pool!" ); throw BootstrapException( "cannot create random pool!" );
sal_uInt8 bytes[ 16 ]; sal_uInt8 bytes[ 16 ];
if ( rtl_random_getBytes( hPool, bytes, ARLEN( bytes ) ) if ( rtl_random_getBytes( hPool, bytes, SAL_N_ELEMENTS( bytes ) )
!= rtl_Random_E_None ) != rtl_Random_E_None )
throw BootstrapException( "random pool error!" ); throw BootstrapException( "random pool error!" );
rtl_random_destroyPool( hPool ); rtl_random_destroyPool( hPool );
@ -167,7 +165,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
// start office process // start office process
oslProcess hProcess = nullptr; oslProcess hProcess = nullptr;
oslProcessError rc = osl_executeProcess( oslProcessError rc = osl_executeProcess(
OUString(path + "soffice").pData, ar_args, ARLEN( ar_args ), OUString(path + "soffice").pData, ar_args, SAL_N_ELEMENTS( ar_args ),
osl_Process_DETACHED, osl_Process_DETACHED,
sec.getHandle(), sec.getHandle(),
nullptr, // => current working dir nullptr, // => current working dir

View File

@ -32,8 +32,6 @@
#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/awt/XWindow.hpp>
#include "dp_misc_api.hxx" #include "dp_misc_api.hxx"
#define ARLEN(x) (sizeof (x) / sizeof *(x))
namespace dp_misc { namespace dp_misc {
const sal_Char CR = 0x0d; const sal_Char CR = 0x0d;

View File

@ -428,7 +428,7 @@ OUString generateRandomPipeId()
throw RuntimeException( "cannot create random pool!?", nullptr ); throw RuntimeException( "cannot create random pool!?", nullptr );
sal_uInt8 bytes[ 32 ]; sal_uInt8 bytes[ 32 ];
if (rtl_random_getBytes( if (rtl_random_getBytes(
s_hPool, bytes, ARLEN(bytes) ) != rtl_Random_E_None) { s_hPool, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
throw RuntimeException( "random pool error!?", nullptr ); throw RuntimeException( "random pool error!?", nullptr );
} }
OUStringBuffer buf; OUStringBuffer buf;

View File

@ -1511,10 +1511,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle(
if (title.endsWithIgnoreAsciiCase("skip_registration") ) if (title.endsWithIgnoreAsciiCase("skip_registration") )
skip_registration = true; skip_registration = true;
OUString ar [] = { OUString("Title"), OUString("IsFolder") }; Sequence<OUString> ar { OUString("Title"), OUString("IsFolder") };
Reference<sdbc::XResultSet> xResultSet( Reference<sdbc::XResultSet> xResultSet( ucbContent.createCursor( ar ) );
ucbContent.createCursor(
Sequence<OUString>( ar, ARLEN(ar) ) ) );
while (xResultSet->next()) while (xResultSet->next())
{ {
checkAborted( abortChannel ); checkAborted( abortChannel );

View File

@ -232,7 +232,7 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r
oslFileHandle pErr = nullptr; oslFileHandle pErr = nullptr;
oslProcessError eErr = runProcessWithPathSearch( oslProcessError eErr = runProcessWithPathSearch(
"pstoedit" EXESUFFIX, "pstoedit" EXESUFFIX,
args, sizeof(args)/sizeof(rtl_uString *), args, SAL_N_ELEMENTS(args),
&aProcess, &pIn, &pOut, &pErr); &aProcess, &pIn, &pOut, &pErr);
if (eErr!=osl_Process_E_None) if (eErr!=osl_Process_E_None)
@ -360,7 +360,7 @@ static bool RenderAsBMPThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRe
return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic, return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic,
("convert" EXESUFFIX), ("convert" EXESUFFIX),
args, args,
sizeof(args)/sizeof(rtl_uString *)); SAL_N_ELEMENTS(args));
} }
static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
@ -390,7 +390,7 @@ static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
"gs" EXESUFFIX, "gs" EXESUFFIX,
#endif #endif
args, args,
sizeof(args)/sizeof(rtl_uString *)); SAL_N_ELEMENTS(args));
} }
static bool RenderAsBMP(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic) static bool RenderAsBMP(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic)

View File

@ -328,13 +328,13 @@ bool SVGFilter::isStreamSvg(const uno::Reference<io::XInputStream>& xInput)
const sal_Int8* pBuffer = aBuffer.getConstArray(); const sal_Int8* pBuffer = aBuffer.getConstArray();
sal_Int8 aMagic1[] = {'<', 's', 'v', 'g'}; sal_Int8 aMagic1[] = {'<', 's', 'v', 'g'};
sal_Int32 aMagic1Size = sizeof(aMagic1) / sizeof(*aMagic1); sal_Int32 aMagic1Size = SAL_N_ELEMENTS(aMagic1);
if (std::search(pBuffer, pBuffer + nBytes, aMagic1, aMagic1 + aMagic1Size) != pBuffer + nBytes ) if (std::search(pBuffer, pBuffer + nBytes, aMagic1, aMagic1 + aMagic1Size) != pBuffer + nBytes )
return true; return true;
sal_Int8 aMagic2[] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ', 's', 'v', 'g'}; sal_Int8 aMagic2[] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ', 's', 'v', 'g'};
sal_Int32 aMagic2Size = sizeof(aMagic2) / sizeof(*aMagic2); sal_Int32 aMagic2Size = SAL_N_ELEMENTS(aMagic2);
return std::search(pBuffer, pBuffer + nBytes, aMagic2, aMagic2 + aMagic2Size) != pBuffer + nBytes; return std::search(pBuffer, pBuffer + nBytes, aMagic2, aMagic2 + aMagic2Size) != pBuffer + nBytes;
} }

View File

@ -58,7 +58,7 @@ const char* getTokenName( sal_Int32 nTokenId )
return nullptr; return nullptr;
const xmltoken* pCurr=wordlist; const xmltoken* pCurr=wordlist;
const xmltoken* pEnd=wordlist+sizeof(wordlist)/sizeof(*wordlist); const xmltoken* pEnd=wordlist+SAL_N_ELEMENTS(wordlist);
while( pCurr != pEnd ) while( pCurr != pEnd )
{ {
if(pCurr->nToken == nTokenId) if(pCurr->nToken == nTokenId)

View File

@ -24,6 +24,7 @@
#include <string.h> #include <string.h>
#endif #endif
#include <sal/types.h>
#include <fontmap.hxx> #include <fontmap.hxx>
struct FontEntry struct FontEntry
@ -145,9 +146,7 @@ const char* const RepFontTab[] =
int getRepFamilyName(const char* orig, char *buf, double &ratio) int getRepFamilyName(const char* orig, char *buf, double &ratio)
{ {
int i; for( int i = 0 ; i < int(SAL_N_ELEMENTS(FontMapTab)); i++)
int size = sizeof(FontMapTab)/sizeof(FontEntry);
for( i = 0 ; i < size ; i++)
{ {
if( !strcmp(orig, FontMapTab[i].familyname) ){ if( !strcmp(orig, FontMapTab[i].familyname) ){
ratio = FontMapTab[i].ratio; ratio = FontMapTab[i].ratio;

View File

@ -480,7 +480,7 @@ static hchar olHanglJaso(int num, int type)
if (type == OL_HANGL_JASO) if (type == OL_HANGL_JASO)
{ {
num = num % (14 + (sizeof(jung) / sizeof(char))); num = num % (14 + SAL_N_ELEMENTS(jung));
if (num < 14) if (num < 14)
hh = (han_init[num] << 8) | 'A'; hh = (han_init[num] << 8) | 'A';
@ -493,7 +493,7 @@ static hchar olHanglJaso(int num, int type)
hh = (han_init[num] << 8) | 'a'; hh = (han_init[num] << 8) | 'a';
else else
{ {
int j = (num / 14) % (sizeof(jung2) / sizeof(char)); int j = (num / 14) % SAL_N_ELEMENTS(jung2);
num = num % 14; num = num % 14;
hh = (han_init[num] << 8) | (jung2[j] << 5) | 1; hh = (han_init[num] << 8) | (jung2[j] << 5) | 1;

View File

@ -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_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}, {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) OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
{ {

View File

@ -841,13 +841,11 @@ struct HebrewNumberChar {
{ 0x05d0, 1 } { 0x05d0, 1 }
}; };
static sal_Int16 nbOfHebrewNumberChar = sizeof(HebrewNumberCharArray)/sizeof(HebrewNumberChar); static const sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0};
static const sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0};
static sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0}; static const sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0};
static sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0}; static const sal_Unicode geresh = 0x05f3;
static sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0}; static const sal_Unicode gershayim = 0x05f4;
static sal_Unicode geresh = 0x05f3;
static sal_Unicode gershayim = 0x05f4;
void makeHebrewNumber(sal_Int64 value, OUStringBuffer& output, bool isLast, bool useGeresh) 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); output.append(value == 1000 ? thousand : isLast ? thousands_last : thousands);
} else { } else {
sal_Int16 nbOfChar = 0; 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) { if (num - HebrewNumberCharArray[j].value >= 0) {
nbOfChar++; nbOfChar++;
if (num == 15 || num == 16) // substitution for 15 and 16 if (num == 15 || num == 16) // substitution for 15 and 16
@ -952,8 +950,6 @@ struct CyrillicNumberChar {
{ 0x0430, 1 } { 0x0430, 1 }
}; };
static sal_Int16 nbOfCyrillicNumberChar = sizeof(CyrillicNumberCharArray)/sizeof(CyrillicNumberChar);
void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo) void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo)
{ {
sal_Int16 num = sal::static_int_cast<sal_Int16>(value % 1000); 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; 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) { if (num < 20 && num > 10) {
num -= 10; num -= 10;
makeCyrillicNumber(num, output, false); makeCyrillicNumber(num, output, false);

View File

@ -87,7 +87,7 @@ sal_Int16 SAL_CALL checkScriptType(sal_Unicode c)
sal_Int16 script; sal_Int16 script;
} UBlock2Script; } UBlock2Script;
static UBlock2Script scriptList[] = { static const UBlock2Script scriptList[] = {
{UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, SCRIPT_HANGUL}, {UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, SCRIPT_HANGUL},
{UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_BOPOMOFO, SCRIPT_HANJA}, {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_BOPOMOFO, SCRIPT_HANJA},
{UBLOCK_HANGUL_COMPATIBILITY_JAMO, UBLOCK_HANGUL_COMPATIBILITY_JAMO, SCRIPT_HANGUL}, {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}, {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); UBlockCode block=ublock_getCode((sal_uInt32) c);
sal_uInt16 i; sal_uInt16 i;
for ( i = 0; i < scriptListCount; i++) { for ( i = 0; i < SAL_N_ELEMENTS(scriptList); i++) {
if (block <= scriptList[i].to) break; 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 #ifdef DISABLE_DYNLOADING

View File

@ -60,7 +60,7 @@ TRANSLITERATION_NUMTOTEXT( KanjiShortModern_ja_JP, NATNUM7)
NumToText##name::NumToText##name() \ NumToText##name::NumToText##name() \
{ \ { \
table = _table;\ table = _table;\
tableSize = sizeof(_table) / sizeof(sal_Unicode); \ tableSize = SAL_N_ELEMENTS(_table); \
recycleSymbol = recycle; \ recycleSymbol = recycle; \
transliterationName = "NumToText"#name; \ transliterationName = "NumToText"#name; \
implementationName = "com.sun.star.i18n.Transliteration.NumToText"#name; \ implementationName = "com.sun.star.i18n.Transliteration.NumToText"#name; \

View File

@ -220,9 +220,7 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
// //
// See the following page for detail: // See the following page for detail:
// http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
int i, j; for( int i = 0; i < int(SAL_N_ELEMENTS(full2halfASCException)); i++ )
int n = sizeof(full2halfASCException) / sizeof(UnicodePairWithFlag);
for( i = 0; i < n; i++ )
{ {
const int high = (full2halfASCException[i].first >> 8) & 0xFF; const int high = (full2halfASCException[i].first >> 8) & 0xFF;
const int low = (full2halfASCException[i].first) & 0xFF; const int low = (full2halfASCException[i].first) & 0xFF;
@ -231,7 +229,7 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
{ {
table.mpIndex[high] = new UnicodePairWithFlag*[256]; table.mpIndex[high] = new UnicodePairWithFlag*[256];
for( j = 0; j < 256; j++ ) for( int j = 0; j < 256; j++ )
table.mpIndex[high][j] = nullptr; table.mpIndex[high][j] = nullptr;
} }
table.mpIndex[high][low] = &full2halfASCException[i]; table.mpIndex[high][low] = &full2halfASCException[i];
@ -255,7 +253,7 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
// See the following page for detail: // See the following page for detail:
// http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
int i, j; int i, j;
int n = sizeof(half2fullJISException) / sizeof(UnicodePairWithFlag); int n = SAL_N_ELEMENTS(half2fullJISException);
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
{ {
const int high = (half2fullJISException[i].first >> 8) & 0xFF; const int high = (half2fullJISException[i].first >> 8) & 0xFF;

View File

@ -47,7 +47,7 @@ char const* const* GnuInfo::getJavaExePaths(int * size)
"gij-4.1", "gij-4.1",
"bin/gij-4.1" "bin/gij-4.1"
}; };
*size = sizeof (ar) / sizeof (char*); *size = SAL_N_ELEMENTS (ar);
return ar; return ar;
} }
@ -82,7 +82,7 @@ char const* const* GnuInfo::getRuntimePaths(int * size)
"/libgcj.so.7", "/libgcj.so.7",
"/libgcj.so.6" "/libgcj.so.6"
}; };
*size = sizeof(ar) / sizeof (char*); *size = SAL_N_ELEMENTS(ar);
return ar; return ar;
} }

View File

@ -44,7 +44,7 @@ char const* const* OtherInfo::getJavaExePaths(int * size)
"jre/bin/java" "jre/bin/java"
#endif #endif
}; };
*size = sizeof (ar) / sizeof (char*); *size = SAL_N_ELEMENTS (ar);
return ar; return ar;
} }
@ -72,7 +72,7 @@ char const* const* OtherInfo::getRuntimePaths(int * size)
#endif #endif
}; };
*size = sizeof(ar) / sizeof (char*); *size = SAL_N_ELEMENTS(ar);
return ar; return ar;
} }
@ -94,7 +94,7 @@ char const* const* OtherInfo::getLibraryPaths(int* size)
"/lib/" JFW_PLUGIN_ARCH "/lib/" JFW_PLUGIN_ARCH
}; };
*size = sizeof(ar) / sizeof (char*); *size = SAL_N_ELEMENTS(ar);
return ar; return ar;
#else #else
*size = 0; *size = 0;

View File

@ -322,24 +322,24 @@ SelfTest::SelfTest()
{ {
bool bRet = true; bool bRet = true;
char const * versions[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0", static char const * versions[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0",
"10.2.2", "10.10.0", "10.10.10", "111.0.999", "10.2.2", "10.10.0", "10.10.10", "111.0.999",
"1.4.1_01", "9.90.99_09", "1.4.1_99", "1.4.1_01", "9.90.99_09", "1.4.1_99",
"1.4.1_00a", "1.4.1_00a",
"1.4.1-ea", "1.4.1-beta", "1.4.1-rc1", "1.4.1-ea", "1.4.1-beta", "1.4.1-rc1",
"1.5.0_01-ea", "1.5.0_01-rc2"}; "1.5.0_01-ea", "1.5.0_01-rc2"};
char const * badVersions[] = {".4.0", "..1", "", "10.0", "10.10.0.", "10.10.0-", "10.10.0.", static char const * badVersions[] = {".4.0", "..1", "", "10.0", "10.10.0.", "10.10.0-", "10.10.0.",
"10.2-2", "10_10.0", "10..10","10.10", "a.0.999", "10.2-2", "10_10.0", "10..10","10.10", "a.0.999",
"1.4b.1_01", "9.90.-99_09", "1.4.1_99-", "1.4b.1_01", "9.90.-99_09", "1.4.1_99-",
"1.4.1_00a2", "1.4.0_z01z", "1.4.1__99A", "1.4.1_00a2", "1.4.0_z01z", "1.4.1__99A",
"1.4.1-1ea", "1.5.0_010", "1.5.0._01-", "1.5.0_01-eac"}; "1.4.1-1ea", "1.5.0_010", "1.5.0._01-", "1.5.0_01-eac"};
char const * orderedVer[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1", static char const * orderedVer[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1",
"1.3.1", "1.3.1_00a", "1.3.1_01", "1.3.1_01a", "1.3.1", "1.3.1_00a", "1.3.1_01", "1.3.1_01a",
"1.3.2", "1.4.0", "1.5.0_01-ea", "2.0.0"}; "1.3.2", "1.4.0", "1.5.0_01-ea", "2.0.0"};
int num = sizeof (versions) / sizeof(char*); int num = SAL_N_ELEMENTS (versions);
int numBad = sizeof (badVersions) / sizeof(char*); int numBad = SAL_N_ELEMENTS (badVersions);
int numOrdered = sizeof (orderedVer) / sizeof(char*); int numOrdered = SAL_N_ELEMENTS (orderedVer);
//parsing test (positive) //parsing test (positive)
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {

View File

@ -1217,21 +1217,21 @@ void addJavaInfosDirScan(
#else // MACOSX #else // MACOSX
OUString excMessage = "[Java framework] sunjavaplugin: " OUString excMessage = "[Java framework] sunjavaplugin: "
"Error in function addJavaInfosDirScan in util.cxx."; "Error in function addJavaInfosDirScan in util.cxx.";
int cJavaNames= sizeof(g_arJavaNames) / sizeof(char*); int cJavaNames= SAL_N_ELEMENTS(g_arJavaNames);
std::unique_ptr<OUString[]> sarJavaNames(new OUString[cJavaNames]); std::unique_ptr<OUString[]> sarJavaNames(new OUString[cJavaNames]);
OUString *arNames = sarJavaNames.get(); OUString *arNames = sarJavaNames.get();
for(int i= 0; i < cJavaNames; i++) for(int i= 0; i < cJavaNames; i++)
arNames[i] = OUString(g_arJavaNames[i], strlen(g_arJavaNames[i]), arNames[i] = OUString(g_arJavaNames[i], strlen(g_arJavaNames[i]),
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
int cSearchPaths= sizeof(g_arSearchPaths) / sizeof(char*); int cSearchPaths= SAL_N_ELEMENTS(g_arSearchPaths);
std::unique_ptr<OUString[]> sarPathNames(new OUString[cSearchPaths]); std::unique_ptr<OUString[]> sarPathNames(new OUString[cSearchPaths]);
OUString *arPaths = sarPathNames.get(); OUString *arPaths = sarPathNames.get();
for(int c = 0; c < cSearchPaths; c++) for(int c = 0; c < cSearchPaths; c++)
arPaths[c] = OUString(g_arSearchPaths[c], strlen(g_arSearchPaths[c]), arPaths[c] = OUString(g_arSearchPaths[c], strlen(g_arSearchPaths[c]),
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
int cCollectDirs = sizeof(g_arCollectDirs) / sizeof(char*); int cCollectDirs = SAL_N_ELEMENTS(g_arCollectDirs);
std::unique_ptr<OUString[]> sarCollectDirs(new OUString[cCollectDirs]); std::unique_ptr<OUString[]> sarCollectDirs(new OUString[cCollectDirs]);
OUString *arCollectDirs = sarCollectDirs.get(); OUString *arCollectDirs = sarCollectDirs.get();
for(int d = 0; d < cCollectDirs; d++) for(int d = 0; d < cCollectDirs; d++)

View File

@ -54,7 +54,7 @@ END_VENDOR_MAP()
bool isVendorSupported(const OUString& sVendor) bool isVendorSupported(const OUString& sVendor)
{ {
const size_t count = sizeof(gVendorMap) / sizeof (VendorSupportMapEntry) - 1; const size_t count = SAL_N_ELEMENTS(gVendorMap) - 1;
for ( size_t pos = 0; pos < count; ++pos ) for ( size_t pos = 0; pos < count; ++pos )
{ {
if (sVendor.equalsAscii(gVendorMap[pos].sVendorName)) if (sVendor.equalsAscii(gVendorMap[pos].sVendorName))

View File

@ -991,7 +991,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
if ( strcmp(sName, "zoom-in-symbolic") == 0) if ( strcmp(sName, "zoom-in-symbolic") == 0)
{ {
for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ ) for ( unsigned int i = 0; i < SAL_N_ELEMENTS( fZooms ); i++ )
{ {
if ( fCurrentZoom < fZooms[i] ) if ( fCurrentZoom < fZooms[i] )
{ {
@ -1006,7 +1006,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
} }
else if ( strcmp(sName, "zoom-out-symbolic") == 0) else if ( strcmp(sName, "zoom-out-symbolic") == 0)
{ {
for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ ) for ( unsigned int i = 0; i < SAL_N_ELEMENTS( fZooms ); i++ )
{ {
if ( fCurrentZoom > fZooms[i] ) if ( fCurrentZoom > fZooms[i] )
{ {