size_t len;
int color;
};
-struct ringbuffer *bot_win_rb;
+static struct ringbuffer *bot_win_rb;
#define NUM_LINES(len) (1 + (len) / bot.cols)
static unsigned scroll_position;
static struct gui_theme theme;
-int _argc;
-char **_argv;
+static int _argc;
+static char **_argv;
static void com_help(void);
static void com_reread_conf(void);
static void com_page_up(void);
static void com_page_down(void);
-struct gui_command command_list[] = {
+static struct gui_command command_list[] = {
{
.key = "?",
.name = "help",
num = 0;
}
/* replace newlines by spaces */
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len && str[i]; i++) {
if (str[i] == '\n')
str[i] = ' ';
}
/* first check user's key bindings */
for (i = 0; i < conf.key_map_given; ++i) {
- char tmp[MAXLINE], *handler, *arg;
+ char *tmp, *handler, *arg;
- strcpy(tmp, conf.key_map_arg[i]);
- if (!split_key_map(tmp, &handler, &arg))
+ tmp = para_strdup(conf.key_map_arg[i]);
+ if (!split_key_map(tmp, &handler, &arg)) {
+ free(tmp);
return;
- if (!strcmp(tmp, km_keyname(c))) {
- if (*handler == 'd') {
- display_cmd(arg);
- return;
- }
- if (*handler == 'x') {
- external_cmd(arg);
- return;
- }
- if (*handler == 'p') {
- client_cmd_cmdline(arg);
- return;
- }
- if (*handler == 'i') {
- int num = find_cmd_byname(arg);
- if (num >= 0)
- command_list[num].handler();
- return;
- }
}
+ if (strcmp(tmp, km_keyname(c))) {
+ free(tmp);
+ continue;
+ }
+ if (*handler == 'd')
+ display_cmd(arg);
+ else if (*handler == 'x')
+ external_cmd(arg);
+ else if (*handler == 'p')
+ client_cmd_cmdline(arg);
+ else if (*handler == 'i') {
+ int num = find_cmd_byname(arg);
+ if (num >= 0)
+ command_list[num].handler();
+ }
+ free(tmp);
}
/* not found, check internal key bindings */
for (i = 0; command_list[i].handler; i++) {