@@ -57,39 +57,38 @@ using namespace Firebird;
5757
5858namespace {
5959#if defined(WIN_NT)
60- const char * const inTemplate = " icuin%s.dll" ;
61- const char * const ucTemplate = " icuuc%s.dll" ;
60+ constexpr const char * inTemplate = " icuin%s.dll" ;
61+ constexpr const char * ucTemplate = " icuuc%s.dll" ;
6262#elif defined(DARWIN)
63- const char * const inTemplate = " lib/libicui18n.%s.dylib" ;
64- const char * const ucTemplate = " lib/libicuuc.%s.dylib" ;
63+ constexpr const char * inTemplate = " lib/libicui18n.%s.dylib" ;
64+ constexpr const char * ucTemplate = " lib/libicuuc.%s.dylib" ;
6565#elif defined(HPUX)
66- const char * const inTemplate = " libicui18n.sl.%s" ;
67- const char * const ucTemplate = " libicuuc.sl.%s" ;
66+ constexpr const char * inTemplate = " libicui18n.sl.%s" ;
67+ constexpr const char * ucTemplate = " libicuuc.sl.%s" ;
6868#elif defined(ANDROID)
69- const char * const inTemplate = " libicui18n.%s.so" ;
70- const char * const ucTemplate = " libicuuc.%s.so" ;
69+ constexpr const char * inTemplate = " libicui18n.%s.so" ;
70+ constexpr const char * ucTemplate = " libicuuc.%s.so" ;
7171// In Android we need to load this library before others.
72- const char * const dataTemplate = " libicudata.%s.so" ;
72+ constexpr const char * dataTemplate = " libicudata.%s.so" ;
7373#else
74- const char * const inTemplate = " libicui18n.so.%s" ;
75- const char * const ucTemplate = " libicuuc.so.%s" ;
74+ constexpr const char * inTemplate = " libicui18n.so.%s" ;
75+ constexpr const char * ucTemplate = " libicuuc.so.%s" ;
7676#endif
7777
7878// encapsulate ICU library
7979struct BaseICU
8080{
81- private:
82- BaseICU (const BaseICU&); // not implemented
83- BaseICU& operator =(const BaseICU&); // not implemented
84-
8581public:
86- BaseICU (int aMajorVersion, int aMinorVersion)
82+ BaseICU (int aMajorVersion, int aMinorVersion) noexcept
8783 : majorVersion(aMajorVersion),
8884 minorVersion (aMinorVersion),
8985 isSystem(aMajorVersion == 0 )
9086 {
9187 }
9288
89+ BaseICU (const BaseICU&) = delete;
90+ BaseICU& operator =(const BaseICU&) = delete ;
91+
9392 ModuleLoader::Module* formatAndLoad (const char * templateName);
9493 void initialize (ModuleLoader::Module* module );
9594
@@ -105,7 +104,7 @@ struct BaseICU
105104 else
106105 {
107106 // ICU has several schemas for entries names
108- const char * const patterns[] =
107+ constexpr const char * patterns[] =
109108 {
110109 " %s_%d" , " %s_%d_%d" , " %s_%d%d" , " %s"
111110 };
@@ -550,7 +549,7 @@ static void getVersions(const string& configInfo, ObjectsArray<string>& versions
550549
551550
552551// BOCU-1
553- USHORT UnicodeUtil::utf16KeyLength (USHORT len)
552+ USHORT UnicodeUtil::utf16KeyLength (USHORT len) noexcept
554553{
555554 return (len / 2 ) * 4 ;
556555}
@@ -718,7 +717,7 @@ ULONG UnicodeUtil::utf16UpperCase(ULONG srcLen, const USHORT* src, ULONG dstLen,
718717
719718
720719ULONG UnicodeUtil::utf16ToUtf8 (ULONG srcLen, const USHORT* src, ULONG dstLen, UCHAR* dst,
721- USHORT* err_code, ULONG* err_position)
720+ USHORT* err_code, ULONG* err_position) noexcept
722721{
723722 fb_assert (srcLen % sizeof (*src) == 0 );
724723 fb_assert (src != NULL || dst == NULL );
@@ -849,7 +848,7 @@ ULONG UnicodeUtil::utf8ToUtf16(ULONG srcLen, const UCHAR* src, ULONG dstLen, USH
849848
850849
851850ULONG UnicodeUtil::utf16ToUtf32 (ULONG srcLen, const USHORT* src, ULONG dstLen, ULONG* dst,
852- USHORT* err_code, ULONG* err_position)
851+ USHORT* err_code, ULONG* err_position) noexcept
853852{
854853 fb_assert (srcLen % sizeof (*src) == 0 );
855854 fb_assert (src != NULL || dst == NULL );
@@ -900,7 +899,7 @@ ULONG UnicodeUtil::utf16ToUtf32(ULONG srcLen, const USHORT* src, ULONG dstLen, U
900899
901900
902901ULONG UnicodeUtil::utf32ToUtf16 (ULONG srcLen, const ULONG* src, ULONG dstLen, USHORT* dst,
903- USHORT* err_code, ULONG* err_position)
902+ USHORT* err_code, ULONG* err_position) noexcept
904903{
905904 fb_assert (srcLen % sizeof (*src) == 0 );
906905 fb_assert (src != NULL || dst == NULL );
@@ -966,8 +965,8 @@ SSHORT UnicodeUtil::utf16Compare(ULONG len1, const USHORT* str1, ULONG len2, con
966965 *error_flag = false ;
967966
968967 // safe casts - alignment not changed
969- int32_t cmp = getConversionICU ().u_strCompare (reinterpret_cast <const UChar*>(str1), len1 / sizeof (* str1),
970- reinterpret_cast <const UChar*>(str2), len2 / sizeof (*str2), true );
968+ const int32_t cmp = getConversionICU ().u_strCompare (reinterpret_cast <const UChar*>(str1),
969+ len1 / sizeof (*str1), reinterpret_cast <const UChar*>(str2), len2 / sizeof (*str2), true );
971970
972971 return (cmp < 0 ? -1 : (cmp > 0 ? 1 : 0 ));
973972}
@@ -982,7 +981,7 @@ ULONG UnicodeUtil::utf16Length(ULONG len, const USHORT* str)
982981
983982
984983ULONG UnicodeUtil::utf16Substring (ULONG srcLen, const USHORT* src, ULONG dstLen, USHORT* dst,
985- ULONG startPos, ULONG length)
984+ ULONG startPos, ULONG length) noexcept
986985{
987986 fb_assert (srcLen % sizeof (*src) == 0 );
988987 fb_assert (src != NULL && dst != NULL );
@@ -1059,7 +1058,7 @@ INTL_BOOL UnicodeUtil::utf8WellFormed(ULONG len, const UCHAR* str, ULONG* offend
10591058}
10601059
10611060
1062- INTL_BOOL UnicodeUtil::utf16WellFormed (ULONG len, const USHORT* str, ULONG* offending_position)
1061+ INTL_BOOL UnicodeUtil::utf16WellFormed (ULONG len, const USHORT* str, ULONG* offending_position) noexcept
10631062{
10641063 fb_assert (str != NULL );
10651064 fb_assert (len % sizeof (*str) == 0 );
@@ -1085,7 +1084,7 @@ INTL_BOOL UnicodeUtil::utf16WellFormed(ULONG len, const USHORT* str, ULONG* offe
10851084}
10861085
10871086
1088- INTL_BOOL UnicodeUtil::utf32WellFormed (ULONG len, const ULONG* str, ULONG* offending_position)
1087+ INTL_BOOL UnicodeUtil::utf32WellFormed (ULONG len, const ULONG* str, ULONG* offending_position) noexcept
10891088{
10901089 fb_assert (str != NULL );
10911090 fb_assert (len % sizeof (*str) == 0 );
@@ -1115,7 +1114,7 @@ void UnicodeUtil::utf8Normalize(UCharBuffer& data)
11151114 HalfStaticArray<USHORT, BUFFER_MEDIUM> utf16Buffer (data.getCount ());
11161115 USHORT errCode;
11171116 ULONG errPosition;
1118- ULONG utf16BufferLen = utf8ToUtf16 (data.getCount (), data.begin (), data.getCount () * sizeof (USHORT),
1117+ const ULONG utf16BufferLen = utf8ToUtf16 (data.getCount (), data.begin (), data.getCount () * sizeof (USHORT),
11191118 utf16Buffer.getBuffer (data.getCount ()), &errCode, &errPosition);
11201119
11211120 UTransliterator* trans = icu->getCiAiTransliterator ();
@@ -1154,7 +1153,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
11541153 for (ObjectsArray<string>::const_iterator i (versions.begin ()); i != versions.end (); ++i)
11551154 {
11561155 int majorVersion, minorVersion;
1157- int n = sscanf ((*i == " default" ? version : *i).c_str (), " %d.%d" ,
1156+ const int n = sscanf ((*i == " default" ? version : *i).c_str (), " %d.%d" ,
11581157 &majorVersion, &minorVersion);
11591158
11601159 if (n == 1 )
@@ -1273,7 +1272,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
12731272}
12741273
12751274
1276- void UnicodeUtil::getICUVersion (ICU* icu, int & majorVersion, int & minorVersion)
1275+ void UnicodeUtil::getICUVersion (ICU* icu, int & majorVersion, int & minorVersion) noexcept
12771276{
12781277 majorVersion = icu->majorVersion ;
12791278 minorVersion = icu->minorVersion ;
@@ -1294,9 +1293,9 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU()
12941293 return *convIcu;
12951294 }
12961295
1297- // Try "favorite" (distributed on windows ) version first
1298- const int favMaj = 77 ;
1299- const int favMin = 1 ;
1296+ // Try "favorite" (distributed on Windows ) version first
1297+ constexpr int favMaj = 77 ;
1298+ constexpr int favMin = 1 ;
13001299 try
13011300 {
13021301 if ((convIcu = ImplementConversionICU::create (favMaj, favMin)))
@@ -1382,7 +1381,7 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU()
13821381string UnicodeUtil::getDefaultIcuVersion ()
13831382{
13841383 string rc;
1385- UnicodeUtil::ConversionICU& icu (UnicodeUtil::getConversionICU ());
1384+ const UnicodeUtil::ConversionICU& icu (UnicodeUtil::getConversionICU ());
13861385
13871386 if (icu.vMajor >= 10 && icu.vMinor == 0 )
13881387 rc.printf (" %d" , icu.vMajor );
@@ -1603,23 +1602,24 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
16031602 // status not verified here.
16041603 icu->ucolGetContractionsAndExpansions (partialCollator, contractions, nullptr , false , &status);
16051604
1606- int contractionsCount = icu->usetGetItemCount (contractions);
1605+ const int contractionsCount = icu->usetGetItemCount (contractions);
16071606
16081607 for (int contractionIndex = 0 ; contractionIndex < contractionsCount; ++contractionIndex)
16091608 {
16101609 UChar strChars[10 ];
16111610 UChar32 start, end;
16121611
16131612 status = U_ZERO_ERROR;
1614- int len = icu->usetGetItem (contractions, contractionIndex, &start, &end, strChars, sizeof (strChars), &status);
1613+ const int len = icu->usetGetItem (contractions, contractionIndex, &start, &end, strChars,
1614+ sizeof (strChars), &status);
16151615
16161616 if (len >= 2 )
16171617 {
16181618 obj->maxContractionsPrefixLength = static_cast <ULONG>(len - 1 ) > obj->maxContractionsPrefixLength ?
16191619 len - 1 : obj->maxContractionsPrefixLength ;
16201620
16211621 UCHAR key[100 ];
1622- int keyLen = icu->ucolGetSortKey (partialCollator, strChars, len, key, sizeof (key));
1622+ const int keyLen = icu->ucolGetSortKey (partialCollator, strChars, len, key, sizeof (key));
16231623
16241624 for (int prefixLen = 1 ; prefixLen < len; ++prefixLen)
16251625 {
@@ -1631,7 +1631,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
16311631 keySet = obj->contractionsPrefix .put (str);
16321632
16331633 UCHAR prefixKey[100 ];
1634- int prefixKeyLen = icu->ucolGetSortKey (partialCollator,
1634+ const int prefixKeyLen = icu->ucolGetSortKey (partialCollator,
16351635 strChars, prefixLen, prefixKey, sizeof (prefixKey));
16361636
16371637 keySet->add (Array<UCHAR>(prefixKey, prefixKeyLen));
@@ -1654,8 +1654,8 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
16541654 continue ;
16551655
16561656 fb_assert (accessor.current ()->first .hasData ());
1657- USHORT firstCh = accessor.current ()->first .front ();
1658- USHORT lastCh = accessor.current ()->first .back ();
1657+ const USHORT firstCh = accessor.current ()->first .front ();
1658+ const USHORT lastCh = accessor.current ()->first .back ();
16591659
16601660 if ((firstCh >= 0xFDD0 && firstCh <= 0xFDEF ) || UTF_IS_SURROGATE (lastCh))
16611661 {
@@ -1707,7 +1707,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
17071707 ++secondKeyDataIt;
17081708 }
17091709
1710- unsigned backSize = commonKeys.back ().getCount ();
1710+ const unsigned backSize = commonKeys.back ().getCount ();
17111711
17121712 if (common > backSize)
17131713 commonKeys.back ().append (secondKeyIt->begin () + backSize, common - backSize);
@@ -1755,7 +1755,7 @@ UnicodeUtil::Utf16Collation::~Utf16Collation()
17551755}
17561756
17571757
1758- USHORT UnicodeUtil::Utf16Collation::keyLength (USHORT len) const
1758+ USHORT UnicodeUtil::Utf16Collation::keyLength (USHORT len) const noexcept
17591759{
17601760 return (len / 4 ) * 6 ;
17611761}
@@ -1842,7 +1842,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
18421842 }
18431843
18441844 auto originalDst = dst;
1845- auto originalDstLen = dstLen;
1845+ const auto originalDstLen = dstLen;
18461846
18471847 if (!trailingNumbersRemoved)
18481848 {
0 commit comments