void VsnprintfTestCase::Percent() { // some tests without any argument passed through ... CMP2("%", "%%"); CMP2("%%%", "%%%%%%"); CMP3("% abc", "%%%5s", wxT("abc")); CMP3("% abc%", "%%%5s%%", wxT("abc")); // do not test odd number of '%' symbols as different implementations // of snprintf() give different outputs as this situation is not considered // by any standard (in fact, GCC will also warn you about a spurious % if // you write %%% as argument of some *printf function !) // Compare(wxT("%"), wxT("%%%")); }
static int assemble_tok(RAsm *a, RAsmOp *op, char *tok[PARSER_MAX_TOKENS], int count) { char *end; int oplen = 0; RBpfSockFilter f = {0,0,0,0}; oplen = strnlen(tok[0], 5); if (oplen < 2 || oplen > 4) { PARSE_FAILURE ("mnemonic length not valid"); } if (CMP4 (tok, 0, 't','x','a','\0')) { ENFORCE_COUNT(count, 1); f.code = BPF_MISC_TXA; COPY_AND_RET (op->buf, &f); } if (CMP4 (tok, 0, 't','a','x','\0')) { ENFORCE_COUNT(count, 1); f.code = BPF_MISC_TAX; COPY_AND_RET (op->buf, &f); } if (CMP4 (tok, 0, 'r','e','t','\0')) { ENFORCE_COUNT(count, 2); if (IS_K_TOK (tok,1)) { f.code = BPF_RET | BPF_K; PARSE_K_OR_FAIL(f.k, tok,1); } else if (tok[1][0] == 'x') { f.code = BPF_RET | BPF_X; } else if (tok[1][0] == 'a') { f.code = BPF_RET | BPF_A; } else { PARSE_FAILURE ("unsupported ret instruction"); } COPY_AND_RET (op->buf, &f); } if (CMP2 (tok, 0, 'l','d')) { ENFORCE_COUNT(count, 2); if (assemble_ld (a, op, tok, count, &f) == 0) { COPY_AND_RET (op->buf, &f); } else { return -1; } } if (CMP2 (tok, 0, 's','t')) { ENFORCE_COUNT(count, 2); if (tok[0][2] == '\0') { f.code = BPF_ST; } else if (tok[0][2] == 'x') { f.code = BPF_STX; } if (CMP2 (tok, 1, 'm','[')) { PARSE_OFFSET_OR_FAIL (f.k, tok, 1, 2); if (f.k > 15) { PARSE_FAILURE ("mem addressing out of bounds"); } COPY_AND_RET (op->buf, &f); } else { PARSE_FAILURE ("invalid store addressing"); } } if (tok[0][0] == 'j') { if ( assemble_j (a, op, tok, count, &f) == 0) { COPY_AND_RET(op->buf, &f); } else { return -1; } } if (assemble_alu (a, op, tok, count, &f) == 0) { COPY_AND_RET(op->buf, &f); } else { return -1; } }
static int assemble_ld(RAsm *a, RAsmOp *op, char *tok[PARSER_MAX_TOKENS], int count, RBpfSockFilter * f) { char * end; switch (tok[0][2]) { case '\0': if (CMP2 (tok, 1, 'm','[')) { f->code = BPF_LD | BPF_MEM; PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 2); } else if (IS_K_TOK (tok, 1)) { f->code = BPF_LD | BPF_IMM; PARSE_K_OR_FAIL (f->k, tok, 1); } else if (IS_LEN (tok, 1)) { f->code = BPF_LD | BPF_LEN; } else { f->code = BPF_LD_W; PARSE_IND_ABS_OR_FAIL (f,tok,1); } break; case 'i': if (IS_K_TOK (tok, 1)) { f->code = BPF_LD | BPF_IMM; PARSE_K_OR_FAIL (f->k, tok, 1); } else { PARSE_FAILURE ("ldi without k"); } break; case 'b': f->code = BPF_LD_B; PARSE_IND_ABS_OR_FAIL (f,tok,1); break; case 'h': f->code = BPF_LD_H; PARSE_IND_ABS_OR_FAIL (f,tok,1); break; case 'x': switch (tok[0][3]) { case '\0': if (CMP2 (tok, 1, 'm','[')) { f->code = BPF_LDX | BPF_MEM; PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 2); } else if (IS_K_TOK (tok, 1)) { f->code = BPF_LDX | BPF_IMM; PARSE_K_OR_FAIL (f->k, tok, 1); } else if (IS_LEN (tok, 1)) { f->code = BPF_LDX | BPF_LEN; } else { f->code = BPF_LDX_W; PARSE_IND_ABS_OR_FAIL (f,tok,1); } break; case 'i': if (IS_K_TOK (tok, 1)) { f->code = BPF_LDX | BPF_IMM; PARSE_K_OR_FAIL (f->k, tok, 1); } else { PARSE_FAILURE ("ldxi without k"); } break; case 'b': f->code = BPF_LDX_B | BPF_MSH; if (sscanf (tok[1], "4*([%d]&0xf)", &f->k) != 1 ) { PARSE_FAILURE ("invalid nibble addressing"); } break; } break; default: PARSE_FAILURE ("unsupported load instruction"); } return 0; }
inline int MapGridCtrl::CompareAspectRatio(const MapData* a, const MapData* b) { CMP2(AspectRatio(a->info), AspectRatio(b->info)); }
inline int MapGridCtrl::CompareArea(const MapData* a, const MapData* b) { CMP2((a->info.width * a->info.height), (b->info.width * b->info.height)); }
inline int MapGridCtrl::CompareWind(const MapData* a, const MapData* b) { CMP2((a->info.minWind + a->info.maxWind), (b->info.minWind + b->info.maxWind)); }