Merge #2011 'Macro cleanup'

This commit is contained in:
Justin M. Keyes 2015-03-05 19:03:37 -05:00
commit a06186de41
19 changed files with 34 additions and 199 deletions

View File

@ -119,7 +119,6 @@ src/nvim/tag.h
src/nvim/term.c
src/nvim/term.h
src/nvim/term_defs.h
src/nvim/types.h
src/nvim/ui.c
src/nvim/ui.h
src/nvim/undo.c

View File

@ -268,13 +268,11 @@ edit (
// set Insstart_orig to Insstart
update_Insstart_orig = true;
#ifdef HAVE_SANDBOX
/* Don't allow inserting in the sandbox. */
// Don't allow inserting in the sandbox.
if (sandbox != 0) {
EMSG(_(e_sandbox));
return FALSE;
}
#endif
/* Don't allow changes in the buffer while editing the cmdline. The
* caller of getcmdline() may get confused. */
if (textlock != 0) {
@ -584,9 +582,6 @@ edit (
old_topline = curwin->w_topline;
old_topfill = curwin->w_topfill;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; /* allow scrolling here */
#endif
/*
* Get a character for Insert mode. Ignore K_IGNORE.
@ -4703,9 +4698,6 @@ int get_literal(void)
if (got_int)
return Ctrl_C;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
++no_mapping; /* don't map the next key hits */
cc = 0;
i = 0;
@ -4964,9 +4956,6 @@ insertchar (
* Don't do this when there an InsertCharPre autocommand is defined,
* because we need to fire the event for every character.
*/
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; /* allow scrolling here */
#endif
if ( !ISSPECIAL(c)
&& (!has_mbyte || (*mb_char2len)(c) == 1)
@ -6731,9 +6720,6 @@ static void ins_reg(void)
add_to_showcmd_c(Ctrl_R);
}
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
/*
* Don't map the register name. This also prevents the mode message to be
@ -8058,9 +8044,6 @@ static int ins_digraph(void)
add_to_showcmd_c(Ctrl_K);
}
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
/* don't map the digraph chars. This also prevents the
* mode message to be deleted when ESC is hit */

View File

@ -3396,16 +3396,13 @@ int check_secure(void)
EMSG(_(e_curdir));
return TRUE;
}
#ifdef HAVE_SANDBOX
/*
* In the sandbox more things are not allowed, including the things
* disallowed in secure mode.
*/
// In the sandbox more things are not allowed, including the things
// disallowed in secure mode.
if (sandbox != 0) {
EMSG(_(e_sandbox));
return TRUE;
}
#endif
return FALSE;
}
@ -3952,9 +3949,6 @@ void do_sub(exarg_T *eap)
ui_cursor_goto(msg_row, msg_col);
RedrawingDisabled = temp;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; /* allow scrolling here */
#endif
++no_mapping; /* don't map this key */
++allow_keys; /* allow special keys */
typed = plain_vgetc();

View File

@ -1093,9 +1093,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
int save_msg_scroll = msg_scroll;
int save_msg_silent = -1;
int did_esilent = 0;
#ifdef HAVE_SANDBOX
int did_sandbox = FALSE;
#endif
cmdmod_T save_cmdmod;
int ni; /* set when Not Implemented */
@ -1240,11 +1238,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
continue;
case 's': if (checkforcmd(&ea.cmd, "sandbox", 3)) {
#ifdef HAVE_SANDBOX
if (!did_sandbox)
++sandbox;
did_sandbox = TRUE;
#endif
continue;
}
if (!checkforcmd(&ea.cmd, "silent", 3))
@ -1509,13 +1505,11 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
if (!ea.skip) {
#ifdef HAVE_SANDBOX
if (sandbox != 0 && !(ea.argt & SBOXOK)) {
/* Command not allowed in sandbox. */
errormsg = (char_u *)_(e_sandbox);
goto doend;
}
#endif
if (!curbuf->b_p_ma && (ea.argt & MODIFY)) {
/* Command not allowed in non-'modifiable' buffer */
errormsg = (char_u *)_(e_modifiable);
@ -1983,10 +1977,8 @@ doend:
msg_col = 0;
}
#ifdef HAVE_SANDBOX
if (did_sandbox)
--sandbox;
#endif
if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */
ea.nextcmd = NULL;
@ -2582,12 +2574,10 @@ set_one_cmd_context (
}
/* An argument can contain just about everything, except
* characters that end the command and white space. */
else if (c == '|' || c == '\n' || c == '"' || (vim_iswhite(c)
#ifdef SPACE_IN_FILENAME
&& (!(ea.argt & NOSPC) ||
usefilter)
#endif
)) {
else if (c == '|'
|| c == '\n'
|| c == '"'
|| vim_iswhite(c)) {
len = 0; /* avoid getting stuck when space is in 'isfname' */
while (*p != NUL) {
if (has_mbyte)
@ -6617,9 +6607,6 @@ static void ex_at(exarg_T *eap)
curwin->w_cursor.lnum = eap->line2;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
/* get the register name. No name means to use the previous one */
c = *eap->arg;

View File

@ -291,9 +291,6 @@ getcmdline (
redir_off = TRUE; /* Don't redirect the typed command.
Repeated, because a ":redir" inside
completion may switch it on. */
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; /* allow scrolling here */
#endif
quit_more = FALSE; /* reset after CTRL-D which had a more-prompt */
cursorcmd(); /* set the cursor on the right spot */
@ -904,9 +901,6 @@ getcmdline (
goto returncmd; /* back to cmd mode */
case Ctrl_R: /* insert register */
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
putcmdline('"', TRUE);
++no_mapping;
i = c = plain_vgetc(); /* CTRL-R <char> */
@ -1270,9 +1264,6 @@ getcmdline (
case Ctrl_K:
ignore_drag_release = TRUE;
putcmdline('?', TRUE);
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
c = get_digraph(TRUE);
if (c != NUL)
break;

View File

@ -457,11 +457,8 @@ typedef enum {
'*', '#', '_', '!', '.', 'o'}
EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */
# define USER_HIGHLIGHT
#ifdef USER_HIGHLIGHT
EXTERN int highlight_user[9]; /* User[1-9] attributes */
EXTERN int highlight_stlnc[9]; /* On top of user */
#endif
EXTERN int cterm_normal_fg_color INIT(= 0);
EXTERN int cterm_normal_fg_bold INIT(= 0);
EXTERN int cterm_normal_bg_color INIT(= 0);
@ -622,7 +619,6 @@ EXTERN int allbuf_lock INIT(= 0);
* changed, no buffer can be deleted and
* current directory can't be changed.
* Used for SwapExists et al. */
# define HAVE_SANDBOX
EXTERN int sandbox INIT(= 0);
/* Non-zero when evaluating an expression in a
* "sandbox". Several things are not allowed
@ -838,13 +834,6 @@ EXTERN int ctrl_x_mode INIT(= 0); /* Which Ctrl-X mode are we in? */
EXTERN int no_abbr INIT(= TRUE); /* TRUE when no abbreviations loaded */
#ifdef USE_EXE_NAME
EXTERN char_u *exe_name; /* the name of the executable */
#endif
#ifdef USE_ON_FLY_SCROLL
EXTERN int dont_scroll INIT(= FALSE); /* don't use scrollbars when TRUE */
#endif
EXTERN int mapped_ctrl_c INIT(= FALSE); /* CTRL-C is mapped */
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
@ -1180,9 +1169,7 @@ EXTERN char_u e_readonlyvar[] INIT(= N_(
EXTERN char_u e_readonlysbx[] INIT(= N_(
"E794: Cannot set variable in the sandbox: \"%s\""));
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
#ifdef HAVE_SANDBOX
EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
#endif
EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here"));
EXTERN char_u e_screenmode[] INIT(= N_(
"E359: Screen mode setting not supported"));

View File

@ -794,9 +794,6 @@ void wait_return(int redraw)
State = HITRETURN;
setmouse();
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
/* Avoid the sequence that the user types ":" at the hit-return prompt
* to start an Ex command, but the file-changed dialog gets in the
* way. */

View File

@ -2290,9 +2290,6 @@ int ask_yesno(char_u *str, int direct)
int save_State = State;
++no_wait_return;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
State = CONFIRM; /* mouse behaves like with :confirm */
setmouse(); /* disables mouse for xterm */
++no_mapping;
@ -2465,9 +2462,6 @@ get_number (
if (msg_silent != 0)
return 0;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
++no_mapping;
++allow_keys; /* no mapping here, but recognize keys */
for (;; ) {
@ -2955,13 +2949,6 @@ char_u *vim_getenv(char_u *name, int *mustfree)
if (p == NULL) {
if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL)
p = p_hf;
#ifdef USE_EXE_NAME
/*
* Use the name of the executable, obtained from argv[0].
*/
else
p = exe_name;
#endif
if (p != NULL) {
/* remove the file name */
pend = path_tail(p);
@ -2970,12 +2957,6 @@ char_u *vim_getenv(char_u *name, int *mustfree)
if (p == p_hf)
pend = remove_tail(p, pend, (char_u *)"doc");
#ifdef USE_EXE_NAME
/* remove "src/" from exe_name, if present */
if (p == exe_name)
pend = remove_tail(p, pend, (char_u *)"src");
#endif
/* for $VIM, remove "runtime/" or "vim54/", if present */
if (!vimruntime) {
pend = remove_tail(p, pend, (char_u *)RUNTIME_DIRNAME);
@ -2995,13 +2976,6 @@ char_u *vim_getenv(char_u *name, int *mustfree)
free(p);
p = NULL;
} else {
#ifdef USE_EXE_NAME
/* may add "/vim54" or "/runtime" if it exists */
if (vimruntime && (pend = vim_version_dir(p)) != NULL) {
free(p);
p = pend;
}
#endif
*mustfree = TRUE;
}
}

View File

@ -473,9 +473,6 @@ normal_cmd (
mapped_len = typebuf_maplen();
State = NORMAL_BUSY;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = false; /* allow scrolling here */
#endif
/* Set v:count here, when called from main() and not a stuffed
* command, so that v:count can be used in an expression mapping
@ -3607,9 +3604,6 @@ static void nv_zet(cmdarg_T *cap)
return;
n = nchar - '0';
for (;; ) {
#ifdef USE_ON_FLY_SCROLL
dont_scroll = true; /* disallow scrolling here */
#endif
++no_mapping;
++allow_keys; /* no mapping for nchar, but allow key codes */
nchar = plain_vgetc();

View File

@ -3200,13 +3200,10 @@ void ex_display(exarg_T *eap)
MSG_PUTS_TITLE(_("\n--- Registers ---"));
for (i = -1; i < NUM_REGISTERS && !got_int; ++i) {
name = get_register_name(i);
if (arg != NULL && vim_strchr(arg, name) == NULL
#ifdef ONE_CLIPBOARD
/* Star register and plus register contain the same thing. */
&& (name != '*' || vim_strchr(arg, '+') == NULL)
#endif
)
if (arg != NULL && vim_strchr(arg, name) == NULL) {
continue; /* did not ask for this register */
}
get_clipboard(name);

View File

@ -2525,13 +2525,11 @@ do_set (
goto skip;
}
#ifdef HAVE_SANDBOX
/* Disallow changing some options in the sandbox */
if (sandbox != 0 && (flags & P_SECURE)) {
errmsg = (char_u *)_(e_sandbox);
goto skip;
}
#endif
if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) {
arg += len;
@ -3066,9 +3064,7 @@ did_set_option (
* flag. */
uint32_t *p = insecure_flag(opt_idx, opt_flags);
if (secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
|| (opt_flags & OPT_MODELINE))
*p = *p | P_INSECURE;
else if (new_value)
@ -3577,11 +3573,8 @@ did_set_string_option (
gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
/* Disallow changing some options from secure mode */
if ((secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
) && (options[opt_idx].flags & P_SECURE)) {
if ((secure || sandbox != 0)
&& (options[opt_idx].flags & P_SECURE)) {
errmsg = e_secure;
}
/* Check for a "normal" file name in some options. Disallow a path
@ -4697,12 +4690,10 @@ set_bool_option (
int old_value = *(int *)varp;
/* Disallow changing some options from secure mode */
if ((secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
) && (options[opt_idx].flags & P_SECURE))
if ((secure || sandbox != 0)
&& (options[opt_idx].flags & P_SECURE)) {
return e_secure;
}
*(int *)varp = value; /* set the new value */
/* Remember where the option was set. */
@ -5064,12 +5055,10 @@ set_num_option (
long *pp = (long *)varp;
/* Disallow changing some options from secure mode. */
if ((secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
) && (options[opt_idx].flags & P_SECURE))
if ((secure || sandbox != 0)
&& (options[opt_idx].flags & P_SECURE)) {
return e_secure;
}
*pp = value;
/* Remember where the option was set. */
@ -5755,13 +5744,11 @@ set_option_value (
EMSG2(_("E355: Unknown option: %s"), name);
else {
uint32_t flags = options[opt_idx].flags;
#ifdef HAVE_SANDBOX
/* Disallow changing some options in the sandbox */
// Disallow changing some options in the sandbox
if (sandbox > 0 && (flags & P_SECURE)) {
EMSG(_(e_sandbox));
return NULL;
}
#endif
if (flags & P_STRING)
return set_string_option(opt_idx, string, opt_flags);
else {

View File

@ -317,11 +317,10 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
return OK;
}
# ifdef HAVE_SANDBOX
/* Don't allow any shell command in the sandbox. */
if (sandbox != 0 && check_secure())
// Don't allow any shell command in the sandbox.
if (sandbox != 0 && check_secure()) {
return FAIL;
# endif
}
/*
* Don't allow the use of backticks in secure and restricted mode.

View File

@ -403,7 +403,7 @@ char_u *save_absolute_path(const char_u *name)
#if !defined(NO_EXPANDPATH)
#if defined(UNIX) || defined(USE_UNIXFILENAME)
#if defined(UNIX)
/*
* Unix style wildcard expansion code.
* It's here because it's used both for Unix and Mac.

View File

@ -1858,11 +1858,6 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
} else
prev_c = u8c;
/* Non-BMP character: display as ? or fullwidth ?. */
#ifdef UNICODE16
if (u8c >= 0x10000)
ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
else
#endif
ScreenLinesUC[idx] = u8c;
for (i = 0; i < Screen_mco; ++i) {
ScreenLinesC[i][idx] = u8cc[i];
@ -3051,30 +3046,13 @@ win_line (
if ((mb_l == 1 && c >= 0x80)
|| (mb_l >= 1 && mb_c == 0)
|| (mb_l > 1 && (!vim_isprintc(mb_c)
# ifdef UNICODE16
|| mb_c >= 0x10000
# endif
))) {
/*
* Illegal UTF-8 byte: display as <xx>.
* Non-BMP character : display as ? or fullwidth ?.
*/
# ifdef UNICODE16
if (mb_c < 0x10000)
# endif
{
transchar_hex(extra, mb_c);
if (wp->w_p_rl) /* reverse */
|| (mb_l > 1 && (!vim_isprintc(mb_c)))) {
// Illegal UTF-8 byte: display as <xx>.
// Non-BMP character : display as ? or fullwidth ?.
transchar_hex(extra, mb_c);
if (wp->w_p_rl) { // reverse
rl_mirror(extra);
}
# ifdef UNICODE16
else if (utf_char2cells(mb_c) != 2)
STRCPY(extra, "?");
else
/* 0xff1f in UTF-8: full-width '?' */
STRCPY(extra, "\357\274\237");
# endif
p_extra = extra;
c = *p_extra;
@ -5226,14 +5204,6 @@ void screen_puts_len(char_u *text, int textlen, int row, int col, int attr)
else
u8c = utfc_ptr2char(ptr, u8cc);
mbyte_cells = utf_char2cells(u8c);
# ifdef UNICODE16
/* Non-BMP character: display as ? or fullwidth ?. */
if (u8c >= 0x10000) {
u8c = (mbyte_cells == 2) ? 0xff1f : (int)'?';
if (attr == 0)
attr = hl_attr(HLF_8);
}
# endif
if (p_arshape && !p_tbidi && arabic_char(u8c)) {
/* Do Arabic shaping. */
if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len) {

View File

@ -7174,12 +7174,10 @@ int highlight_changed(void)
int attr;
char_u *end;
int id;
#ifdef USER_HIGHLIGHT
char_u userhl[10];
int id_SNC = -1;
int id_S = -1;
int hlcnt;
#endif
static int hl_flags[HLF_COUNT] = HL_FLAGS;
need_highlight_changed = FALSE;
@ -7251,12 +7249,10 @@ int highlight_changed(void)
return FAIL;
attr = syn_id2attr(id);
p = end - 1;
#ifdef USER_HIGHLIGHT
if (hlf == (int)HLF_SNC)
id_SNC = syn_get_final_id(id);
else if (hlf == (int)HLF_S)
id_S = syn_get_final_id(id);
#endif
break;
default: return FAIL;
}
@ -7267,7 +7263,6 @@ int highlight_changed(void)
}
}
#ifdef USER_HIGHLIGHT
/* Setup the user highlights
*
* Temporarily utilize 10 more hl entries. Have to be in there
@ -7327,8 +7322,6 @@ int highlight_changed(void)
}
highlight_ga.ga_len = hlcnt;
#endif /* USER_HIGHLIGHT */
return OK;
}

View File

@ -2416,9 +2416,7 @@ jumpto_tag (
save_secure = secure;
secure = 1;
#ifdef HAVE_SANDBOX
++sandbox;
#endif
save_magic = p_magic;
p_magic = FALSE; /* always execute with 'nomagic' */
/* Save value of no_hlsearch, jumping to a tag is not a real search */
@ -2525,9 +2523,7 @@ jumpto_tag (
wait_return(TRUE);
secure = save_secure;
p_magic = save_magic;
#ifdef HAVE_SANDBOX
--sandbox;
#endif
/* restore no_hlsearch when keeping the old search pattern */
if (search_options) {
SET_NO_HLSEARCH(save_no_hlsearch);

View File

@ -13,19 +13,11 @@
// dummy to pass an ACL to a function
typedef void *vim_acl_T;
/*
* Shorthand for unsigned variables. Many systems, but not all, have u_char
* already defined, so we use char_u to avoid trouble.
*/
// Shorthand for unsigned variables. Many systems, but not all, have u_char
// already defined, so we use char_u to avoid trouble.
typedef unsigned char char_u;
// The u8char_T can hold one decoded UTF-8 character. We normally use 32
// bits now, since some Asian characters don't fit in 16 bits. u8char_T is
// only used for displaying, it could be 16 bits to save memory.
#ifdef UNICODE16
typedef uint16_t u8char_T;
#else
// Can hold one decoded UTF-8 character.
typedef uint32_t u8char_T;
#endif
#endif /* NVIM_TYPES_H */
#endif // NVIM_TYPES_H

View File

@ -295,13 +295,11 @@ int undo_allowed(void)
return FALSE;
}
#ifdef HAVE_SANDBOX
/* In the sandbox it's not allowed to change the text. */
// In the sandbox it's not allowed to change the text.
if (sandbox != 0) {
EMSG(_(e_sandbox));
return FALSE;
}
#endif
/* Don't allow changes in the buffer while editing the cmdline. The
* caller of getcmdline() may get confused. */

View File

@ -441,9 +441,6 @@ wingotofile:
case 'g':
case Ctrl_G:
CHECK_CMDWIN
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
++ no_mapping;
++allow_keys; /* no mapping for xchar, but allow key codes */
if (xchar == NUL)