* kconfig: @ 2004-12-30 23:51 Sam Ravnborg 2004-12-30 23:52 ` kconfig: avoid temporary file Sam Ravnborg ` (3 more replies) 0 siblings, 4 replies; 15+ messages in thread From: Sam Ravnborg @ 2004-12-30 23:51 UTC (permalink / raw) To: Roman Zippel, linux-kernel; +Cc: Sam Ravnborg Hi Roman & lkml Here follows a few kconfig patches. Main purpose is to improve readability of the output when doing search and to inculde dependency information in the help text. They are not pushed to my kbuild tree yet - will see if this generate any feedback first. One will now see something like this when getting help on a menu item: CONFIG_FOO bla bla bla depends on: USB selects: HOTPLUG selected by: FW_LOADER Empty lines are omitted - so a symbol that does not seletcs any other symbol the symbol line will not appear. Let me know if you want me to push them towards mainstream. Sam ^ permalink raw reply [flat|nested] 15+ messages in thread
* kconfig: avoid temporary file 2004-12-30 23:51 kconfig: Sam Ravnborg @ 2004-12-30 23:52 ` Sam Ravnborg 2005-01-03 0:55 ` Roman Zippel 2004-12-30 23:52 ` kconfig: remove noise from show_expr Sam Ravnborg ` (2 subsequent siblings) 3 siblings, 1 reply; 15+ messages in thread From: Sam Ravnborg @ 2004-12-30 23:52 UTC (permalink / raw) To: Roman Zippel, linux-kernel # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/12/30 22:30:10+01:00 sam@mars.ravnborg.org # kconfig: avoid temporary file # # Use a growable string when building up result of searching - avoiding an additional # temporary file. A temporary file is still used but on a higher level. # # Signed-off-by: Sam Ravnborg <sam@ravnborg.org> # # scripts/kconfig/mconf.c # 2004/12/30 22:29:51+01:00 sam@mars.ravnborg.org +78 -28 # introduce a general growable string. # Allow us to skip one additional temporary file # diff -Nru a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c --- a/scripts/kconfig/mconf.c 2004-12-31 00:45:13 +01:00 +++ b/scripts/kconfig/mconf.c 2004-12-31 00:45:13 +01:00 @@ -104,7 +104,6 @@ static void show_help(struct menu *menu); static void show_readme(void); static void show_file(const char *filename, const char *title, int r, int c); -static void show_expr(struct menu *menu, FILE *fp); static void search_conf(char *pattern); static int regex_match(const char *string, regex_t *re); @@ -113,6 +112,53 @@ static void cprint_done(void); static int cprint(const char *fmt, ...); +/* Growable string. Allocates memory as needed when string expands */ +struct gstr { + char *s; + size_t len; +}; + +static struct gstr str_init(void) +{ + struct gstr gs; + gs.s = malloc(sizeof(char) * 16); + strcpy(gs.s, "\0"); + gs.len = 16; + return gs; +} + +static void str_del(struct gstr *gs) +{ + if (gs->len && gs->s) + free(gs->s); + gs->s = NULL; + gs->len = 0; +} + +static void str_add(struct gstr *gs, const char *s) +{ + size_t l = strlen(gs->s) + strlen(s) + 1; + if (l >= gs->len) + gs->s = realloc(gs->s, l); + gs->len = l; + strcat(gs->s, s); +} + +static void str_printf(struct gstr *gs, const char *fmt, ...) +{ + va_list ap; + char s[1024]; + va_start(ap, fmt); + vsnprintf(s, sizeof(s), fmt, ap); + str_add(gs, s); + va_end(ap); +} + +static const char *str_get(struct gstr *gs) +{ + return gs->s; +} + static void init_wsize(void) { struct winsize ws; @@ -289,36 +335,46 @@ return 1; } -static void show_expr(struct menu *menu, FILE *fp) +static void expr_print_str_helper(void *data, const char *str) +{ + str_add((struct gstr*)data, str); +} + +static void expr_str(struct expr *e, struct gstr *gs) +{ + expr_print(e, expr_print_str_helper, gs, E_NONE); +} + +static void show_expr(struct menu *menu, struct gstr *gs) { bool hit = false; - fprintf(fp, "Depends:\n "); + str_add(gs, "Depends:\n "); if (menu->prompt->visible.expr) { if (!hit) hit = true; - expr_fprint(menu->prompt->visible.expr, fp); + expr_str(menu->prompt->visible.expr, gs); } if (!hit) - fprintf(fp, "None"); + str_add(gs, "None"); if (menu->sym) { struct property *prop; hit = false; - fprintf(fp, "\nSelects:\n "); + str_add(gs, "\nSelects:\n "); for_all_properties(menu->sym, prop, P_SELECT) { if (!hit) hit = true; - expr_fprint(prop->expr, fp); + expr_str(prop->expr, gs); } if (!hit) - fprintf(fp, "None"); + str_add(gs, "None"); hit = false; - fprintf(fp, "\nSelected by:\n "); + str_add(gs, "\nSelected by:\n "); if (menu->sym->rev_dep.expr) { hit = true; - expr_fprint(menu->sym->rev_dep.expr, fp); + expr_str(menu->sym->rev_dep.expr, gs); } if (!hit) - fprintf(fp, "None"); + str_add(gs, "None"); } } @@ -327,19 +383,13 @@ struct symbol *sym = NULL; struct menu *menu[32] = { 0 }; struct property *prop = NULL; - FILE *fp = NULL; + struct gstr str = str_init(); bool hit = false; int i, j, k, l; regex_t re; if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB)) return; - - fp = fopen(".search.tmp", "w"); - if (fp == NULL) { - perror("fopen"); - return; - } for_all_symbols(i, sym) { if (!sym->name) continue; @@ -358,33 +408,33 @@ if (j > 0) { if (!hit) hit = true; - fprintf(fp, "%s (%s)\n", prop->text, sym->name); - fprintf(fp, "Location:\n"); + str_printf(&str, "%s (%s)\n", + prop->text, sym->name); + str_add(&str, "Location:\n"); } for (k = j-2, l=1; k > 0; k--, l++) { const char *prompt = menu_get_prompt(menu[k]); if (menu[k]->sym) - fprintf(fp, "%*c-> %s (%s)\n", + str_printf(&str, "%*c-> %s (%s)\n", l, ' ', prompt, menu[k]->sym->name); else - fprintf(fp, "%*c-> %s\n", + str_printf(&str, "%*c-> %s\n", l, ' ', prompt); } if (hit) { - show_expr(menu[0], fp); - fprintf(fp, "\n\n\n"); + show_expr(menu[0], &str); + str_add(&str, "\n\n\n"); } } } if (!hit) - fprintf(fp, "No matches found."); + str_add(&str, "No matches found."); regfree(&re); - fclose(fp); - show_file(".search.tmp", "Search Results", rows, cols); - unlink(".search.tmp"); + show_textbox("Search Results", str_get(&str), rows, cols); + str_del(&str); } static void build_conf(struct menu *menu) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: avoid temporary file 2004-12-30 23:52 ` kconfig: avoid temporary file Sam Ravnborg @ 2005-01-03 0:55 ` Roman Zippel 2005-01-03 5:10 ` Sam Ravnborg 0 siblings, 1 reply; 15+ messages in thread From: Roman Zippel @ 2005-01-03 0:55 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel Hi, On Friday 31 December 2004 00:52, Sam Ravnborg wrote: > # scripts/kconfig/mconf.c > # 2004/12/30 22:29:51+01:00 sam@mars.ravnborg.org +78 -28 > # introduce a general growable string. > # Allow us to skip one additional temporary file I'm not really against the change, but the reason is weird. In the end the string is still written to a file anyway... > +/* Growable string. Allocates memory as needed when string expands */ > +struct gstr { > + char *s; > + size_t len; > +}; I would prefer something more like this: struct gstr { int size; char s[0]; }; and this would be better names for the functions: struct gstr *str_new(void); void str_free(struct gstr *gs); void str_append(struct gstr *gs, const char *s); It would be useful to have these sort of functions in the library, so we can e.g. use them to dynamically generate the help text. bye, Roman ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: avoid temporary file 2005-01-03 0:55 ` Roman Zippel @ 2005-01-03 5:10 ` Sam Ravnborg 2005-01-05 12:40 ` Roman Zippel 0 siblings, 1 reply; 15+ messages in thread From: Sam Ravnborg @ 2005-01-03 5:10 UTC (permalink / raw) To: Roman Zippel; +Cc: Sam Ravnborg, linux-kernel On Mon, Jan 03, 2005 at 01:55:04AM +0100, Roman Zippel wrote: > > I'm not really against the change, but the reason is weird. In the end the > string is still written to a file anyway... Next step is to integrate Petr Baudis patch to link lxdialog with mconf. Then it is nice to get rid of the file based interface. > > +/* Growable string. Allocates memory as needed when string expands */ > > +struct gstr { > > + char *s; > > + size_t len; > > +}; > > I would prefer something more like this: > > struct gstr { > int size; > char s[0]; > }; > > and this would be better names for the functions: > > struct gstr *str_new(void); > void str_free(struct gstr *gs); > void str_append(struct gstr *gs, const char *s); > > It would be useful to have these sort of functions in the library, so we can > e.g. use them to dynamically generate the help text. I will update my patch with your suggestions later this week. Sam ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: avoid temporary file 2005-01-03 5:10 ` Sam Ravnborg @ 2005-01-05 12:40 ` Roman Zippel 2005-01-05 18:14 ` Sam Ravnborg 0 siblings, 1 reply; 15+ messages in thread From: Roman Zippel @ 2005-01-05 12:40 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel Hi, On Monday 03 January 2005 06:10, Sam Ravnborg wrote: > Next step is to integrate Petr Baudis patch to link lxdialog with mconf. I had two major problems with his patch: - it didn't resize when the terminal changed. - window layering, old windows are not removed and just drawn over (this was especially a problem with help texts). The current approach solves this rather nicely by just reinitialising everything. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: avoid temporary file 2005-01-05 12:40 ` Roman Zippel @ 2005-01-05 18:14 ` Sam Ravnborg 2005-01-06 14:53 ` Roman Zippel 0 siblings, 1 reply; 15+ messages in thread From: Sam Ravnborg @ 2005-01-05 18:14 UTC (permalink / raw) To: Roman Zippel; +Cc: Sam Ravnborg, linux-kernel On Wed, Jan 05, 2005 at 01:40:31PM +0100, Roman Zippel wrote: > Hi, > > On Monday 03 January 2005 06:10, Sam Ravnborg wrote: > > > Next step is to integrate Petr Baudis patch to link lxdialog with mconf. > > I had two major problems with his patch: > - it didn't resize when the terminal changed. Resize support will not be added until it works. > - window layering, old windows are not removed and just drawn over (this was > especially a problem with help texts). Did not see it as a problem as such - will try to play with it a bit more. I have the original patch more or less blindly applied. For an acceptable version a parts of it will be redone. I also noticed that ESC was not working as usual. Sam ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: avoid temporary file 2005-01-05 18:14 ` Sam Ravnborg @ 2005-01-06 14:53 ` Roman Zippel 0 siblings, 0 replies; 15+ messages in thread From: Roman Zippel @ 2005-01-06 14:53 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel Hi, On Wednesday 05 January 2005 19:14, Sam Ravnborg wrote: > > - it didn't resize when the terminal changed. > > Resize support will not be added until it works. Well, please keep it mind. I don't want to lose this feature, because you had to rewrite everything once again. > > - window layering, old windows are not removed and just drawn over (this > > was especially a problem with help texts). > > Did not see it as a problem as such - will try to play with it a bit > more. I have the original patch more or less blindly applied. For an > acceptable version a parts of it will be redone. Try to select help from an input or choice dialog - it's ugly. The current interface expects that only a single dialog window is visible at a time, maybe it's better to keep this behaviour for the first version, do some cleanups and add new features later. > I also noticed that ESC was not working as usual. Yes, now I remember that one too, but it's already some time ago, I tested this. :) bye, Roman ^ permalink raw reply [flat|nested] 15+ messages in thread
* kconfig: remove noise from show_expr 2004-12-30 23:51 kconfig: Sam Ravnborg 2004-12-30 23:52 ` kconfig: avoid temporary file Sam Ravnborg @ 2004-12-30 23:52 ` Sam Ravnborg 2004-12-30 23:53 ` kconfig: help includes dependency information Sam Ravnborg 2005-01-03 0:34 ` kconfig: Roman Zippel 3 siblings, 0 replies; 15+ messages in thread From: Sam Ravnborg @ 2004-12-30 23:52 UTC (permalink / raw) To: Roman Zippel, linux-kernel # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/12/31 00:36:09+01:00 sam@mars.ravnborg.org # kconfig: remove noise from show_expr # # This makes readout more compact when searching for specific symbols # # Signed-off-by: Sam Ravnborg <sam@ravnborg.org> # # scripts/kconfig/mconf.c # 2004/12/31 00:35:50+01:00 sam@mars.ravnborg.org +7 -17 # avoid printing empty information in show_expr # increase buffer size in str_printf - people write that big text blocks # diff -Nru a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c --- a/scripts/kconfig/mconf.c 2004-12-31 00:45:40 +01:00 +++ b/scripts/kconfig/mconf.c 2004-12-31 00:45:40 +01:00 @@ -147,7 +147,7 @@ static void str_printf(struct gstr *gs, const char *fmt, ...) { va_list ap; - char s[1024]; + char s[4096]; va_start(ap, fmt); vsnprintf(s, sizeof(s), fmt, ap); str_add(gs, s); @@ -347,34 +347,24 @@ static void show_expr(struct menu *menu, struct gstr *gs) { - bool hit = false; - str_add(gs, "Depends:\n "); if (menu->prompt->visible.expr) { - if (!hit) - hit = true; + str_add(gs, "\ndepends on:\n "); expr_str(menu->prompt->visible.expr, gs); } - if (!hit) - str_add(gs, "None"); if (menu->sym) { struct property *prop; - hit = false; - str_add(gs, "\nSelects:\n "); + bool hit = false; for_all_properties(menu->sym, prop, P_SELECT) { - if (!hit) + if (!hit) { + str_add(gs, "\nselects:\n "); hit = true; + } expr_str(prop->expr, gs); } - if (!hit) - str_add(gs, "None"); - hit = false; - str_add(gs, "\nSelected by:\n "); if (menu->sym->rev_dep.expr) { - hit = true; + str_add(gs, "\nselected by:\n "); expr_str(menu->sym->rev_dep.expr, gs); } - if (!hit) - str_add(gs, "None"); } } ^ permalink raw reply [flat|nested] 15+ messages in thread
* kconfig: help includes dependency information 2004-12-30 23:51 kconfig: Sam Ravnborg 2004-12-30 23:52 ` kconfig: avoid temporary file Sam Ravnborg 2004-12-30 23:52 ` kconfig: remove noise from show_expr Sam Ravnborg @ 2004-12-30 23:53 ` Sam Ravnborg 2005-01-01 4:02 ` Ingo Oeser 2005-01-03 0:34 ` kconfig: Roman Zippel 3 siblings, 1 reply; 15+ messages in thread From: Sam Ravnborg @ 2004-12-30 23:53 UTC (permalink / raw) To: Roman Zippel, linux-kernel # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/12/31 00:43:45+01:00 sam@mars.ravnborg.org # kconfig: help includes dependency information # # When selecting help on a menu item display # "depends on:" # "selects:" # "selected by:" # # Only relevant headlines are displayed - so if no "selects:" appear then this menu # does not select a specific symbol. # Loosly based on a patch by: Cal Peake <cp@absolutedigital.net> # # Signed-off-by: Sam Ravnborg <sam@ravnborg.org> # # scripts/kconfig/mconf.c # 2004/12/31 00:43:27+01:00 sam@mars.ravnborg.org +5 -5 # display # "depends on:" # "selects:" # "selected by:" # # information when selecting help on a menu # diff -Nru a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c --- a/scripts/kconfig/mconf.c 2004-12-31 00:46:29 +01:00 +++ b/scripts/kconfig/mconf.c 2004-12-31 00:46:29 +01:00 @@ -732,17 +732,17 @@ static void show_help(struct menu *menu) { const char *help; - char *helptext; struct symbol *sym = menu->sym; help = sym->help; if (!help) help = nohelp_text; if (sym->name) { - helptext = malloc(strlen(sym->name) + strlen(help) + 16); - sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help); - show_helptext(menu_get_prompt(menu), helptext); - free(helptext); + struct gstr str = str_init(); + str_printf(&str, "CONFIG_%s:\n\n%s", sym->name, help); + show_expr(menu, &str); + show_helptext(menu_get_prompt(menu), str_get(&str)); + str_del(&str); } else show_helptext(menu_get_prompt(menu), help); } ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: help includes dependency information 2004-12-30 23:53 ` kconfig: help includes dependency information Sam Ravnborg @ 2005-01-01 4:02 ` Ingo Oeser 2005-01-02 20:16 ` Sam Ravnborg 0 siblings, 1 reply; 15+ messages in thread From: Ingo Oeser @ 2005-01-01 4:02 UTC (permalink / raw) To: linux-kernel; +Cc: Sam Ravnborg, Roman Zippel Hi Sam, nice to have this information available now. Sam Ravnborg wrote: > # This is a BitKeeper generated diff -Nru style patch. > # > # ChangeSet > # 2004/12/31 00:43:45+01:00 sam@mars.ravnborg.org > # kconfig: help includes dependency information > # > # When selecting help on a menu item display > # "depends on:" > # "selects:" > # "selected by:" > # > # Only relevant headlines are displayed - so if no "selects:" appear then > this menu # does not select a specific symbol. > # Loosly based on a patch by: Cal Peake <cp@absolutedigital.net> I would prefer this information at the END of the help text, since it is actually most useful to developers and more advanced users and thus equals in value to the old notice how a module is called. If I call for help, I usually like to know WHAT it is and then WHY I might need it. Using the verbose config information and linking to their help texts would make it even more user friendly in my opinion. "depends on:" is not really needed, since you usually cannot select any option, where you didn't fulfill the dependencies, AFAICS. Regards Ingo Oeser ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: help includes dependency information 2005-01-01 4:02 ` Ingo Oeser @ 2005-01-02 20:16 ` Sam Ravnborg 2005-01-03 19:24 ` Ingo Oeser 0 siblings, 1 reply; 15+ messages in thread From: Sam Ravnborg @ 2005-01-02 20:16 UTC (permalink / raw) To: Ingo Oeser; +Cc: linux-kernel, Sam Ravnborg, Roman Zippel On Sat, Jan 01, 2005 at 05:02:55AM +0100, Ingo Oeser wrote: > > I would prefer this information at the END of the help text, > since it is actually most useful to developers and more advanced users > and thus equals in value to the old notice how a module is called. Thats where it is placed. > Using the verbose config information and linking to their help texts would > make it even more user friendly in my opinion. verbose config option - please explain what you have in mind here. > "depends on:" is not really needed, since you usually cannot select any > option, where you didn't fulfill the dependencies, AFAICS. It is sometimes usefull to see what a specific config option is dependent of. But you are right that it is not visible in menuconfig (today) when "depends on" is not satisfied. I'm digging through Petr Baudis patch to link lxdialog with kconfig - and when finished I may look into extending menuconfig a bit. Sam ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: help includes dependency information 2005-01-02 20:16 ` Sam Ravnborg @ 2005-01-03 19:24 ` Ingo Oeser 0 siblings, 0 replies; 15+ messages in thread From: Ingo Oeser @ 2005-01-03 19:24 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel, Roman Zippel Hi Sam, hi Roman, Sam Ravnborg schrieb: > > Using the verbose config information and linking to their help texts > > would make it even more user friendly in my opinion. > > verbose config option - please explain what you have in mind here. Example from drivers/char/Kconfig: SERIAL_NONSTANDARD - the config option "Non-standard serial port support" - the verbose config option please present the latter to the user, if not done already. > > "depends on:" is not really needed, since you usually cannot select any > > option, where you didn't fulfill the dependencies, AFAICS. > > It is sometimes usefull to see what a specific config option is dependent > of. But you are right that it is not visible in menuconfig (today) when > "depends on" is not satisfied. Yes, I've been told later, that you see that in xconfig. I only use either menuconfig or oldconfig, so I've never seen that before ;-) Regards Ingo Oeser ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: 2004-12-30 23:51 kconfig: Sam Ravnborg ` (2 preceding siblings ...) 2004-12-30 23:53 ` kconfig: help includes dependency information Sam Ravnborg @ 2005-01-03 0:34 ` Roman Zippel 2005-01-03 5:11 ` kconfig: Sam Ravnborg 3 siblings, 1 reply; 15+ messages in thread From: Roman Zippel @ 2005-01-03 0:34 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 458 bytes --] Hi, On Friday 31 December 2004 00:51, Sam Ravnborg wrote: > Here follows a few kconfig patches. > Main purpose is to improve readability of the output when doing search > and to inculde dependency information in the help text. I completely missed that the search patch was already merged... :-( It wasn't ready yet, it was still a quick hack. I attached a patch which does the basic cleanup, so that it not only works for the trivial cases. bye, Roman [-- Attachment #2: search_cleanup --] [-- Type: text/x-diff, Size: 10105 bytes --] kconfig/lkc_proto.h | 1 kconfig/mconf.c | 202 +++++++++++++++++++++------------------------------- kconfig/symbol.c | 35 +++++++++ lxdialog/menubox.c | 11 -- 4 files changed, 123 insertions(+), 126 deletions(-) Index: linux-2.6.10/scripts/lxdialog/menubox.c =================================================================== --- linux-2.6.10.orig/scripts/lxdialog/menubox.c 2005-01-02 23:24:41.000000000 +0100 +++ linux-2.6.10/scripts/lxdialog/menubox.c 2005-01-03 00:26:53.000000000 +0100 @@ -276,15 +276,6 @@ dialog_menu (const char *title, const ch while (key != ESC) { key = wgetch(menu); - if ( key == '/' ) { - int ret = dialog_inputbox("Search Configuration Parameter", - "Enter Keyword", height, width, - (char *) NULL); - if (ret == 0) { - fprintf(stderr, "%s", dialog_input_result); - return 26; - } - } if (key < 256 && isalpha(key)) key = tolower(key); @@ -408,6 +399,7 @@ dialog_menu (const char *title, const ch case 'y': case 'n': case 'm': + case '/': /* save scroll info */ if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { fprintf(f,"%d\n",scroll); @@ -421,6 +413,7 @@ dialog_menu (const char *title, const ch case 'n': return 4; case 'm': return 5; case ' ': return 6; + case '/': return 7; } return 0; case 'h': Index: linux-2.6.10/scripts/kconfig/symbol.c =================================================================== --- linux-2.6.10.orig/scripts/kconfig/symbol.c 2005-01-02 23:24:41.000000000 +0100 +++ linux-2.6.10/scripts/kconfig/symbol.c 2005-01-03 00:26:53.000000000 +0100 @@ -6,6 +6,7 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <regex.h> #include <sys/utsname.h> #define LKC_DIRECT_LINK @@ -656,6 +657,40 @@ struct symbol *sym_find(const char *name return symbol; } +struct symbol **sym_re_search(const char *pattern, int flags) +{ + struct symbol *sym, **sym_arr = NULL; + int i, cnt, size; + regex_t re; + + cnt = size = 0; + if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) + return NULL; + + for_all_symbols(i, sym) { + if (sym->flags & SYMBOL_CONST || !sym->name) + continue; + if (regexec(&re, sym->name, 0, NULL, 0)) + continue; + if (cnt + 1 >= size) { + void *tmp = sym_arr; + size += 16; + sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); + if (!sym_arr) { + free(tmp); + return NULL; + } + } + sym_arr[cnt++] = sym; + } + if (sym_arr) + sym_arr[cnt] = NULL; + regfree(&re); + + return sym_arr; +} + + struct symbol *sym_check_deps(struct symbol *sym); static struct symbol *sym_check_expr_deps(struct expr *e) Index: linux-2.6.10/scripts/kconfig/mconf.c =================================================================== --- linux-2.6.10.orig/scripts/kconfig/mconf.c 2005-01-02 23:24:41.000000000 +0100 +++ linux-2.6.10/scripts/kconfig/mconf.c 2005-01-03 00:27:03.000000000 +0100 @@ -18,7 +18,6 @@ #include <string.h> #include <termios.h> #include <unistd.h> -#include <regex.h> #define LKC_DIRECT_LINK #include "lkc.h" @@ -104,9 +103,7 @@ static void show_helptext(const char *ti static void show_help(struct menu *menu); static void show_readme(void); static void show_file(const char *filename, const char *title, int r, int c); -static void show_expr(struct menu *menu, FILE *fp); -static void search_conf(char *pattern); -static int regex_match(const char *string, regex_t *re); +static void search_conf(void); static void cprint_init(void); static int cprint1(const char *fmt, ...); @@ -279,111 +276,96 @@ static int exec_conf(void) return WEXITSTATUS(stat); } -static int regex_match(const char *string, regex_t *re) +static void search_conf(void) { - int rc; - - rc = regexec(re, string, (size_t) 0, NULL, 0); - if (rc) - return 0; - return 1; -} - -static void show_expr(struct menu *menu, FILE *fp) -{ - bool hit = false; - fprintf(fp, "Depends:\n "); - if (menu->prompt->visible.expr) { - if (!hit) - hit = true; - expr_fprint(menu->prompt->visible.expr, fp); - } - if (!hit) - fprintf(fp, "None"); - if (menu->sym) { - struct property *prop; - hit = false; - fprintf(fp, "\nSelects:\n "); - for_all_properties(menu->sym, prop, P_SELECT) { - if (!hit) - hit = true; - expr_fprint(prop->expr, fp); - } - if (!hit) - fprintf(fp, "None"); - hit = false; - fprintf(fp, "\nSelected by:\n "); - if (menu->sym->rev_dep.expr) { - hit = true; - expr_fprint(menu->sym->rev_dep.expr, fp); - } - if (!hit) - fprintf(fp, "None"); - } -} - -static void search_conf(char *pattern) -{ - struct symbol *sym = NULL; - struct menu *menu[32] = { 0 }; - struct property *prop = NULL; - FILE *fp = NULL; - bool hit = false; - int i, j, k, l; - regex_t re; - - if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB)) + struct symbol *sym, **sym_arr; + struct menu *submenu[8], *menu; + struct property *prop; + FILE *fp; + bool hit; + int i, j, k, stat; + +again: + cprint_init(); + cprint("--title"); + cprint("Search Configuration Parameter"); + cprint("--inputbox"); + cprint("Enter Keyword"); + cprint("10"); + cprint("75"); + cprint(""); + stat = exec_conf(); + if (stat < 0) + goto again; + switch (stat) { + case 0: + break; + case 1: + show_helptext("Search Configuration", "to be filled in..."); + goto again; + default: return; - + } fp = fopen(".search.tmp", "w"); if (fp == NULL) { perror("fopen"); return; } - for_all_symbols(i, sym) { - if (!sym->name) - continue; - if (!regex_match(sym->name, &re)) - continue; + + sym_arr = sym_re_search(input_buf, 0); + for (i = 0; sym_arr && (sym = sym_arr[i]); i++) { + fprintf(fp, "Symbol: %s\n", sym->name); for_all_prompts(sym, prop) { - struct menu *submenu = prop->menu; - if (!submenu) - continue; - j = 0; - hit = false; - while (submenu) { - menu[j++] = submenu; - submenu = submenu->parent; - } + fprintf(fp, "Prompt: %s\n", prop->text); + fprintf(fp, " Defined at %s:%d\n", prop->menu->file->name, + prop->menu->lineno); + if (!expr_is_yes(prop->visible.expr)) { + fprintf(fp, " Depends on: "); + expr_fprint(prop->visible.expr, fp); + fprintf(fp, "\n"); + } + menu = prop->menu->parent; + for (j = 0; menu != &rootmenu && j < 8; menu = menu->parent) + submenu[j++] = menu; if (j > 0) { - if (!hit) - hit = true; - fprintf(fp, "%s (%s)\n", prop->text, sym->name); - fprintf(fp, "Location:\n"); - } - for (k = j-2, l=1; k > 0; k--, l++) { - const char *prompt = menu_get_prompt(menu[k]); - if (menu[k]->sym) - fprintf(fp, "%*c-> %s (%s)\n", - l, ' ', - prompt, - menu[k]->sym->name); - else - fprintf(fp, "%*c-> %s\n", - l, ' ', - prompt); - } - if (hit) { - show_expr(menu[0], fp); - fprintf(fp, "\n\n\n"); + fprintf(fp, " Location:\n"); + for (k = 4; --j >= 0; k += 2) { + menu = submenu[j]; + fprintf(fp, "%*c-> %s", k, ' ', menu_get_prompt(menu)); + if (menu->sym) { + fprintf(fp, " (%s:[%s])", menu->sym->name ? + menu->sym->name : "<choice>", + sym_get_string_value(menu->sym)); + + } + fprintf(fp, "\n"); + } } } + hit = false; + for_all_properties(sym, prop, P_SELECT) { + if (!hit) { + fprintf(fp, " Selects: "); + hit = true; + } else + fprintf(fp, " && "); + expr_fprint(prop->expr, fp); + } + if (hit) + fprintf(fp, "\n"); + if (sym->rev_dep.expr) { + fprintf(fp, " Selected by: "); + expr_fprint(sym->rev_dep.expr, fp); + fprintf(fp, "\n"); + } + fprintf(fp, "\n\n"); } - if (!hit) - fprintf(fp, "No matches found."); - regfree(&re); + if (!i) + fprintf(fp, "No matches found.\n"); + + free(sym_arr); fclose(fp); - show_file(".search.tmp", "Search Results", rows, cols); + show_file(".search.tmp", "Search Results", 0, 0); unlink(".search.tmp"); } @@ -576,23 +558,6 @@ static void conf(struct menu *menu) cprint(" Save Configuration to an Alternate File"); } stat = exec_conf(); - if (stat == 26) { - char *pattern; - - if (!strlen(input_buf)) - continue; - pattern = malloc(sizeof(char)*sizeof(input_buf)); - if (pattern == NULL) { - perror("malloc"); - continue; - } - for (i = 0; input_buf[i]; i++) - pattern[i] = toupper(input_buf[i]); - pattern[i] = '\0'; - search_conf(pattern); - free(pattern); - continue; - } if (stat < 0) continue; @@ -669,6 +634,9 @@ static void conf(struct menu *menu) else if (type == 'm') conf(submenu); break; + case 7: + search_conf(); + break; } } } @@ -686,7 +654,7 @@ static void show_textbox(const char *tit static void show_helptext(const char *title, const char *text) { - show_textbox(title, text, rows, cols); + show_textbox(title, text, 0, 0); } static void show_help(struct menu *menu) @@ -709,7 +677,7 @@ static void show_help(struct menu *menu) static void show_readme(void) { - show_file("scripts/README.Menuconfig", NULL, rows, cols); + show_file("scripts/README.Menuconfig", NULL, 0, 0); } static void show_file(const char *filename, const char *title, int r, int c) @@ -722,8 +690,8 @@ static void show_file(const char *filena } cprint("--textbox"); cprint("%s", filename); - cprint("%d", r); - cprint("%d", c); + cprint("%d", r ? r : rows); + cprint("%d", c ? c : cols); } while (exec_conf() < 0); } Index: linux-2.6.10/scripts/kconfig/lkc_proto.h =================================================================== --- linux-2.6.10.orig/scripts/kconfig/lkc_proto.h 2005-01-02 23:24:41.000000000 +0100 +++ linux-2.6.10/scripts/kconfig/lkc_proto.h 2005-01-03 00:26:53.000000000 +0100 @@ -18,6 +18,7 @@ P(sym_change_count,int,); P(sym_lookup,struct symbol *,(const char *name, int isconst)); P(sym_find,struct symbol *,(const char *name)); +P(sym_re_search,struct symbol **,(const char *pattern, int flags)); P(sym_type_name,const char *,(enum symbol_type type)); P(sym_calc_value,void,(struct symbol *sym)); P(sym_get_type,enum symbol_type,(struct symbol *sym)); ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: kconfig: 2005-01-03 0:34 ` kconfig: Roman Zippel @ 2005-01-03 5:11 ` Sam Ravnborg 0 siblings, 0 replies; 15+ messages in thread From: Sam Ravnborg @ 2005-01-03 5:11 UTC (permalink / raw) To: Roman Zippel; +Cc: Sam Ravnborg, linux-kernel On Mon, Jan 03, 2005 at 01:34:36AM +0100, Roman Zippel wrote: > Hi, > > On Friday 31 December 2004 00:51, Sam Ravnborg wrote: > > > Here follows a few kconfig patches. > > Main purpose is to improve readability of the output when doing search > > and to inculde dependency information in the help text. > > I completely missed that the search patch was already merged... :-( > It wasn't ready yet, it was still a quick hack. I attached a patch which does > the basic cleanup, so that it not only works for the trivial cases. Thanks - looks good at first sight. I will give it a spin and post updated kconfig patches. Sam ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <fa.hcrei7d.knakqt@ifi.uio.no>]
[parent not found: <fa.gau82p1.1g24ton@ifi.uio.no>]
* Re: kconfig: help includes dependency information [not found] ` <fa.gau82p1.1g24ton@ifi.uio.no> @ 2005-01-01 8:58 ` Bodo Eggert 0 siblings, 0 replies; 15+ messages in thread From: Bodo Eggert @ 2005-01-01 8:58 UTC (permalink / raw) To: Ingo Oeser, linux-kernel Ingo Oeser wrote: >> # kconfig: help includes dependency information > "depends on:" is not really needed, since you usually cannot select any > option, where you didn't fulfill the dependencies, AFAICS. If you can't select the option, you'll still be able to see it in xconfig and read which option you missed to select. ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2005-01-06 15:40 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-12-30 23:51 kconfig: Sam Ravnborg 2004-12-30 23:52 ` kconfig: avoid temporary file Sam Ravnborg 2005-01-03 0:55 ` Roman Zippel 2005-01-03 5:10 ` Sam Ravnborg 2005-01-05 12:40 ` Roman Zippel 2005-01-05 18:14 ` Sam Ravnborg 2005-01-06 14:53 ` Roman Zippel 2004-12-30 23:52 ` kconfig: remove noise from show_expr Sam Ravnborg 2004-12-30 23:53 ` kconfig: help includes dependency information Sam Ravnborg 2005-01-01 4:02 ` Ingo Oeser 2005-01-02 20:16 ` Sam Ravnborg 2005-01-03 19:24 ` Ingo Oeser 2005-01-03 0:34 ` kconfig: Roman Zippel 2005-01-03 5:11 ` kconfig: Sam Ravnborg [not found] <fa.hcrei7d.knakqt@ifi.uio.no> [not found] ` <fa.gau82p1.1g24ton@ifi.uio.no> 2005-01-01 8:58 ` kconfig: help includes dependency information Bodo Eggert
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).