Skip to contentSkip to conversation

kconfig: print each first level disjunction block from a new line

PATCH New Konstantin Khlebnikov 1 participant 1 message Mar 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: print each first level disjunction block from a new line

This patch improves readability of complicated expressions.

before:
Selected by: A && AA && AAA || B && BB && (BBB || BBBB) || C && CC && CCC

after:
Selected by: A && AA && AAA

 || B && BB && (BBB || BBBB)
 || C && CC && CCC

Modules' config options usually comes first in these blocks.

---
 scripts/kconfig/expr.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
scripts/kconfig/expr.c +9 -3
index d662652..e47eb28 100644
@@ -1087,9 +1087,15 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
 		fn(data, e->right.sym, e->right.sym->name);
 		break;
 	case E_OR:
-		expr_print(e->left.expr, fn, data, E_OR);
-		fn(data, NULL, " || ");
-		expr_print(e->right.expr, fn, data, E_OR);
+		if (prevtoken == E_NONE) {
+			expr_print(e->left.expr, fn, data, E_NONE);
+			fn(data, NULL, "\n|| ");
+			expr_print(e->right.expr, fn, data, E_NONE);
+		} else {
+			expr_print(e->left.expr, fn, data, E_OR);
+			fn(data, NULL, " || ");
+			expr_print(e->right.expr, fn, data, E_OR);
+		}
 		break;
 	case E_AND:
 		expr_print(e->left.expr, fn, data, E_AND);