public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Menuconfig search changes - pt. 3
@ 2004-09-03 19:00 Yuval Turgeman
  2004-09-04  0:47 ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-03 19:00 UTC (permalink / raw)
  To: sam, zippel, rddunlap; +Cc: linux-kernel

Changes -
The search results are indented.
Added "Selects" to the search results.
The patch is finally attached as inline text... :-)
(Once again, this patch should be applied after Andrew's changes)

Signed-off-by: Yuval Turgeman <yuvalt@gmail.com>

diff -uprN linux-2.6.8.1/scripts/kconfig/mconf.c linux/scripts/kconfig/mconf.c
--- linux-2.6.8.1/scripts/kconfig/mconf.c	2004-09-02 23:36:30.000000000 +0300
+++ linux/scripts/kconfig/mconf.c	2004-09-02 23:30:58.000000000 +0300
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
+#include <regex.h>
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
@@ -102,7 +103,10 @@ static void show_textbox(const char *tit
 static void show_helptext(const char *title, const char *text);
 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 *);
+static int regex_match(const char *, char *);
 
 static void cprint_init(void);
 static int cprint1(const char *fmt, ...);
@@ -275,33 +279,59 @@ static int exec_conf(void)
 	return WEXITSTATUS(stat);
 }
 
-static struct menu *do_search(struct menu *menu, struct symbol *sym)
+static int regex_match(const char *string, char *pattern)
 {
-	struct menu *child, *ret;
-	/* Ignore invisible menus ?
-	if (!menu_is_visible(menu))
-		return NULL;
-	*/
+	regex_t re;
+	int rc;
 
-	if (menu->sym) {
-		if (menu->sym->name && !strcmp(menu->sym->name, sym->name))
-			return menu;
+	if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB))
+		return 0;
+	rc = regexec(&re, string, (size_t) 0, NULL, 0);
+	regfree(&re);
+	if (rc)
+		return 0;
+	return 1;
+}
+
+static void show_expr(struct menu *menu, FILE *fp)
+{
+	bool hit = false;
+	fprintf(fp, "Depends:\n ");
+	if (menu->dep) {
+		if (!hit)
+			hit = true;
+		expr_fprint(menu->dep, fp);
+	}
+	if (menu->sym && menu->sym->dep) {
+		if (!hit)
+			hit = true;
+		expr_fprint(menu->sym->dep, fp);
 	}
-	for (child = menu->list; child; child = child->next) {
-		ret = do_search(child, sym);
-		if (ret)
-			return ret;
+	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");
 	}
-	return NULL;
 }
 
 static void search_conf(char *search_str)
 {
-	struct symbol *sym;
+	struct symbol *sym = NULL;
 	struct menu *menu[32] = { 0 };
-	int i, j, k;
-	FILE *fp;
+	struct property *prop = NULL;
+	char *space = NULL;
+	FILE *fp = NULL;
 	bool hit = false;
+	int i, j, k, l;
 
 	fp = fopen(".search.tmp", "w");
 	if (fp == NULL) {
@@ -309,49 +339,59 @@ static void search_conf(char *search_str
 		return;
 	}
 	for_all_symbols(i, sym) {
-		if (sym->name && strstr(sym->name, search_str)) {
-			struct menu *submenu = do_search(&rootmenu, sym);
-
+		if (!sym->name)
+			continue;
+		if (!regex_match(sym->name, search_str))
+			continue;
+		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;
 			}
 			if (j > 0) {
-				if (sym->prop && sym->prop->text)
-					fprintf(fp, "%s (%s)\n",
-						sym->prop->text, sym->name);
+				if (!hit)
+					hit = true;
+				if (prop->text)
+					fprintf(fp, "%s (%s)\n", prop->text, 
+								sym->name);
 				else
 					fprintf(fp, "%s\n", sym->name);
+				fprintf(fp, "Location:\n");
 			}
-			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);
+			space = (char*)malloc(sizeof(char)*j);
+			if (space == NULL) {
+				perror("malloc");
+				continue;
+			}
+			memset(space, ' ', j);
+			for (k = j-2, l=1; k > 0; k--, l++) {
+				const char *prompt = menu_get_prompt(menu[k]);
+				space[l-1] = ' ';
+				space[l] = '\0';
+				if (menu[k]->sym)
+					fprintf(fp, "%s-> %s (%s)\n", 
+								space, prompt,
+								menu[k]->sym->name);
 				else
-					fprintf(fp, " -> %s\n", prompt);
+					fprintf(fp, "%s-> %s\n", space, 
+								prompt);
+			}
+			free(space);
+			if (hit) {
+				show_expr(menu[0], fp);
+				fprintf(fp, "\n\n\n");
 			}
-			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);
+	show_file(".search.tmp", "Search Results", rows, cols);
 	unlink(".search.tmp");
 }
 
@@ -554,11 +594,9 @@ static void conf(struct menu *menu)
 				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;
@@ -650,17 +688,7 @@ static void show_textbox(const char *tit
 	fd = creat(".help.tmp", 0777);
 	write(fd, text, strlen(text));
 	close(fd);
-	do {
-		cprint_init();
-		if (title) {
-			cprint("--title");
-			cprint("%s", title);
-		}
-		cprint("--textbox");
-		cprint(".help.tmp");
-		cprint("%d", r);
-		cprint("%d", c);
-	} while (exec_conf() < 0);
+	show_file(".help.tmp", title, r, c);
 	unlink(".help.tmp");
 }
 
@@ -689,13 +717,22 @@ static void show_help(struct menu *menu)
 
 static void show_readme(void)
 {
+	show_file("scripts/README.Menuconfig", NULL, rows, cols);
+}
+
+static void show_file(const char *filename, const char *title, int r, int c)
+{
 	do {
 		cprint_init();
+		if (title) {
+			cprint("--title");
+			cprint("%s", title);
+		}
 		cprint("--textbox");
-		cprint("scripts/README.Menuconfig");
-		cprint("%d", rows);
-		cprint("%d", cols);
-	} while (exec_conf() == -1);
+		cprint("%s", filename);
+		cprint("%d", r);
+		cprint("%d", c);
+	} while (exec_conf() < 0);
 }
 
 static void conf_choice(struct menu *menu)

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-03 19:00 [PATCH] Menuconfig search changes - pt. 3 Yuval Turgeman
@ 2004-09-04  0:47 ` Roman Zippel
  2004-09-04 17:13   ` Yuval Turgeman
  0 siblings, 1 reply; 12+ messages in thread
From: Roman Zippel @ 2004-09-04  0:47 UTC (permalink / raw)
  To: yuvalt; +Cc: sam, rddunlap, linux-kernel

Hi,

On Fri, 3 Sep 2004, Yuval Turgeman wrote:

> (Once again, this patch should be applied after Andrew's changes)

Please send a complete patch, it makes commenting on it easier.

> +	if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB))
> +		return 0;
> +	rc = regexec(&re, string, (size_t) 0, NULL, 0);
> +	regfree(&re);

You shouldn't compute the pattern at every search.

> +static void show_expr(struct menu *menu, FILE *fp)
> +{
> +	bool hit = false;
> +	fprintf(fp, "Depends:\n ");
> +	if (menu->dep) {
> +		if (!hit)
> +			hit = true;
> +		expr_fprint(menu->dep, fp);
> +	}

menu->dep contains only temporary information. The real information is in 
prop->visible.expr.

> +	if (menu->sym && menu->sym->dep) {
> +		if (!hit)
> +			hit = true;
> +		expr_fprint(menu->sym->dep, fp);
>  	}

sym->dep doesn't contain user relevant information.

> +	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);
> +		}

With this you print all selection with every menu entry.
You probably also want to print sym->rev_dep, which is used to calculate 
the selections for this symbol.

>  			while (submenu) {
>  				menu[j++] = submenu;
>  				submenu = submenu->parent;
>  			}

This loop should stop when you find root_menu.

>  			if (j > 0) {
> +				if (!hit)
> +					hit = true;
> +				if (prop->text)
> +					fprintf(fp, "%s (%s)\n", prop->text, 
> +								sym->name);
>  				else
>  					fprintf(fp, "%s\n", sym->name);

This test isn't necessary, every prompt has a text.

> +			space = (char*)malloc(sizeof(char)*j);

This isn't necessary, just use "%*c" like the other indentations.

bye, Roman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-04  0:47 ` Roman Zippel
@ 2004-09-04 17:13   ` Yuval Turgeman
  2004-09-13 23:16     ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-04 17:13 UTC (permalink / raw)
  To: Roman Zippel; +Cc: sam, rddunlap, linux-kernel

On Sat, 4 Sep 2004 02:47:29 +0200 (CEST), Roman Zippel
<zippel@linux-m68k.org> wrote:

> Please send a complete patch, it makes commenting on it easier.

Ok, will do.

> You shouldn't compute the pattern at every search.
You are correct, I fixed it.

> menu->dep contains only temporary information. The real information is in
> prop->visible.expr.
Fixed that also... 

> sym->dep doesn't contain user relevant information.
Fixed.

> With this you print all selection with every menu entry.
> You probably also want to print sym->rev_dep, which is used to calculate
> the selections for this symbol.
I wasn't really aware of rev_dep - very cool! Added a "Selected by" tag also.

> 
> >                       while (submenu) {
> >                               menu[j++] = submenu;
> >                               submenu = submenu->parent;
> >                       }
> 
> This loop should stop when you find root_menu.
It does stop when it gets to rootmenu (rootmenu's parent is NULL).

> 
> >                       if (j > 0) {
> > +                             if (!hit)
> > +                                     hit = true;
> > +                             if (prop->text)
> > +                                     fprintf(fp, "%s (%s)\n", prop->text,
> > +                                                             sym->name);
> >                               else
> >                                       fprintf(fp, "%s\n", sym->name);
> 
> This test isn't necessary, every prompt has a text.
Left overs from the old menu search.  Removed.

> 
> > +                     space = (char*)malloc(sizeof(char)*j);
> 
> This isn't necessary, just use "%*c" like the other indentations.
Ok - I keep learning new stuff.... :) - Done also.

I'll submit a final patch against mm3 soon.
Thanks for the help!


-- 
Yuval Turgeman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-04 17:13   ` Yuval Turgeman
@ 2004-09-13 23:16     ` Roman Zippel
  2004-09-14 10:53       ` Yuval Turgeman
  0 siblings, 1 reply; 12+ messages in thread
From: Roman Zippel @ 2004-09-13 23:16 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: Sam Ravnborg, linux-kernel

Hi,

On Sat, 4 Sep 2004, Yuval Turgeman wrote:

> > Please send a complete patch, it makes commenting on it easier.
> 
> Ok, will do.

Could you please resend one complete (logical) patch.
Something I'd really like to see before merging this (besides other small 
fixes) is separating the search into a function, which returns the result 
in a NULL terminated, allocated array.

bye, Roman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-13 23:16     ` Roman Zippel
@ 2004-09-14 10:53       ` Yuval Turgeman
  2004-09-14 11:00         ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-14 10:53 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Sam Ravnborg, linux-kernel

On Tue, 14 Sep 2004 01:16:01 +0200 (CEST), Roman Zippel
<zippel@linux-m68k.org> wrote:

> Could you please resend one complete (logical) patch.

I did - http://lkml.org/lkml/2004/9/4/155 (patch against mm3)

> Something I'd really like to see before merging this (besides other small
> fixes) is separating the search into a function, which returns the result
> in a NULL terminated, allocated array.

I agree - exporting the search function to a seperate location in
order to use it in other guis (the patch above only applies to mconf).

Thanks,
Yuval.

--
Yuval Turgeman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 10:53       ` Yuval Turgeman
@ 2004-09-14 11:00         ` Roman Zippel
  2004-09-14 11:10           ` Yuval Turgeman
  0 siblings, 1 reply; 12+ messages in thread
From: Roman Zippel @ 2004-09-14 11:00 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: Sam Ravnborg, linux-kernel

Hi,

On Tue, 14 Sep 2004, Yuval Turgeman wrote:

> > Could you please resend one complete (logical) patch.
> 
> I did - http://lkml.org/lkml/2004/9/4/155 (patch against mm3)

That's only one part of the patch, it's only arbitrary splitted, I need 
the merged patch to properly comment on it.

bye, Roman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 11:00         ` Roman Zippel
@ 2004-09-14 11:10           ` Yuval Turgeman
  2004-09-14 11:45             ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-14 11:10 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Sam Ravnborg, linux-kernel

On Tue, 14 Sep 2004 13:00:43 +0200 (CEST), Roman Zippel
<zippel@linux-m68k.org> wrote:
> Hi,
> 
> On Tue, 14 Sep 2004, Yuval Turgeman wrote:
> 
> > > Could you please resend one complete (logical) patch.
> >
> > I did - http://lkml.org/lkml/2004/9/4/155 (patch against mm3)
> 
> That's only one part of the patch, it's only arbitrary splitted, I need
> the merged patch to properly comment on it.

Ok, the first patch was against 2.6.8.1 which was inserted to mm3
(along with Andrew's coding style modifications).  The patch mentioned
above is against mm3 (so there are 2 patches...)
Do you want a complete patch against 2.6.8.1 ?  It could be arranged easily.

Thanks,
Yuval.

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 11:10           ` Yuval Turgeman
@ 2004-09-14 11:45             ` Roman Zippel
  0 siblings, 0 replies; 12+ messages in thread
From: Roman Zippel @ 2004-09-14 11:45 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: Sam Ravnborg, linux-kernel

Hi,

On Tue, 14 Sep 2004, Yuval Turgeman wrote:

> Ok, the first patch was against 2.6.8.1 which was inserted to mm3
> (along with Andrew's coding style modifications).  The patch mentioned
> above is against mm3 (so there are 2 patches...)

There is no reason to keep these patches apart, the first one wasn't 
finished and it also wasn't logically separate from the second.

> Do you want a complete patch against 2.6.8.1 ?  It could be arranged easily.

Yes, thanks.

bye, Roman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
@ 2004-09-14 12:14 Yuval Turgeman
  2004-09-14 17:53 ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-14 12:14 UTC (permalink / raw)
  To: zippel, sam; +Cc: linux-kernel

On Tue, 14 Sep 2004 13:45:27 +0200 (CEST), Roman Zippel <zippel@linux-m68k.org> wrote:

> Yes, thanks.

Ok then,
Here's a complete patch of the changes against 2.6.8.1.

diff -uprN linux-2.6.8.1/scripts/kconfig/mconf.c linux-2.6.9-rc1-mm5/scripts/kconfig/mconf.c
--- linux-2.6.8.1/scripts/kconfig/mconf.c	2004-08-14 13:54:51.000000000 +0300
+++ linux-2.6.9-rc1-mm5/scripts/kconfig/mconf.c	2004-09-14 15:00:21.000000000 +0300
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
+#include <regex.h>
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
@@ -28,7 +29,7 @@ static const char menu_instructions[] =
 	"<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 "
@@ -88,7 +89,7 @@ static char *args[1024], **argptr = args
 static int indent;
 static struct termios ios_org;
 static int rows = 0, cols = 0;
-static struct menu *current_menu;
+struct menu *current_menu;
 static int child_count;
 static int do_resize;
 static int single_menu_mode;
@@ -102,6 +103,10 @@ static void show_textbox(const char *tit
 static void show_helptext(const char *title, const char *text);
 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 cprint_init(void);
 static int cprint1(const char *fmt, ...);
@@ -274,6 +279,114 @@ static int exec_conf(void)
 	return WEXITSTATUS(stat);
 }
 
+static int regex_match(const char *string, regex_t *re)
+{
+	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))
+		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;
+		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;
+			}
+			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");
+			}
+		}
+	}
+	if (!hit)
+		fprintf(fp, "No matches found.");
+	regfree(&re);
+	fclose(fp);
+	show_file(".search.tmp", "Search Results", rows, cols);
+	unlink(".search.tmp");
+}
+
 static void build_conf(struct menu *menu)
 {
 	struct symbol *sym;
@@ -463,6 +576,23 @@ 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;
 
@@ -550,17 +680,7 @@ static void show_textbox(const char *tit
 	fd = creat(".help.tmp", 0777);
 	write(fd, text, strlen(text));
 	close(fd);
-	do {
-		cprint_init();
-		if (title) {
-			cprint("--title");
-			cprint("%s", title);
-		}
-		cprint("--textbox");
-		cprint(".help.tmp");
-		cprint("%d", r);
-		cprint("%d", c);
-	} while (exec_conf() < 0);
+	show_file(".help.tmp", title, r, c);
 	unlink(".help.tmp");
 }
 
@@ -589,13 +709,22 @@ static void show_help(struct menu *menu)
 
 static void show_readme(void)
 {
+	show_file("scripts/README.Menuconfig", NULL, rows, cols);
+}
+
+static void show_file(const char *filename, const char *title, int r, int c)
+{
 	do {
 		cprint_init();
+		if (title) {
+			cprint("--title");
+			cprint("%s", title);
+		}
 		cprint("--textbox");
-		cprint("scripts/README.Menuconfig");
-		cprint("%d", rows);
-		cprint("%d", cols);
-	} while (exec_conf() == -1);
+		cprint("%s", filename);
+		cprint("%d", r);
+		cprint("%d", c);
+	} while (exec_conf() < 0);
 }
 
 static void conf_choice(struct menu *menu)
diff -uprN linux-2.6.8.1/scripts/lxdialog/menubox.c linux-2.6.9-rc1-mm5/scripts/lxdialog/menubox.c
--- linux-2.6.8.1/scripts/lxdialog/menubox.c	2004-08-14 13:56:22.000000000 +0300
+++ linux-2.6.9-rc1-mm5/scripts/lxdialog/menubox.c	2004-09-14 15:00:21.000000000 +0300
@@ -276,6 +276,15 @@ 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);

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 12:14 Yuval Turgeman
@ 2004-09-14 17:53 ` Roman Zippel
  2004-09-14 22:19   ` Yuval Turgeman
  0 siblings, 1 reply; 12+ messages in thread
From: Roman Zippel @ 2004-09-14 17:53 UTC (permalink / raw)
  To: yuvalt; +Cc: sam, linux-kernel

Hi,

On Tue, 14 Sep 2004, Yuval Turgeman wrote:

> +static int regex_match(const char *string, regex_t *re)
> +{
> +	int rc;
> +
> +	rc = regexec(re, string, (size_t) 0, NULL, 0);
> +	if (rc)
> +		return 0;
> +	return 1;
> +}

I guess, this doesn't has to be a separate function anymore.

> +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");
> +	}
> +}

This still prints duplicate information, look at how 
ConfigMainWindow::setHelp() in qconf.cc does it. Your function should have 
pretty much the same structure, e.g.

> +	for_all_symbols(i, sym) {
> +		if (!sym->name)
> +			continue;
> +		if (!regex_match(sym->name, &re))
> +			continue;
> +		for_all_prompts(sym, prop) {

here you should iterate over all properties and print the info about it.

> +	if (!hit)
> +		fprintf(fp, "No matches found.");

You could print the number of found symbols here.

>  		stat = exec_conf();
> +		if (stat == 26) {

Move this into the switch part a few lines below and simply use the next 
available number. For this you need to print the currently selected 
symbol and the search string from lxdialog, this way you also return to 
the same previously selected symbol after exiting the search.

bye, Roman

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 17:53 ` Roman Zippel
@ 2004-09-14 22:19   ` Yuval Turgeman
  2004-09-17 15:59     ` Roman Zippel
  0 siblings, 1 reply; 12+ messages in thread
From: Yuval Turgeman @ 2004-09-14 22:19 UTC (permalink / raw)
  To: Roman Zippel; +Cc: sam, linux-kernel

On Tue, 14 Sep 2004 19:53:26 +0200 (CEST), Roman Zippel
<zippel@linux-m68k.org> wrote:
> Hi,
> 
> On Tue, 14 Sep 2004, Yuval Turgeman wrote:
> 
> > +static int regex_match(const char *string, regex_t *re)
> > +{
> > +     int rc;
> > +
> > +     rc = regexec(re, string, (size_t) 0, NULL, 0);
> > +     if (rc)
> > +             return 0;
> > +     return 1;
> > +}
> 
> I guess, this doesn't has to be a separate function anymore.

Ok.

> > +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");
> > +     }
> > +}
> 
> This still prints duplicate information, look at how
> ConfigMainWindow::setHelp() in qconf.cc does it. Your function should have
> pretty much the same structure, e.g.

I don't understand - duplicate information of what ?
Can you perhaps give me an example (it seems to me that i am actually
doing what qconf is doing... printing all the P_SELECT of the all the
properties, printing the dependencies and the reverse dependencies) ?

> > +     for_all_symbols(i, sym) {
> > +             if (!sym->name)
> > +                     continue;
> > +             if (!regex_match(sym->name, &re))
> > +                     continue;
> > +             for_all_prompts(sym, prop) {
> 
> here you should iterate over all properties and print the info about it.

The search prints out plenty of info already - what info do you think
is missing ?

> 
> > +     if (!hit)
> > +             fprintf(fp, "No matches found.");
> 
> You could print the number of found symbols here.

Ok.

> 
> >               stat = exec_conf();
> > +             if (stat == 26) {
> 
> Move this into the switch part a few lines below and simply use the next
> available number. For this you need to print the currently selected
> symbol and the search string from lxdialog, this way you also return to
> the same previously selected symbol after exiting the search.

Ok (although if I remember correctly it does return to selected symbol)

Thanks,
Yuval.

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

* Re: [PATCH] Menuconfig search changes - pt. 3
  2004-09-14 22:19   ` Yuval Turgeman
@ 2004-09-17 15:59     ` Roman Zippel
  0 siblings, 0 replies; 12+ messages in thread
From: Roman Zippel @ 2004-09-17 15:59 UTC (permalink / raw)
  To: Yuval Turgeman; +Cc: sam, linux-kernel

Hi,

On Wed, 15 Sep 2004, Yuval Turgeman wrote:

> > This still prints duplicate information, look at how
> > ConfigMainWindow::setHelp() in qconf.cc does it. Your function should have
> > pretty much the same structure, e.g.
> 
> I don't understand - duplicate information of what ?
> Can you perhaps give me an example (it seems to me that i am actually
> doing what qconf is doing... printing all the P_SELECT of the all the
> properties, printing the dependencies and the reverse dependencies) ?

try the following:

config FOO
	bool "foo1"
	select BAR

config FOO
	bool "foo2"

config BAR
	bool "bar"

> > here you should iterate over all properties and print the info about it.
> 
> The search prints out plenty of info already - what info do you think
> is missing ?

defaults are missing. Don't concentrate too much on the menu structure 
(it's only relevant for the prompts), if you want to print information 
about a symbol, you have to primarily work with the properties.

bye, Roman

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

end of thread, other threads:[~2004-09-17 16:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-03 19:00 [PATCH] Menuconfig search changes - pt. 3 Yuval Turgeman
2004-09-04  0:47 ` Roman Zippel
2004-09-04 17:13   ` Yuval Turgeman
2004-09-13 23:16     ` Roman Zippel
2004-09-14 10:53       ` Yuval Turgeman
2004-09-14 11:00         ` Roman Zippel
2004-09-14 11:10           ` Yuval Turgeman
2004-09-14 11:45             ` Roman Zippel
  -- strict thread matches above, loose matches on Subject: below --
2004-09-14 12:14 Yuval Turgeman
2004-09-14 17:53 ` Roman Zippel
2004-09-14 22:19   ` Yuval Turgeman
2004-09-17 15:59     ` Roman Zippel

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