Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199493
b: refs/heads/master
c: da60fbb
h: refs/heads/master
i:
  199491: 5bd7e4f
v: v3
  • Loading branch information
Vadim Bendebury (вб) authored and Michal Marek committed Feb 2, 2010
1 parent 1b25d4f commit e335b99
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5358db0b0e16470337c6ec08177deb3f68ed7673
refs/heads/master: da60fbbcb637b37b1d77a41886ae4e275422ca96
27 changes: 25 additions & 2 deletions trunk/scripts/kconfig/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions trunk/scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ int file_write_dep(const char *name);
struct gstr {
size_t len;
char *s;
/*
* when max_width is not zero long lines in string s (if any) get
* wrapped not to exceed the max_width value
*/
int max_width;
};
struct gstr str_new(void);
struct gstr str_assign(const char *s);
Expand Down
1 change: 1 addition & 0 deletions trunk/scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ static void show_help(struct menu *menu)
{
struct gstr help = str_new();

help.max_width = getmaxx(stdscr) - 10;
menu_get_ext_help(menu, &help);

show_helptext(_(menu_get_prompt(menu)), str_get(&help));
Expand Down
2 changes: 2 additions & 0 deletions trunk/scripts/kconfig/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct gstr str_new(void)
struct gstr gs;
gs.s = malloc(sizeof(char) * 64);
gs.len = 64;
gs.max_width = 0;
strcpy(gs.s, "\0");
return gs;
}
Expand All @@ -88,6 +89,7 @@ struct gstr str_assign(const char *s)
struct gstr gs;
gs.s = strdup(s);
gs.len = strlen(s) + 1;
gs.max_width = 0;
return gs;
}

Expand Down

0 comments on commit e335b99

Please sign in to comment.