diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-28 23:21:24 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-06-16 01:31:37 -0300 |
commit | 3d10e2e0cb8e40bd04df6fff3548f2ca9d08e46b (patch) | |
tree | ef287be0f00a2ccd4081629b7e2a056b3db4aa3d /src | |
parent | 3b648b0a7bfee90659c04e17a3dfb752d25cc67e (diff) | |
download | rneovim-3d10e2e0cb8e40bd04df6fff3548f2ca9d08e46b.tar.gz rneovim-3d10e2e0cb8e40bd04df6fff3548f2ca9d08e46b.tar.bz2 rneovim-3d10e2e0cb8e40bd04df6fff3548f2ca9d08e46b.zip |
No OOM in msg_show_console_dialog()
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/message.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index e099c9b0a5..6a7e843648 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -21,6 +21,7 @@ #include "nvim/eval.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -2710,51 +2711,49 @@ do_dialog ( ++no_wait_return; hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); - if (hotkeys != NULL) { - for (;; ) { - /* Get a typed character directly from the user. */ - c = get_keystroke(); - switch (c) { - case CAR: /* User accepts default option */ - case NL: + for (;; ) { + /* Get a typed character directly from the user. */ + c = get_keystroke(); + switch (c) { + case CAR: /* User accepts default option */ + case NL: + retval = dfltbutton; + break; + case Ctrl_C: /* User aborts/cancels */ + case ESC: + retval = 0; + break; + default: /* Could be a hotkey? */ + if (c < 0) /* special keys are ignored here */ + continue; + if (c == ':' && ex_cmd) { retval = dfltbutton; + ins_char_typebuf(':'); break; - case Ctrl_C: /* User aborts/cancels */ - case ESC: - retval = 0; - break; - default: /* Could be a hotkey? */ - if (c < 0) /* special keys are ignored here */ - continue; - if (c == ':' && ex_cmd) { - retval = dfltbutton; - ins_char_typebuf(':'); - break; - } + } - /* Make the character lowercase, as chars in "hotkeys" are. */ - c = vim_tolower(c); - retval = 1; - for (i = 0; hotkeys[i]; ++i) { - if (has_mbyte) { - if ((*mb_ptr2char)(hotkeys + i) == c) - break; - i += (*mb_ptr2len)(hotkeys + i) - 1; - } else if (hotkeys[i] == c) + /* Make the character lowercase, as chars in "hotkeys" are. */ + c = vim_tolower(c); + retval = 1; + for (i = 0; hotkeys[i]; ++i) { + if (has_mbyte) { + if ((*mb_ptr2char)(hotkeys + i) == c) break; - ++retval; - } - if (hotkeys[i]) + i += (*mb_ptr2len)(hotkeys + i) - 1; + } else if (hotkeys[i] == c) break; - /* No hotkey match, so keep waiting */ - continue; + ++retval; } - break; + if (hotkeys[i]) + break; + /* No hotkey match, so keep waiting */ + continue; } - - free(hotkeys); + break; } + free(hotkeys); + State = oldState; setmouse(); --no_wait_return; @@ -2871,6 +2870,7 @@ static char_u * console_dialog_alloc(const char_u *message, * Returns an allocated string with hotkeys, or NULL for error. */ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfltbutton) + FUNC_ATTR_NONNULL_RET { bool has_hotkey[HAS_HOTKEY_LEN]; char_u *hotk = console_dialog_alloc(message, buttons, has_hotkey); |