8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 23:23:04 +01:00
This commit is contained in:
robocop 2008-02-26 07:23:32 +00:00
parent 62a00ef37b
commit ac9836f499
14 changed files with 115 additions and 118 deletions

View File

@ -197,10 +197,8 @@ INTL_BOOL CVBIG5_check_big5(charset* cs,
*offending_position = big5_str - big5_str_start;
return (false);
}
else {
big5_str += 2;
big5_len -= 1;
}
big5_str += 2;
big5_len -= 1;
}
else { /* it is a ASCII */

View File

@ -559,10 +559,8 @@ static USHORT CVJIS_check_euc(const UCHAR* euc_str, USHORT euc_len)
if (euc_len == 0) { /* truncated kanji */
return (1);
}
else {
euc_str += 2;
euc_len -= 1;
}
euc_str += 2;
euc_len -= 1;
}
else { /* it is a ASCII */
euc_str++;
@ -595,10 +593,8 @@ static USHORT CVJIS_check_sjis(const UCHAR* sjis_str, USHORT sjis_len)
if (sjis_len == 0) { /* truncated KANJI */
return (1);
}
else {
sjis_str += 2;
sjis_len -= 1;
}
sjis_str += 2;
sjis_len -= 1;
}
else { /*It is a KANA */
sjis_str++;

View File

@ -189,10 +189,8 @@ INTL_BOOL CVKSC_check_ksc(charset* cs,
*offending_position = ksc_str - ksc_str_start;
return (false);
}
else {
ksc_str += 2;
ksc_len -= 1;
}
ksc_str += 2;
ksc_len -= 1;
}
else if (c1 > 0x7f) /* error */
{

View File

@ -71,10 +71,8 @@ USHORT KANJI_check_euc(const UCHAR* euc_str, USHORT euc_len)
if (euc_len == 0) { /* truncated kanji */
return (1);
}
else {
euc_str += 2;
euc_len -= 1;
}
euc_str += 2;
euc_len -= 1;
}
else { /* it is a ASCII */
euc_str++;
@ -105,10 +103,8 @@ USHORT KANJI_check_sjis(const UCHAR* sjis_str, USHORT sjis_len)
if (sjis_len == 0) { /* truncated KANJI */
return (1);
}
else {
sjis_str += 2;
sjis_len -= 1;
}
sjis_str += 2;
sjis_len -= 1;
}
else { /*It is a KANA */
sjis_str++;

View File

@ -561,14 +561,14 @@ SSHORT famasc_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const B
for (ULONG i = 0; i < len; i++) {
if (s1[i] == s2[i])
continue;
else if (all_spaces(&s1[i], (SLONG) (l1 - i)))
if (all_spaces(&s1[i], (SLONG) (l1 - i)))
return -1;
else if (all_spaces(&s2[i], (SLONG) (l2 - i)))
if (all_spaces(&s2[i], (SLONG) (l2 - i)))
return 1;
else if (s1[i] < s2[i])
if (s1[i] < s2[i])
return -1;
else
return 1;
return 1;
}
if (l1 > len) {

View File

@ -150,12 +150,12 @@ bool LCICU_texttype_init(texttype* tt,
tt, name, charSetName, attributes,
specificAttributes, specificAttributesLength, configInfo);
}
else if (len > 8 && strcmp(name + len - 8, "_UNICODE") == 0)
if (len > 8 && strcmp(name + len - 8, "_UNICODE") == 0)
{
return texttype_unicode_init(
tt, name, charSetName, attributes,
specificAttributes, specificAttributesLength, configInfo);
}
else
return false;
return false;
}

View File

@ -65,8 +65,8 @@ TEXTTYPE_ENTRY(JIS220_init)
//cache->texttype_fn_str_to_lower = sjis_str_to_lower;
return true;
}
else
return false;
return false;
}
@ -80,8 +80,8 @@ TEXTTYPE_ENTRY(JIS230_init)
//cache->texttype_fn_str_to_lower = famasc_str_to_lower;
return true;
}
else
return false;
return false;
}

View File

@ -78,8 +78,8 @@ TEXTTYPE_ENTRY(ksc_5601_dict_init)
cache->texttype_fn_compare = LCKSC_compare;
return true;
}
else
return false;
return false;
}
@ -267,15 +267,15 @@ static SSHORT LCKSC_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, c
for (ULONG i = 0; i < len; i++) {
if (key1[i] == key2[i])
continue;
else if (key1[i] < key2[i])
if (key1[i] < key2[i])
return -1;
else
return 1;
return 1;
}
if (len1 < len2)
return -1;
else if (len1 > len2)
if (len1 > len2)
return 1;
else
return 0;
return 0;
}

View File

@ -310,8 +310,10 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
iOutLen -= lprimary;
if (key_type == INTL_KEY_PARTIAL)
{
/* return length of key */
return (outbuff - pOutChar);
}
bool useLevel = !(obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive);
@ -492,17 +494,16 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
(*p)++;
return col;
}
else
{
/* Both flags set indicate a special value */
/* Need a new col */
(*l)--;
(*p)++;
stat->stat_flags |= LC_HAVE_SPECIAL;
continue;
}
/* Both flags set indicate a special value */
/* Need a new col */
(*l)--;
(*p)++;
stat->stat_flags |= LC_HAVE_SPECIAL;
continue;
}
else if (!((col->IsExpand && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
if (!((col->IsExpand && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(col->IsCompress && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
/* Have col */
@ -510,7 +511,8 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
(*p)++;
return col;
}
else if (col->IsExpand) {
if (col->IsExpand) {
const ExpandChar* exp = &((const ExpandChar*) obj->texttype_impl->texttype_expand_table)[0];
while (exp->Ch && exp->Ch != **p)
exp++;
@ -524,29 +526,29 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
stat->stat_flags |= LC_HAVE_WAITING;
return col;
}
else { /* (col->IsCompress) */
if (*l > 1) {
const CompressPair* cmp =
&((const CompressPair*) obj->texttype_impl->
texttype_compress_table)[0];
while (cmp->CharPair[0]) {
if ((cmp->CharPair[0] == **p) &&
(cmp->CharPair[1] == *(*p + 1)))
{
/* Have Col */
col = &cmp->NoCaseWeight;
(*l) -= 2;
(*p) += 2;
return col;
}
cmp++;
/* (col->IsCompress) */
if (*l > 1) {
const CompressPair* cmp =
&((const CompressPair*) obj->texttype_impl->
texttype_compress_table)[0];
while (cmp->CharPair[0]) {
if ((cmp->CharPair[0] == **p) &&
(cmp->CharPair[1] == *(*p + 1)))
{
/* Have Col */
col = &cmp->NoCaseWeight;
(*l) -= 2;
(*p) += 2;
return col;
}
cmp++;
}
/* Have col */
(*l)--;
(*p)++;
return col;
}
/* Have col */
(*l)--;
(*p)++;
return col;
}
return NULL;
}
@ -687,15 +689,16 @@ static SSHORT old_fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
for (ULONG i = 0; i < len; i++) {
if (key1[i] == key2[i])
continue;
else if (key1[i] < key2[i])
if (key1[i] < key2[i])
return (-1);
else
return (1);
return (1);
}
if (len1 < len2)
return (-1);
else if (len1 > len2)
if (len1 > len2)
return (1);
return (0);
}
#endif /* DEBUG_COMPARE */
@ -1014,8 +1017,8 @@ bool LC_NARROW_family3(
return true;
}
else
return false;
return false;
}

View File

@ -528,8 +528,8 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_n
{
if (LD_lookup_charset(&cs, charset_name, configInfo))
break;
else
return false;
return false;
}
}
@ -572,13 +572,14 @@ ULONG FB_DLL_EXPORT LD_setup_attributes(
if (dstLen == 0)
return newSpecificAttributes.length();
else if (newSpecificAttributes.length() <= dstLen)
if (newSpecificAttributes.length() <= dstLen)
{
memcpy(dst, newSpecificAttributes.begin(), newSpecificAttributes.length());
return newSpecificAttributes.length();
}
else
return INTL_BAD_STR_LENGTH;
return INTL_BAD_STR_LENGTH;
}

View File

@ -108,8 +108,7 @@ int main()
for (i = 0; i <= 255; i++) {
if (from_unicode_map[i] + 0xFF >= sizeof(from_unicode_mapping_array)) {
printf("From_unicode array bounds error at position %02x00\n",
i);
printf("From_unicode array bounds error at position %02x00\n", i);
continue;
}

View File

@ -1771,21 +1771,21 @@ static sort_record* get_merge(merge_control* merge, sort_context* scb
}
if (!merge->mrg_record_b)
{
if (merge->mrg_stream_b) {
merge = (merge_control*) merge->mrg_stream_b;
continue;
}
else if ( (record = merge->mrg_record_a) ) {
merge->mrg_record_a = NULL;
merge = merge->mrg_header.rmh_parent;
continue;
}
else {
eof = true;
record = (sort_record*) - 1;
merge = merge->mrg_header.rmh_parent;
continue;
}
continue;
}
if (!merge->mrg_record_a) {
record = merge->mrg_record_b;

View File

@ -195,7 +195,7 @@ USHORT UnicodeUtil::utf16ToKey(USHORT srcLen, const USHORT* src, USHORT dstLen,
UConverter* conv = ucnv_open("BOCU-1", &status);
fb_assert(U_SUCCESS(status));
int32_t len = ucnv_fromUChars(conv, reinterpret_cast<char*>(dst), dstLen,
const int32_t len = ucnv_fromUChars(conv, reinterpret_cast<char*>(dst), dstLen,
// safe cast - alignment not changed
reinterpret_cast<const UChar*>(src), srcLen / sizeof(*src), &status);
fb_assert(U_SUCCESS(status));
@ -493,10 +493,10 @@ ULONG UnicodeUtil::utf16ToUtf32(ULONG srcLen, const USHORT* src, ULONG dstLen, U
while (src < srcEnd && dst < dstEnd)
{
ULONG ch = *src++;
ULONG ch2;
if (UTF_IS_LEAD(ch))
{
ULONG ch2;
if (src < srcEnd && UTF_IS_TRAIL(ch2 = *src))
{
ch = UTF16_GET_PAIR_VALUE(ch, ch2);
@ -543,7 +543,7 @@ ULONG UnicodeUtil::utf32ToUtf16(ULONG srcLen, const ULONG* src, ULONG dstLen, US
while (src < srcEnd && dst < dstEnd)
{
ULONG ch = *src++;
const ULONG ch = *src++;
if (ch <= 0xFFFF)
*(dst++) = ch;
@ -621,7 +621,7 @@ ULONG UnicodeUtil::utf16Substring(ULONG srcLen, const USHORT* src, ULONG dstLen,
while (src < srcEnd && dst < dstEnd && pos < startPos)
{
ULONG ch = *src++;
const ULONG ch = *src++;
if (UTF_IS_LEAD(ch))
{
@ -634,13 +634,13 @@ ULONG UnicodeUtil::utf16Substring(ULONG srcLen, const USHORT* src, ULONG dstLen,
while (src < srcEnd && dst < dstEnd && pos < startPos + length)
{
ULONG ch = *src++;
ULONG ch2;
const ULONG ch = *src++;
*(dst++) = ch;
if (UTF_IS_LEAD(ch))
{
ULONG ch2;
if (src < srcEnd && UTF_IS_TRAIL(ch2 = *src))
{
*(dst++) = ch2;
@ -665,7 +665,7 @@ INTL_BOOL UnicodeUtil::utf8WellFormed(ULONG len, const UCHAR* str, ULONG* offend
if (c > 0x7F)
{
ULONG save_i = i - 1;
const ULONG save_i = i - 1;
c = utf8_nextCharSafeBody(str, reinterpret_cast<int32_t*>(&i), len, c, -1);
@ -691,7 +691,7 @@ INTL_BOOL UnicodeUtil::utf16WellFormed(ULONG len, const USHORT* str, ULONG* offe
for (ULONG i = 0; i < len;)
{
ULONG save_i = i;
const ULONG save_i = i;
uint32_t c;
U16_NEXT(str, i, len, c);
@ -898,7 +898,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion,
WriteLockGuard writeGuard(icuModules->lock);
// In this small amount of time, one may already loaded the
// same version, so withing the write lock we verify again.
// same version, so within the write lock we verify again.
ICU* icu2;
if (icuModules->modules().get(version, icu2))
{
@ -938,12 +938,13 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
Firebird::IntlUtil::SpecificAttributesMap& specificAttributes, const Firebird::string& configInfo)
{
string locale;
string collVersion;
int attributeCount = 0;
bool error;
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16("LOCALE"), locale))
++attributeCount;
string collVersion;
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16("COLL-VERSION"), collVersion))
{
++attributeCount;
@ -1015,6 +1016,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
tt->texttype_flags = TEXTTYPE_DIRECT_MATCH;
USet* contractions = icu->usetOpen(0, 0);
// status not verified here.
icu->ucolGetContractions(partialCollator, contractions, &status);
Utf16Collation* obj = new Utf16Collation();
@ -1033,11 +1035,11 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
UnicodeUtil::Utf16Collation::~Utf16Collation()
{
icu->usetClose(static_cast<USet*>(contractions));
icu->usetClose(contractions);
icu->ucolClose((UCollator*)compareCollator);
icu->ucolClose((UCollator*)partialCollator);
icu->ucolClose((UCollator*)sortCollator);
icu->ucolClose(compareCollator);
icu->ucolClose(partialCollator);
icu->ucolClose(sortCollator);
// ASF: we should not "delete icu"
}
@ -1077,7 +1079,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
srcLen = pad - src + 1;
}
void* coll;
const UCollator* coll = 0;
switch (key_type)
{
@ -1091,7 +1093,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
{
UChar str[10];
UErrorCode status = U_ZERO_ERROR;
int len = icu->usetGetItem(static_cast<USet*>(contractions),
int len = icu->usetGetItem(contractions,
i, NULL, NULL, str, sizeof(str), &status);
if (len > srcLen)
@ -1126,7 +1128,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
if (srcLen == 0)
return 0;
return icu->ucolGetSortKey(static_cast<const UCollator*>(coll),
return icu->ucolGetSortKey(coll,
reinterpret_cast<const UChar*>(src), srcLen, dst, dstLen);
}
@ -1165,7 +1167,7 @@ SSHORT UnicodeUtil::Utf16Collation::compare(ULONG len1, const USHORT* str1,
len2 = pad - str2 + 1;
}
return (SSHORT)icu->ucolStrColl(static_cast<const UCollator*>(compareCollator),
return (SSHORT)icu->ucolStrColl(compareCollator,
// safe casts - alignment not changed
reinterpret_cast<const UChar*>(str1), len1,
reinterpret_cast<const UChar*>(str2), len2);
@ -1175,9 +1177,6 @@ SSHORT UnicodeUtil::Utf16Collation::compare(ULONG len1, const USHORT* str1,
ULONG UnicodeUtil::Utf16Collation::canonical(ULONG srcLen, const USHORT* src, ULONG dstLen, ULONG* dst,
const ULONG* exceptions)
{
USHORT errCode;
ULONG errPosition;
HalfStaticArray<USHORT, BUFFER_SMALL / 2> upperStr;
if ((attributes & (TEXTTYPE_ATTR_CASE_INSENSITIVE | TEXTTYPE_ATTR_ACCENT_INSENSITIVE)) ==
@ -1193,7 +1192,7 @@ ULONG UnicodeUtil::Utf16Collation::canonical(ULONG srcLen, const USHORT* src, UL
if (errorCode <= 0)
{
int32_t capacity = dstLen;
const int32_t capacity = dstLen;
int32_t len = srcLen / sizeof(USHORT);
int32_t limit = len;
@ -1219,6 +1218,8 @@ ULONG UnicodeUtil::Utf16Collation::canonical(ULONG srcLen, const USHORT* src, UL
}
// convert UTF-16 to UTF-32
USHORT errCode;
ULONG errPosition;
return utf16ToUtf32(srcLen, src, dstLen, dst, &errCode, &errPosition) / sizeof(ULONG);
}
@ -1236,7 +1237,7 @@ UnicodeUtil::ICU* UnicodeUtil::Utf16Collation::loadICU(
if (!icu)
continue;
UErrorCode status = U_ZERO_ERROR;
//UErrorCode status = U_ZERO_ERROR;
if (locale.hasData())
{

View File

@ -30,6 +30,11 @@
#include "intlobj_new.h"
#include "../jrd/IntlUtil.h"
#include "../jrd/os/mod_loader.h"
//#include "unicode/ucol.h"
//#include "unicode/ucnv.h"
struct UCollator;
struct USet;
namespace Jrd {
@ -93,10 +98,10 @@ public:
ICU* icu;
texttype* tt;
USHORT attributes;
void* compareCollator;
void* partialCollator;
void* sortCollator;
void* contractions;
UCollator* compareCollator;
UCollator* partialCollator;
UCollator* sortCollator;
USet* contractions;
int contractionsCount;
};