mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
The menu already limits entries with MENU_MAXENTRY, so don't bother
holding a command name limit as well.
This commit is contained in:
parent
fd827fd757
commit
0a71742af4
7
calmwm.h
7
calmwm.h
@ -259,10 +259,9 @@ TAILQ_HEAD(keybinding_q, binding);
|
|||||||
TAILQ_HEAD(mousebinding_q, binding);
|
TAILQ_HEAD(mousebinding_q, binding);
|
||||||
|
|
||||||
struct cmd {
|
struct cmd {
|
||||||
TAILQ_ENTRY(cmd) entry;
|
TAILQ_ENTRY(cmd) entry;
|
||||||
#define CMD_MAXNAMELEN 256
|
char *name;
|
||||||
char name[CMD_MAXNAMELEN];
|
char path[MAXPATHLEN];
|
||||||
char path[MAXPATHLEN];
|
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(cmd_q, cmd);
|
TAILQ_HEAD(cmd_q, cmd);
|
||||||
|
|
||||||
|
10
conf.c
10
conf.c
@ -51,13 +51,11 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
|
|||||||
sizeof(c->lockpath))
|
sizeof(c->lockpath))
|
||||||
return (0);
|
return (0);
|
||||||
} else {
|
} else {
|
||||||
cmd = xmalloc(sizeof(*cmd));
|
|
||||||
|
|
||||||
conf_cmd_remove(c, name);
|
conf_cmd_remove(c, name);
|
||||||
|
|
||||||
if (strlcpy(cmd->name, name, sizeof(cmd->name)) >=
|
cmd = xmalloc(sizeof(*cmd));
|
||||||
sizeof(cmd->name))
|
|
||||||
return (0);
|
cmd->name = xstrdup(name);
|
||||||
if (strlcpy(cmd->path, path, sizeof(cmd->path)) >=
|
if (strlcpy(cmd->path, path, sizeof(cmd->path)) >=
|
||||||
sizeof(cmd->path))
|
sizeof(cmd->path))
|
||||||
return (0);
|
return (0);
|
||||||
@ -74,6 +72,7 @@ conf_cmd_remove(struct conf *c, const char *name)
|
|||||||
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
|
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
|
||||||
if (strcmp(cmd->name, name) == 0) {
|
if (strcmp(cmd->name, name) == 0) {
|
||||||
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
||||||
|
free(cmd->name);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,6 +290,7 @@ conf_clear(struct conf *c)
|
|||||||
|
|
||||||
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
|
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
|
||||||
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
||||||
|
free(cmd->name);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user