📄 phb_name_num_index.c
字号:
* second [?]
* result [?]
* external_data(?) [IN] External data
* RETURNS
* void
*****************************************************************************/
#if defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__)
void phb_compare_by_key_alpha_id(alpha_id_type *first, alpha_id_type *second, compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
istring_type istr_first, istr_second;
/* MTK 2003-12-30 Wilson, For PinYin Search. */
kal_uint8 temp1[PHB_ALPHA_ID_DEPTH], temp2[PHB_ALPHA_ID_DEPTH];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_COMPARE_BY_KEY_ALPHA_ID);
/* MTK 2003-12-30 Wilson, For PinYin Search */
if ((first->charset == PHB_UCS2) && (find_pinyin_str_for_ucs2_with_tone(first->data, temp1)))
{
istr_first.data = temp1;
istr_first.length = strlen((char*)istr_first.data);
istr_first.charset = PHB_ASCII;
}
else
{
istr_first.length = first->length;
istr_first.charset = first->charset;
istr_first.data = first->data;
}
//MTK 2003-12-30 Wilson, For PinYin Search
//Use for encoding match
if ((second->charset == PHB_UCS2 && first->charset == PHB_UCS2) &&
(find_pinyin_str_for_ucs2_with_tone(second->data, temp2)))
{
istr_second.data = temp2;
istr_second.length = strlen((char*)istr_second.data);
istr_second.charset = PHB_ASCII;
}
/* Use for PinYin Match */
else if ((second->charset == PHB_UCS2 && first->charset == PHB_ASCII) &&
(find_pinyin_str_for_ucs2_without_tone(second->data, temp2)))
{
istr_second.data = temp2;
istr_second.length = strlen((char*)istr_second.data);
istr_second.charset = PHB_ASCII;
}
else
{
istr_second.length = second->length;
istr_second.charset = second->charset;
istr_second.data = second->data;
}
phb_istring_icmp(&istr_first, &istr_second, result);
} /* end of phb_compare_by_alpha_id */
#else /* defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__) */
/*****************************************************************************
* FUNCTION
* phb_compare_by_key_alpha_id
* DESCRIPTION
*
* PARAMETERS
* first [?]
* second [?]
* result [?]
* RETURNS
* void
*****************************************************************************/
void phb_compare_by_key_alpha_id(alpha_id_type *first, alpha_id_type *second, compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
istring_type istr_first, istr_second;
kal_uint16 code;
kal_uint8 *temp;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_COMPARE_BY_KEY_ALPHA_ID);
istr_first.length = first->length;
istr_first.charset = first->charset;
istr_first.data = first->data;
code = *((kal_uint16*) second->data);
if ((second->charset == PHB_UCS2)
&& (code >= 0x4e00 && code <= 0x9fa5) && ((temp = (kal_uint8*) find_pinying_str_for_ucs2(code)) != NULL))
{
istr_second.data = temp;
istr_second.length = strlen((char*)istr_second.data);
istr_second.charset = PHB_ASCII;
}
else
{
istr_second.length = second->length;
istr_second.charset = second->charset;
istr_second.data = second->data;
}
phb_istring_icmp(&istr_first, &istr_second, result);
} /* end of phb_compare_by_alpha_id */
#endif /* defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__) */
/*****************************************************************************
* FUNCTION
* phb_compare_by_alpha_id
* DESCRIPTION
* Compare two alpha_id's. Their length could be unequal when comparing.
* For ASCII charset, character comparison is case insensitive.
* PARAMETERS
* external_data [IN] External data
* first [?]
* second_pos [?]
* result [?]
* second(?)
* RETURNS
* void
*****************************************************************************/
void phb_compare_by_alpha_id(
data_entry_table_type *external_data,
alpha_id_type *first,
pindex_struct *second_pos,
compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_COMPARE_BY_ALPHA_ID);
phb_compare_by_key_alpha_id(first, &external_data->table[second_pos->position].alpha_id, result);
} /* end of phb_compare_by_alpha_id */
/* MTK 2003-12-30 Wilson, For Exactly Match after PinYin Search */
/*****************************************************************************
* FUNCTION
* phb_compare_by_key_alpha_id_by_encoding
* DESCRIPTION
* Compare two UCS2 string using their encoding only.
* PARAMETERS
* first [?]
* second [?]
* result [?]
* RETURNS
* void
*****************************************************************************/
void phb_compare_by_key_alpha_id_by_encoding(
alpha_id_type *first,
alpha_id_type *second,
compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
istring_type istr_first, istr_second;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
istr_first.length = first->length;
istr_first.charset = first->charset;
istr_first.data = first->data;
istr_second.length = second->length;
istr_second.charset = second->charset;
istr_second.data = second->data;
phb_istring_icmp(&istr_first, &istr_second, result);
} /* end of phb_compare_by_alpha_id */
/*****************************************************************************
* FUNCTION
* phb_compare_by_alpha_id_by_encoding
* DESCRIPTION
* Compare two UCS2 string using their encoding only.
* PARAMETERS
* external_data [?]
* first [?]
* second_pos [?]
* result [?]
* RETURNS
* True if input string is UCS2
*****************************************************************************/
kal_bool phb_compare_by_alpha_id_by_encoding(
data_entry_table_type *external_data,
alpha_id_type *first,
pindex_struct *second_pos,
compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (external_data->table[second_pos->position].alpha_id.charset == PHB_UCS2)
{
phb_compare_by_key_alpha_id_by_encoding(first, &external_data->table[second_pos->position].alpha_id, result);
}
else
{
return 0;
}
return 1;
} /* end of phb_compare_by_alpha_id */
/* END MTK 2003-12-30 */
/*****************************************************************************
* FUNCTION
* phb_compare_by_alpha_id_storage
* DESCRIPTION
* Compare two alpha_id and storage's.
* Inequality definition: SIM is larger than NVRAM.
* PARAMETERS
* external_data [IN] External data
* first [?]
* second_pos [?]
* result [?]
* second(?)
* RETURNS
* void
*****************************************************************************/
static void phb_compare_by_alpha_id_storage(
data_entry_table_type *external_data,
alpha_id_storage_type *first,
pindex_struct *second_pos,
compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_COMPARE_BY_ALPHA_ID_STORAGE);
phb_compare_by_alpha_id(external_data, first->alpha_id, second_pos, result);
/* MTK 2004-04-19 Wilson, Put ASCII string in front of UCS2 string.(For PinYin Search) */
#if defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__)
if (result->distance == 0)
{
/* If Original String is ASCII, appears before UCS2. For PinYin conversion only. */
if (first->alpha_id->charset != external_data->table[second_pos->position].alpha_id.charset)
{
if (first->alpha_id->charset == PHB_UCS2)
{
result->distance = 1;
}
else
{
result->distance = -1;
}
}
}
#endif /* defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__) */
/* Only when 2 alpha_id's are identical should their storage's are required to compare */
if (result->distance == 0)
{
if (first->storage != external_data->table[second_pos->position].storage)
{
/**
* Define SIM is lexicongraphically larger than NVRAM.
* Hence, if 2 alpha id's are identical, NVRAM appears in front
* of SIM
*/
if (first->storage == PHB_SIM)
{
result->distance = 1;
}
else
{
result->distance = -1;
}
}
}
}
/*****************************************************************************
* FUNCTION
* phb_compare_by_tel_num_sig
* DESCRIPTION
* Compare two 2-digits telephone numbers. If they are equal, compare
* signature.
* PARAMETERS
* external_data [IN] External data
* first [?]
* second_pos [?]
* result [?]
* second(?)
* RETURNS
* result->distance is greater than, equal to, or less than 0, according to(?)
* first is greater than, equal to, or less than second.(?)
*****************************************************************************/
static void phb_compare_by_tel_num_sig(
data_entry_table_type *external_data,
num_sig_type *first,
pindex_struct *second_pos,
compare_result_type *result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_COMPARE_BY_TEL_NUM_SIG);
result->same_count = 0;
result->distance = 0;
if (first->tel_num > external_data->table[second_pos->position].tel_num)
{
result->distance = 1;
}
else if (first->tel_num < external_data->table[second_pos->position].tel_num)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -