public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* searching for parameters in 'make menuconfig'
@ 2004-08-30  9:28 Yuval Turgeman
  2004-08-30 16:29 ` Randy.Dunlap
  2004-08-31  9:04 ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Yuval Turgeman @ 2004-08-30  9:28 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

Hello,
I added the ability to search for parameters in make menuconfig (find
a given parameter's location in the tree).
The patch is for the 2.6.8.1 release.
Thanks,

-- 
Yuval Turgeman

[-- Attachment #2: mconf_search.diff --]
[-- Type: text/plain, Size: 4166 bytes --]

diff -Nru a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
--- a/scripts/kconfig/mconf.c	2004-08-14 13:54:51.000000000 +0300
+++ b/scripts/kconfig/mconf.c	2004-08-30 12:08:23.000000000 +0300
@@ -28,7 +28,7 @@
 	"<Enter> selects submenus --->.  "
 	"Highlighted letters are hotkeys.  "
 	"Pressing <Y> includes, <N> excludes, <M> modularizes features.  "
-	"Press <Esc><Esc> to exit, <?> for Help.  "
+	"Press <Esc><Esc> to exit, <?> for Help, </> for Search.  "
 	"Legend: [*] built-in  [ ] excluded  <M> module  < > module capable",
 radiolist_instructions[] =
 	"Use the arrow keys to navigate this window or "
@@ -102,6 +102,7 @@
 static void show_helptext(const char *title, const char *text);
 static void show_help(struct menu *menu);
 static void show_readme(void);
+static void search_conf(char *);
 
 static void cprint_init(void);
 static int cprint1(const char *fmt, ...);
@@ -274,6 +275,84 @@
 	return WEXITSTATUS(stat);
 }
 
+static struct menu *do_search(struct menu *menu, struct symbol *sym)
+{
+	struct menu *child, *ret;
+	/* Ignore invisible menus ?
+	if (!menu_is_visible(menu))
+		return NULL;
+	*/
+
+	if ( menu->sym ) {
+		if ( menu->sym->name && !strcmp(menu->sym->name, sym->name )) {
+			return menu;
+		}
+	}
+	for (child = menu->list; child; child = child->next) {
+		ret = do_search(child, sym);
+		if ( ret ) return ret;
+	}
+	return NULL;
+}
+
+static void search_conf(char *search_str)
+{
+    struct symbol *sym;
+	struct menu *menu[32] = { 0 };
+	int i, j, k;
+	FILE *fp;
+	bool hit = false;
+
+	fp = fopen(".search.tmp", "w");
+	if ( fp == NULL ) {
+		perror("fopen");
+		return;
+	}
+	for_all_symbols(i, sym) {
+		if ( sym->name && strstr(sym->name, search_str) ) {
+			struct menu *submenu = do_search(&rootmenu, sym);
+			j = 0;
+			while ( submenu ) {
+				menu[j++] = submenu;
+				submenu = submenu->parent;
+			}
+			if ( j > 0 ) {
+				if ( sym->prop && sym->prop->text ) {
+					fprintf(fp, "%s (%s)\n", sym->prop->text, sym->name);
+				} else {
+					fprintf(fp, "%s\n", sym->name);
+				}
+			}
+			for (k = j-2; k > 0; k-- ) {
+				if ( ! hit ) hit = true;
+				submenu = menu[k];
+				const char *prompt = menu_get_prompt(submenu);
+				if ( submenu->sym ) {
+					fprintf(fp, " -> %s (%s)\n", prompt, submenu->sym->name);
+				} else {
+					fprintf(fp, " -> %s\n", prompt);
+				}
+			}
+			if ( hit )
+				fprintf(fp, "\n");
+		}
+    }
+	if ( ! hit ) {
+		fprintf(fp, "No matches found.");
+	}
+	fclose(fp);
+    do {
+        cprint_init();
+        cprint("--title");
+        cprint("Search Results");
+        cprint("--textbox");
+        cprint(".search.tmp");
+        cprint("%d", rows);
+        cprint("%d", cols);
+    } while (exec_conf() < 0);
+	unlink(".search.tmp");
+}
+
 static void build_conf(struct menu *menu)
 {
 	struct symbol *sym;
@@ -463,6 +542,23 @@
 			cprint("    Save Configuration to an Alternate File");
 		}
 		stat = exec_conf();
+		if ( stat == 26 ) {
+			if ( ! strlen(input_buf) ) continue;
+			char *search_str = (char*)malloc(sizeof(char)*sizeof(input_buf));
+			if ( search_str == NULL ) {
+				perror("malloc");
+				continue;
+			}
+			/* Capitalizing the string */
+			for ( i = 0; input_buf[i]; i++ ) {
+				search_str[i] = toupper(input_buf[i]);
+			}
+			search_str[i] = '\0';
+			/* Searching and displaying all matches */
+			search_conf( search_str );
+			free(search_str);
+			continue;
+		}
 		if (stat < 0)
 			continue;
 
diff -Nru a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c
--- a/scripts/lxdialog/menubox.c	2004-08-14 13:56:22.000000000 +0300
+++ b/scripts/lxdialog/menubox.c	2004-08-30 12:09:02.000000000 +0300
@@ -276,6 +276,16 @@
 
     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);
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: searching for parameters in 'make menuconfig'
  2004-08-30  9:28 searching for parameters in 'make menuconfig' Yuval Turgeman
@ 2004-08-30 16:29 ` Randy.Dunlap
  2004-08-31  9:04 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Randy.Dunlap @ 2004-08-30 16:29 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: linux-kernel

On Mon, 30 Aug 2004 12:28:07 +0300 Yuval Turgeman wrote:

| Hello,
| I added the ability to search for parameters in make menuconfig (find
| a given parameter's location in the tree).
| The patch is for the 2.6.8.1 release.

That's nice.  Thanks.

--
~Randy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: searching for parameters in 'make menuconfig'
  2004-08-30  9:28 searching for parameters in 'make menuconfig' Yuval Turgeman
  2004-08-30 16:29 ` Randy.Dunlap
@ 2004-08-31  9:04 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2004-08-31  9:04 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: linux-kernel

Yuval Turgeman <yuvalt@gmail.com> wrote:
>
> I added the ability to search for parameters in make menuconfig (find
>  a given parameter's location in the tree).

Well that beats grepping the Kconfig files.  Thanks - I just used it.

I extensively reworked your code layout.  Please follow
Documentation/CodginStyle, and the surrounding code in future.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-31  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-30  9:28 searching for parameters in 'make menuconfig' Yuval Turgeman
2004-08-30 16:29 ` Randy.Dunlap
2004-08-31  9:04 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox