diff options
Diffstat (limited to 'scripts/kconfig/expr.c')
| -rw-r--r-- | scripts/kconfig/expr.c | 27 | 
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index edd3f39a080..d83f2322893 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1097,9 +1097,32 @@ void expr_fprint(struct expr *e, FILE *out)  static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)  { -	str_append((struct gstr*)data, str); +	struct gstr *gs = (struct gstr*)data; +	const char *sym_str = NULL; + +	if (sym) +		sym_str = sym_get_string_value(sym); + +	if (gs->max_width) { +		unsigned extra_length = strlen(str); +		const char *last_cr = strrchr(gs->s, '\n'); +		unsigned last_line_length; + +		if (sym_str) +			extra_length += 4 + strlen(sym_str); + +		if (!last_cr) +			last_cr = gs->s; + +		last_line_length = strlen(gs->s) - (last_cr - gs->s); + +		if ((last_line_length + extra_length) > gs->max_width) +			str_append(gs, "\\\n"); +	} + +	str_append(gs, str);  	if (sym) -		str_printf((struct gstr*)data, " [=%s]", sym_get_string_value(sym)); +		str_printf(gs, " [=%s]", sym_str);  }  void expr_gstr_print(struct expr *e, struct gstr *gs)  | 
