mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Add a function that adds an entry to a menuq, normalizing a common code
path; from Tiago Cunha.
This commit is contained in:
11
search.c
11
search.c
@ -172,10 +172,9 @@ search_print_client(struct menu *mi, int list)
|
||||
static void
|
||||
search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag)
|
||||
{
|
||||
struct menu *mi;
|
||||
char pattern[MAXPATHLEN];
|
||||
glob_t g;
|
||||
int i;
|
||||
char pattern[MAXPATHLEN];
|
||||
glob_t g;
|
||||
int i;
|
||||
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
@ -187,9 +186,7 @@ search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, in
|
||||
for (i = 0; i < g.gl_pathc; i++) {
|
||||
if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK))
|
||||
continue;
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, g.gl_pathv[i], sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
||||
menuq_add(resultq, NULL, "%s", g.gl_pathv[i]);
|
||||
}
|
||||
globfree(&g);
|
||||
}
|
||||
|
Reference in New Issue
Block a user