16 struct expr *
e = calloc(1,
sizeof(*e));
24 struct expr *
e = calloc(1,
sizeof(*e));
32 struct expr *
e = calloc(1,
sizeof(*e));
41 struct expr *
e = calloc(1,
sizeof(*e));
70 memcpy(e, org,
sizeof(*org));
80 e->left.sym = org->left.sym;
125 static int trans_count;
132 if (
e1->type == type) {
133 __expr_eliminate_eq(type, &
e1->left.expr, &
e2);
134 __expr_eliminate_eq(type, &
e1->right.expr, &
e2);
137 if (
e2->type == type) {
138 __expr_eliminate_eq(type, &
e1, &
e2->left.expr);
139 __expr_eliminate_eq(type, &
e1, &
e2->right.expr);
143 e1->left.sym ==
e2->left.sym &&
171 __expr_eliminate_eq(
e1->type, ep1, ep2);
175 if (
e1->type !=
e2->type)
switch (
e2->type) {
178 __expr_eliminate_eq(
e2->type, ep1, ep2);
200 return e1->left.sym == e2->left.sym;
202 return expr_eq(e1->left.expr, e2->left.expr);
207 old_count = trans_count;
210 e1->left.sym == e2->left.sym);
213 trans_count = old_count;
235 if (e)
switch (e->
type) {
240 if (e->left.expr->left.sym == &
symbol_no) {
247 }
else if (e->left.expr->left.sym == &
symbol_yes) {
266 *e = *(e->left.expr);
276 if (e->left.expr->left.sym == &
symbol_no) {
282 }
else if (e->left.expr->left.sym == &
symbol_yes) {
295 *e = *(e->left.expr);
349 struct symbol *sym1, *sym2;
361 sym1 = tmp->left.sym;
367 sym2 = e2->left.expr->left.sym;
410 static struct expr *expr_join_and(
struct expr *e1,
struct expr *e2)
413 struct symbol *sym1, *sym2;
425 sym1 = tmp->left.sym;
431 sym2 = e2->left.expr->left.sym;
510 if (e1->
type == type) {
511 expr_eliminate_dups1(type, &e1->left.expr, &e2);
512 expr_eliminate_dups1(type, &e1->
right.
expr, &e2);
515 if (e2->
type == type) {
516 expr_eliminate_dups1(type, &e1, &e2->left.expr);
517 expr_eliminate_dups1(type, &e1, &e2->
right.
expr);
525 expr_eliminate_dups1(e1->
type, &e1, &e1);
532 tmp = expr_join_or(e1, e2);
541 tmp = expr_join_and(e1, e2);
556 static void expr_eliminate_dups2(
enum expr_type type,
struct expr **ep1,
struct expr **ep2)
562 if (e1->
type == type) {
563 expr_eliminate_dups2(type, &e1->left.expr, &e2);
564 expr_eliminate_dups2(type, &e1->
right.
expr, &e2);
567 if (e2->
type == type) {
568 expr_eliminate_dups2(type, &e1, &e2->left.expr);
569 expr_eliminate_dups2(type, &e1, &e2->
right.
expr);
576 expr_eliminate_dups2(e1->
type, &e1, &e1);
581 if (expr_is_yes(tmp1)) {
591 expr_eliminate_dups2(e1->
type, &e1, &e1);
596 if (expr_is_no(tmp1)) {
618 oldcount = trans_count;
623 expr_eliminate_dups1(e->
type, &e, &e);
624 expr_eliminate_dups2(e->
type, &e, &e);
632 trans_count = oldcount;
664 printf(
"boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
685 printf(
"boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
699 switch (e->left.expr->
type) {
702 tmp = e->left.expr->left.expr;
753 if (e->left.expr->left.sym == &
symbol_no) {
784 return dep->left.sym == sym;
787 return dep->left.sym == sym ||
807 return dep->left.sym == sym;
809 if (dep->left.sym == sym) {
815 if (dep->left.sym == sym) {
852 if (e1->
type == type) {
857 if (e2->
type == type) {
868 }
else if (type ==
E_OR) {
912 if (type == E_EQUAL) {
941 const char *
str1, *str2;
949 return e->left.sym->curr.tri;
1006 printf(
"[%dgt%d?]", t1, t2);
1011 static inline struct expr *
1012 expr_get_leftmost_symbol(
const struct expr *
e)
1050 return expr_get_leftmost_symbol(ret);
1064 if (e->left.sym->name)
1065 fn(data, e->left.sym, e->left.sym->name);
1067 fn(data,
NULL,
"<choice>");
1074 if (e->left.sym->name)
1075 fn(data, e->left.sym, e->left.sym->name);
1077 fn(data,
NULL,
"<choice>");
1082 if (e->left.sym->name)
1083 fn(data, e->left.sym, e->left.sym->name);
1085 fn(data,
NULL,
"<choice>");
1108 fn(data, e->left.sym, e->left.sym->name);
1125 static void expr_print_file_helper(
void *
data,
struct symbol *sym,
const char *
str)
1127 xfwrite(str,
strlen(str), 1, data);
1135 static void expr_print_gstr_helper(
void *data,
struct symbol *sym,
const char *str)
1138 const char *sym_str =
NULL;
1144 unsigned extra_length =
strlen(str);
1145 const char *last_cr =
strrchr(gs->
s,
'\n');
1146 unsigned last_line_length;
1149 extra_length += 4 +
strlen(sym_str);
1154 last_line_length =
strlen(gs->
s) - (last_cr - gs->
s);
1156 if ((last_line_length + extra_length) > gs->
max_width)