aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-03-18 19:46:51 +0100
committerWolfgang Müller2021-04-27 12:28:35 +0200
commita0387a0fd66954e024c926655c866a3ab80e460f (patch)
tree0272f0158f5424cfcdbdccdabe3f31f4a29919a3
parent8dc8d620c2f5873408b34385d9ca763574655b13 (diff)
downloadcwm-a0387a0fd66954e024c926655c866a3ab80e460f.tar.gz
Remove path completion in the exec menu
There are a couple of issues I found with this functionality: 1) To my knowledge, it is undocumented and extremely specific. 2) Since this function would only complete a full path (by wrapping it in quotes before passing it on), it is entirely useless when composing a command that has more than one argument. 3) The snprintf call has no check for truncation, possibly leading to the path not being quoted properly.
-rw-r--r--calmwm.h2
-rw-r--r--menu.c39
-rw-r--r--search.c7
3 files changed, 0 insertions, 48 deletions
diff --git a/calmwm.h b/calmwm.h
index 521f8d8..030dfac 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -472,8 +472,6 @@ void search_match_exec(struct menu_q *, struct menu_q *,
char *);
void search_match_group(struct menu_q *, struct menu_q *,
char *);
-void search_match_path(struct menu_q *, struct menu_q *,
- char *);
void search_match_text(struct menu_q *, struct menu_q *,
char *);
void search_match_wm(struct menu_q *, struct menu_q *,
diff --git a/menu.c b/menu.c
index 60ee46a..6648286 100644
--- a/menu.c
+++ b/menu.c
@@ -76,7 +76,6 @@ static void menu_draw(struct menu_ctx *, struct menu_q *,
static void menu_draw_entry(struct menu_ctx *, struct menu_q *,
int, int);
static int menu_calc_entry(struct menu_ctx *, int, int);
-static struct menu *menu_complete_path(struct menu_ctx *);
static int menu_keycode(XKeyEvent *, enum ctltype *, char *);
struct menu *
@@ -189,34 +188,6 @@ out:
}
static struct menu *
-menu_complete_path(struct menu_ctx *mc)
-{
- struct screen_ctx *sc = mc->sc;
- struct menu *mi, *mr;
- struct menu_q menuq;
- int mflags = (CWM_MENU_DUMMY);
-
- mr = xcalloc(1, sizeof(*mr));
-
- TAILQ_INIT(&menuq);
-
- if ((mi = menu_filter(sc, &menuq, mc->searchstr, NULL, mflags,
- search_match_path, search_print_text)) != NULL) {
- mr->abort = mi->abort;
- mr->dummy = mi->dummy;
- if (mi->text[0] != '\0')
- snprintf(mr->text, sizeof(mr->text), "%s \"%s\"",
- mc->searchstr, mi->text);
- else if (!mr->abort)
- strlcpy(mr->text, mc->searchstr, sizeof(mr->text));
- }
-
- menuq_clear(&menuq);
-
- return mr;
-}
-
-static struct menu *
menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
struct menu_q *resultq)
{
@@ -277,16 +248,6 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
case CTL_TAB:
if ((mi = TAILQ_FIRST(resultq)) != NULL) {
/*
- * - We are in exec_path menu mode
- * - It is equal to the input
- * We got a command, launch the file menu
- */
- if ((mc->flags & CWM_MENU_FILE) &&
- (strncmp(mc->searchstr, mi->text,
- strlen(mi->text))) == 0)
- return menu_complete_path(mc);
-
- /*
* Put common prefix of the results into searchstr
*/
(void)strlcpy(mc->searchstr,
diff --git a/search.c b/search.c
index 591a7c3..df6f74c 100644
--- a/search.c
+++ b/search.c
@@ -206,13 +206,6 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
}
void
-search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search)
-{
- TAILQ_INIT(resultq);
- match_path_type(resultq, search, PATH_ANY);
-}
-
-void
search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
{
struct menu *mi;