aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-list-keys.c35
-rw-r--r--cmd-parse.y4
-rw-r--r--cmd.c2
-rw-r--r--layout-custom.c4
-rw-r--r--tty-term.c4
5 files changed, 35 insertions, 14 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 57f65c8e..8636b70a 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -61,8 +61,9 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
struct key_table *table;
struct key_binding *bd;
const char *tablename, *r;
- char *key, *cp, tmp[BUFSIZ];
+ char *key, *cp, *tmp;
int repeat, width, tablewidth, keywidth;
+ size_t tmpsize, tmpused, cplen;
if (self->entry == &cmd_list_commands_entry)
return (cmd_list_keys_commands(self, item));
@@ -101,6 +102,9 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
table = key_bindings_next_table(table);
}
+ tmpsize = 256;
+ tmp = xmalloc(tmpsize);
+
table = key_bindings_first_table ();
while (table != NULL) {
if (tablename != NULL && strcmp(table->name, tablename) != 0) {
@@ -117,20 +121,35 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
r = "-r ";
else
r = " ";
- xsnprintf(tmp, sizeof tmp, "%s-T ", r);
+ tmpused = xsnprintf(tmp, tmpsize, "%s-T ", r);
cp = utf8_padcstr(table->name, tablewidth);
- strlcat(tmp, cp, sizeof tmp);
- strlcat(tmp, " ", sizeof tmp);
+ cplen = strlen(cp) + 1;
+ while (tmpused + cplen + 1 >= tmpsize) {
+ tmpsize *= 2;
+ tmp = xrealloc(tmp, tmpsize);
+ }
+ tmpused = strlcat(tmp, cp, tmpsize);
+ tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
cp = utf8_padcstr(key, keywidth);
- strlcat(tmp, cp, sizeof tmp);
- strlcat(tmp, " ", sizeof tmp);
+ cplen = strlen(cp) + 1;
+ while (tmpused + cplen + 1 >= tmpsize) {
+ tmpsize *= 2;
+ tmp = xrealloc(tmp, tmpsize);
+ }
+ tmpused = strlcat(tmp, cp, tmpsize);
+ tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
cp = cmd_list_print(bd->cmdlist, 1);
- strlcat(tmp, cp, sizeof tmp);
+ cplen = strlen(cp);
+ while (tmpused + cplen + 1 >= tmpsize) {
+ tmpsize *= 2;
+ tmp = xrealloc(tmp, tmpsize);
+ }
+ strlcat(tmp, cp, tmpsize);
free(cp);
cmdq_print(item, "bind-key %s", tmp);
@@ -141,6 +160,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
table = key_bindings_next_table(table);
}
+ free(tmp);
+
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-parse.y b/cmd-parse.y
index 6d2b970c..a51e4f6e 100644
--- a/cmd-parse.y
+++ b/cmd-parse.y
@@ -1245,7 +1245,7 @@ yylex_token_variable(char **buf, size_t *len)
{
struct environ_entry *envent;
int ch, brackets = 0;
- char name[BUFSIZ];
+ char name[1024];
size_t namelen = 0;
const char *value;
@@ -1297,7 +1297,7 @@ yylex_token_tilde(char **buf, size_t *len)
{
struct environ_entry *envent;
int ch;
- char name[BUFSIZ];
+ char name[1024];
size_t namelen = 0;
struct passwd *pw;
const char *home = NULL;
diff --git a/cmd.c b/cmd.c
index 96cedc97..f77176c9 100644
--- a/cmd.c
+++ b/cmd.c
@@ -384,7 +384,7 @@ cmd_find(const char *name, char **cause)
{
const struct cmd_entry **loop, *entry, *found = NULL;
int ambiguous;
- char s[BUFSIZ];
+ char s[8192];
ambiguous = 0;
for (loop = cmd_table; *loop != NULL; loop++) {
diff --git a/layout-custom.c b/layout-custom.c
index e02eead3..d7371292 100644
--- a/layout-custom.c
+++ b/layout-custom.c
@@ -60,7 +60,7 @@ layout_checksum(const char *layout)
char *
layout_dump(struct layout_cell *root)
{
- char layout[BUFSIZ], *out;
+ char layout[8192], *out;
*layout = '\0';
if (layout_append(root, layout, sizeof layout) != 0)
@@ -210,7 +210,7 @@ layout_parse(struct window *w, const char *layout)
}
break;
}
- if (lc->sx != sx || lc->sy != sy) {
+ if (lc->type != LAYOUT_WINDOWPANE && (lc->sx != sx || lc->sy != sy)) {
log_debug("fix layout %u,%u to %u,%u", lc->sx, lc->sy, sx,sy);
layout_print_cell(lc, __func__, 0);
lc->sx = sx - 1; lc->sy = sy - 1;
diff --git a/tty-term.c b/tty-term.c
index 182edd7d..c7c3d11f 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -281,7 +281,7 @@ static char *
tty_term_strip(const char *s)
{
const char *ptr;
- static char buf[BUFSIZ];
+ static char buf[8192];
size_t len;
/* Ignore strings with no padding. */
@@ -309,7 +309,7 @@ tty_term_strip(const char *s)
static char *
tty_term_override_next(const char *s, size_t *offset)
{
- static char value[BUFSIZ];
+ static char value[8192];
size_t n = 0, at = *offset;
if (s[at] == '\0')