本文整理匯總了C++中CK函數的典型用法代碼示例。如果您正苦於以下問題:C++ CK函數的具體用法?C++ CK怎麽用?C++ CK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: real_malloc
void *X(malloc_plain)(size_t n)
{
void *p;
if (n == 0)
n = 1;
p = real_malloc(n);
CK(p);
#ifdef MIN_ALIGMENT
A((((uintptr_t)p) % MIN_ALIGNMENT) == 0);
#endif
return p;
}
示例2: mbfl_filt_conv_utf16_wchar
/*
* UTF-16 => wchar
*/
int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter)
{
int n, endian;
endian = filter->status & 0xff00;
switch (filter->status & 0x0f) {
case 0:
if (endian) {
n = c & 0xff;
} else {
n = (c & 0xff) << 8;
}
filter->cache |= n;
filter->status++;
break;
default:
if (endian) {
n = (c & 0xff) << 8;
} else {
n = c & 0xff;
}
n |= filter->cache & 0xffff;
filter->status &= ~0x0f;
if (n >= 0xd800 && n < 0xdc00) {
filter->cache = ((n & 0x3ff) << 16) + 0x400000;
} else if (n >= 0xdc00 && n < 0xe000) {
n &= 0x3ff;
n |= (filter->cache & 0xfff0000) >> 6;
filter->cache = 0;
if (n >= MBFL_WCSPLANE_SUPMIN && n < MBFL_WCSPLANE_SUPMAX) {
CK((*filter->output_function)(n, filter->data));
} else { /* illegal character */
n &= MBFL_WCSGROUP_MASK;
n |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(n, filter->data));
}
} else {
示例3: mbfl_filt_conv_wchar_hz
/*
* wchar => HZ
*/
int
mbfl_filt_conv_wchar_hz(int c, mbfl_convert_filter *filter)
{
int s;
s = 0;
if (c >= ucs_a1_cp936_table_min && c < ucs_a1_cp936_table_max) {
s = ucs_a1_cp936_table[c - ucs_a1_cp936_table_min];
} else if (c >= ucs_a2_cp936_table_min && c < ucs_a2_cp936_table_max) {
s = ucs_a2_cp936_table[c - ucs_a2_cp936_table_min];
} else if (c >= ucs_a3_cp936_table_min && c < ucs_a3_cp936_table_max) {
s = ucs_a3_cp936_table[c - ucs_a3_cp936_table_min];
} else if (c >= ucs_i_cp936_table_min && c < ucs_i_cp936_table_max) {
s = ucs_i_cp936_table[c - ucs_i_cp936_table_min];
} else if (c >= ucs_hff_cp936_table_min && c < ucs_hff_cp936_table_max) {
s = ucs_hff_cp936_table[c - ucs_hff_cp936_table_min];
}
if (s & 0x8000) {
s -= 0x8080;
}
if (s <= 0) {
if (c == 0) {
s = 0;
} else if (s <= 0) {
s = -1;
}
} else if ((s >= 0x80 && s < 0x2121) || (s > 0x8080)) {
s = -1;
}
if (s >= 0) {
if (s < 0x80) { /* ASCII */
if ((filter->status & 0xff00) != 0) {
CK((*filter->output_function)(0x7e, filter->data)); /* '~' */
CK((*filter->output_function)(0x7d, filter->data)); /* '}' */
}
filter->status = 0;
if (s == 0x7e){
CK((*filter->output_function)(0x7e, filter->data));
}
CK((*filter->output_function)(s, filter->data));
} else { /* GB 2312-80 */
if ((filter->status & 0xff00) != 0x200) {
CK((*filter->output_function)(0x7e, filter->data)); /* '~' */
CK((*filter->output_function)(0x7b, filter->data)); /* '{' */
}
filter->status = 0x200;
CK((*filter->output_function)((s >> 8) & 0x7f, filter->data));
CK((*filter->output_function)(s & 0x7f, filter->data));
}
} else {
if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
示例4: main
int
main (void)
{
size_t b_size = 2;
char *b = malloc (b_size);
ASSERT (b);
/* Ideally we would rely on the snprintf-posix module, in which case
this guard would not be required, but due to limitations in gnulib's
implementation (see modules/snprintf-posix), we cannot. */
if (snprintf (b, b_size, "%ju", (uintmax_t) 3) == 1
&& b[0] == '3' && b[1] == '\0')
{
CK (int, inttostr);
CK (unsigned int, uinttostr);
CK (off_t, offtostr);
CK (uintmax_t, umaxtostr);
CK (intmax_t, imaxtostr);
return 0;
}
/* snprintf doesn't accept %ju; skip this test. */
return 77;
}
示例5: mbfl_filt_conv_ucs2be_wchar
/*
* UCS-2BE => wchar
*/
int mbfl_filt_conv_ucs2be_wchar(int c, mbfl_convert_filter *filter)
{
int n;
if (filter->status == 0) {
filter->status = 1;
n = (c & 0xff) << 8;
filter->cache = n;
} else {
filter->status = 0;
n = (c & 0xff) | filter->cache;
CK((*filter->output_function)(n, filter->data));
}
return c;
}
示例6: GET_KEY
void FlatCodeGen::COND_TRANSLATE()
{
out <<
" _widec = " << GET_KEY() << ";\n";
out <<
" _keys = " << ARR_OFF( CK(), "(" + vCS() + "<<1)" ) << ";\n"
" _conds = " << ARR_OFF( C(), CO() + "[" + vCS() + "]" ) << ";\n"
"\n"
" _slen = " << CSP() << "[" << vCS() << "];\n"
" _cond = _slen > 0 && _keys[0] <=" << GET_WIDE_KEY() << " &&\n"
" " << GET_WIDE_KEY() << " <= _keys[1] ?\n"
" _conds[" << GET_WIDE_KEY() << " - _keys[0]] : 0;\n"
"\n";
out <<
" switch ( _cond ) {\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId + 1 << ": {\n";
out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
out << " ) _widec += " << condValOffset << ";\n";
}
out << " }\n";
out << " break;\n";
}
SWITCH_DEFAULT();
out <<
" }\n";
}
示例7: mbfl_filt_conv_byte4be_wchar
int mbfl_filt_conv_byte4be_wchar(int c, mbfl_convert_filter *filter)
{
int n;
if (filter->status == 0) {
filter->status = 1;
n = (c & 0xff) << 24;
filter->cache = n;
} else if (filter->status == 1) {
filter->status = 2;
n = (c & 0xff) << 16;
filter->cache |= n;
} else if (filter->status == 2) {
filter->status = 3;
n = (c & 0xff) << 8;
filter->cache |= n;
} else {
filter->status = 0;
n = (c & 0xff) | filter->cache;
CK((*filter->output_function)(n, filter->data));
}
return c;
}
示例8: mbfl_filt_conv_armscii8_wchar
/*
* armscii8 => wchar
*/
int mbfl_filt_conv_armscii8_wchar(int c, mbfl_convert_filter *filter)
{
int s;
if (c >= 0 && c < armscii8_ucs_table_min) {
s = c;
} else if (c >= armscii8_ucs_table_min && c < 0x100) {
s = armscii8_ucs_table[c - armscii8_ucs_table_min];
if (s <= 0) {
s = c;
s &= MBFL_WCSPLANE_MASK;
s |= MBFL_WCSPLANE_ARMSCII8;
}
} else {
s = c;
s &= MBFL_WCSGROUP_MASK;
s |= MBFL_WCSGROUP_THROUGH;
}
CK((*filter->output_function)(s, filter->data));
return c;
}
示例9: mbfl_filt_conv_8859_13_wchar
/*
* ISO-8859-13 => wchar
*/
int mbfl_filt_conv_8859_13_wchar(int c, mbfl_convert_filter *filter)
{
int s;
if (c >= 0 && c < 0xa0) {
s = c;
} else if (c >= 0xa0 && c < 0x100) {
s = iso8859_13_ucs_table[c - 0xa0];
if (s <= 0) {
s = c;
s &= MBFL_WCSPLANE_MASK;
s |= MBFL_WCSPLANE_8859_13;
}
} else {
s = c;
s &= MBFL_WCSGROUP_MASK;
s |= MBFL_WCSGROUP_THROUGH;
}
CK((*filter->output_function)(s, filter->data));
return c;
}
示例10: mbfl_filt_conv_html_enc
/*
* any => HTML
*/
int mbfl_filt_conv_html_enc(int c, mbfl_convert_filter *filter)
{
int tmp[64];
int i;
unsigned int uc;
const mbfl_html_entity_entry *e;
if (c < sizeof(htmlentitifieds) / sizeof(htmlentitifieds[0]) &&
htmlentitifieds[c] != 1) {
CK((*filter->output_function)(c, filter->data));
} else {
CK((*filter->output_function)('&', filter->data));
for (i = 0; (e = &mbfl_html_entity_list[i])->name != NULL; i++) {
if (c == e->code) {
char *p;
for (p = e->name; *p != '\0'; p++) {
CK((*filter->output_function)((int)*p, filter->data));
}
goto last;
}
}
{
int *p = tmp + sizeof(tmp) / sizeof(tmp[0]);
CK((*filter->output_function)('#', filter->data));
uc = (unsigned int)c;
*(--p) = '\0';
do {
*(--p) = "0123456789"[uc % 10];
uc /= 10;
} while (uc);
for (; *p != '\0'; p++) {
CK((*filter->output_function)(*p, filter->data));
}
}
last:
CK((*filter->output_function)(';', filter->data));
}
return c;
}
示例11: mbfl_filt_conv_cp1254_wchar
/*
* cp1254 => wchar
*/
int
mbfl_filt_conv_cp1254_wchar(int c, mbfl_convert_filter *filter)
{
int s;
if (c >= 0 && c < cp1254_ucs_table_min) {
s = c;
} else if (c >= cp1254_ucs_table_min && c < 0x100) {
s = cp1254_ucs_table[c - cp1254_ucs_table_min];
if (s <= 0) {
s = c;
s &= MBFL_WCSPLANE_MASK;
s |= MBFL_WCSPLANE_CP1254;
}
} else {
s = c;
s &= MBFL_WCSGROUP_MASK;
s |= MBFL_WCSGROUP_THROUGH;
}
CK((*filter->output_function)(s, filter->data));
return c;
}
示例12: mbfl_filt_conv_html_dec
int mbfl_filt_conv_html_dec(int c, mbfl_convert_filter *filter)
{
int pos, ent = 0;
mbfl_html_entity_entry *entity;
char *buffer = (char*)filter->opaque;
if (!filter->status) {
if (c == '&' ) {
filter->status = 1;
buffer[0] = '&';
} else {
CK((*filter->output_function)(c, filter->data));
}
} else {
if (c == ';') {
if (buffer[1]=='#') {
if (filter->status > 2 && (buffer[2] == 'x' || buffer[2] == 'X')) {
if (filter->status > 3) {
/* numeric entity */
for (pos=3; pos<filter->status; pos++) {
int v = buffer[pos];
if (v >= '0' && v <= '9') {
v = v - '0';
} else if (v >= 'A' && v <= 'F') {
v = v - 'A' + 10;
} else if (v >= 'a' && v <= 'f') {
v = v - 'a' + 10;
} else {
ent = -1;
break;
}
ent = ent * 16 + v;
}
} else {
ent = -1;
}
} else {
/* numeric entity */
if (filter->status > 2) {
for (pos=2; pos<filter->status; pos++) {
int v = buffer[pos];
if (v >= '0' && v <= '9') {
v = v - '0';
} else {
ent = -1;
break;
}
ent = ent*10 + v;
}
} else {
ent = -1;
}
}
if (ent >= 0 && ent < 0x110000) {
CK((*filter->output_function)(ent, filter->data));
} else {
for (pos = 0; pos < filter->status; pos++) {
CK((*filter->output_function)(buffer[pos], filter->data));
}
CK((*filter->output_function)(c, filter->data));
}
filter->status = 0;
/*php_error_docref("ref.mbstring" TSRMLS_CC, E_NOTICE, "mbstring decoded '%s'=%d", buffer, ent);*/
} else {
/* named entity */
buffer[filter->status] = 0;
entity = (mbfl_html_entity_entry *)mbfl_html_entity_list;
while (entity->name) {
if (!strcmp(buffer+1, entity->name)) {
ent = entity->code;
break;
}
entity++;
}
if (ent) {
/* decoded */
CK((*filter->output_function)(ent, filter->data));
filter->status = 0;
/*php_error_docref("ref.mbstring" TSRMLS_CC, E_NOTICE,"mbstring decoded '%s'=%d", buffer, ent);*/
} else {
/* failure */
buffer[filter->status++] = ';';
buffer[filter->status] = 0;
/* php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring cannot decode '%s'", buffer); */
mbfl_filt_conv_html_dec_flush(filter);
}
}
} else {
/* add character */
buffer[filter->status++] = c;
/* add character and check */
if (!strchr(html_entity_chars, c) || filter->status+1==html_enc_buffer_size || (c=='#' && filter->status>2))
{
/* illegal character or end of buffer */
if (c=='&')
filter->status--;
buffer[filter->status] = 0;
/* php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring cannot decode '%s'", buffer)l */
mbfl_filt_conv_html_dec_flush(filter);
if (c=='&')
//.........這裏部分代碼省略.........
示例13: mbfl_filt_conv_eucjp_wchar
/*
* EUC-JP => wchar
*/
int
mbfl_filt_conv_eucjp_wchar(int c, mbfl_convert_filter *filter)
{
int c1, s, w;
switch (filter->status) {
case 0:
if (c >= 0 && c < 0x80) { /* latin */
CK((*filter->output_function)(c, filter->data));
} else if (c > 0xa0 && c < 0xff) { /* X 0208 first char */
filter->status = 1;
filter->cache = c;
} else if (c == 0x8e) { /* kana first char */
filter->status = 2;
} else if (c == 0x8f) { /* X 0212 first char */
filter->status = 3;
} else {
w = c & MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
case 1: /* got first half */
filter->status = 0;
c1 = filter->cache;
if (c > 0xa0 && c < 0xff) {
s = (c1 - 0xa1)*94 + c - 0xa1;
if (s >= 0 && s < jisx0208_ucs_table_size) {
w = jisx0208_ucs_table[s];
} else {
w = 0;
}
if (w <= 0) {
w = ((c1 & 0x7f) << 8) | (c & 0x7f);
w &= MBFL_WCSPLANE_MASK;
w |= MBFL_WCSPLANE_JIS0208;
}
CK((*filter->output_function)(w, filter->data));
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
} else {
w = (c1 << 8) | c;
w &= MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
case 2: /* got 0x8e */
filter->status = 0;
if (c > 0xa0 && c < 0xe0) {
w = 0xfec0 + c;
CK((*filter->output_function)(w, filter->data));
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
} else {
w = 0x8e00 | c;
w &= MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
case 3: /* got 0x8f, X 0212 first char */
if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
filter->status = 0;
} else {
filter->status++;
filter->cache = c;
}
break;
case 4: /* got 0x8f, X 0212 second char */
filter->status = 0;
c1 = filter->cache;
if (c1 > 0xa0 && c1 < 0xff && c > 0xa0 && c < 0xff) {
s = (c1 - 0xa1)*94 + c - 0xa1;
if (s >= 0 && s < jisx0212_ucs_table_size) {
w = jisx0212_ucs_table[s];
} else {
w = 0;
}
if (w <= 0) {
w = ((c1 & 0x7f) << 8) | (c & 0x7f);
w &= MBFL_WCSPLANE_MASK;
w |= MBFL_WCSPLANE_JIS0212;
}
CK((*filter->output_function)(w, filter->data));
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
} else {
w = (c1 << 8) | c | 0x8f0000;
w &= MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
//.........這裏部分代碼省略.........
示例14: OPEN_ARRAY
void TabCodeGen::writeData()
{
/* If there are any transtion functions then output the array. If there
* are none, don't bother emitting an empty array that won't be used. */
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() );
ACTIONS_ARRAY();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyConditions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() );
COND_OFFSETS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() );
COND_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
COND_KEYS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() );
COND_SPACES();
CLOSE_ARRAY() <<
"\n";
}
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() );
KEY_OFFSETS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
KEYS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() );
SINGLE_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() );
RANGE_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() );
INDEX_OFFSETS();
CLOSE_ARRAY() <<
"\n";
if ( useIndicies ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
INDICIES();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
TRANS_TARGS_WI();
CLOSE_ARRAY() <<
"\n";
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() );
TRANS_ACTIONS_WI();
CLOSE_ARRAY() <<
"\n";
}
}
else {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
TRANS_TARGS();
CLOSE_ARRAY() <<
"\n";
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() );
TRANS_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
}
if ( redFsm->anyToStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
TO_STATE_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyFromStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
FROM_STATE_ACTIONS();
//.........這裏部分代碼省略.........
示例15: mbfl_filt_conv_utf8_wchar
/*
* UTF-8 => wchar
*/
int mbfl_filt_conv_utf8_wchar(int c, mbfl_convert_filter *filter)
{
int s, c1, w = 0, flag = 0;
retry:
switch (filter->status & 0xff) {
case 0x00:
if (c < 0x80) {
CK((*filter->output_function)(c, filter->data));
} else if (c >= 0xc2 && c <= 0xdf) { /* 2byte code first char: 0xc2-0xdf */
filter->status = 0x10;
filter->cache = c & 0x1f;
} else if (c >= 0xe0 && c <= 0xef) { /* 3byte code first char: 0xe0-0xef */
filter->status = 0x20;
filter->cache = c & 0xf;
} else if (c >= 0xf0 && c <= 0xf4) { /* 3byte code first char: 0xf0-0xf4 */
filter->status = 0x30;
filter->cache = c & 0x7;
} else {
mbfl_filt_put_invalid_char(c, filter);
}
break;
case 0x10: /* 2byte code 2nd char: 0x80-0xbf */
case 0x21: /* 3byte code 3rd char: 0x80-0xbf */
case 0x32: /* 4byte code 4th char: 0x80-0xbf */
filter->status = 0;
if (c >= 0x80 && c <= 0xbf) {
s = (filter->cache<<6) | (c & 0x3f);
filter->cache = 0;
CK((*filter->output_function)(s, filter->data));
} else {
mbfl_filt_put_invalid_char(filter->cache, filter);
goto retry;
}
break;
case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */
s = (filter->cache<<6) | (c & 0x3f);
c1 = filter->cache & 0xf;
if ((c >= 0x80 && c <= 0xbf) &&
((c1 == 0x0 && c >= 0xa0) ||
(c1 == 0xd && c < 0xa0) ||
(c1 > 0x0 && c1 != 0xd))) {
filter->cache = s;
filter->status++;
} else {
mbfl_filt_put_invalid_char(filter->cache, filter);
goto retry;
}
break;
case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */
s = (filter->cache<<6) | (c & 0x3f);
c1 = filter->cache & 0x7;
if ((c >= 0x80 && c <= 0xbf) &&
((c1 == 0x0 && c >= 0x90) ||
(c1 == 0x4 && c < 0x90) ||
(c1 > 0x0 && c1 != 0x4))) {
filter->cache = s;
filter->status++;
} else {
mbfl_filt_put_invalid_char(filter->cache, filter);
goto retry;
}
break;
case 0x31: /* 4byte code 3rd char: 0x80-0xbf */
if (c >= 0x80 && c <= 0xbf) {
filter->cache = (filter->cache<<6) | (c & 0x3f);
filter->status++;
} else {
mbfl_filt_put_invalid_char(filter->cache, filter);
goto retry;
}
break;
default:
filter->status = 0;
break;
}
return c;
}