8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:40:38 +01:00
This commit is contained in:
robocop 2009-05-09 13:46:06 +00:00
parent fbcf6ecf07
commit 0e7dc28051
23 changed files with 601 additions and 456 deletions

View File

@ -37,7 +37,7 @@ CHARSET_ENTRY(CS_gb_2312)
csptr->charset_min_bytes_per_char = 1;
csptr->charset_max_bytes_per_char = 2;
csptr->charset_space_length = 1;
csptr->charset_space_character = (const BYTE*) " "; /* 0x20 */
csptr->charset_space_character = (const BYTE*) " "; // 0x20
csptr->charset_fn_well_formed = CVGB_check_gb2312;
CV_convert_init(&csptr->charset_to_unicode,

View File

@ -38,7 +38,7 @@ CHARSET_ENTRY(CS_jis_0208_1990)
csptr->charset_min_bytes_per_char = 2;
csptr->charset_max_bytes_per_char = 2;
csptr->charset_space_length = 2;
csptr->charset_space_character = (const BYTE*) &space; /* 0x20 */
csptr->charset_space_character = (const BYTE*) &space; // 0x20
csptr->charset_fn_well_formed = NULL;
CV_convert_init(&csptr->charset_to_unicode,
@ -59,7 +59,7 @@ CHARSET_ENTRY(CS_sjis)
csptr->charset_flags |= CHARSET_LEGACY_SEMANTICS;
csptr->charset_min_bytes_per_char = 1;
csptr->charset_space_length = 1;
csptr->charset_space_character = (const BYTE*) " "; /* 0x20 */
csptr->charset_space_character = (const BYTE*) " "; // 0x20
csptr->charset_to_unicode.csconvert_fn_convert = CVJIS_sjis_to_unicode;
csptr->charset_from_unicode.csconvert_fn_convert = CVJIS_unicode_to_sjis;
csptr->charset_fn_well_formed = CVJIS_check_sjis;
@ -74,7 +74,7 @@ CHARSET_ENTRY(CS_euc_j)
csptr->charset_flags |= CHARSET_LEGACY_SEMANTICS;
csptr->charset_min_bytes_per_char = 1;
csptr->charset_space_length = 1;
csptr->charset_space_character = (const BYTE*) " "; /* 0x20 */
csptr->charset_space_character = (const BYTE*) " "; // 0x20
csptr->charset_to_unicode.csconvert_fn_convert = CVJIS_eucj_to_unicode;
csptr->charset_from_unicode.csconvert_fn_convert = CVJIS_unicode_to_eucj;
csptr->charset_fn_well_formed = CVJIS_check_euc;

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________.
*/
/* Note: all routines have cousins in jrd/intl.c */
// Note: all routines have cousins in jrd/intl.cpp
#include "firebird.h"
#include "../intl/ldcommon.h"
@ -36,7 +36,7 @@ CHARSET_ENTRY(CS_unicode_fss)
csptr->charset_min_bytes_per_char = 1;
csptr->charset_max_bytes_per_char = 3;
csptr->charset_space_length = 1;
csptr->charset_space_character = (const BYTE*) " "; /* 0x20 */
csptr->charset_space_character = (const BYTE*) " "; // 0x20
csptr->charset_fn_well_formed = NULL;
CV_convert_init(&csptr->charset_to_unicode,
CS_UTFFSS_fss_to_unicode_cc,

View File

@ -35,7 +35,7 @@ CHARSET_ENTRY(CS_unicode_ucs2)
csptr->charset_min_bytes_per_char = 2;
csptr->charset_max_bytes_per_char = 2;
csptr->charset_space_length = sizeof(space);
csptr->charset_space_character = (const BYTE*) &space; /* 0x0020 */
csptr->charset_space_character = (const BYTE*) &space; // 0x0020
csptr->charset_fn_well_formed = NULL;
CV_convert_init(&csptr->charset_to_unicode,
CV_wc_copy,

View File

@ -59,35 +59,40 @@ ULONG CVBIG5_big5_to_unicode(csconvert* obj,
USHORT wide;
USHORT this_len;
const USHORT* const start = dest_ptr;
while ((src_len) && (dest_len > 1)) {
if (*src_ptr & 0x80) {
while ((src_len) && (dest_len > 1))
{
if (*src_ptr & 0x80)
{
const UCHAR c1 = *src_ptr++;
if (BIG51(c1)) { /* first byte is Big5 */
if (BIG51(c1))
{ // first byte is Big5
if (src_len == 1) {
*err_code = CS_BAD_INPUT;
break;
}
const UCHAR c2 = *src_ptr++;
if (!(BIG52(c2))) { /* Bad second byte */
if (!(BIG52(c2))) { // Bad second byte
*err_code = CS_BAD_INPUT;
break;
}
wide = (c1 << 8) + c2;
this_len = 2;
}
else {
else
{
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* it is ASCII */
else
{ // it is ASCII
wide = *src_ptr++;
this_len = 1;
}
/* Convert from BIG5 to UNICODE */
// Convert from BIG5 to UNICODE
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT) wide / 256] + (wide % 256)];
@ -130,16 +135,17 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
const ULONG src_start = unicode_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (big5_str == NULL)
return (unicode_len); /* worst case - all han character input */
return (unicode_len); // worst case - all han character input
Firebird::Aligner<USHORT> s(p_unicode_str, unicode_len);
const USHORT* unicode_str = s;
const UCHAR* const start = big5_str;
while ((big5_len) && (unicode_len > 1)) {
/* Convert from UNICODE to BIG5 code */
while ((big5_len) && (unicode_len > 1))
{
// Convert from UNICODE to BIG5 code
const USHORT wide = *unicode_str++;
const USHORT big5_ch = ((const USHORT*) impl->csconvert_datatable)
@ -152,7 +158,8 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
// int ???
const int tmp1 = big5_ch / 256;
const int tmp2 = big5_ch % 256;
if (tmp1 == 0) { /* ASCII character */
if (tmp1 == 0)
{ // ASCII character
fb_assert((UCHAR(tmp2) & 0x80) == 0);
@ -161,11 +168,13 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
unicode_len -= sizeof(*unicode_str);
continue;
}
if (big5_len < 2) {
if (big5_len < 2)
{
*err_code = CS_TRUNCATION_ERROR;
break;
}
else {
else
{
fb_assert(BIG51(tmp1));
fb_assert(BIG52(tmp2));
*big5_str++ = tmp1;
@ -203,7 +212,7 @@ INTL_BOOL CVBIG5_check_big5(charset*, // cs,
if (BIG51(c1)) // Is it BIG-5
{
if (big5_len == 0) /* truncated BIG-5 */
if (big5_len == 0) // truncated BIG-5
{
if (offending_position)
*offending_position = big5_str - big5_str_start;

View File

@ -65,35 +65,40 @@ ULONG CVGB_gb2312_to_unicode(csconvert* obj,
USHORT wide;
USHORT this_len;
const USHORT* const start = dest_ptr;
while ((src_len) && (dest_len > 1)) {
if (*src_ptr & 0x80) {
while ((src_len) && (dest_len > 1))
{
if (*src_ptr & 0x80)
{
const UCHAR c1 = *src_ptr++;
if (GB1(c1)) { /* first byte is GB2312 */
if (GB1(c1))
{ // first byte is GB2312
if (src_len == 1) {
*err_code = CS_BAD_INPUT;
break;
}
const UCHAR c2 = *src_ptr++;
if (!(GB2(c2))) { /* Bad second byte */
if (!(GB2(c2))) { // Bad second byte
*err_code = CS_BAD_INPUT;
break;
}
wide = (c1 << 8) + c2;
this_len = 2;
}
else {
else
{
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* it is ASCII */
else
{ // it is ASCII
wide = *src_ptr++;
this_len = 1;
}
/* Convert from GB2312 to UNICODE */
// Convert from GB2312 to UNICODE
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT) wide / 256] + (wide % 256)];
@ -136,16 +141,17 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
const ULONG src_start = unicode_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (gb_str == NULL)
return (unicode_len); /* worst case - all han character input */
return (unicode_len); // worst case - all han character input
Firebird::Aligner<USHORT> s(p_unicode_str, unicode_len);
const USHORT* unicode_str = s;
const UCHAR* const start = gb_str;
while ((gb_len) && (unicode_len > 1)) {
/* Convert from UNICODE to GB2312 code */
while ((gb_len) && (unicode_len > 1))
{
// Convert from UNICODE to GB2312 code
const USHORT wide = *unicode_str++;
const USHORT gb_ch = ((const USHORT*) impl->csconvert_datatable)
@ -157,7 +163,8 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
const int tmp1 = gb_ch / 256;
const int tmp2 = gb_ch % 256;
if (tmp1 == 0) { /* ASCII character */
if (tmp1 == 0)
{ // ASCII character
fb_assert((UCHAR(tmp2) & 0x80) == 0);
@ -166,11 +173,13 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
unicode_len -= sizeof(*unicode_str);
continue;
}
if (gb_len < 2) {
if (gb_len < 2)
{
*err_code = CS_TRUNCATION_ERROR;
break;
}
else {
else
{
fb_assert(GB1(tmp1));
fb_assert(GB2(tmp2));
*gb_str++ = tmp1;

View File

@ -51,7 +51,7 @@ ULONG CVJIS_eucj_to_unicode(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (p_dest_ptr == NULL)
return sizeof(USHORT) * src_len;
@ -62,38 +62,41 @@ ULONG CVJIS_eucj_to_unicode(csconvert* obj,
USHORT wide;
USHORT this_len;
const USHORT* const start = dest_ptr;
while ((src_len) && (dest_len > 1)) {
while ((src_len) && (dest_len > 1))
{
const UCHAR ch1 = *src_ptr++;
/* Step 1: Convert from EUC to JIS */
if (!(ch1 & 0x80)) { /* 1 byte SCHAR */
/* Plane 0 of EUC-J is defined as ASCII */
// Step 1: Convert from EUC to JIS
if (!(ch1 & 0x80))
{ // 1 byte SCHAR
// Plane 0 of EUC-J is defined as ASCII
wide = ch1;
this_len = 1;
/* Step 2: Convert from ASCII to UNICODE */
// Step 2: Convert from ASCII to UNICODE
ch = ch1;
}
else if (src_len == 1 || !(*src_ptr & 0x80)) {
/* We received a multi-byte indicator, but either
there isn't a 2nd byte or the 2nd byte isn't marked */
else if (src_len == 1 || !(*src_ptr & 0x80))
{
// We received a multi-byte indicator, but either
// there isn't a 2nd byte or the 2nd byte isn't marked
*err_code = CS_BAD_INPUT;
break;
}
else {
else
{
wide = ((ch1 << 8) + (*src_ptr++)) & ~0x8080;
this_len = 2;
/* Step 2: Convert from JIS to UNICODE */
// Step 2: Convert from JIS to UNICODE
ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256] + (wide % 256)];
}
/* No need to check for CS_CONVERT_ERROR -
* EUCJ must convert to Unicode
*/
// No need to check for CS_CONVERT_ERROR -
// EUCJ must convert to Unicode
*dest_ptr++ = ch;
dest_len -= sizeof(*dest_ptr);
@ -109,14 +112,16 @@ ULONG CVJIS_eucj_to_unicode(csconvert* obj,
static void S2E(const UCHAR s1, const UCHAR s2, UCHAR& j1, UCHAR& j2)
{
if (s2 >= 0x9f) {
if (s2 >= 0x9f)
{
if (s1 >= 0xe0)
j1 = (s1 * 2 - 0xe0);
else
j1 = (s1 * 2 - 0x60);
j2 = (s2 + 2);
}
else {
else
{
if (s1 >= 0xe0)
j1 = (s1 * 2 - 0xe1);
else
@ -151,9 +156,9 @@ ULONG CVJIS_sjis_to_unicode(csconvert* obj,
const ULONG src_start = sjis_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (p_dest_ptr == NULL)
return (sjis_len * 2); /* worst case - all ascii input */
return (sjis_len * 2); // worst case - all ascii input
Firebird::OutAligner<USHORT> d(p_dest_ptr, dest_len);
USHORT* dest_ptr = d;
@ -162,62 +167,71 @@ ULONG CVJIS_sjis_to_unicode(csconvert* obj,
USHORT this_len;
USHORT wide;
const USHORT* const start = dest_ptr;
while (sjis_len && dest_len > 1) {
/* Step 1: Convert from SJIS to JIS code */
if (*sjis_str & 0x80) { /* Non-Ascii - High bit set */
while (sjis_len && dest_len > 1)
{
// Step 1: Convert from SJIS to JIS code
if (*sjis_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *sjis_str++;
if (SJIS1(c1)) { /* First byte is a KANJI */
if (sjis_len == 1) { /* truncated KANJI */
if (SJIS1(c1))
{ // First byte is a KANJI
if (sjis_len == 1) { // truncated KANJI
*err_code = CS_BAD_INPUT;
break;
}
const UCHAR c2 = *sjis_str++;
if (!(SJIS2(c2))) { /* Bad second byte */
if (!(SJIS2(c2))) { // Bad second byte
*err_code = CS_BAD_INPUT;
break;
}
/* Step 1b: Convert 2 byte SJIS to EUC-J */
// Step 1b: Convert 2 byte SJIS to EUC-J
UCHAR tmp1, tmp2;
S2E(c1, c2, tmp1, tmp2);
/* Step 2b: Convert 2 byte EUC-J to JIS */
// Step 2b: Convert 2 byte EUC-J to JIS
wide = ((tmp1 << 8) + tmp2) & ~0x8080;
this_len = 2;
table = 1;
}
else if (SJIS_SINGLE(c1)) {
else if (SJIS_SINGLE(c1))
{
wide = c1;
this_len = 1;
table = 2;
}
else { /* It is some bad character */
else
{ // It is some bad character
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* it is a ASCII */
else
{ // it is a ASCII
wide = *sjis_str++;
this_len = 1;
table = 2;
}
/* Step 2: Convert from JIS code (in wide) to UNICODE */
// Step 2: Convert from JIS code (in wide) to UNICODE
USHORT ch;
if (table == 1)
{
ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256] + (wide % 256)];
else {
}
else
{
fb_assert(table == 2);
fb_assert(wide <= 255);
ch = sjis_to_unicode_mapping_array
[sjis_to_unicode_map[(USHORT) wide / 256] + (wide % 256)];
}
/* This is only important for bad-SJIS in input stream */
// This is only important for bad-SJIS in input stream
if ((ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
break;
@ -291,13 +305,15 @@ static void seven2eight(USHORT *p1, USHORT *p2)
if ((*p2 >= 127) && (*p2 < 158))
(*p2)++;
if ((*p1 >= 33) && (*p1 <= 94)) {
if ((*p1 >= 33) && (*p1 <= 94))
{
if (isodd(*p1))
*p1 = ((*p1 - 1) / 2) + 113;
else
*p1 = (*p1 / 2) + 112;
}
else if ((*p1 >= 95) && (*p1 <= 126)) {
else if ((*p1 >= 95) && (*p1 <= 126))
{
if (isodd(*p1))
*p1 = ((*p1 - 1) / 2) + 177;
else
@ -413,24 +429,26 @@ ULONG CVJIS_unicode_to_sjis(csconvert* obj,
const ULONG src_start = unicode_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (sjis_str == NULL)
return (unicode_len); /* worst case - all han character input */
return (unicode_len); // worst case - all han character input
Firebird::Aligner<USHORT> s(p_unicode_str, unicode_len);
const USHORT* unicode_str = s;
const UCHAR* const start = sjis_str;
while ((sjis_len) && (unicode_len > 1)) {
/* Step 1: Convert from UNICODE to JIS code */
while ((sjis_len) && (unicode_len > 1))
{
// Step 1: Convert from UNICODE to JIS code
const USHORT wide = *unicode_str++;
USHORT jis_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT)wide / 256] + (wide % 256)];
if ((jis_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
if ((jis_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP))
{
/* Handle the non-JIS codes in SJIS (ASCII & half-width Kana) */
// Handle the non-JIS codes in SJIS (ASCII & half-width Kana)
jis_ch = sjis_from_unicode_mapping_array
[sjis_from_unicode_map[(USHORT) wide / 256] + (wide % 256)];
if ((jis_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
@ -439,27 +457,31 @@ ULONG CVJIS_unicode_to_sjis(csconvert* obj,
}
}
/* Step 2: Convert from JIS code to SJIS */
// Step 2: Convert from JIS code to SJIS
USHORT tmp1 = jis_ch / 256;
USHORT tmp2 = jis_ch % 256;
if (tmp1 == 0) { /* ASCII character */
if (tmp1 == 0)
{ // ASCII character
*sjis_str++ = tmp2;
sjis_len--;
unicode_len -= sizeof(*unicode_str);
continue;
}
seven2eight(&tmp1, &tmp2);
if (tmp1 == 0) { /* half-width kana ? */
if (tmp1 == 0)
{ // half-width kana ?
fb_assert(SJIS_SINGLE(tmp2));
*sjis_str++ = tmp2;
unicode_len -= sizeof(*unicode_str);
sjis_len--;
}
else if (sjis_len < 2) {
else if (sjis_len < 2)
{
*err_code = CS_TRUNCATION_ERROR;
break;
}
else {
else
{
fb_assert(SJIS1(tmp1));
fb_assert(SJIS2(tmp2));
*sjis_str++ = tmp1;
@ -496,17 +518,18 @@ ULONG CVJIS_unicode_to_eucj(csconvert* obj, ULONG unicode_len, const UCHAR* p_un
// See if we're only after a length estimate
if (eucj_str == NULL)
return (unicode_len); /* worst case - all han character input */
return (unicode_len); // worst case - all han character input
Firebird::Aligner<USHORT> s(p_unicode_str, unicode_len);
const USHORT* unicode_str = s;
const UCHAR* const start = eucj_str;
while ((eucj_len) && (unicode_len > 1)) {
/* Step 1: Convert from UNICODE to JIS code */
while ((eucj_len) && (unicode_len > 1))
{
// Step 1: Convert from UNICODE to JIS code
const USHORT wide = *unicode_str++;
/* ASCII range characters map directly -- others go to the table */
// ASCII range characters map directly -- others go to the table
USHORT jis_ch;
if (wide <= 0x007F)
jis_ch = wide;
@ -519,21 +542,24 @@ ULONG CVJIS_unicode_to_eucj(csconvert* obj, ULONG unicode_len, const UCHAR* p_un
break;
}
/* Step 2: Convert from JIS code to EUC-J */
// Step 2: Convert from JIS code to EUC-J
const USHORT tmp1 = jis_ch / 256;
const USHORT tmp2 = jis_ch % 256;
if (tmp1 == 0) { /* ASCII character */
if (tmp1 == 0)
{ // ASCII character
fb_assert(!(tmp2 & 0x80));
*eucj_str++ = tmp2;
eucj_len--;
unicode_len -= sizeof(*unicode_str);
continue;
}
if (eucj_len < 2) {
if (eucj_len < 2)
{
*err_code = CS_TRUNCATION_ERROR;
break;
}
else {
else
{
fb_assert(!(tmp1 & 0x80));
fb_assert(!(tmp2 & 0x80));
*eucj_str++ = tmp1 | 0x80;
@ -656,34 +682,39 @@ static USHORT CVJIS_euc2sjis(csconvert* obj, UCHAR *sjis_str, USHORT sjis_len,
const USHORT src_start = euc_len;
*err_code = 0;
/* Length estimate needed? */
// Length estimate needed?
if (sjis_str == NULL)
return (euc_len); /* worst case */
return (euc_len); // worst case
const UCHAR* const sjis_start = sjis_str;
while (euc_len && sjis_len) {
if (*euc_str & 0x80) { /* Non-Ascii - High bit set */
while (euc_len && sjis_len)
{
if (*euc_str & 0x80)
{ // Non-Ascii - High bit set
UCHAR c1 = *euc_str++;
if (EUC1(c1)) { /* It is a EUC */
if (EUC1(c1))
{ // It is a EUC
if (euc_len == 1) {
*err_code = CS_BAD_INPUT; /* truncated EUC */
*err_code = CS_BAD_INPUT; // truncated EUC
break;
}
UCHAR c2 = *euc_str++;
if (!(EUC2(c2))) {
*err_code = CS_BAD_INPUT; /* Bad EUC */
*err_code = CS_BAD_INPUT; // Bad EUC
break;
}
if (c1 == 0x8e) { /* Kana */
if (c1 == 0x8e)
{ // Kana
sjis_len--;
*sjis_str++ = c2;
euc_len -= 2;
}
else { /* Kanji */
else
{ // Kanji
if (sjis_len < 2) { /*buffer full */
if (sjis_len < 2) { // buffer full
*err_code = CS_TRUNCATION_ERROR;
break;
}
@ -691,22 +722,22 @@ static USHORT CVJIS_euc2sjis(csconvert* obj, UCHAR *sjis_str, USHORT sjis_len,
euc_len -= 2;
c1 ^= 0x80;
c2 ^= 0x80;
*sjis_str++ =
(USHORT) (c1 - 0x21) / 2 +
((c1 <= 0x5e) ? 0x81 : 0xc1);
if (c1 & 1) /* odd */
*sjis_str++ = (USHORT) (c1 - 0x21) / 2 + ((c1 <= 0x5e) ? 0x81 : 0xc1);
if (c1 & 1) // odd
*sjis_str++ = c2 + ((c2 <= 0x5f) ? 0x1f : 0x20);
else
*sjis_str++ = c2 + 0x7e;
}
}
else { /* It is some bad character */
else
{ // It is some bad character
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* ASCII */
else
{ // ASCII
euc_len--;
sjis_len--;
*sjis_str++ = *euc_str++;
@ -741,24 +772,27 @@ static USHORT CVJIS_sjis2euc(csconvert* obj, UCHAR *euc_str, USHORT euc_len,
const USHORT src_start = sjis_len;
*err_code = 0;
if (euc_str == NULL)
return (2 * sjis_len); /* worst case */
return (2 * sjis_len); // worst case
const UCHAR* const euc_start = euc_str;
while (sjis_len && euc_len) {
while (sjis_len && euc_len)
{
if (*sjis_str & 0x80) { /* Non-Ascii - High bit set */
if (*sjis_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *sjis_str++;
if (SJIS1(c1)) { /* First byte is a KANJI */
if (sjis_len == 1) { /* truncated KANJI */
if (SJIS1(c1))
{ // First byte is a KANJI
if (sjis_len == 1) { // truncated KANJI
*err_code = CS_BAD_INPUT;
break;
}
const UCHAR c2 = *sjis_str++;
if (!(SJIS2(c2))) { /* Bad second byte */
if (!(SJIS2(c2))) { // Bad second byte
*err_code = CS_BAD_INPUT;
break;
}
if (euc_len < 2) { /*buffer full */
if (euc_len < 2) { // buffer full
*err_code = CS_TRUNCATION_ERROR;
break;
}
@ -767,22 +801,25 @@ static USHORT CVJIS_sjis2euc(csconvert* obj, UCHAR *euc_str, USHORT euc_len,
euc_len -= 2;
sjis_len -= 2;
}
else if (SJIS_SINGLE(c1)) {
if (euc_len < 2) { /*buffer full */
else if (SJIS_SINGLE(c1))
{
if (euc_len < 2) { // buffer full
*err_code = CS_TRUNCATION_ERROR;
break;
}
euc_len -= 2; /* Kana */
euc_len -= 2; // Kana
sjis_len--;
*euc_str++ = 0x8e;
*euc_str++ = c1;
}
else { /* It is some bad character */
else
{ // It is some bad character
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* it is a ASCII */
else
{ // it is a ASCII
euc_len--;
sjis_len--;
*euc_str++ = *sjis_str++;

View File

@ -27,11 +27,10 @@
#include "cv_ksc.h"
#include "ld_proto.h"
/*
* KSC-5601 -> unicode
* % KSC-5601 is same to EUC cs1(codeset 1). Then converting
* KSC-5601 to EUC is not needed.
*/
// KSC-5601 -> unicode
// % KSC-5601 is same to EUC cs1(codeset 1). Then converting
// KSC-5601 to EUC is not needed.
ULONG CVKSC_ksc_to_unicode(csconvert* obj,
ULONG src_len,
@ -65,29 +64,34 @@ ULONG CVKSC_ksc_to_unicode(csconvert* obj,
USHORT wide;
USHORT this_len;
const USHORT* const start = dest_ptr;
while (src_len && (dest_len > 1)) {
if (*src_ptr & 0x80) {
while (src_len && (dest_len > 1))
{
if (*src_ptr & 0x80)
{
const UCHAR c1 = *src_ptr++;
if (KSC1(c1)) { /* first byte is KSC */
if (KSC1(c1))
{ // first byte is KSC
if (src_len == 1) {
*err_code = CS_BAD_INPUT;
break;
}
const UCHAR c2 = *src_ptr++;
if (!(KSC2(c2))) { /* Bad second byte */
if (!(KSC2(c2))) { // Bad second byte
*err_code = CS_BAD_INPUT;
break;
}
wide = (c1 << 8) + c2;
this_len = 2;
}
else {
else
{
*err_code = CS_BAD_INPUT;
break;
}
}
else { /* it is ASCII */
else
{ // it is ASCII
wide = *src_ptr++;
this_len = 1;
}
@ -143,7 +147,8 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
const USHORT* unicode_str = s;
const UCHAR* const start = ksc_str;
while (ksc_len && unicode_len > 1) {
while (ksc_len && unicode_len > 1)
{
const USHORT wide = *unicode_str++;
const USHORT ksc_ch = ((const USHORT*) impl->csconvert_datatable)
@ -155,7 +160,8 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
const int tmp1 = ksc_ch / 256;
const int tmp2 = ksc_ch % 256;
if (tmp1 == 0) { /* ASCII character */
if (tmp1 == 0)
{ // ASCII character
fb_assert((UCHAR(tmp2) & 0x80) == 0);
@ -164,11 +170,13 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
unicode_len -= sizeof(*unicode_str);
continue;
}
if (ksc_len < 2) {
if (ksc_len < 2)
{
*err_code = CS_TRUNCATION_ERROR;
break;
}
else {
else
{
fb_assert(KSC1(tmp1));
fb_assert(KSC2(tmp2));
*ksc_str++ = tmp1;
@ -176,7 +184,7 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
unicode_len -= sizeof(*unicode_str);
ksc_len -= 2;
}
} /* end-while */
} // end-while
if (unicode_len && !*err_code) {
*err_code = CS_TRUNCATION_ERROR;
}
@ -192,10 +200,12 @@ INTL_BOOL CVKSC_check_ksc(charset*, // cs,
{
const UCHAR* ksc_str_start = ksc_str;
while (ksc_len--) {
while (ksc_len--)
{
const UCHAR c1 = *ksc_str;
if (KSC1(c1)) { /* Is it KSC-5601 ? */
if (ksc_len == 0) /* truncated KSC */
if (KSC1(c1))
{ // Is it KSC-5601 ?
if (ksc_len == 0) // truncated KSC
{
if (offending_position)
*offending_position = ksc_str - ksc_str_start;
@ -205,13 +215,13 @@ INTL_BOOL CVKSC_check_ksc(charset*, // cs,
ksc_str += 2;
ksc_len -= 1;
}
else if (c1 > 0x7f) /* error */
else if (c1 > 0x7f) // error
{
if (offending_position)
*offending_position = ksc_str - ksc_str_start;
return false;
}
else /* ASCII */
else // ASCII
ksc_str++;
}
return (true);

View File

@ -66,12 +66,13 @@ ULONG CV_unicode_to_nc(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (dest_ptr == NULL)
return ((ULONG) (src_len + 1) / 2);
const BYTE* const start = dest_ptr;
while ((src_len > 1) && dest_len) {
while ((src_len > 1) && dest_len)
{
const UNICODE uni = *((const UNICODE*) src_ptr);
const UCHAR ch = impl->csconvert_datatable[
((const USHORT*) impl->csconvert_misc)[(USHORT) uni / 256] + (uni % 256)];
@ -84,7 +85,8 @@ ULONG CV_unicode_to_nc(csconvert* obj,
src_len -= 2;
dest_len -= 1;
}
if (src_len && !*err_code) {
if (src_len && !*err_code)
{
if (src_len == 1)
*err_code = CS_BAD_INPUT;
else
@ -117,7 +119,7 @@ ULONG CV_wc_to_wc(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (p_dest_ptr == NULL)
return (src_len);
@ -127,7 +129,8 @@ ULONG CV_wc_to_wc(csconvert* obj,
USHORT* dest_ptr = d;
const USHORT* const start = dest_ptr;
while ((src_len > 1) && (dest_len > 1)) {
while ((src_len > 1) && (dest_len > 1))
{
const UNICODE uni = *((const UNICODE*) src_ptr);
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)[
((const USHORT*) impl->csconvert_misc)[(USHORT) uni / 256] + (uni % 256)];
@ -140,7 +143,8 @@ ULONG CV_wc_to_wc(csconvert* obj,
src_len -= 2;
dest_len -= 2;
}
if (src_len && !*err_code) {
if (src_len && !*err_code)
{
if (src_len == 1)
*err_code = CS_BAD_INPUT;
else
@ -173,16 +177,16 @@ ULONG CV_nc_to_unicode(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (dest_ptr == NULL)
return (src_len * 2);
const BYTE* const start = dest_ptr;
while (src_len && (dest_len > 1)) {
while (src_len && (dest_len > 1))
{
const UNICODE ch = ((const UNICODE*) (impl->csconvert_datatable))[*src_ptr];
/* No need to check for CS_CONVERT_ERROR, all charsets
* must convert to unicode.
*/
// No need to check for CS_CONVERT_ERROR, all charsets
// must convert to unicode.
*((UNICODE *) dest_ptr) = ch;
src_ptr++;
@ -215,18 +219,20 @@ ULONG CV_wc_copy(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (dest_ptr == NULL)
return (src_len);
const BYTE* const start = dest_ptr;
while ((src_len > 1) && (dest_len > 1)) {
*dest_ptr++ = *src_ptr++; /* first byte of unicode */
*dest_ptr++ = *src_ptr++; /* 2nd byte of unicode */
while ((src_len > 1) && (dest_len > 1))
{
*dest_ptr++ = *src_ptr++; // first byte of unicode
*dest_ptr++ = *src_ptr++; // 2nd byte of unicode
src_len -= 2;
dest_len -= 2;
}
if (src_len && !*err_code) {
if (src_len && !*err_code)
{
if (src_len == 1)
*err_code = CS_BAD_INPUT;
else
@ -258,12 +264,13 @@ ULONG eight_bit_convert(csconvert* obj,
const ULONG src_start = src_len;
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (dest_ptr == NULL)
return (src_len);
const BYTE* const start = dest_ptr;
while (src_len && dest_len) {
while (src_len && dest_len)
{
const UCHAR ch = impl->csconvert_datatable[*src_ptr];
if ((ch == CS_CANT_MAP) && (*src_ptr != CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________.
*/
/* Note: all routines have cousins in jrd/intl.c */
// Note: all routines have cousins in jrd/intl.cpp
#include "firebird.h"
#include "../intl/ldcommon.h"
@ -170,9 +170,11 @@ static fss_size_t fss_mbtowc( fss_wchar_t* p, const UCHAR* s, fss_size_t n)
const int c0 = *s & 0xff;
long l = c0;
for (const Fss_table* t = fss_sequence_table; t->cmask; t++) {
for (const Fss_table* t = fss_sequence_table; t->cmask; t++)
{
nc++;
if ((c0 & t->cmask) == t->cval) {
if ((c0 & t->cmask) == t->cval)
{
l &= t->lmask;
if (l < t->lval)
return -1;
@ -198,12 +200,15 @@ static fss_size_t fss_wctomb(UCHAR* s, fss_wchar_t wc)
const long l = wc;
int nc = 0;
for (const Fss_table* t = fss_sequence_table; t->cmask; t++) {
for (const Fss_table* t = fss_sequence_table; t->cmask; t++)
{
nc++;
if (l <= t->lmask) {
if (l <= t->lmask)
{
int c = t->shift;
*s = t->cval | (l >> c);
while (c > 0) {
while (c > 0)
{
c -= 6;
s++;
*s = 0x80 | ((l >> c) & 0x3F);
@ -225,13 +230,14 @@ ULONG fss_to_unicode(ULONG src_len,
*err_code = 0;
/* See if we're only after a length estimate */
// See if we're only after a length estimate
if (dest_ptr == NULL)
return (src_len * 2); /* All single byte narrow characters */
return (src_len * 2); // All single byte narrow characters
const UNICODE* const start = dest_ptr;
const ULONG src_start = src_len;
while ((src_len) && (dest_len >= sizeof(*dest_ptr))) {
while ((src_len) && (dest_len >= sizeof(*dest_ptr)))
{
const fss_size_t res = fss_mbtowc(dest_ptr, src_ptr, src_len);
if (res == -1) {
*err_code = CS_BAD_INPUT;
@ -289,26 +295,27 @@ ULONG CS_UTFFSS_unicode_to_fss(csconvert* obj,
// See if we're only after a length estimate
if (fss_str == NULL)
return ((ULONG) (unicode_len + 1) / 2 * 3); /* worst case - all han character input */
return ((ULONG) (unicode_len + 1) / 2 * 3); // worst case - all han character input
Firebird::Aligner<UNICODE> s(p_unicode_str, unicode_len);
const UNICODE* unicode_str = s;
UCHAR tmp_buffer[6];
const UCHAR* const start = fss_str;
while ((fss_len) && (unicode_len >= sizeof(*unicode_str))) {
/* Convert the wide character into temp buffer */
while ((fss_len) && (unicode_len >= sizeof(*unicode_str)))
{
// Convert the wide character into temp buffer
fss_size_t res = fss_wctomb(tmp_buffer, *unicode_str);
if (res == -1) {
*err_code = CS_BAD_INPUT;
break;
}
/* will the mb sequence fit into space left? */
// will the mb sequence fit into space left?
if (static_cast<ULONG>(res) > fss_len) {
*err_code = CS_TRUNCATION_ERROR;
break;
}
/* copy the converted bytes into the destination */
// copy the converted bytes into the destination
const UCHAR* p = tmp_buffer;
for (; res; res--, fss_len--)
*fss_str++ = *p++;

View File

@ -31,14 +31,16 @@
static void S2E(const UCHAR s1, const UCHAR s2, UCHAR& j1, UCHAR& j2)
{
if (s2 >= 0x9f) {
if (s2 >= 0x9f)
{
if (s1 >= 0xe0)
j1 = (s1 * 2 - 0xe0);
else
j1 = (s1 * 2 - 0x60);
j2 = (s2 + 2);
}
else {
else
{
if (s1 >= 0xe0)
j1 = (s1 * 2 - 0xe1);
else
@ -66,16 +68,18 @@ USHORT KANJI_check_euc(const UCHAR* euc_str, USHORT euc_len)
* return 1.
* else return(0);
**************************************/
while (euc_len--) {
if (*euc_str & 0x80) { /* Is it EUC */
if (euc_len == 0) { /* truncated kanji */
while (euc_len--)
{
if (*euc_str & 0x80)
{ // Is it EUC
if (euc_len == 0) { // truncated kanji
return (1);
}
euc_str += 2;
euc_len -= 1;
}
else { /* it is a ASCII */
else { // it is a ASCII
euc_str++;
}
}
@ -98,21 +102,24 @@ USHORT KANJI_check_sjis(const UCHAR* sjis_str, USHORT sjis_len)
* return 1.
* else return(0);
**************************************/
while (sjis_len--) {
if (*sjis_str & 0x80) { /* Is it SJIS */
if SJIS1(*sjis_str) { /* It is a KANJI */
if (sjis_len == 0) { /* truncated KANJI */
while (sjis_len--)
{
if (*sjis_str & 0x80)
{ // Is it SJIS
if SJIS1(*sjis_str)
{ // It is a KANJI
if (sjis_len == 0) { // truncated KANJI
return (1);
}
sjis_str += 2;
sjis_len -= 1;
}
else { /*It is a KANA */
else { //It is a KANA
sjis_str++;
}
}
else { /* it is a ASCII */
else { // it is a ASCII
sjis_str++;
}
}
@ -140,43 +147,48 @@ USHORT KANJI_euc2sjis(const UCHAR* euc_str,
*
**************************************/
*sjis_len = 0;
while (euc_len) {
if (*euc_str & 0x80) { /* Non-Ascii - High bit set */
if (*sjis_len >= sjis_buf_len) /*buffer full */
while (euc_len)
{
if (*euc_str & 0x80)
{ // Non-Ascii - High bit set
if (*sjis_len >= sjis_buf_len) // buffer full
return (1);
UCHAR c1 = *euc_str++;
euc_len--;
if (EUC1(c1)) { /* It is a EUC */
if (EUC1(c1))
{ // It is a EUC
if (euc_len == 0)
return (1); /* truncated EUC */
return (1); // truncated EUC
UCHAR c2 = *euc_str++;
euc_len--;
if (!(EUC2(c2)))
return (1); /* Bad EUC */
if (c1 == 0x8e) { /* Kana */
return (1); // Bad EUC
if (c1 == 0x8e)
{ // Kana
*sjis_len += 1;
*sjis_str++ = c2;
}
else { /* Kanji */
else
{ // Kanji
*sjis_len += 2;
if (*sjis_len > sjis_buf_len) /*buffer full */
if (*sjis_len > sjis_buf_len) // buffer full
return (1);
c1 ^= 0x80;
c2 ^= 0x80;
*sjis_str++ =
(c1 - 0x21) / 2 + ((c1 <= 0x5e) ? 0x81 : 0xc1);
if (c1 & 1) /* odd */
*sjis_str++ = (c1 - 0x21) / 2 + ((c1 <= 0x5e) ? 0x81 : 0xc1);
if (c1 & 1) // odd
*sjis_str++ = c2 + ((c2 <= 0x5f) ? 0x1f : 0x20);
else
*sjis_str++ = c2 + 0x7e;
}
}
else /* It is some bad character */
else // It is some bad character
return (1);
}
else { /* ASCII */
else
{ // ASCII
euc_len--;
*sjis_len += 1;
*sjis_str++ = *euc_str++;
@ -205,7 +217,8 @@ USHORT KANJI_euc_byte2short(const UCHAR* src, USHORT* dst, USHORT len)
*
**************************************/
USHORT l;
for (l = 0; len-- > 0; l++) {
for (l = 0; len-- > 0; l++)
{
USHORT x = (EUC1(*src)) ? (len--, (*src++ << 8)) : 0;
x |= *src++;
*dst++ = x;
@ -229,26 +242,30 @@ USHORT KANJI_euc_len(const UCHAR* sjis_str, USHORT sjis_len, USHORT* euc_len)
*
**************************************/
*euc_len = 0;
while (sjis_len) {
if (*sjis_str & 0x80) { /* Non-Ascii - High bit set */
while (sjis_len)
{
if (*sjis_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *sjis_str++;
sjis_len--;
if (SJIS1(c1)) { /* First byte is a KANJI */
if (SJIS1(c1))
{ // First byte is a KANJI
if (sjis_len == 0)
return (1); /* truncated KANJI */
return (1); // truncated KANJI
const UCHAR c2 = *sjis_str++;
sjis_len--;
if (!(SJIS2(c2)))
return (1); /* Bad second byte */
*euc_len += 2; /* Good Kanji */
return (1); // Bad second byte
*euc_len += 2; // Good Kanji
}
else if (SJIS_SINGLE(c1))
*euc_len += 2; /* Kana */
*euc_len += 2; // Kana
else
return (1); /* It is some bad character */
return (1); // It is some bad character
}
else { /* it is a ASCII */
else
{ // it is a ASCII
sjis_len--;
*euc_len += 1;
@ -277,38 +294,43 @@ USHORT KANJI_sjis2euc(const UCHAR* sjis_str,
*
**************************************/
*euc_len = 0;
while (sjis_len) {
if (*euc_len >= euc_buf_len) /*buffer full */
while (sjis_len)
{
if (*euc_len >= euc_buf_len) // buffer full
return (1);
if (*sjis_str & 0x80) { /* Non-Ascii - High bit set */
if (*sjis_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *sjis_str++;
sjis_len--;
if (SJIS1(c1)) { /* First byte is a KANJI */
if (SJIS1(c1))
{ // First byte is a KANJI
if (sjis_len == 0)
return (1); /* truncated KANJI */
return (1); // truncated KANJI
const UCHAR c2 = *sjis_str++;
sjis_len--;
if (!(SJIS2(c2)))
return (1); /* Bad second byte */
*euc_len += 2; /* Good Kanji */
if (*euc_len > euc_buf_len) /*buffer full */
return (1); // Bad second byte
*euc_len += 2; // Good Kanji
if (*euc_len > euc_buf_len) // buffer full
return (1);
S2E(c1, c2, *euc_str, *(euc_str + 1));
euc_str += 2;
}
else if (SJIS_SINGLE(c1)) {
*euc_len += 2; /* Kana */
if (*euc_len > euc_buf_len) /*buffer full */
else if (SJIS_SINGLE(c1))
{
*euc_len += 2; // Kana
if (*euc_len > euc_buf_len) // buffer full
return (1);
*euc_str++ = 0x8e;
*euc_str++ = c1;
}
else
return (1); /* It is some bad character */
return (1); // It is some bad character
}
else { /* it is a ASCII */
else
{ // it is a ASCII
*euc_len += 1;
sjis_len--;
*euc_str++ = *sjis_str++;
@ -376,32 +398,36 @@ USHORT KANJI_sjis2euc5(const UCHAR* sjis_str,
**************************************/
*euc_len = 0;
*ib_sjis = *ib_euc = 0;
while (sjis_len) {
if (*euc_len >= euc_buf_len) /*buffer full */
while (sjis_len)
{
if (*euc_len >= euc_buf_len) // buffer full
return (1);
if (*sjis_str & 0x80) { /* Non-Ascii - High bit set */
if (*sjis_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *sjis_str++;
sjis_len--;
if (SJIS1(c1)) { /* First byte is a KANJI */
if (SJIS1(c1))
{ // First byte is a KANJI
if (sjis_len == 0)
return (2); /* truncated KANJI */
return (2); // truncated KANJI
const UCHAR c2 = *sjis_str++;
sjis_len--;
if (!(SJIS2(c2)))
return (2); /* Bad second byte */
*euc_len += 2; /* Good Kanji */
if (*euc_len > euc_buf_len) /*buffer full */
return (2); // Bad second byte
*euc_len += 2; // Good Kanji
if (*euc_len > euc_buf_len) // buffer full
return (1);
S2E(c1, c2, *euc_str, *(euc_str + 1));
euc_str += 2;
*ib_sjis += 2;
*ib_euc += 2;
}
else if (SJIS_SINGLE(c1)) {
*euc_len += 2; /* Kana */
if (*euc_len > euc_buf_len) /*buffer full */
else if (SJIS_SINGLE(c1))
{
*euc_len += 2; // Kana
if (*euc_len > euc_buf_len) // buffer full
return (1);
*euc_str++ = 0x8e;
*euc_str++ = c1;
@ -409,9 +435,10 @@ USHORT KANJI_sjis2euc5(const UCHAR* sjis_str,
*ib_euc += 2;
}
else
return (2); /* It is some bad character */
return (2); // It is some bad character
}
else { /* it is a ASCII */
else
{ // it is a ASCII
*euc_len += 1;
sjis_len--;
*euc_str++ = *sjis_str++;
@ -438,27 +465,31 @@ USHORT KANJI_sjis_len(const UCHAR* euc_str, USHORT euc_len, USHORT* sjis_len)
*
**************************************/
*sjis_len = 0;
while (euc_len) {
if (*euc_str & 0x80) { /* Non-Ascii - High bit set */
while (euc_len)
{
if (*euc_str & 0x80)
{ // Non-Ascii - High bit set
const UCHAR c1 = *euc_str++;
euc_len--;
if (EUC1(c1)) { /* It is a EUC */
if (EUC1(c1))
{ // It is a EUC
if (euc_len == 0)
return (1); /* truncated EUC */
return (1); // truncated EUC
const UCHAR c2 = *euc_str++;
euc_len--;
if (!(EUC2(c2)))
return (1); /* Bad EUC */
return (1); // Bad EUC
if (c1 == 0x8e)
*sjis_len += 1; /* Kana */
*sjis_len += 1; // Kana
else
*sjis_len += 2; /* Kanji */
*sjis_len += 2; // Kanji
}
else /* It is some bad character */
else // It is some bad character
return (1);
}
else { /* ASCII */
else
{ // ASCII
euc_len--;
*sjis_len += 1;
euc_str++;

View File

@ -493,7 +493,7 @@ const BYTE ASCII_SPACE = 32; // ASCII code for space
*/
USHORT famasc_key_length(texttype* /*obj*/, USHORT inLen)
{
/* fb_assert (inLen <= LANGASCII_MAX_KEY); - possible upper logic error if true */
// fb_assert (inLen <= LANGASCII_MAX_KEY); - possible upper logic error if true
return (MIN(inLen, LANGASCII_MAX_KEY));
}
@ -517,12 +517,12 @@ USHORT famasc_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar, U
fb_assert(iOutLen <= LANGASCII_MAX_KEY);
fb_assert(iOutLen >= famasc_key_length(obj, iInLen));
/* point inbuff at last character */
// point inbuff at last character
const BYTE* inbuff = pInChar + iInLen - 1;
if (obj->texttype_pad_option)
{
/* skip backwards over all spaces & reset input length */
// skip backwards over all spaces & reset input length
while ((inbuff >= pInChar) && (*inbuff == ASCII_SPACE))
inbuff--;
}
@ -541,7 +541,8 @@ static bool all_spaces(const BYTE* s, SLONG len)
{
fb_assert(s != NULL);
while (len-- > 0) {
while (len-- > 0)
{
if (*s++ != ASCII_SPACE)
return false;
}
@ -560,7 +561,8 @@ SSHORT famasc_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const B
*error_flag = false;
const ULONG len = MIN(l1, l2);
for (ULONG i = 0; i < len; i++) {
for (ULONG i = 0; i < len; i++)
{
if (s1[i] == s2[i])
continue;
if (all_spaces(&s1[i], (SLONG) (l1 - i)))
@ -573,12 +575,14 @@ SSHORT famasc_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const B
return 1;
}
if (l1 > len) {
if (l1 > len)
{
if (obj->texttype_pad_option && all_spaces(&s1[len], (SLONG) (l1 - len)))
return 0;
return 1;
}
if (l2 > len) {
if (l2 > len)
{
if (obj->texttype_pad_option && all_spaces(&s2[len], (SLONG) (l2 - len)))
return 0;
return -1;

View File

@ -54,7 +54,7 @@ static inline bool FAMILY_MULTIBYTE(texttype* cache,
TEXTTYPE_ENTRY(BIG5_init)
TEXTTYPE_ENTRY3(BIG5_init)
{
static const ASCII POSIX[] = "C.BIG5";
@ -65,8 +65,6 @@ TEXTTYPE_ENTRY(BIG5_init)
#ifdef NOT_USED_OR_REPLACED
/*
* Returns INTL_BAD_STR_LENGTH if output buffer was too small
*/
/*
* Note: This function expects Multibyte input
*/
static ULONG big5_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
@ -77,7 +75,8 @@ static ULONG big5_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
BYTE c = *pStr++;
if (waiting_for_big52 || BIG51(c)) {
waiting_for_big52 = !waiting_for_big52;
@ -91,15 +90,13 @@ static ULONG big5_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
iOutLen--;
}
if (iLen != 0)
return (INTL_BAD_STR_LENGTH); /* Must have ran out of output space */
return (INTL_BAD_STR_LENGTH); // Must have ran out of output space
return (pOutStr - p);
}
/*
* Returns INTL_BAD_STR_LENGTH if output buffer was too small
*/
/*
* Note: This function expects Multibyte input
*/
static ULONG big5_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
@ -110,7 +107,8 @@ static ULONG big5_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
BYTE c = *pStr++;
if (waiting_for_big52 || BIG51(c)) {
waiting_for_big52 = !waiting_for_big52;
@ -124,7 +122,7 @@ static ULONG big5_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
iOutLen--;
}
if (iLen != 0)
return (INTL_BAD_STR_LENGTH); /* Must have ran out of output space */
return (INTL_BAD_STR_LENGTH); // Must have ran out of output space
return (pOutStr - p);
}
#endif //NOT_USED_OR_REPLACED

View File

@ -547,7 +547,8 @@ ULONG fam1_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutL
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
*pOutStr++ = LOCALE_UPPER(*pStr);
pStr++;
iLen--;
@ -568,7 +569,8 @@ ULONG fam1_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutL
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
*pOutStr++ = LOCALE_LOWER(*pStr);
pStr++;
iLen--;

View File

@ -88,8 +88,6 @@ TEXTTYPE_ENTRY3(JIS230_init)
#ifdef NOT_USED_OR_REPLACED
/*
* Returns INTL_BAD_STR_LENGTH if output buffer was too small
*/
/*
* Note: This function expects Multibyte input
*/
static ULONG sjis_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
@ -100,12 +98,15 @@ static ULONG sjis_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
BYTE c = *pStr++;
if (waiting_for_sjis2 || SJIS1(c)) {
if (waiting_for_sjis2 || SJIS1(c))
{
waiting_for_sjis2 = !waiting_for_sjis2;
}
else {
else
{
if (c >= ASCII_LOWER_A && c <= ASCII_LOWER_Z)
c = (c - ASCII_LOWER_A + ASCII_UPPER_A);
}
@ -114,15 +115,13 @@ static ULONG sjis_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
iOutLen--;
}
if (iLen != 0)
return (INTL_BAD_STR_LENGTH); /* Must have ran out of output space */
return (INTL_BAD_STR_LENGTH); // Must have ran out of output space
return (pOutStr - p);
}
/*
* Returns INTL_BAD_STR_LENGTH if output buffer was too small
*/
/*
* Note: This function expects Multibyte input
*/
static ULONG sjis_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
@ -133,12 +132,15 @@ static ULONG sjis_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
BYTE c = *pStr++;
if (waiting_for_sjis2 || SJIS1(c)) {
if (waiting_for_sjis2 || SJIS1(c))
{
waiting_for_sjis2 = !waiting_for_sjis2;
}
else {
else
{
if (c >= ASCII_UPPER_A && c <= ASCII_UPPER_Z)
c = (c - ASCII_UPPER_A + ASCII_LOWER_A);
}
@ -147,7 +149,7 @@ static ULONG sjis_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
iOutLen--;
}
if (iLen != 0)
return (INTL_BAD_STR_LENGTH); /* Must have ran out of output space */
return (INTL_BAD_STR_LENGTH); // Must have ran out of output space
return (pOutStr - p);
}
#endif

View File

@ -42,7 +42,7 @@ static inline bool FAMILY_MULTIBYTE(texttype* cache,
const UCHAR*, // specific_attributes,
ULONG specific_attributes_length)
{
//static inline void FAMILY_MULTIBYTE(id_number, name, charset, country)
//static inline void FAMILY_MULTIBYTE(id_number, name, charset, country)
if ((attributes & ~TEXTTYPE_ATTR_PAD_SPACE) || specific_attributes_length)
return false;
@ -85,7 +85,7 @@ TEXTTYPE_ENTRY3(ksc_5601_dict_init)
const UCHAR spe_han[18][2] =
{
/* special hangul -> character sets with dictionary collation */
// special hangul -> character sets with dictionary collation
{ 0xa4, 0xa2 },
{ 0xa4, 0xa4 },
{ 0xa4, 0xa7 },
@ -108,7 +108,7 @@ const UCHAR spe_han[18][2] =
const UCHAR gen_han[18][2] =
{
/* general hangul -> character sets with binary collation */
// general hangul -> character sets with binary collation
{ 0xb1, 0xed },
{ 0xb3, 0xa9 },
{ 0xb4, 0xd8 },
@ -150,10 +150,13 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
BYTE* outbuff = pOutChar;
for (USHORT i = 0; i < iInLen && iOutLen; i++, pInChar++) {
if (GEN_HAN(*pInChar, *(pInChar + 1))) { /* general hangul */
for (USHORT i = 0; i < iInLen && iOutLen; i++, pInChar++)
{
if (GEN_HAN(*pInChar, *(pInChar + 1)))
{ // general hangul
const int idx = GetGenHanNdx(*pInChar, *(pInChar + 1));
if (idx >= 0) {
if (idx >= 0)
{
if (iOutLen < 3)
break;
@ -162,7 +165,8 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
*outbuff++ = 1;
iOutLen -= 3;
}
else {
else
{
if (iOutLen < 2)
break;
@ -173,7 +177,8 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
pInChar += 1;
i++;
}
else if (SPE_HAN(*pInChar, *(pInChar + 1))) { /* special hangul */
else if (SPE_HAN(*pInChar, *(pInChar + 1)))
{ // special hangul
const int idx = GetSpeHanNdx(*(pInChar + 1));
fb_assert(idx >= 0);
@ -187,12 +192,14 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
pInChar += 1;
i++;
}
else { /* ascii or rest -> in case with binary collation */
else
{ // ascii or rest -> in case with binary collation
*outbuff++ = *pInChar;
iOutLen--;
fb_assert(KSC1(*pInChar) || (*pInChar < 0x80));
if (KSC1(*pInChar)) { /* the rest characters of KSC_5601 table */
if (KSC1(*pInChar))
{ // the rest characters of KSC_5601 table
fb_assert(KSC2(*(pInChar + 1)));
if (!iOutLen)
break;
@ -201,7 +208,7 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
pInChar += 1;
i++;
}
else /* ascii */
else // ascii
continue;
}
}
@ -217,7 +224,8 @@ static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInC
static int GetGenHanNdx(UCHAR b1, UCHAR b2)
{
for (int i = 0; i < 18; i++) {
for (int i = 0; i < 18; i++)
{
if (gen_han[i][0] == b1 && b2 == gen_han[i][1])
return i;
}
@ -232,7 +240,8 @@ static int GetGenHanNdx(UCHAR b1, UCHAR b2)
static int GetSpeHanNdx(const UCHAR b2)
{
for (int i = 0; i < 18; i++) {
for (int i = 0; i < 18; i++)
{
if (b2 == spe_han[i][1])
return i;
}
@ -264,7 +273,8 @@ static SSHORT LCKSC_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, c
const ULONG len1 = LCKSC_string_to_key(obj, l1, s1, sizeof(key1), key1, 0);
const ULONG len2 = LCKSC_string_to_key(obj, l2, s2, sizeof(key2), key2, 0);
const ULONG len = MIN(len1, len2);
for (ULONG i = 0; i < len; i++) {
for (ULONG i = 0; i < len; i++)
{
if (key1[i] == key2[i])
continue;
if (key1[i] < key2[i])

View File

@ -98,7 +98,7 @@ const UINT16 NULL_TERTIARY = 0;
*/
USHORT LC_NARROW_key_length(texttype* obj, USHORT inLen)
{
/* fb_assert (inLen <= LANGFAM2_MAX_KEY); *//* almost certainly an error */
// fb_assert (inLen <= LANGFAM2_MAX_KEY); // almost certainly an error
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
@ -170,19 +170,20 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
{
fb_assert(pOutChar != NULL);
fb_assert(pInChar != NULL);
/* fb_assert (iInLen <= LANGFAM2_MAX_KEY); */
// fb_assert (iInLen <= LANGFAM2_MAX_KEY);
fb_assert(iOutLen <= LANGFAM2_MAX_KEY);
fb_assert(iOutLen >= LC_NARROW_key_length(obj, iInLen));
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
#ifdef DEBUG
/* Dump out the input string */
if (do_debug) {
// Dump out the input string
if (do_debug)
{
printf("string: (%02d) '%*s'\n", iInLen, iInLen, pInChar);
fflush(stdout);
}
#endif /* DEBUG */
#endif // DEBUG
BYTE* outbuff = pOutChar;
USHORT lprimary = 0;
@ -194,12 +195,12 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
BYTE tertiary[LANGFAM2_MAX_KEY];
BYTE special[LANGFAM2_MAX_KEY * 2];
/* point inbuff at last character */
// point inbuff at last character
const BYTE* inbuff = pInChar + iInLen - 1;
if (obj->texttype_pad_option)
{
/* skip backwards over all spaces & reset input length */
// skip backwards over all spaces & reset input length
while ((inbuff >= pInChar) && (*inbuff == ASCII_SPACE))
inbuff--;
}
@ -208,7 +209,8 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
USHORT i;
for (i = 0; i < iInLen; i++, pInChar++) {
for (i = 0; i < iInLen; i++, pInChar++)
{
fb_assert(lprimary < iOutLen);
fb_assert(lsecondary < sizeof(secondary));
fb_assert(ltertiary < sizeof(tertiary));
@ -217,8 +219,9 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*) impl->texttype_collation_table)[*pInChar];
if (coll->IsExpand && coll->IsCompress) {
/* Both flags set indicate a special value */
if (coll->IsExpand && coll->IsCompress)
{
// Both flags set indicate a special value
if (impl->texttype_flags & TEXTTYPE_specials_first)
{
@ -235,7 +238,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
!(impl->texttype_flags & TEXTTYPE_ignore_specials) &&
lspecial + 1u < sizeof(special))
{
special[lspecial++] = (i + 1); /* position */
special[lspecial++] = (i + 1); // position
special[lspecial++] = coll->Primary;
}
}
@ -250,12 +253,14 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
if (coll->Tertiary != NULL_TERTIARY && ltertiary < sizeof(tertiary))
tertiary[ltertiary++] = coll->Tertiary;
}
else if (coll->IsExpand) {
else if (coll->IsExpand)
{
const ExpandChar* exp = &((const ExpandChar*) impl->texttype_expand_table)[0];
while (exp->Ch && exp->Ch != *pInChar)
exp++;
fb_assert(exp->Ch == *pInChar);
for (int j = 0; j < 2; j++) {
for (int j = 0; j < 2; j++)
{
if (j)
coll = &((const SortOrderTblEntry*) impl->texttype_collation_table)[exp->ExpCh2];
if (coll->Primary != NULL_WEIGHT && lprimary < iOutLen)
@ -266,16 +271,19 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
tertiary[ltertiary++] = coll->Tertiary;
}
}
else { /* (col->IsCompress) */
else
{ // (col->IsCompress)
const bool complete = (USHORT) (i + 1) < iInLen;
if (complete) {
if (complete)
{
const CompressPair* cmp = &((const CompressPair*) impl->texttype_compress_table)[0];
while (cmp->CharPair[0]) {
while (cmp->CharPair[0])
{
if ((cmp->CharPair[0] == *pInChar) &&
(cmp->CharPair[1] == *(pInChar + 1)))
{
/* Gobble the two-to-1 entry */
// Gobble the two-to-1 entry
coll = &cmp->NoCaseWeight;
pInChar++;
i++;
@ -300,14 +308,14 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
}
/* primary keys are already in output key */
// primary keys are already in output key
outbuff += lprimary;
iOutLen -= lprimary;
if (key_type == INTL_KEY_PARTIAL)
{
/* return length of key */
// return length of key
return (outbuff - pOutChar);
}
@ -321,14 +329,16 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
if (useLevel)
{
/* put secondary keys into output key */
if (impl->texttype_flags & TEXTTYPE_reverse_secondary) {
// put secondary keys into output key
if (impl->texttype_flags & TEXTTYPE_reverse_secondary)
{
for (i = 0; i < lsecondary && iOutLen; i++) {
*outbuff++ = secondary[lsecondary - i - 1];
iOutLen--;
}
}
else {
else
{
for (i = 0; i < lsecondary && iOutLen; i++) {
*outbuff++ = secondary[i];
iOutLen--;
@ -346,17 +356,17 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
if (useLevel)
{
/* put tertiary keys into output key */
// put tertiary keys into output key
for (i = 0; i < ltertiary && iOutLen; i++) {
*outbuff++ = tertiary[i];
iOutLen--;
}
}
/* put special keys into output key */
// put special keys into output key
if ((lspecial && iOutLen) && !(impl->texttype_flags & TEXTTYPE_ignore_specials))
{
/* Insert the marker-byte */
// Insert the marker-byte
*outbuff++ = 0;
iOutLen--;
for (i = 0; i < lspecial && iOutLen; i++) {
@ -366,8 +376,9 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
#ifdef DEBUG
/* Dump out the computed key */
if (do_debug) {
// Dump out the computed key
if (do_debug)
{
printf(" key: (%02d) ", (outbuff - pOutChar));
for (const UCHAR* p = pOutChar; p < outbuff; p++)
printf("%2x ", *p);
@ -376,7 +387,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
#endif
/* return length of key */
// return length of key
return (outbuff - pOutChar);
}
@ -385,10 +396,11 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
#define LC_HAVE_WAITING 1
#define LC_HAVE_SPECIAL 2
/* expansion char go before the expansion. */
/* eg: S-set collates before ss */
// expansion char go before the expansion.
// eg: S-set collates before ss
struct coltab_status {
struct coltab_status
{
USHORT stat_flags;
const SortOrderTblEntry* stat_waiting;
};
@ -407,9 +419,11 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
const bool noSpecialsFirst = !(impl->texttype_flags & TEXTTYPE_specials_first);
while (true) {
/* Scan to find ignore char from l1 */
while (l1) {
while (true)
{
// Scan to find ignore char from l1
while (l1)
{
col1 = &((const SortOrderTblEntry*) impl->texttype_collation_table)[*s1];
if (col1->IsExpand && col1->IsCompress && noSpecialsFirst)
@ -422,8 +436,9 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
index1++;
}
/* Scan to find ignore char from l2 */
while (l2) {
// Scan to find ignore char from l2
while (l2)
{
col2 = &((const SortOrderTblEntry*) impl->texttype_collation_table)[*s2];
if (col2->IsExpand && col2->IsCompress && noSpecialsFirst)
{
@ -434,15 +449,15 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
s2++;
index2++;
}
if (!l1 && !l2) /* All out of ignore characters */
if (!l1 && !l2) // All out of ignore characters
return 0;
if (l1 && !l2) /* Out in l2 only */
if (l1 && !l2) // Out in l2 only
return 1000;
if (!l1 && l2) /* Out in l1 only */
if (!l1 && l2) // Out in l1 only
return -1000;
if (index1 < index2) /* l1 has ignore ch before l2 */
if (index1 < index2) // l1 has ignore ch before l2
return -2000;
if (index1 > index2) /* l2 has ignore ch before l1 */
if (index1 > index2) // l2 has ignore ch before l1
return 2000;
if (col1->Primary != col2->Primary)
return (col1->Primary - col2->Primary);
@ -463,7 +478,8 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
*sum = impl->primary_sum;
if (stat->stat_flags & LC_HAVE_WAITING) {
if (stat->stat_flags & LC_HAVE_WAITING)
{
--*l;
++*p;
stat->stat_flags &= ~LC_HAVE_WAITING;
@ -472,7 +488,8 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
}
stat->stat_waiting = NULL;
while (*l) {
while (*l)
{
const SortOrderTblEntry* col =
&((const SortOrderTblEntry*) impl->texttype_collation_table)[**p];
@ -482,14 +499,14 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
{
*sum = impl->ignore_sum;
/* Have col */
// Have col
--*l;
++*p;
return col;
}
/* Both flags set indicate a special value */
/* Need a new col */
// Both flags set indicate a special value
// Need a new col
--*l;
++*p;
stat->stat_flags |= LC_HAVE_SPECIAL;
@ -499,33 +516,36 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
if (!((col->IsExpand && !(impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(col->IsCompress && !(impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
/* Have col */
// Have col
--*l;
++*p;
return col;
}
if (col->IsExpand) {
if (col->IsExpand)
{
const ExpandChar* exp = &((const ExpandChar*) impl->texttype_expand_table)[0];
while (exp->Ch && exp->Ch != **p)
exp++;
fb_assert(exp->Ch == **p);
/* Have coll1 */
/* Have waiting */
// Have coll1
// Have waiting
stat->stat_waiting = &((const SortOrderTblEntry*) impl->texttype_collation_table)[exp->ExpCh2];
stat->stat_flags |= LC_HAVE_WAITING;
return col;
}
/* (col->IsCompress) */
if (*l > 1) {
// (col->IsCompress)
if (*l > 1)
{
const CompressPair* cmp = &((const CompressPair*) impl->texttype_compress_table)[0];
while (cmp->CharPair[0]) {
while (cmp->CharPair[0])
{
if ((cmp->CharPair[0] == **p) &&
(cmp->CharPair[1] == *(*p + 1)))
{
/* Have Col */
// Have Col
col = &cmp->NoCaseWeight;
(*l) -= 2;
(*p) += 2;
@ -534,7 +554,7 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
cmp++;
}
}
/* Have col */
// Have col
--*l;
++*p;
return col;
@ -544,7 +564,7 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
#define XOR ^ /* C bitwise XOR operator - defined for readability */
#define XOR ^ // C bitwise XOR operator - defined for readability
SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const BYTE* s2,
INTL_BOOL* error_flag)
@ -560,7 +580,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
if (obj->texttype_pad_option)
{
/* Start at EOS, scan backwards to find non-space */
// Start at EOS, scan backwards to find non-space
const BYTE* p = s1 + l1 - 1;
while ((p >= s1) && (*p == ASCII_SPACE))
p--;
@ -587,7 +607,8 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
const SortOrderTblEntry* col1 = 0;
const SortOrderTblEntry* col2 = 0;
while (true) {
while (true)
{
int sum1, sum2;
col1 = get_coltab_entry(obj, &s1, &l1, &stat1, &sum1);
@ -600,8 +621,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
if ((impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0 &&
col1->Secondary != col2->Secondary)
{
if ((impl->texttype_flags & TEXTTYPE_reverse_secondary) ||
!save_secondary)
if ((impl->texttype_flags & TEXTTYPE_reverse_secondary) || !save_secondary)
{
save_secondary = (col1->Secondary - col2->Secondary);
}
@ -622,7 +642,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
}
}
/* One of the strings ended */
// One of the strings ended
fb_assert(l1 == 0 || l2 == 0);
fb_assert(col1 == NULL || col2 == NULL);
@ -632,7 +652,8 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
if (!col1 && col2)
return -500;
if (l1 == 0 && l2 == 0) {
if (l1 == 0 && l2 == 0)
{
if (save_secondary)
return save_secondary;
if (save_tertiary)
@ -640,7 +661,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
if (save_quandary)
return save_quandary;
if (((stat1.stat_flags & LC_HAVE_SPECIAL) ||
(stat2.stat_flags & LC_HAVE_SPECIAL)) &&
(stat2.stat_flags & LC_HAVE_SPECIAL)) &&
!(impl->texttype_flags & TEXTTYPE_ignore_specials) &&
!(impl->texttype_flags & TEXTTYPE_specials_first))
{
@ -676,7 +697,8 @@ static SSHORT old_fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
const ULONG len1 = LC_NARROW_string_to_key(obj, l1, s1, sizeof(key1), key1, INTL_KEY_SORT);
const ULONG len2 = LC_NARROW_string_to_key(obj, l2, s2, sizeof(key2), key2, INTL_KEY_SORT);
const ULONG len = MIN(len1, len2);
for (ULONG i = 0; i < len; i++) {
for (ULONG i = 0; i < len; i++)
{
if (key1[i] == key2[i])
continue;
if (key1[i] < key2[i])
@ -692,7 +714,7 @@ static SSHORT old_fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
return (0);
}
#endif /* DEBUG_COMPARE */
#endif // DEBUG_COMPARE
#ifdef DEBUG_COMPARE
@ -710,7 +732,8 @@ static SSHORT fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
SSHORT res1 = old_fam2_compare(obj, l1, s1, l2, s2);
SSHORT res2 = LC_NARROW_compare(obj, l1, s1, l2, s2);
if (SIGN(res1) != SIGN(res2)) {
if (SIGN(res1) != SIGN(res2))
{
printf("different compares:\n%d %s\n%d %s\nold = %d new = %d\n",
l1, s1, l2, s2, res1, res2);
fflush(stdout);
@ -722,7 +745,7 @@ static SSHORT fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
return res2;
}
#endif /* DEBUG_COMPARE */
#endif // DEBUG_COMPARE
ULONG LC_NARROW_canonical(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst)
{
@ -1031,7 +1054,8 @@ static ULONG fam2_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
*pOutStr++ = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_toupper_table[(unsigned) *pStr];
pStr++;
iLen--;
@ -1052,7 +1076,8 @@ static ULONG fam2_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
while (iLen && iOutLen)
{
*pOutStr++ = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_tolower_table[(unsigned) *pStr];
pStr++;
iLen--;

View File

@ -31,16 +31,16 @@
#include "fb_exception.h"
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/param.h> // for MAXPATHLEN
#endif
#include <stdio.h>
using namespace Firebird;
/* Commented out to make Linux version work because it is inaccessiable on all
known platforms. Nickolay Samofatov, 10 Sept 2002
void gds__log(UCHAR*, ...);
*/
// Commented out to make Linux version work because it is inaccessiable on all
// known platforms. Nickolay Samofatov, 10 Sept 2002
// void gds__log(UCHAR*, ...);
#define EXTERN_texttype(name) INTL_BOOL name (texttype*, charset*, const ASCII*, const ASCII*, USHORT, const UCHAR*, ULONG, const ASCII*)
// #define EXTERN_convert(name) INTL_BOOL name (csconvert*, const ASCII*, const ASCII*)
@ -99,10 +99,10 @@ EXTERN_texttype(CYRL_c0_init);
EXTERN_texttype(CYRL_c1_init);
EXTERN_texttype(CYRL_c2_init);
/* Latin 1 character set */
// Latin 1 character set
EXTERN_texttype(ISO88591_cp_init);
/* Latin 1 collations */
// Latin 1 collations
EXTERN_texttype(ISO88591_39_init);
EXTERN_texttype(ISO88591_40_init);
EXTERN_texttype(ISO88591_41_init);
@ -120,10 +120,10 @@ EXTERN_texttype(ISO88591_54_init);
EXTERN_texttype(ISO88591_55_init);
EXTERN_texttype(ISO88591_56_init);
/* Latin 2 character set */
// Latin 2 character set
EXTERN_texttype (ISO88592_cp_init);
/* latin 2 collations */
// latin 2 collations
EXTERN_texttype (ISO88592_c1_init);
EXTERN_texttype (ISO88592_c2_init);
EXTERN_texttype (ISO88592_c3_init);

View File

@ -73,68 +73,71 @@ int main()
printf("The from_unicode_map is too small! %d entries!\n",
sizeof(from_unicode_map) / sizeof(from_unicode_map[0]));
for (i = 0; i <= 255; i++) {
for (i = 0; i <= 255; i++)
{
const unsigned short uch = to_unicode_map[i];
if (uch == CANT_MAP_CHARACTER)
continue;
const unsigned char ch2 = UNICODE_LOOKUP(uch);
if (ch2 != i) {
printf
("Mapping error: Character %02x -> Unicode %04x (index %3d) -> Char %02x\n",
i, uch, UNICODE_INDEX(uch), ch2);
if (ch2 != i)
{
printf("Mapping error: Character %02x -> Unicode %04x (index %3d) -> Char %02x\n",
i, uch, UNICODE_INDEX(uch), ch2);
/* Find the Character in the from_unicode_mapping_array */
// Find the Character in the from_unicode_mapping_array
int j;
for (j = 0; j < sizeof(from_unicode_mapping_array); j++)
if (from_unicode_mapping_array[j] == i) {
/* Mapping table is wrong - recommend a fix for it */
printf
("Recommend from_unicode_map[0x%02x] be set to %d\n",
uch / 256, j - (uch % 256));
{
if (from_unicode_mapping_array[j] == i)
{
// Mapping table is wrong - recommend a fix for it
printf("Recommend from_unicode_map[0x%02x] be set to %d\n",
uch / 256, j - (uch % 256));
break;
}
}
if (j == sizeof(from_unicode_mapping_array)) {
/* Oops - found a character that does exists in the character set
but not in unicode - an obvious error! */
if (j == sizeof(from_unicode_mapping_array))
{
// Oops - found a character that does exists in the character set
// but not in unicode - an obvious error!
printf
("Error: Character %d does not exist in the from_unicode_mapping_array\n",
i);
printf("Error: Character %d does not exist in the from_unicode_mapping_array\n", i);
}
}
}
for (i = 0; i <= 255; i++) {
if (from_unicode_map[i] + 0xFF >= sizeof(from_unicode_mapping_array)) {
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);
continue;
}
for (int j = 0; j <= 255; j++) {
for (int j = 0; j <= 255; j++)
{
const unsigned short uch = i * 256 + j;
const unsigned char ch2 = UNICODE_LOOKUP(uch);
if (ch2 == CANT_MAP_CHARACTER)
continue;
const unsigned short uch2 = to_unicode_map[ch2];
if (uch != uch2) {
printf
("Mapping error: Unicode %04x -> ch %02x -> Unicode %04x\n",
uch, ch2, uch2);
if (uch != uch2)
{
printf("Mapping error: Unicode %04x -> ch %02x -> Unicode %04x\n",
uch, ch2, uch2);
int k;
for (k = 0; k <= 255; k++)
if (to_unicode_map[k] == uch) {
/* Can map this character from charset to unicode */
/* Assume fix was printed out above */
// Can map this character from charset to unicode
// Assume fix was printed out above
}
if (k > 255) {
/* This unicode doesn't exist in charset */
/* Mapping table is wrong - recommend a fix for it */
printf
("Recommend from_unicode_map[0x%02x] be set to %d\n",
uch / 256, 0);
// This unicode doesn't exist in charset
// Mapping table is wrong - recommend a fix for it
printf("Recommend from_unicode_map[0x%02x] be set to %d\n", uch / 256, 0);
}
}
}

View File

@ -581,7 +581,7 @@ rem_port* INET_connect(const TEXT* name,
}
#endif
rem_port* port = alloc_port(NULL);
rem_port* const port = alloc_port(NULL);
port->port_status_vector = status_vector;
REMOTE_get_timeout_params(port, dpb);
status_vector[0] = isc_arg_gds;
@ -935,7 +935,7 @@ rem_port* INET_reconnect(HANDLE handle, ISC_STATUS* status_vector)
* a port block.
*
**************************************/
rem_port* port = alloc_port(NULL);
rem_port* const port = alloc_port(NULL);
port->port_status_vector = status_vector;
status_vector[0] = isc_arg_gds;
status_vector[1] = 0;
@ -973,7 +973,7 @@ rem_port* INET_server(int sock)
*
**************************************/
int n = 0;
rem_port* port = alloc_port(NULL);
rem_port* const port = alloc_port(NULL);
port->port_flags |= PORT_server;
port->port_server_flags |= SRVR_server;
port->port_handle = (HANDLE) sock;
@ -1185,7 +1185,7 @@ static rem_port* alloc_port(rem_port* const parent)
}
}
rem_port* port = new rem_port(rem_port::INET, INET_remote_buffer * 2);
rem_port* const port = new rem_port(rem_port::INET, INET_remote_buffer * 2);
REMOTE_get_timeout_params(port, 0);
TEXT buffer[BUFFER_SMALL];
@ -1260,7 +1260,7 @@ static rem_port* aux_connect(rem_port* port, PACKET* packet)
return port;
}
rem_port* new_port = alloc_port(port->port_parent);
rem_port* const new_port = alloc_port(port->port_parent);
port->port_async = new_port;
new_port->port_dummy_packet_interval = port->port_dummy_packet_interval;
new_port->port_dummy_timeout = new_port->port_dummy_packet_interval;
@ -1366,7 +1366,7 @@ static rem_port* aux_request( rem_port* port, PACKET* packet)
return NULL;
}
rem_port* new_port = alloc_port(port->port_parent);
rem_port* const new_port = alloc_port(port->port_parent);
port->port_async = new_port;
new_port->port_dummy_packet_interval = port->port_dummy_packet_interval;
new_port->port_dummy_timeout = new_port->port_dummy_packet_interval;
@ -1978,7 +1978,7 @@ static rem_port* select_accept( rem_port* main_port)
**************************************/
struct sockaddr_in address;
rem_port* port = alloc_port(main_port);
rem_port* const port = alloc_port(main_port);
socklen_t l = sizeof(address);
inet_ports->registerPort(port);

View File

@ -333,7 +333,7 @@ rem_port* WNET_connect(const TEXT* name,
* connect is for a server process.
*
**************************************/
rem_port* port = alloc_port(0);
rem_port* const port = alloc_port(0);
port->port_status_vector = status_vector;
status_vector[0] = isc_arg_gds;
status_vector[1] = 0;
@ -355,7 +355,8 @@ rem_port* WNET_connect(const TEXT* name,
break;
}
const ISC_STATUS status = GetLastError();
if (status != ERROR_PIPE_BUSY) {
if (status != ERROR_PIPE_BUSY)
{
wnet_error(port, "CreateFile", isc_net_connect_err, status);
disconnect(port);
return NULL;
@ -473,7 +474,7 @@ rem_port* WNET_reconnect(HANDLE handle, ISC_STATUS* status_vector)
* a port block.
*
**************************************/
rem_port* port = alloc_port(0);
rem_port* const port = alloc_port(0);
port->port_status_vector = status_vector;
status_vector[0] = isc_arg_gds;
status_vector[1] = 0;
@ -502,7 +503,7 @@ rem_port* WNET_server(void* handle)
* established. Set up port block with the appropriate socket.
*
**************************************/
rem_port* port = alloc_port(0);
rem_port* const port = alloc_port(0);
port->port_server_flags |= SRVR_server;
port->port_handle = (HANDLE) handle;
@ -655,7 +656,7 @@ static rem_port* aux_connect( rem_port* port, PACKET* packet)
p = str_pid;
}
rem_port* new_port = alloc_port(port->port_parent);
rem_port* const new_port = alloc_port(port->port_parent);
port->port_async = new_port;
new_port->port_flags = port->port_flags & PORT_no_oob;
new_port->port_flags |= PORT_async;
@ -696,11 +697,11 @@ static rem_port* aux_request( rem_port* vport, PACKET* packet)
* generate a unique id based on connection.
*
**************************************/
rem_port* new_port = NULL; // If this is the client, we will return NULL
const DWORD server_pid = (vport->port_server_flags & SRVR_multi_client) ?
++event_counter : GetCurrentProcessId();
vport->port_async = new_port = alloc_port(vport->port_parent);
rem_port* const new_port = alloc_port(vport->port_parent);
vport->port_async = new_port;
new_port->port_server_flags = vport->port_server_flags;
new_port->port_flags = vport->port_flags & PORT_no_oob;

View File

@ -646,9 +646,9 @@ static bool accept_connection(rem_port* port, const P_CNCT*)
static rem_port* alloc_port(rem_port* parent,
UCHAR * send_buffer,
UCHAR* send_buffer,
ULONG send_length,
UCHAR * receive_buffer,
UCHAR* receive_buffer,
ULONG receive_length)
{
/**************************************
@ -662,7 +662,7 @@ static rem_port* alloc_port(rem_port* parent,
* and initialize input and output XDR streams.
*
**************************************/
rem_port* port = new rem_port(rem_port::XNET, 0);
rem_port* const port = new rem_port(rem_port::XNET, 0);
TEXT buffer[BUFFER_TINY];
ISC_get_host(buffer, sizeof(buffer));
@ -719,7 +719,6 @@ static rem_port* aux_connect(rem_port* port, PACKET* /*packet*/)
return port;
}
rem_port* new_port = NULL;
XCC parent_xcc = NULL;
XCC xcc = NULL;
TEXT name_buffer[BUFFER_TINY];
@ -788,11 +787,9 @@ static rem_port* aux_connect(rem_port* port, PACKET* /*packet*/)
((UCHAR *) xcc->xcc_mapped_addr + sizeof(struct xps) + (XNET_EVENT_SPACE));
// alloc new port and link xcc to it
new_port = alloc_port(NULL,
channel_c2s_client_ptr,
xcc->xcc_send_channel->xch_size,
channel_s2c_client_ptr,
xcc->xcc_recv_channel->xch_size);
rem_port* const new_port = alloc_port(NULL,
channel_c2s_client_ptr, xcc->xcc_send_channel->xch_size,
channel_s2c_client_ptr, xcc->xcc_recv_channel->xch_size);
port->port_async = new_port;
new_port->port_flags = port->port_flags & PORT_no_oob;
@ -844,23 +841,19 @@ static rem_port* aux_request(rem_port* port, PACKET* packet)
*
**************************************/
rem_port* new_port = NULL;
XCC parent_xcc = NULL;
XCC xcc = NULL;
TEXT name_buffer[BUFFER_TINY];
XPS xps = NULL;
XPM xpm = NULL;
try {
// make a new xcc
parent_xcc = port->port_xcc;
xps = (XPS) parent_xcc->xcc_mapped_addr;
XCC parent_xcc = port->port_xcc;
XPS xps = (XPS) parent_xcc->xcc_mapped_addr;
xcc = new struct xcc;
xpm = xcc->xcc_xpm = parent_xcc->xcc_xpm;
XPM xpm = xcc->xcc_xpm = parent_xcc->xcc_xpm;
xcc->xcc_map_num = parent_xcc->xcc_map_num;
xcc->xcc_slot = parent_xcc->xcc_slot;
DuplicateHandle(GetCurrentProcess(), parent_xcc->xcc_proc_h,
@ -922,11 +915,9 @@ static rem_port* aux_request(rem_port* port, PACKET* packet)
((UCHAR *) xcc->xcc_mapped_addr + sizeof(struct xps));
// alloc new port and link xcc to it
new_port = alloc_port(NULL,
channel_s2c_client_ptr,
xcc->xcc_send_channel->xch_size,
channel_c2s_client_ptr,
xcc->xcc_recv_channel->xch_size);
rem_port* const new_port = alloc_port(NULL,
channel_s2c_client_ptr, xcc->xcc_send_channel->xch_size,
channel_c2s_client_ptr, xcc->xcc_recv_channel->xch_size);
port->port_async = new_port;
new_port->port_xcc = xcc;
@ -1319,12 +1310,10 @@ static rem_port* connect_client(PACKET* packet, ISC_STATUS* status_vector)
UCHAR* const channel_c2s_client_ptr = start_ptr;
UCHAR* const channel_s2c_client_ptr = start_ptr + avail;
rem_port* port =
rem_port* const port =
alloc_port(NULL,
channel_c2s_client_ptr,
xcc->xcc_send_channel->xch_size,
channel_s2c_client_ptr,
xcc->xcc_recv_channel->xch_size);
channel_c2s_client_ptr, xcc->xcc_send_channel->xch_size,
channel_s2c_client_ptr, xcc->xcc_recv_channel->xch_size);
status_vector[1] = FB_SUCCESS;
port->port_status_vector = status_vector;
@ -1342,7 +1331,8 @@ static rem_port* connect_client(PACKET* packet, ISC_STATUS* status_vector)
cleanup_comm(xcc);
else if (xpm)
cleanup_mapping(xpm);
else if (file_handle) {
else if (file_handle)
{
if (mapped_address) {
UnmapViewOfFile(mapped_address);
}
@ -1790,7 +1780,8 @@ static bool_t xnet_getbytes(XDR * xdrs, SCHAR * buff, u_int count)
while (bytecount && !xnet_shutdown)
{
#ifdef SUPERCLIENT
if (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN) {
if (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN)
{
if (!(xcc->xcc_flags & XCCF_SERVER_SHUTDOWN)) {
xcc->xcc_flags |= XCCF_SERVER_SHUTDOWN;
xnet_error(port, isc_lost_db_connection, 0);
@ -1804,7 +1795,8 @@ static bool_t xnet_getbytes(XDR * xdrs, SCHAR * buff, u_int count)
else
to_copy = xdrs->x_handy;
if (xdrs->x_handy) {
if (xdrs->x_handy)
{
if (to_copy == sizeof(SLONG))
*((SLONG*)buff) = *((SLONG*)xdrs->x_private);
else
@ -2598,10 +2590,8 @@ static rem_port* get_server_port(ULONG client_pid,
// finally, allocate and set the port structure for this client
port = alloc_port(NULL,
channel_s2c_data_buffer,
xcc->xcc_send_channel->xch_size,
channel_c2s_data_buffer,
xcc->xcc_recv_channel->xch_size);
channel_s2c_data_buffer, xcc->xcc_send_channel->xch_size,
channel_c2s_data_buffer, xcc->xcc_recv_channel->xch_size);
port->port_xcc = xcc;
port->port_server_flags |= SRVR_server;

View File

@ -94,7 +94,7 @@ typedef struct xch
{
ULONG xch_length; // message length
ULONG xch_size; // channel data size
USHORT xch_flags; // flags
USHORT xch_flags; // flags, UNUSED
ULONG xch_dummy1; // for binary compatibility
ULONG xch_dummy2; // with 32-bit builds
} *XCH;
@ -140,7 +140,7 @@ typedef struct xps
PID_T xps_client_proc_id; // client's process id
USHORT xps_flags; // flags word
struct xch xps_channels[4]; // comm channels
ULONG xps_data[1]; // start of data area
ULONG xps_data[1]; // start of data area, UNUSED at least directly
} *XPS;
// XPS flags
@ -175,21 +175,21 @@ const size_t XNET_CONNECT_RESPONZE_SIZE = sizeof(XNET_RESPONSE);
// Windows names used to identify various named objects
const char* XNET_MAPPED_FILE_NAME = "%s_MAP_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_MAPPED_FILE_NAME = "%s_MAP_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_CONNECT_MAP = "%s_CONNECT_MAP";
const char* XNET_CONNECT_MUTEX = "%s_CONNECT_MUTEX";
const char* XNET_CONNECT_EVENT = "%s_CONNECT_EVENT";
const char* XNET_RESPONSE_EVENT = "%s_RESPONSE_EVENT";
const char* const XNET_CONNECT_MAP = "%s_CONNECT_MAP";
const char* const XNET_CONNECT_MUTEX = "%s_CONNECT_MUTEX";
const char* const XNET_CONNECT_EVENT = "%s_CONNECT_EVENT";
const char* const XNET_RESPONSE_EVENT = "%s_RESPONSE_EVENT";
const char* XNET_E_C2S_DATA_CHAN_FILLED = "%s_E_C2S_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_C2S_DATA_CHAN_EMPTED = "%s_E_C2S_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_S2C_DATA_CHAN_FILLED = "%s_E_S2C_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_S2C_DATA_CHAN_EMPTED = "%s_E_S2C_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_C2S_DATA_CHAN_FILLED = "%s_E_C2S_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_C2S_DATA_CHAN_EMPTED = "%s_E_C2S_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_S2C_DATA_CHAN_FILLED = "%s_E_S2C_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_S2C_DATA_CHAN_EMPTED = "%s_E_S2C_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_C2S_EVNT_CHAN_FILLED = "%s_E_C2S_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_C2S_EVNT_CHAN_EMPTED = "%s_E_C2S_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_S2C_EVNT_CHAN_FILLED = "%s_E_S2C_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* XNET_E_S2C_EVNT_CHAN_EMPTED = "%s_E_S2C_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_C2S_EVNT_CHAN_FILLED = "%s_E_C2S_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_C2S_EVNT_CHAN_EMPTED = "%s_E_C2S_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_S2C_EVNT_CHAN_FILLED = "%s_E_S2C_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
const char* const XNET_E_S2C_EVNT_CHAN_EMPTED = "%s_E_S2C_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT;
#endif // REMOTE_XNET_H