This commit is contained in:
Jan Edmund Lazo 2018-08-16 13:23:51 -04:00
parent 7482aef113
commit 0223c81457
4 changed files with 35 additions and 32 deletions

View File

@ -2786,9 +2786,9 @@ const char * set_one_cmd_context(
xp->xp_context = EXPAND_NOTHING; /* Default now that we're past command */ xp->xp_context = EXPAND_NOTHING; /* Default now that we're past command */
if (*p == '!') { /* forced commands */ if (*p == '!') { // forced commands
forceit = true; forceit = true;
++p; p++;
} }
/* /*
@ -2813,9 +2813,9 @@ const char * set_one_cmd_context(
} }
if (ea.cmdidx == CMD_read) { if (ea.cmdidx == CMD_read) {
usefilter = forceit; /* :r! filter if forced */ usefilter = forceit; // :r! filter if forced
if (*arg == '!') { /* :r !filter */ if (*arg == '!') { // :r !filter
++arg; arg++;
usefilter = true; usefilter = true;
} }
} }
@ -8393,23 +8393,23 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
#define SPEC_PERC 0 #define SPEC_PERC 0
"#", "#",
#define SPEC_HASH (SPEC_PERC + 1) #define SPEC_HASH (SPEC_PERC + 1)
"<cword>", /* cursor word */ "<cword>", // cursor word
#define SPEC_CWORD (SPEC_HASH + 1) #define SPEC_CWORD (SPEC_HASH + 1)
"<cWORD>", /* cursor WORD */ "<cWORD>", // cursor WORD
#define SPEC_CCWORD (SPEC_CWORD + 1) #define SPEC_CCWORD (SPEC_CWORD + 1)
"<cexpr>", // expr under cursor "<cexpr>", // expr under cursor
#define SPEC_CEXPR (SPEC_CCWORD + 1) #define SPEC_CEXPR (SPEC_CCWORD + 1)
"<cfile>", /* cursor path name */ "<cfile>", // cursor path name
#define SPEC_CFILE (SPEC_CEXPR + 1) #define SPEC_CFILE (SPEC_CEXPR + 1)
"<sfile>", /* ":so" file name */ "<sfile>", // ":so" file name
#define SPEC_SFILE (SPEC_CFILE + 1) #define SPEC_SFILE (SPEC_CFILE + 1)
"<slnum>", /* ":so" file line number */ "<slnum>", // ":so" file line number
#define SPEC_SLNUM (SPEC_SFILE + 1) #define SPEC_SLNUM (SPEC_SFILE + 1)
"<afile>", /* autocommand file name */ "<afile>", // autocommand file name
#define SPEC_AFILE (SPEC_SLNUM + 1) #define SPEC_AFILE (SPEC_SLNUM + 1)
"<abuf>", /* autocommand buffer number */ "<abuf>", // autocommand buffer number
#define SPEC_ABUF (SPEC_AFILE + 1) #define SPEC_ABUF (SPEC_AFILE + 1)
"<amatch>", /* autocommand match name */ "<amatch>", // autocommand match name
#define SPEC_AMATCH (SPEC_ABUF + 1) #define SPEC_AMATCH (SPEC_ABUF + 1)
}; };
@ -8541,7 +8541,7 @@ eval_vars (
// just a minus sign, don't skip over it // just a minus sign, don't skip over it
s--; s--;
} }
*usedlen = (size_t)(s - src); /* length of what we expand */ *usedlen = (size_t)(s - src); // length of what we expand
if (src[1] == '<' && i != 0) { if (src[1] == '<' && i != 0) {
if (*usedlen < 2) { if (*usedlen < 2) {

View File

@ -3309,9 +3309,9 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
/* Need to save and restore ccline. And set "textlock" to avoid nasty /* Need to save and restore ccline. And set "textlock" to avoid nasty
* things like going to another buffer when evaluating an expression. */ * things like going to another buffer when evaluating an expression. */
save_cmdline(&save_ccline); save_cmdline(&save_ccline);
++textlock; textlock++;
const bool i = get_spec_reg(regname, &arg, &allocated, true); const bool i = get_spec_reg(regname, &arg, &allocated, true);
--textlock; textlock--;
restore_cmdline(&save_ccline); restore_cmdline(&save_ccline);
if (i) { if (i) {

View File

@ -3129,13 +3129,12 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol,
} }
if (ptr[col] == NUL || (i == 0 && this_class != 2)) { if (ptr[col] == NUL || (i == 0 && this_class != 2)) {
/* // didn't find an identifier or string
* didn't find an identifier or string if (find_type & FIND_STRING) {
*/
if (find_type & FIND_STRING)
EMSG(_("E348: No string under cursor")); EMSG(_("E348: No string under cursor"));
else } else {
EMSG(_(e_noident)); EMSG(_(e_noident));
}
return 0; return 0;
} }
ptr += col; ptr += col;

View File

@ -1207,8 +1207,8 @@ bool get_spec_reg(
*argp = curbuf->b_fname; *argp = curbuf->b_fname;
return true; return true;
case '#': /* alternate file name */ case '#': // alternate file name
*argp = getaltfname(errmsg); /* may give emsg if not set */ *argp = getaltfname(errmsg); // may give emsg if not set
return true; return true;
case '=': /* result of expression */ case '=': /* result of expression */
@ -1231,22 +1231,24 @@ bool get_spec_reg(
case '.': /* last inserted text */ case '.': /* last inserted text */
*argp = get_last_insert_save(); *argp = get_last_insert_save();
*allocated = true; *allocated = true;
if (*argp == NULL && errmsg) if (*argp == NULL && errmsg) {
EMSG(_(e_noinstext)); EMSG(_(e_noinstext));
}
return true; return true;
case Ctrl_F: /* Filename under cursor */ case Ctrl_F: // Filename under cursor
case Ctrl_P: /* Path under cursor, expand via "path" */ case Ctrl_P: // Path under cursor, expand via "path"
if (!errmsg) { if (!errmsg) {
return false; return false;
} }
*argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP *argp = file_name_at_cursor(
| (regname == Ctrl_P ? FNAME_EXP : 0), 1L, NULL); FNAME_MESS | FNAME_HYP | (regname == Ctrl_P ? FNAME_EXP : 0),
1L, NULL);
*allocated = true; *allocated = true;
return true; return true;
case Ctrl_W: /* word under cursor */ case Ctrl_W: // word under cursor
case Ctrl_A: /* WORD (mnemonic All) under cursor */ case Ctrl_A: // WORD (mnemonic All) under cursor
if (!errmsg) { if (!errmsg) {
return false; return false;
} }
@ -2757,8 +2759,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
* ':' (last command line), etc. we have to create a fake yank register. * ':' (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) if (insert_string == NULL) {
return; return;
}
} }
if (!curbuf->terminal) { if (!curbuf->terminal) {
@ -4917,8 +4920,9 @@ void *get_reg_contents(int regname, int flags)
char_u *retval; char_u *retval;
bool allocated; bool allocated;
if (get_spec_reg(regname, &retval, &allocated, false)) { if (get_spec_reg(regname, &retval, &allocated, false)) {
if (retval == NULL) if (retval == NULL) {
return NULL; return NULL;
}
if (allocated) { if (allocated) {
return get_reg_wrap_one_line(retval, flags); return get_reg_wrap_one_line(retval, flags);
} }