static void match_condition(struct expression *expr) { if (expr->type == EXPR_ASSIGNMENT) match_condition(expr->left); if (get_state_expr(my_id, expr) == &filehandle) { char *name; name = expr_to_var(expr); sm_msg("error: comparing a filehandle against zero '%s'", name); set_state_expr(my_id, expr, &oktocheck); free_string(name); } }
static int match_condition(fz_css_condition *cond, fz_xml *node) { if (!cond) return 1; switch (cond->type) { default: return 0; case ':': return 0; /* don't support pseudo-classes */ case '#': if (!match_id_condition(node, cond->val)) return 0; break; case '.': if (!match_class_condition(node, cond->val)) return 0; break; } return match_condition(cond->next, node); }
static int match_condition(fz_css_condition *cond, fz_xml *node) { if (!cond) return 1; switch (cond->type) { default: return 0; case ':': return 0; /* don't support pseudo-classes */ case '#': if (!match_att_is_condition(node, "id", cond->val)) return 0; break; case '.': if (!match_att_has_condition(node, "class", cond->val)) return 0; break; case '[': if (!match_att_exists_condition(node, cond->key)) return 0; break; case '=': if (!match_att_is_condition(node, cond->key, cond->val)) return 0; break; case '~': if (!match_att_has_condition(node, cond->key, cond->val)) return 0; break; case '|': if (!match_att_is_condition(node, cond->key, cond->val)) return 0; break; } return match_condition(cond->next, node); }
static int match_selector(fz_css_selector *sel, fz_xml *node) { if (!node) return 0; if (sel->combine) { /* descendant */ if (sel->combine == ' ') { fz_xml *parent = fz_xml_up(node); while (parent) { if (match_selector(sel->left, parent)) if (match_selector(sel->right, node)) return 1; parent = fz_xml_up(parent); } return 0; } /* child */ if (sel->combine == '>') { fz_xml *parent = fz_xml_up(node); if (!parent) return 0; if (!match_selector(sel->left, parent)) return 0; if (!match_selector(sel->right, node)) return 0; } /* adjacent */ if (sel->combine == '+') { fz_xml *prev = fz_xml_prev(node); while (prev && !fz_xml_tag(prev)) prev = fz_xml_prev(prev); if (!prev) return 0; if (!fz_xml_tag(prev)) return 0; if (!match_selector(sel->left, prev)) return 0; if (!match_selector(sel->right, node)) return 0; } } if (sel->name) { if (strcmp(sel->name, fz_xml_tag(node))) return 0; } if (sel->cond) { if (!match_condition(sel->cond, node)) return 0; } return 1; }