Skip to content

Commit 9a47cee

Browse files
committed
kconfig: clean-up reverse dependency help implementation
This commit splits out the special E_OR handling ('-' instead of '||') into a dedicated helper expr_print_revdev(). Restore the original expr_print() prior to commit 1ccb271 ("kconfig: make "Selected by:" and "Implied by:" readable"). This makes sense because: - We need to chop those expressions only when printing the reverse dependency, and only when E_OR is encountered - Otherwise, it should be printed as before, so fall back to expr_print() This also improves the behavior; for a single line, it was previously displayed in the same line as "Selected by", like this: Selected by: A [=n] && B [=n] This will be displayed in a new line, consistently: Selected by: - A [=n] && B [=n] Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Petr Vorel <[email protected]>
1 parent 84af7a6 commit 9a47cee

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

scripts/kconfig/expr.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,9 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
11791179
return expr_get_leftmost_symbol(ret);
11801180
}
11811181

1182-
static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep)
1182+
void expr_print(struct expr *e,
1183+
void (*fn)(void *, struct symbol *, const char *),
1184+
void *data, int prevtoken)
11831185
{
11841186
if (!e) {
11851187
fn(data, NULL, "y");
@@ -1234,14 +1236,9 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
12341236
fn(data, e->right.sym, e->right.sym->name);
12351237
break;
12361238
case E_OR:
1237-
if (revdep && e->left.expr->type != E_OR)
1238-
fn(data, NULL, "\n - ");
1239-
__expr_print(e->left.expr, fn, data, E_OR, revdep);
1240-
if (revdep)
1241-
fn(data, NULL, "\n - ");
1242-
else
1243-
fn(data, NULL, " || ");
1244-
__expr_print(e->right.expr, fn, data, E_OR, revdep);
1239+
expr_print(e->left.expr, fn, data, E_OR);
1240+
fn(data, NULL, " || ");
1241+
expr_print(e->right.expr, fn, data, E_OR);
12451242
break;
12461243
case E_AND:
12471244
expr_print(e->left.expr, fn, data, E_AND);
@@ -1274,11 +1271,6 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
12741271
fn(data, NULL, ")");
12751272
}
12761273

1277-
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
1278-
{
1279-
__expr_print(e, fn, data, prevtoken, false);
1280-
}
1281-
12821274
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
12831275
{
12841276
xfwrite(str, strlen(str), 1, data);
@@ -1329,7 +1321,21 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
13291321
* line with a minus. This makes expressions much easier to read.
13301322
* Suitable for reverse dependency expressions.
13311323
*/
1324+
static void expr_print_revdep(struct expr *e,
1325+
void (*fn)(void *, struct symbol *, const char *),
1326+
void *data)
1327+
{
1328+
if (e->type == E_OR) {
1329+
expr_print_revdep(e->left.expr, fn, data);
1330+
expr_print_revdep(e->right.expr, fn, data);
1331+
} else {
1332+
fn(data, NULL, " - ");
1333+
expr_print(e, fn, data, E_NONE);
1334+
fn(data, NULL, "\n");
1335+
}
1336+
}
1337+
13321338
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
13331339
{
1334-
__expr_print(e, expr_print_gstr_helper, gs, E_NONE, true);
1340+
expr_print_revdep(e, expr_print_gstr_helper, gs);
13351341
}

scripts/kconfig/menu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,15 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
829829
get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
830830
if (sym->rev_dep.expr) {
831831
str_append(r, _(" Selected by: "));
832-
expr_gstr_print_revdep(sym->rev_dep.expr, r);
833832
str_append(r, "\n");
833+
expr_gstr_print_revdep(sym->rev_dep.expr, r);
834834
}
835835

836836
get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
837837
if (sym->implied.expr) {
838838
str_append(r, _(" Implied by: "));
839-
expr_gstr_print_revdep(sym->implied.expr, r);
840839
str_append(r, "\n");
840+
expr_gstr_print_revdep(sym->implied.expr, r);
841841
}
842842

843843
str_append(r, "\n\n");

0 commit comments

Comments
 (0)