static char* get_strings_by_bit (const char *pkeywords, const long long int num ) //根据比特位对相应字符取反 { char *back = NULL; int lens = strlen(pkeywords); back = (char*)malloc(lens + 1); memset(back, '\0', lens + 1); int i = 0; for(i = 0; i < lens ; i++) { long long int is_bit_true = pow(2, i); if((is_bit_true&num) != 0) { back[i] = is_anti(pkeywords[i]); } else { back[i] = pkeywords[i]; } } back[lens] = '\0'; return back; } /* ----- end of function get_strings_by_bit ----- */
sql_exp * exp_copy( sql_allocator *sa, sql_exp * e) { sql_exp *l, *r, *r2, *ne = NULL; switch(e->type){ case e_column: ne = exp_column(sa, e->l, e->r, exp_subtype(e), e->card, has_nil(e), is_intern(e)); ne->flag = e->flag; break; case e_cmp: if (e->flag == cmp_or) { list *l = exps_copy(sa, e->l); list *r = exps_copy(sa, e->r); if (l && r) ne = exp_or(sa, l,r); } else if (e->flag == cmp_in || e->flag == cmp_notin || get_cmp(e) == cmp_filter) { sql_exp *l = exp_copy(sa, e->l); list *r = exps_copy(sa, e->r); if (l && r) { if (get_cmp(e) == cmp_filter) ne = exp_filter(sa, l, r, e->f, is_anti(e)); else ne = exp_in(sa, l, r, e->flag); } } else { l = exp_copy(sa, e->l); r = exp_copy(sa, e->r); if (e->f) { r2 = exp_copy(sa, e->f); if (l && r && r2) ne = exp_compare2(sa, l, r, r2, e->flag); } else if (l && r) { ne = exp_compare(sa, l, r, e->flag); } } break; case e_convert: l = exp_copy(sa, e->l); if (l) ne = exp_convert(sa, l, exp_fromtype(e), exp_totype(e)); break; case e_aggr: case e_func: { list *l = e->l, *nl = NULL; if (!l) { return e; } else { nl = exps_copy(sa, l); if (!nl) return NULL; } if (e->type == e_func) ne = exp_op(sa, nl, e->f); else ne = exp_aggr(sa, nl, e->f, need_distinct(e), need_no_nil(e), e->card, has_nil(e)); break; } case e_atom: if (e->l) ne = exp_atom(sa, e->l); else if (!e->r) ne = exp_atom_ref(sa, e->flag, &e->tpe); else ne = exp_param(sa, e->r, &e->tpe, e->flag); break; case e_psm: if (e->flag == PSM_SET) ne = exp_set(sa, e->name, exp_copy(sa, e->l), GET_PSM_LEVEL(e->flag)); break; } if (ne && e->p) ne->p = prop_copy(sa, e->p); if (e->name) exp_setname(sa, ne, exp_find_rel_name(e), exp_name(e)); return ne; }