diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-20 03:18:47 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-03-25 13:03:57 -0400 |
commit | 9a47ceec543bfb703fbe2f8d584850b582caf1a6 (patch) | |
tree | 565f1ac80d53e33db268d68986055733caca0194 /scripts/kconfig/expr.c | |
parent | 84af7a6194e493fae312a2b7fa5a3b51f76d9282 (diff) |
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 1ccb27143360
("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 <yamada.masahiro@socionext.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Diffstat (limited to 'scripts/kconfig/expr.c')
-rw-r--r-- | scripts/kconfig/expr.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d45381986ac7..cd3a8f501f38 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -1179,7 +1179,9 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) | |||
1179 | return expr_get_leftmost_symbol(ret); | 1179 | return expr_get_leftmost_symbol(ret); |
1180 | } | 1180 | } |
1181 | 1181 | ||
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) | ||
1183 | { | 1185 | { |
1184 | if (!e) { | 1186 | if (!e) { |
1185 | fn(data, NULL, "y"); | 1187 | fn(data, NULL, "y"); |
@@ -1234,14 +1236,9 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con | |||
1234 | fn(data, e->right.sym, e->right.sym->name); | 1236 | fn(data, e->right.sym, e->right.sym->name); |
1235 | break; | 1237 | break; |
1236 | case E_OR: | 1238 | case E_OR: |
1237 | if (revdep && e->left.expr->type != E_OR) | 1239 | expr_print(e->left.expr, fn, data, E_OR); |
1238 | fn(data, NULL, "\n - "); | 1240 | fn(data, NULL, " || "); |
1239 | __expr_print(e->left.expr, fn, data, E_OR, revdep); | 1241 | expr_print(e->right.expr, fn, data, E_OR); |
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); | ||
1245 | break; | 1242 | break; |
1246 | case E_AND: | 1243 | case E_AND: |
1247 | expr_print(e->left.expr, fn, data, E_AND); | 1244 | 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 | |||
1274 | fn(data, NULL, ")"); | 1271 | fn(data, NULL, ")"); |
1275 | } | 1272 | } |
1276 | 1273 | ||
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 | |||
1282 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) | 1274 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) |
1283 | { | 1275 | { |
1284 | xfwrite(str, strlen(str), 1, data); | 1276 | xfwrite(str, strlen(str), 1, data); |
@@ -1329,7 +1321,21 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) | |||
1329 | * line with a minus. This makes expressions much easier to read. | 1321 | * line with a minus. This makes expressions much easier to read. |
1330 | * Suitable for reverse dependency expressions. | 1322 | * Suitable for reverse dependency expressions. |
1331 | */ | 1323 | */ |
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 | |||
1332 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs) | 1338 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs) |
1333 | { | 1339 | { |
1334 | __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true); | 1340 | expr_print_revdep(e, expr_print_gstr_helper, gs); |
1335 | } | 1341 | } |