diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-16 22:32:06 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-16 23:05:33 -0400 |
commit | 58ad7fc578125aed6187944eb44c574041479fbf (patch) | |
tree | 3ee0f84968042afaab7b96f01a1c27bbcdeb3ced /src/nvim/ops.c | |
parent | 015df9c66e66283277c3709376bf6d1f83d55f53 (diff) | |
download | rneovim-58ad7fc578125aed6187944eb44c574041479fbf.tar.gz rneovim-58ad7fc578125aed6187944eb44c574041479fbf.tar.bz2 rneovim-58ad7fc578125aed6187944eb44c574041479fbf.zip |
ops: refactor get_spec_reg()
Return value is bool.
errmsg (param) is bool in here and in getaltfname().
allocated (param) is bool.
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index af95f94946..f4a65a2314 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1110,7 +1110,7 @@ int insert_reg( ) { int retval = OK; - int allocated; + bool allocated; /* * It is possible to get into an endless loop by having CTRL-R a in @@ -1187,75 +1187,75 @@ static void stuffescaped(const char *arg, int literally) } } -/* - * If "regname" is a special register, return TRUE and store a pointer to its - * value in "argp". - */ -int get_spec_reg( +// If "regname" is a special register, return true and store a pointer to its +// value in "argp". +bool get_spec_reg( int regname, char_u **argp, - int *allocated, /* return: TRUE when value was allocated */ - int errmsg /* give error message when failing */ + bool *allocated, // return: true when value was allocated + bool errmsg // give error message when failing ) { size_t cnt; *argp = NULL; - *allocated = FALSE; + *allocated = false; switch (regname) { case '%': /* file name */ if (errmsg) check_fname(); /* will give emsg if not set */ *argp = curbuf->b_fname; - return TRUE; + return true; case '#': /* alternate file name */ *argp = getaltfname(errmsg); /* may give emsg if not set */ - return TRUE; + return true; case '=': /* result of expression */ *argp = get_expr_line(); - *allocated = TRUE; - return TRUE; + *allocated = true; + return true; case ':': /* last command line */ if (last_cmdline == NULL && errmsg) EMSG(_(e_nolastcmd)); *argp = last_cmdline; - return TRUE; + return true; case '/': /* last search-pattern */ if (last_search_pat() == NULL && errmsg) EMSG(_(e_noprevre)); *argp = last_search_pat(); - return TRUE; + return true; case '.': /* last inserted text */ *argp = get_last_insert_save(); - *allocated = TRUE; + *allocated = true; if (*argp == NULL && errmsg) EMSG(_(e_noinstext)); - return TRUE; + return true; case Ctrl_F: /* Filename under cursor */ case Ctrl_P: /* Path under cursor, expand via "path" */ - if (!errmsg) - return FALSE; + if (!errmsg) { + return false; + } *argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP | (regname == Ctrl_P ? FNAME_EXP : 0), 1L, NULL); - *allocated = TRUE; - return TRUE; + *allocated = true; + return true; case Ctrl_W: /* word under cursor */ case Ctrl_A: /* WORD (mnemonic All) under cursor */ - if (!errmsg) - return FALSE; + if (!errmsg) { + return false; + } cnt = find_ident_under_cursor(argp, (regname == Ctrl_W ? (FIND_IDENT|FIND_STRING) : FIND_STRING)); *argp = cnt ? vim_strnsave(*argp, cnt) : NULL; - *allocated = TRUE; - return TRUE; + *allocated = true; + return true; case Ctrl_L: // Line under cursor if (!errmsg) { @@ -1267,10 +1267,10 @@ int get_spec_reg( case '_': /* black hole: always empty */ *argp = (char_u *)""; - return TRUE; + return true; } - return FALSE; + return false; } /// Paste a yank register into the command line. @@ -2660,7 +2660,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) int lendiff = 0; pos_T old_pos; char_u *insert_string = NULL; - int allocated = FALSE; + bool allocated = false; long cnt; if (flags & PUT_FIXINDENT) @@ -2756,7 +2756,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) * For special registers '%' (file name), '#' (alternate file name) and * ':' (last command line), etc. we have to create a fake yank register. */ - if (get_spec_reg(regname, &insert_string, &allocated, TRUE)) { + if (get_spec_reg(regname, &insert_string, &allocated, true)) { if (insert_string == NULL) return; } @@ -4915,8 +4915,8 @@ void *get_reg_contents(int regname, int flags) return NULL; char_u *retval; - int allocated; - if (get_spec_reg(regname, &retval, &allocated, FALSE)) { + bool allocated; + if (get_spec_reg(regname, &retval, &allocated, false)) { if (retval == NULL) return NULL; if (allocated) { |