@@ -1189,7 +1189,12 @@ expr_print_newline(struct expr *e,
expr_print(e, fn, data, prevtoken);
}
-static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep)
+static void
+__expr_print(struct expr *e,
+ void (*fn)(void *, struct symbol *, const char *),
+ void *data,
+ int prevtoken,
+ enum print_type type)
{
if (!e) {
fn(data, NULL, "y");
@@ -1201,10 +1206,14 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
switch (e->type) {
case E_SYMBOL:
if (e->left.sym->name)
- if (!revdep)
+ switch (type) {
+ case PRINT_NORMAL:
fn(data, e->left.sym, e->left.sym->name);
- else
+ break;
+ case PRINT_REVDEP_ALL:
expr_print_newline(e, fn, data, E_OR);
+ break;
+ }
else
fn(data, NULL, "<choice>");
break;
@@ -1247,18 +1256,21 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
fn(data, e->right.sym, e->right.sym->name);
break;
case E_OR:
- __expr_print(e->left.expr, fn, data, E_OR, revdep);
- if (!revdep)
+ __expr_print(e->left.expr, fn, data, E_OR, type);
+ if (type == PRINT_NORMAL)
fn(data, NULL, " || ");
- __expr_print(e->right.expr, fn, data, E_OR, revdep);
+ __expr_print(e->right.expr, fn, data, E_OR, type);
break;
case E_AND:
- if (!revdep) {
+ switch (type) {
+ case PRINT_NORMAL:
expr_print(e->left.expr, fn, data, E_AND);
fn(data, NULL, " && ");
expr_print(e->right.expr, fn, data, E_AND);
- } else {
+ break;
+ case PRINT_REVDEP_ALL:
expr_print_newline(e, fn, data, E_OR);
+ break;
}
break;
case E_LIST:
@@ -1289,7 +1301,7 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
{
- __expr_print(e, fn, data, prevtoken, false);
+ __expr_print(e, fn, data, prevtoken, PRINT_NORMAL);
}
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
@@ -1342,7 +1354,7 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
* line with a minus. This makes expressions much easier to read.
* Suitable for reverse dependency expressions.
*/
-void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
+void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, enum print_type t)
{
- __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true);
+ __expr_print(e, expr_print_gstr_helper, gs, E_NONE, t);
}
@@ -34,6 +34,11 @@ enum expr_type {
E_LIST, E_SYMBOL, E_RANGE
};
+enum print_type {
+ PRINT_NORMAL,
+ PRINT_REVDEP_ALL,
+};
+
union expr_data {
struct expr *expr;
struct symbol *sym;
@@ -310,7 +315,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs);
-void expr_gstr_print_revdep(struct expr *e, struct gstr *gs);
+void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, enum print_type t);
static inline int expr_is_yes(struct expr *e)
{
@@ -828,14 +828,14 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
if (sym->rev_dep.expr) {
str_append(r, _(" Selected by: "));
- expr_gstr_print_revdep(sym->rev_dep.expr, r);
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, PRINT_REVDEP_ALL);
str_append(r, "\n");
}
get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
if (sym->implied.expr) {
str_append(r, _(" Implied by: "));
- expr_gstr_print_revdep(sym->implied.expr, r);
+ expr_gstr_print_revdep(sym->implied.expr, r, PRINT_REVDEP_ALL);
str_append(r, "\n");
}