X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=keymap.c;h=0c450f77fd4977afc5122fde1814798dc5cb9f70;hp=d28ca0f0874491f86899dbc2f24cecff11603d42;hb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c;hpb=8e037c67a88cb4680c4391134c578e3b55a80f8a diff --git a/keymap.c b/keymap.c index d28ca0f..0c450f7 100644 --- a/keymap.c +++ b/keymap.c @@ -12,19 +12,18 @@ #endif #include +#include +#include +#include +#include #include "mutt.h" -#include "buffer.h" -#include "ascii.h" #include "mutt_menu.h" #include "mutt_curses.h" #include "keymap.h" #include "mapping.h" #include "mutt_crypt.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include #include @@ -99,7 +98,7 @@ static struct keymap_t *allocKeys(int len, keycode_t *keys) { struct keymap_t *p; - p = mem_calloc (1, sizeof (struct keymap_t)); + p = p_new(struct keymap_t, 1); p->len = len; p->keys = p_dup(keys, len); return p; @@ -195,8 +194,8 @@ void km_bind (const char *s, int menu, int op, char *macro, char *descr) map = allocKeys (len, buf); map->op = op; - map->macro = str_dup (macro); - map->descr = str_dup (descr); + map->macro = m_strdup(macro); + map->descr = m_strdup(descr); tmp = Keymaps[menu]; @@ -253,7 +252,7 @@ static int get_op (struct binding_t *bindings, const char *start, size_t len) for (i = 0; bindings[i].name; i++) { if (!ascii_strncasecmp (start, bindings[i].name, len) && - str_len (bindings[i].name) == len) + m_strlen(bindings[i].name) == len) return bindings[i].op; } @@ -273,9 +272,9 @@ static const char *get_func (struct binding_t *bindings, int op) return NULL; } -static void push_string (char *s) +static void push_string(const char *s) { - char *pp, *p = s + str_len (s) - 1; + const char *pp, *p = s + m_strlen(s) - 1; size_t l; int i, op = OP_NULL; @@ -360,7 +359,7 @@ int km_dokey (int menu) if (!map) return (retry_generic (menu, NULL, 0, 0)); - FOREVER { + for (;;) { /* ncurses doesn't return on resized screen when timeout is set to zero */ if (menu != MENU_EDITOR) timeout ((Timeout > 0 ? Timeout : 60) * 1000); @@ -404,7 +403,7 @@ int km_dokey (int menu) /* careful not to feed the <..> as one token. otherwise * push_string() will push the bogus op right back! */ mutt_ungetch ('>', 0); - push_string (func); + push_string(func); mutt_ungetch ('<', 0); break; } @@ -492,9 +491,9 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map) if (!map) return (0); - FOREVER { + for (;;) { strfcpy (s, km_keyname (map->keys[p]), len); - len -= (l = str_len (s)); + len -= (l = m_strlen(s)); if (++p >= map->len || !len) return (1); @@ -517,7 +516,7 @@ struct keymap_t *km_find_func (int menu, int func) void km_init (void) { - memset (Keymaps, 0, sizeof (struct keymap_t *) * MENU_MAX); + p_clear(Keymaps, MENU_MAX); create_bindings (OpAttach, MENU_ATTACH); create_bindings (OpBrowser, MENU_FOLDER); @@ -678,7 +677,7 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus, int i = 0; char *p, *q; - memset (&buf, 0, sizeof (buf)); + p_clear(&buf, 1); /* menu name */ mutt_extract_token (&buf, s, 0); @@ -723,7 +722,7 @@ try_bind (char *key, int menu, char *func, struct binding_t *bindings) int i; for (i = 0; bindings[i].name; i++) - if (str_cmp (func, bindings[i].name) == 0) { + if (m_strcmp(func, bindings[i].name) == 0) { km_bindkey (key, menu, bindings[i].op); return (0); } @@ -838,7 +837,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } else { if (MoreArgs (s)) { - seq = str_dup (buf->data); + seq = m_strdup(buf->data); mutt_extract_token (buf, s, M_TOKEN_CONDENSE); if (MoreArgs (s)) { @@ -886,9 +885,9 @@ int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data, && CurrentMenu != MENU_PAGER) bindings = OpGeneric; - ops[nops] = get_op (bindings, function, str_len (function)); + ops[nops] = get_op (bindings, function, m_strlen(function)); if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER) - ops[nops] = get_op (OpGeneric, function, str_len (function)); + ops[nops] = get_op (OpGeneric, function, m_strlen(function)); if (ops[nops] == OP_NULL) { mutt_flushinp ();