diff options
Diffstat (limited to 'src')
55 files changed, 948 insertions, 1170 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 21bfc5ede0..a268e04559 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -490,7 +490,7 @@ static void switch_to_win_for_buf(buf_T *buf, win_T *wp; tabpage_T *tp; - if (find_win_for_buf(buf, &wp, &tp) == FAIL + if (!find_win_for_buf(buf, &wp, &tp) || switch_win(save_curwinp, save_curtabp, wp, tp, true) == FAIL) switch_buffer(save_curbufp, buf); } diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 354a74d19a..f6fb46e1d1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -343,6 +343,20 @@ String cstr_to_string(const char *str) }; } +/// Creates a String using the given C string. Unlike +/// cstr_to_string this function DOES NOT copy the C string. +/// +/// @param str the C string to use +/// @return The resulting String, or an empty String if +/// str was NULL +String cstr_as_string(char *str) FUNC_ATTR_PURE +{ + if (str == NULL) { + return (String) STRING_INIT; + } + return (String) {.data = str, .size = strlen(str)}; +} + bool object_to_vim(Object obj, typval_T *tv, Error *err) { tv->v_type = VAR_UNKNOWN; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 6c793cbc54..a2c50b4c81 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -54,55 +54,52 @@ void vim_command(String str, Error *err) /// Pass input keys to Neovim /// /// @param keys to be typed -/// @param replace_tcodes If true replace special keys such as <CR> or <Leader> -/// for compatibility with Vim --remote-send expressions -/// @param remap If True remap keys -/// @param typed Handle keys as if typed; otherwise they are handled as -/// if coming from a mapping. This matters for undo, -/// opening folds, etc. -void vim_feedkeys(String keys, Boolean replace_tcodes, Boolean remap, - Boolean typed, Error *err) +/// @param mode specifies the mapping options +/// @see feedkeys() +void vim_feedkeys(String keys, String mode) { - char *ptr = NULL; - char *cpo_save = (char *)p_cpo; - - if (replace_tcodes) { - // Set 'cpoptions' the way we want it. - // B set - backslashes are *not* treated specially - // k set - keycodes are *not* reverse-engineered - // < unset - <Key> sequences *are* interpreted - // The last but one parameter of replace_termcodes() is TRUE so that the - // <lt> sequence is recognised - needed for a real backslash. - p_cpo = (char_u *)"Bk"; - replace_termcodes((char_u *)keys.data, (char_u **)&ptr, false, true, true); - p_cpo = (char_u *)cpo_save; - } else { - ptr = keys.data; + bool remap = true; + bool typed = false; + + if (keys.size == 0) { + return; } - if (ptr == NULL) { - set_api_error("Failed to eval expression", err); - } else { - // Add the string to the input stream. - // Can't use add_to_input_buf() here, we now have K_SPECIAL bytes. - // - // First clear typed characters from the typeahead buffer, there could - // be half a mapping there. Then append to the existing string, so - // that multiple commands from a client are concatenated. - if (typebuf.tb_maplen < typebuf.tb_len) { - del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen); + for (size_t i = 0; i < mode.size; ++i) { + switch (mode.data[i]) { + case 'n': remap = false; break; + case 'm': remap = true; break; + case 't': typed = true; break; } - (void)ins_typebuf((char_u *)ptr, (remap ? REMAP_YES : REMAP_NONE), - typebuf.tb_len, !typed, false); + } + + /* Need to escape K_SPECIAL and CSI before putting the string in the + * typeahead buffer. */ + char *keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data); + ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE), + typebuf.tb_len, !typed, false); + free(keys_esc); - // Let input_available() know we inserted text in the typeahead - // buffer. */ + if (vgetc_busy) typebuf_was_filled = true; +} - if (replace_tcodes) { - free(ptr); - } +/// Replace any terminal codes with the internal representation +/// +/// @see replace_termcodes +/// @see cpoptions +String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, + Boolean special) +{ + if (str.size == 0) { + // Empty string + return str; } + + char *ptr = NULL; + replace_termcodes((char_u *)str.data, (char_u **)&ptr, + from_part, do_lt, special); + return cstr_as_string(ptr); } /// Evaluates the expression str using the vim internal expression diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index e39ee8012b..7880c66e1e 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -1361,24 +1361,19 @@ static int half_shape(int c) int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c) { - int curr_c; - int shape_c; - int curr_laa; - int prev_laa; - /* Deal only with Arabic character, pass back all others */ if (!A_is_ok(c)) { return c; } /* half-shape current and previous character */ - shape_c = half_shape(prev_c); + int shape_c = half_shape(prev_c); /* Save away current character */ - curr_c = c; + int curr_c = c; - curr_laa = A_firstc_laa(c, *c1p); - prev_laa = A_firstc_laa(prev_c, prev_c1); + int curr_laa = A_firstc_laa(c, *c1p); + int prev_laa = A_firstc_laa(prev_c, prev_c1); if (curr_laa) { if (A_is_valid(prev_c) && !A_is_f(shape_c) && !A_is_s(shape_c) && diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h index 258b798e5b..d9d9eac04d 100644 --- a/src/nvim/ascii.h +++ b/src/nvim/ascii.h @@ -8,14 +8,7 @@ #ifndef NVIM_ASCII_H #define NVIM_ASCII_H -/* - * Definitions of various common control characters. - * For EBCDIC we have to use different values. - */ - - -/* IF_EB(ASCII_constant, EBCDIC_constant) */ -#define IF_EB(a, b) a +// Definitions of various common control characters. #define CharOrd(x) ((x) < 'a' ? (x) - 'A' : (x) - 'a') #define CharOrdLow(x) ((x) - 'a') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f3128c7f6f..77bed67d5f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1530,6 +1530,7 @@ void free_buf_options(buf_T *buf, int free_p_ff) clear_string_option(&buf->b_p_qe); buf->b_p_ar = -1; buf->b_p_ul = NO_LOCAL_UNDOLEVEL; + clear_string_option(&buf->b_p_lw); } /* @@ -4255,7 +4256,7 @@ char_u *buf_spname(buf_T *buf) * For location list window, w_llist_ref points to the location list. * For quickfix window, w_llist_ref is NULL. */ - if (find_win_for_buf(buf, &win, &tp) == OK && win->w_llist_ref != NULL) + if (find_win_for_buf(buf, &win, &tp) && win->w_llist_ref != NULL) return (char_u *)_(msg_loclist); else return (char_u *)_(msg_qflist); @@ -4274,17 +4275,17 @@ char_u *buf_spname(buf_T *buf) /* * Find a window for buffer "buf". - * If found OK is returned and "wp" and "tp" are set to the window and tabpage. - * If not found FAIL is returned. + * If found true is returned and "wp" and "tp" are set to the window and tabpage. + * If not found false is returned. */ -int find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp) +bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp) { FOR_ALL_TAB_WINDOWS(*tp, *wp) { if ((*wp)->w_buffer == buf) { - return OK; + return true; } } - return FAIL; + return false; } /* diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index e827642d8a..9f5d7b86eb 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -677,6 +677,7 @@ struct file_buffer { char_u *b_p_tsr; /* 'thesaurus' local value */ long b_p_ul; /* 'undolevels' local value */ int b_p_udf; /* 'undofile' */ + char_u *b_p_lw; // 'lispwords' local value /* end of buffer options */ diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 3e1e7c1870..baf6895b4c 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -89,9 +89,6 @@ int buf_init_chartab(buf_T *buf, int global) // Set the default size for printable characters: // From <Space> to '~' is 1 (printable), others are 2 (not printable). // This also inits all 'isident' and 'isfname' flags to FALSE. - // - // EBCDIC: all chars below ' ' are not printable, all others are - // printable. c = 0; while (c < ' ') { @@ -583,11 +580,8 @@ void transchar_nonprint(char_u *buf, int c) buf[2] = NUL; } else { // 0x80 - 0x9f and 0xff - // TODO: EBCDIC I don't know what to do with this chars, so I display - // them as '~?' for now buf[0] = '~'; buf[1] = (c - 0x80) ^ 0x40; - // 0xff displayed as ~? buf[2] = NUL; } } diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 8edb12526c..f41a16bc1b 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -835,6 +835,8 @@ static digr_T digraphdefault[] = { 'W', '=', 0x20a9 }, { '=', 'e', 0x20ac }, // euro { 'E', 'u', 0x20ac }, // euro + { '=', 'R', 0x20bd }, // rouble + { '=', 'P', 0x20bd }, // rouble { 'o', 'C', 0x2103 }, { 'c', 'o', 0x2105 }, { 'o', 'F', 0x2109 }, diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 22687d8203..93e127394b 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3151,7 +3151,9 @@ static int ins_compl_prep(int c) ins_compl_free(); compl_started = FALSE; compl_matches = 0; - msg_clr_cmdline(); /* necessary for "noshowmode" */ + if (!shortmess(SHM_COMPLETIONMENU)) { + msg_clr_cmdline(); // necessary for "noshowmode" + } ctrl_x_mode = 0; compl_enter_selects = FALSE; if (edit_submode != NULL) { @@ -4379,7 +4381,9 @@ static int ins_complete(int c) if (col == -3) { ctrl_x_mode = 0; edit_submode = NULL; - msg_clr_cmdline(); + if (!shortmess(SHM_COMPLETIONMENU)) { + msg_clr_cmdline(); + } return FAIL; } @@ -4598,13 +4602,17 @@ static int ins_complete(int c) /* Show a message about what (completion) mode we're in. */ showmode(); - if (edit_submode_extra != NULL) { - if (!p_smd) - msg_attr(edit_submode_extra, - edit_submode_highl < HLF_COUNT - ? hl_attr(edit_submode_highl) : 0); - } else - msg_clr_cmdline(); /* necessary for "noshowmode" */ + if (!shortmess(SHM_COMPLETIONMENU)) { + if (edit_submode_extra != NULL) { + if (!p_smd) { + msg_attr(edit_submode_extra, + edit_submode_highl < HLF_COUNT + ? hl_attr(edit_submode_highl) : 0); + } + } else { + msg_clr_cmdline(); // necessary for "noshowmode" + } + } /* Show the popup menu, unless we got interrupted. */ if (!compl_interrupted) { @@ -6073,8 +6081,8 @@ stuff_inserted ( /* a trailing "0" is inserted as "<C-V>048", "^" as "<C-V>^" */ if (last) stuffReadbuff((char_u *)(last == '0' - ? IF_EB("\026\060\064\070", CTRL_V_STR "xf0") - : IF_EB("\026^", CTRL_V_STR "^"))); + ? "\026\060\064\070" + : "\026^")); } while (--count > 0); if (last) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fd2c3a6dd8..1cef91785c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -83,7 +83,7 @@ #include "nvim/os/time.h" #include "nvim/os/channel.h" #include "nvim/api/private/helpers.h" -#include "nvim/api/private/defs.h" +#include "nvim/api/vim.h" #include "nvim/os/msgpack_rpc_helpers.h" #include "nvim/os/dl.h" #include "nvim/os/provider.h" @@ -193,6 +193,9 @@ static int current_copyID = 0; #define COPYID_INC 2 #define COPYID_MASK (~0x1) +/// Abort conversion to string after a recursion error. +static bool did_echo_string_emsg = false; + /* * Array to hold the hashtab with variables local to each sourced script. * Each item holds a variable (nameless) that points to the dict_T. @@ -5322,6 +5325,9 @@ list_join_inner ( } line_breakcheck(); + if (did_echo_string_emsg) { // recursion error, bail out + break; + } } /* Allocate result buffer with its total size, avoid re-allocation and @@ -5945,8 +5951,10 @@ static char_u *dict2string(typval_T *tv, int copyID) if (s != NULL) ga_concat(&ga, s); free(tofree); - if (s == NULL) + if (s == NULL || did_echo_string_emsg) { break; + } + line_breakcheck(); } } if (todo > 0) { @@ -6077,9 +6085,15 @@ static char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int co char_u *r = NULL; if (recurse >= DICT_MAXNEST) { - EMSG(_("E724: variable nested too deep for displaying")); + if (!did_echo_string_emsg) { + // Only give this message once for a recursive call to avoid + // flooding the user with errors. And stop iterating over lists + // and dicts. + did_echo_string_emsg = true; + EMSG(_("E724: variable nested too deep for displaying")); + } *tofree = NULL; - return NULL; + return (char_u *)"{E724}"; } ++recurse; @@ -6134,7 +6148,9 @@ static char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int co *tofree = NULL; } - --recurse; + if (--recurse == 0) { + did_echo_string_emsg = false; + } return r; } @@ -6392,7 +6408,7 @@ static struct fst { {"getwinposy", 0, 0, f_getwinposy}, {"getwinvar", 2, 3, f_getwinvar}, {"glob", 1, 3, f_glob}, - {"globpath", 2, 3, f_globpath}, + {"globpath", 2, 4, f_globpath}, {"has", 1, 1, f_has}, {"has_key", 2, 2, f_has_key}, {"haslocaldir", 0, 0, f_haslocaldir}, @@ -8283,11 +8299,8 @@ static void f_extend(typval_T *argvars, typval_T *rettv) */ static void f_feedkeys(typval_T *argvars, typval_T *rettv) { - int remap = TRUE; - char_u *keys, *flags; + char_u *keys, *flags = NULL; char_u nbuf[NUMBUFLEN]; - int typed = FALSE; - char_u *keys_esc; /* This is not allowed in the sandbox. If the commands would still be * executed in the sandbox it would be OK, but it probably happens later, @@ -8299,23 +8312,10 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv) if (*keys != NUL) { if (argvars[1].v_type != VAR_UNKNOWN) { flags = get_tv_string_buf(&argvars[1], nbuf); - for (; *flags != NUL; ++flags) { - switch (*flags) { - case 'n': remap = FALSE; break; - case 'm': remap = TRUE; break; - case 't': typed = TRUE; break; - } - } } - /* Need to escape K_SPECIAL and CSI before putting the string in the - * typeahead buffer. */ - keys_esc = vim_strsave_escape_csi(keys); - ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE), - typebuf.tb_len, !typed, FALSE); - free(keys_esc); - if (vgetc_busy) - typebuf_was_filled = TRUE; + vim_feedkeys(cstr_as_string((char *)keys), + cstr_as_string((char *)flags)); } } @@ -9608,27 +9608,50 @@ static void f_glob(typval_T *argvars, typval_T *rettv) rettv->vval.v_string = NULL; } -/* - * "globpath()" function - */ +/// "globpath()" function static void f_globpath(typval_T *argvars, typval_T *rettv) { - int flags = 0; - char_u buf1[NUMBUFLEN]; - char_u *file = get_tv_string_buf_chk(&argvars[1], buf1); - int error = FALSE; + int flags = 0; // Flags for globpath. + int error = false; - /* When the optional second argument is non-zero, don't remove matches - * for 'wildignore' and don't put matches for 'suffixes' at the end. */ - if (argvars[2].v_type != VAR_UNKNOWN - && get_tv_number_chk(&argvars[2], &error)) - flags |= WILD_KEEP_ALL; + // Return a string, or a list if the optional third argument is non-zero. rettv->v_type = VAR_STRING; - if (file == NULL || error) + + if (argvars[2].v_type != VAR_UNKNOWN) { + // When the optional second argument is non-zero, don't remove matches + // for 'wildignore' and don't put matches for 'suffixes' at the end. + if (get_tv_number_chk(&argvars[2], &error)) { + flags |= WILD_KEEP_ALL; + } + + if (argvars[3].v_type != VAR_UNKNOWN + && get_tv_number_chk(&argvars[3], &error)) { + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; + } + } + + char_u buf1[NUMBUFLEN]; + char_u *file = get_tv_string_buf_chk(&argvars[1], buf1); + if (file != NULL && !error) { + garray_T ga; + ga_init(&ga, (int)sizeof(char_u *), 10); + globpath(get_tv_string(&argvars[0]), file, &ga, flags); + + if (rettv->v_type == VAR_STRING) { + rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n"); + } else { + rettv_list_alloc(rettv); + for (int i = 0; i < ga.ga_len; i++) { + list_append_string(rettv->vval.v_list, + ((char_u **)(ga.ga_data))[i], -1); + } + } + + ga_clear_strings(&ga); + } else { rettv->vval.v_string = NULL; - else - rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file, - flags); + } } /* @@ -9745,9 +9768,6 @@ static void f_has(typval_T *argvars, typval_T *rettv) #endif "tag_binary", "tag_old_static", -#ifdef FEAT_TAG_ANYWHITE - "tag_any_white", -#endif #ifdef TERMINFO "terminfo", #endif @@ -18032,7 +18052,10 @@ call_user_func ( if (argvars[i].v_type == VAR_NUMBER) msg_outnum((long)argvars[i].vval.v_number); else { + // Do not want errors such as E724 here. + ++emsg_off; s = tv2string(&argvars[i], &tofree, numbuf2, 0); + --emsg_off; if (s != NULL) { if (vim_strsize(s) > MSG_BUF_CLEN) { trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); @@ -18114,10 +18137,12 @@ call_user_func ( char_u *tofree; char_u *s; - /* The value may be very long. Skip the middle part, so that we - * have some idea how it starts and ends. smsg() would always - * truncate it at the end. */ + // The value may be very long. Skip the middle part, so that we + // have some idea how it starts and ends. smsg() would always + // truncate it at the end. Don't want errors such as E724 here. + ++emsg_off; s = tv2string(fc->rettv, &tofree, numbuf2, 0); + --emsg_off; if (s != NULL) { if (vim_strsize(s) > MSG_BUF_CLEN) { trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); @@ -19019,8 +19044,10 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags) if (regmatch.startp[0] == regmatch.endp[0]) { if (zero_width == regmatch.startp[0]) { /* avoid getting stuck on a match with an empty string */ - *((char_u *)ga.ga_data + ga.ga_len) = *tail++; - ++ga.ga_len; + int i = MB_PTR2LEN(tail); + memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); + ga.ga_len += i; + tail += i; continue; } zero_width = regmatch.startp[0]; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 338a7bb4c1..5b6604fc93 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1307,52 +1307,58 @@ do_shell ( apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf); } -/* - * Create a shell command from a command string, input redirection file and - * output redirection file. - * Returns an allocated string with the shell command. - */ -char_u * -make_filter_cmd ( - char_u *cmd, /* command */ - char_u *itmp, /* NULL or name of input file */ - char_u *otmp /* NULL or name of output file */ -) +/// Create a shell command from a command string, input redirection file and +/// output redirection file. +/// +/// @param cmd Command to execute. +/// @param itmp NULL or the input file. +/// @param otmp NULL or the output file. +/// @returns an allocated string with the shell command. +char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp) { - size_t len = STRLEN(cmd) + 3; /* "()" + NUL */ + bool is_fish_shell = +#if defined(UNIX) + STRNCMP(invocation_path_tail(p_sh, NULL), "fish", 4) == 0; +#else + false; +#endif + + size_t len = STRLEN(cmd) + 1; // At least enough space for cmd + NULL. + + len += is_fish_shell ? sizeof("begin; ""; end") - 1 + : sizeof("("")") - 1; + if (itmp != NULL) - len += STRLEN(itmp) + 9; /* " { < " + " } " */ + len += STRLEN(itmp) + sizeof(" { "" < "" } ") - 1; if (otmp != NULL) - len += STRLEN(otmp) + STRLEN(p_srr) + 2; /* " " */ + len += STRLEN(otmp) + STRLEN(p_srr) + 2; // two extra spaces (" "), char_u *buf = xmalloc(len); #if defined(UNIX) - /* - * Put braces around the command (for concatenated commands) when - * redirecting input and/or output. - */ - if (itmp != NULL || otmp != NULL) - vim_snprintf((char *)buf, len, "(%s)", (char *)cmd); - else + // Put delimiters around the command (for concatenated commands) when + // redirecting input and/or output. + if (itmp != NULL || otmp != NULL) { + char *fmt = is_fish_shell ? "begin; %s; end" + : "(%s)"; + vim_snprintf((char *)buf, len, fmt, (char *)cmd); + } else { STRCPY(buf, cmd); + } + if (itmp != NULL) { STRCAT(buf, " < "); STRCAT(buf, itmp); } #else - /* - * for shells that don't understand braces around commands, at least allow - * the use of commands in a pipe. - */ + // For shells that don't understand braces around commands, at least allow + // the use of commands in a pipe. STRCPY(buf, cmd); if (itmp != NULL) { char_u *p; - /* - * If there is a pipe, we have to put the '<' in front of it. - * Don't do this when 'shellquote' is not empty, otherwise the - * redirection would be inside the quotes. - */ + // If there is a pipe, we have to put the '<' in front of it. + // Don't do this when 'shellquote' is not empty, otherwise the + // redirection would be inside the quotes. if (*p_shq == NUL) { p = vim_strchr(buf, '|'); if (p != NULL) @@ -1363,7 +1369,7 @@ make_filter_cmd ( if (*p_shq == NUL) { p = vim_strchr(cmd, '|'); if (p != NULL) { - STRCAT(buf, " "); /* insert a space before the '|' for DOS */ + STRCAT(buf, " "); // Insert a space before the '|' for DOS STRCAT(buf, p); } } @@ -1606,13 +1612,13 @@ void write_viminfo(char_u *file, int forceit) fp_out = mch_fopen((char *)tempname, WRITEBIN); } -#if defined(UNIX) && defined(HAVE_FCHOWN) +#ifdef UNIX /* * Make sure the owner can read/write it. This only works for * root. */ if (fp_out != NULL) { - fchown(fileno(fp_out), old_info.stat.st_uid, old_info.stat.st_gid); + os_fchown(fileno(fp_out), old_info.stat.st_uid, old_info.stat.st_gid); } #endif } @@ -1933,7 +1939,7 @@ void viminfo_writestring(FILE *fd, char_u *p) * the string (e.g., variable name). Add something to the length for the * '<', NL and trailing NUL. */ if (len > LSIZE / 2) - fprintf(fd, IF_EB("\026%d\n<", CTRL_V_STR "%d\n<"), len + 3); + fprintf(fd, "\026%d\n<", len + 3); while ((c = *p++) != NUL) { if (c == Ctrl_V || c == '\n') { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index bf5076bdc3..28048c933c 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4051,45 +4051,38 @@ static int ExpandUserList(expand_T *xp, int *num_file, char_u ***file) */ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirnames[]) { - char_u *matches; - char_u *s; - char_u *e; - garray_T ga; - int i; - int pat_len; - *num_file = 0; *file = NULL; - pat_len = (int)STRLEN(pat); + size_t pat_len = STRLEN(pat); + + garray_T ga; ga_init(&ga, (int)sizeof(char *), 10); - for (i = 0; dirnames[i] != NULL; ++i) { - s = xmalloc(STRLEN(dirnames[i]) + pat_len + 7); - sprintf((char *)s, "%s/%s*.vim", dirnames[i], pat); - matches = globpath(p_rtp, s, 0); + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 7; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "%s/%s*.vim", dirnames[i], pat); + globpath(p_rtp, s, &ga, 0); free(s); - if (matches == NULL) - continue; + } - for (s = matches; *s != NUL; s = e) { - e = vim_strchr(s, '\n'); - if (e == NULL) - e = s + STRLEN(s); - ga_grow(&ga, 1); - if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0) { - for (s = e - 4; s > matches; mb_ptr_back(matches, s)) - if (*s == '\n' || vim_ispathsep(*s)) - break; - ++s; - ((char_u **)ga.ga_data)[ga.ga_len] = - vim_strnsave(s, (int)(e - s - 4)); - ++ga.ga_len; + for (int i = 0; i < ga.ga_len; i++) { + char_u *match = ((char_u **)ga.ga_data)[i]; + char_u *s = match; + char_u *e = s + STRLEN(s); + if (e - s > 4 && STRNICMP(e - 4, ".vim", 4) == 0) { + e -= 4; + for (s = e; s > match; mb_ptr_back(match, s)) { + if (vim_ispathsep(*s)) { + break; + } } - if (*e != NUL) - ++e; + s++; + *e = NUL; + memmove(match, s, e - s + 1); } - free(matches); } + if (GA_EMPTY(&ga)) return FAIL; @@ -4103,60 +4096,43 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname } -/* - * Expand "file" for all comma-separated directories in "path". - * Returns an allocated string with all matches concatenated, separated by - * newlines. Returns NULL for an error or no matches. - */ -char_u *globpath(char_u *path, char_u *file, int expand_options) +/// Expand `file` for all comma-separated directories in `path`. +/// Adds matches to `ga`. +void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options) { expand_T xpc; - garray_T ga; - int i; - int len; - int num_p; - char_u **p; - char_u *cur = NULL; - - char_u *buf = xmalloc(MAXPATHL); - ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - ga_init(&ga, 1, 100); + char_u *buf = xmalloc(MAXPATHL); - /* Loop over all entries in {path}. */ + // Loop over all entries in {path}. while (*path != NUL) { - /* Copy one item of the path to buf[] and concatenate the file name. */ + // Copy one item of the path to buf[] and concatenate the file name. copy_option_part(&path, buf, MAXPATHL, ","); if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) { add_pathsep(buf); - STRCAT(buf, file); + STRCAT(buf, file); // NOLINT + + char_u **p; + int num_p; if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT|expand_options) != FAIL && num_p > 0) { ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options); - for (len = 0, i = 0; i < num_p; ++i) - len += (int)STRLEN(p[i]) + 1; - - /* Concatenate new results to previous ones. */ - ga_grow(&ga, len); - cur = (char_u *)ga.ga_data + ga.ga_len; - for (i = 0; i < num_p; ++i) { - STRCPY(cur, p[i]); - cur += STRLEN(p[i]); - *cur++ = '\n'; + + // Concatenate new results to previous ones. + ga_grow(ga, num_p); + for (int i = 0; i < num_p; i++) { + ((char_u **)ga->ga_data)[ga->ga_len] = vim_strsave(p[i]); + ga->ga_len++; } - ga.ga_len += len; FreeWild(num_p, p); } } } - if (cur != NULL) - *--cur = 0; /* Replace trailing newline with NUL */ free(buf); - return (char_u *)ga.ga_data; } diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 845a99acad..c7e1f5cbbc 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -409,7 +409,6 @@ vim_findfile_init ( * The octet after a '**' is used as a (binary) counter. * So '**3' is transposed to '**^C' ('^C' is ASCII value 3) * or '**76' is transposed to '**N'( 'N' is ASCII value 76). - * For EBCDIC you get different character values. * If no restrict is given after '**' the default is used. * Due to this technique the path looks awful if you print it as a * string. diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c072be424e..2e932e9695 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2711,16 +2711,10 @@ buf_write ( * - it's a hard link * - it's a symbolic link * - we don't have write permission in the directory - * - we can't set the owner/group of the new file */ if (file_info_old.stat.st_nlink > 1 || !os_get_file_info_link((char *)fname, &file_info) - || !os_file_info_id_equal(&file_info, &file_info_old) -# ifndef HAVE_FCHOWN - || file_info.stat.st_uid != file_info_old.stat.st_uid - || file_info.stat.st_gid != file_info_old.stat.st_gid -# endif - ) { + || !os_file_info_id_equal(&file_info, &file_info_old)) { backup_copy = TRUE; } else # endif @@ -2744,9 +2738,7 @@ buf_write ( backup_copy = TRUE; else { # ifdef UNIX -# ifdef HAVE_FCHOWN - fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); -# endif + os_fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); if (!os_get_file_info((char *)IObuff, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid @@ -2909,10 +2901,7 @@ buf_write ( * others. */ if (file_info_new.stat.st_gid != file_info_old.stat.st_gid -# ifdef HAVE_FCHOWN /* sequent-ptx lacks fchown() */ - && fchown(bfd, (uid_t)-1, file_info_old.stat.st_gid) != 0 -# endif - ) { + && os_fchown(bfd, -1, file_info_old.stat.st_gid) != 0) { os_setperm(backup, (perm & 0707) | ((perm & 07) << 3)); } # ifdef HAVE_SELINUX @@ -3424,19 +3413,16 @@ restore_backup: /* When creating a new file, set its owner/group to that of the original * file. Get the new device and inode number. */ if (backup != NULL && !backup_copy) { -# ifdef HAVE_FCHOWN - /* don't change the owner when it's already OK, some systems remove * permission or ACL stuff */ FileInfo file_info; if (!os_get_file_info((char *)wfname, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid) { - fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); + os_fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); if (perm >= 0) /* set permission again, may have changed */ (void)os_setperm(wfname, perm); } -# endif buf_set_file_id(buf); } else if (!buf->file_id_valid) { // Set the file_id when creating a new file. @@ -7183,45 +7169,8 @@ match_file_pat ( { regmatch_T regmatch; int result = FALSE; -#ifdef FEAT_OSFILETYPE - int no_pattern = FALSE; /* TRUE if check is filetype only */ - char_u *type_start; - char_u c; - int match = FALSE; -#endif regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */ -#ifdef FEAT_OSFILETYPE - if (*pattern == '<') { - /* There is a filetype condition specified with this pattern. - * Check the filetype matches first. If not, don't bother with the - * pattern (set regprog to NULL). - * Always use magic for the regexp. - */ - - for (type_start = pattern + 1; (c = *pattern); pattern++) { - if ((c == ';' || c == '>') && match == FALSE) { - *pattern = NUL; /* Terminate the string */ - /* TODO: match with 'filetype' of buffer that "fname" comes - * from. */ - match = mch_check_filetype(fname, type_start); - *pattern = c; /* Restore the terminator */ - type_start = pattern + 1; - } - if (c == '>') - break; - } - - /* (c should never be NUL, but check anyway) */ - if (match == FALSE || c == NUL) - regmatch.regprog = NULL; /* Doesn't match - don't check pat. */ - else if (*pattern == NUL) { - regmatch.regprog = NULL; /* Vim will try to free regprog later */ - no_pattern = TRUE; /* Always matches - don't check pat. */ - } else - regmatch.regprog = vim_regcomp(pattern + 1, RE_MAGIC); - } else -#endif { if (prog != NULL) regmatch.regprog = prog; @@ -7236,12 +7185,6 @@ match_file_pat ( * 3. the tail of the file name, when the pattern has no '/'. */ if ( -#ifdef FEAT_OSFILETYPE - /* If the check is for a filetype only and we don't care - * about the path then skip all the regexp stuff. - */ - no_pattern || -#endif (regmatch.regprog != NULL && ((allow_dirs && (vim_regexec(®match, fname, (colnr_T)0) @@ -7294,9 +7237,6 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname) * allow_dirs, otherwise FALSE is put there -- webb. * Handle backslashes before special characters, like "\*" and "\ ". * - * If FEAT_OSFILETYPE defined then pass initial <type> through unchanged. Eg: - * '<html>myfile' becomes '<html>^myfile$' -- leonard. - * * Returns NULL on failure. */ char_u * @@ -7314,38 +7254,13 @@ file_pat_to_reg_pat ( int i; int nested = 0; int add_dollar = TRUE; -#ifdef FEAT_OSFILETYPE - int check_length = 0; -#endif if (allow_dirs != NULL) *allow_dirs = FALSE; if (pat_end == NULL) pat_end = pat + STRLEN(pat); -#ifdef FEAT_OSFILETYPE - /* Find out how much of the string is the filetype check */ - if (*pat == '<') { - /* Count chars until the next '>' */ - for (p = pat + 1; p < pat_end && *p != '>'; p++) - ; - if (p < pat_end) { - /* Pattern is of the form <.*>.* */ - check_length = p - pat + 1; - if (p + 1 >= pat_end) { - /* The 'pattern' is a filetype check ONLY */ - reg_pat = xmemdupz(pat, (size_t)check_length); - return reg_pat; - } - } - /* else: there was no closing '>' - assume it was a normal pattern */ - - } - pat += check_length; - size = 2 + (size_t)check_length; -#else size = 2; /* '^' at start, '$' at end */ -#endif for (p = pat; p < pat_end; p++) { switch (*p) { @@ -7374,14 +7289,7 @@ file_pat_to_reg_pat ( } reg_pat = xmalloc(size + 1); -#ifdef FEAT_OSFILETYPE - /* Copy the type check in to the start. */ - if (check_length) - memmove(reg_pat, pat - check_length, (size_t)check_length); - i = check_length; -#else i = 0; -#endif if (pat[0] == '*') while (pat[0] == '*' && pat < pat_end - 1) diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 033ea9baac..08a38493bf 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -133,6 +133,7 @@ void ga_remove_duplicate_strings(garray_T *gap) /// strings with sep as separator. /// /// @param gap +/// @param sep /// /// @returns the concatenated strings char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep) @@ -159,7 +160,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep) s = xstpcpy(s, strings[i]); s = xstpcpy(s, sep); } - s = xstpcpy(s, strings[nelem - 1]); + strcpy(s, strings[nelem - 1]); return (char_u *) ret; } diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 340b31d80a..e98bb2744c 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -543,9 +543,7 @@ AppendToRedobuffLit ( /* Put a string of normal characters in the redo buffer (that's * faster). */ start = s; - while (*s >= ' ' - && *s < DEL /* EBCDIC: all chars above space are normal */ - && (len < 0 || s - str < len)) + while (*s >= ' ' && *s < DEL && (len < 0 || s - str < len)) ++s; /* Don't put '0' or '^' as last character, just in case a CTRL-D is @@ -567,7 +565,7 @@ AppendToRedobuffLit ( if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) add_char_buff(&redobuff, Ctrl_V); - /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */ + /* CTRL-V '0' must be inserted as CTRL-V 048 */ if (*s == NUL && c == '0') add_buff(&redobuff, (char_u *)"048", 3L); else @@ -4078,7 +4076,7 @@ int put_escstr(FILE *fd, char_u *strstart, int what) */ if (c == NL) { if (what == 2) { - if (fprintf(fd, IF_EB("\\\026\n", "\\" CTRL_V_STR "\n")) < 0) + if (fprintf(fd, "\\\026\n") < 0) return FAIL; } else { if (fprintf(fd, "<NL>") < 0) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index b496b7e576..ad65f7e6fd 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -905,9 +905,6 @@ EXTERN int read_cmd_fd INIT(= 0); /* fd to read commands from */ /* volatile because it is used in signal handler catch_sigint(). */ EXTERN volatile int got_int INIT(= FALSE); /* set to TRUE when interrupt signal occurred */ -#ifdef USE_TERM_CONSOLE -EXTERN int term_console INIT(= FALSE); /* set to TRUE when console used */ -#endif EXTERN int termcap_active INIT(= FALSE); /* set by starttermcap() */ EXTERN int cur_tmode INIT(= TMODE_COOK); /* input terminal mode */ EXTERN int bangredo INIT(= FALSE); /* set to TRUE with ! command */ diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 64a5879d7d..b964aa7353 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -1502,9 +1502,7 @@ static void prt_flush_buffer(void) prt_write_real(prt_text_run, 2); prt_write_string("ul\n"); } - /* Draw the text - * Note: we write text out raw - EBCDIC conversion is handled in the - * PostScript world via the font encoding vector. */ + // Draw the text if (prt_out_mbyte) prt_write_string("<"); else @@ -2803,7 +2801,7 @@ void mch_print_end(prt_settings_T *psettings) /* Write CTRL-D to close serial communication link if used. * NOTHING MUST BE WRITTEN AFTER THIS! */ - prt_write_file((char_u *)IF_EB("\004", "\067")); + prt_write_file((char_u *)"\004"); if (!prt_file_error && psettings->outfile == NULL && !got_int && !psettings->user_abort) { @@ -3031,20 +3029,18 @@ int mch_print_text_out(char_u *p, int len) if (ch < 32 || ch == '(' || ch == ')' || ch == '\\') { /* Convert non-printing characters to either their escape or octal * sequence, ensures PS sent over a serial line does not interfere - * with the comms protocol. Note: For EBCDIC we need to write out - * the escape sequences as ASCII codes! - * Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK! + * with the comms protocol. */ - ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); + ga_append(&prt_ps_buffer, '\\'); switch (ch) { - case BS: ga_append(&prt_ps_buffer, IF_EB('b', 0142)); break; - case TAB: ga_append(&prt_ps_buffer, IF_EB('t', 0164)); break; - case NL: ga_append(&prt_ps_buffer, IF_EB('n', 0156)); break; - case FF: ga_append(&prt_ps_buffer, IF_EB('f', 0146)); break; - case CAR: ga_append(&prt_ps_buffer, IF_EB('r', 0162)); break; - case '(': ga_append(&prt_ps_buffer, IF_EB('(', 0050)); break; - case ')': ga_append(&prt_ps_buffer, IF_EB(')', 0051)); break; - case '\\': ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); break; + case BS: ga_append(&prt_ps_buffer, 'b'); break; + case TAB: ga_append(&prt_ps_buffer, 't'); break; + case NL: ga_append(&prt_ps_buffer, 'n'); break; + case FF: ga_append(&prt_ps_buffer, 'f'); break; + case CAR: ga_append(&prt_ps_buffer, 'r'); break; + case '(': ga_append(&prt_ps_buffer, '('); break; + case ')': ga_append(&prt_ps_buffer, ')'); break; + case '\\': ga_append(&prt_ps_buffer, '\\'); break; default: sprintf((char *)ch_buff, "%03o", (unsigned int)ch); diff --git a/src/nvim/indent.c b/src/nvim/indent.c index ebc5955bae..d4c6b36177 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -690,7 +690,7 @@ static int lisp_match(char_u *p) { char_u buf[LSIZE]; int len; - char_u *word = p_lispwords; + char_u *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords; while (*word != NUL) { (void)copy_option_part(&word, buf, LSIZE, ","); diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h index c6f2e46bb0..67392234d3 100644 --- a/src/nvim/mark_defs.h +++ b/src/nvim/mark_defs.h @@ -8,9 +8,6 @@ * (a normal mark is a lnum/col pair, the same as a file position) */ -/* (Note: for EBCDIC there are more than 26, because there are gaps in the - * alphabet coding. To minimize changes to the code, I decided to just - * increase the number of possible marks. */ #define NMARKS ('z' - 'a' + 1) /* max. # of named marks */ #define JUMPLISTSIZE 100 /* max. # of marks in jump list */ #define TAGSTACKSIZE 20 /* max. # of tags in tag stack */ diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 9c81824cbb..1573aaae84 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1185,21 +1185,7 @@ static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext) if (p[1] == NUL) /* trailing "&" */ break; if (mnemonic != NULL && p[1] != '&') -#if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED) *mnemonic = p[1]; -#else - { - /* - * Well there is a bug in the Motif libraries on OS390 Unix. - * The mnemonic keys needs to be converted to ASCII values - * first. - * This behavior has been seen in 2.8 and 2.9. - */ - char c = p[1]; - __etoa_l(&c, 1); - *mnemonic = c; - } -#endif STRMOVE(p, p + 1); p = p + 1; } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3008af94f3..0bf338947b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1147,10 +1147,7 @@ static void stuffescaped(char_u *arg, int literally) * stuff K_SPECIAL to get the effect of a special key when "literally" * is TRUE. */ start = arg; - while ((*arg >= ' ' - && *arg < DEL /* EBCDIC: chars above space are normal */ - ) - || (*arg == K_SPECIAL && !literally)) + while ((*arg >= ' ' && *arg < DEL) || (*arg == K_SPECIAL && !literally)) ++arg; if (arg > start) stuffReadbuffLen(start, (long)(arg - start)); @@ -2508,6 +2505,9 @@ int op_yank(oparg_T *oap, int deleting, int mess) free(y_current->y_array); y_current = curr; } + if (curwin->w_p_rnu) { + redraw_later(SOME_VALID); // cursor moved to start + } if (mess) { /* Display message about yank? */ if (yanktype == MCHAR && !oap->block_mode diff --git a/src/nvim/option.c b/src/nvim/option.c index ebf2e8b4af..63ea2ee338 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -143,6 +143,7 @@ # define PV_KMAP OPT_BUF(BV_KMAP) #define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) # define PV_LISP OPT_BUF(BV_LISP) +# define PV_LW OPT_BOTH(OPT_BUF(BV_LW)) #define PV_MA OPT_BUF(BV_MA) #define PV_ML OPT_BUF(BV_ML) #define PV_MOD OPT_BUF(BV_MOD) @@ -965,10 +966,10 @@ static struct vimoption {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"initclipboard","icpb",P_STRING|P_VI_DEF|P_SECURE, (char_u *)&p_icpb, PV_NONE, - {(char_u *)NULL, (char_u *)0L} SCRIPTID_INIT}, + {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"initpython","ipy",P_STRING|P_VI_DEF|P_SECURE, (char_u *)&p_ipy, PV_NONE, - {(char_u *)NULL, (char_u *)0L} SCRIPTID_INIT}, + {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_im, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, @@ -1057,7 +1058,7 @@ static struct vimoption (char_u *)&p_lisp, PV_LISP, {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, - (char_u *)&p_lispwords, PV_NONE, + (char_u *)&p_lispwords, PV_LW, {(char_u *)LISPWORD_VALUE, (char_u *)0L} SCRIPTID_INIT}, {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, @@ -1596,7 +1597,7 @@ static struct vimoption {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, (char_u *)&p_tf, PV_NONE, - {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, + {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, #if defined(FEAT_MOUSE) && defined(UNIX) (char_u *)&p_ttym, PV_NONE, @@ -1933,26 +1934,15 @@ void set_init_1(void) */ opt_idx = findoption((char_u *)"maxmemtot"); if (opt_idx >= 0) { -#ifndef HAVE_TOTAL_MEM - if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) -#endif { -#ifdef HAVE_TOTAL_MEM /* Use half of amount of memory available to Vim. */ /* If too much to fit in long_u, get long_u max */ uint64_t available_kib = os_get_total_mem_kib(); n = available_kib / 2 > ULONG_MAX ? ULONG_MAX : (long_u)(available_kib /2); -#else - n = (0x7fffffff >> 11); -#endif options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; opt_idx = findoption((char_u *)"maxmem"); if (opt_idx >= 0) { -#ifndef HAVE_TOTAL_MEM - if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n - || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L) -#endif options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; } } @@ -1995,7 +1985,7 @@ void set_init_1(void) } } -#if defined(MSWIN) || defined(EBCDIC) || defined(MAC) +#if defined(MSWIN) || defined(MAC) /* Set print encoding on platforms that don't default to latin1 */ set_string_default("penc", (char_u *)"hp-roman8" @@ -2369,7 +2359,6 @@ void set_init_3(void) * This is done after other initializations, where 'shell' might have been * set, but only if they have not been set before. */ - char_u *p; int idx_srr; int do_srr; int idx_sp; @@ -2386,28 +2375,10 @@ void set_init_3(void) else do_sp = !(options[idx_sp].flags & P_WAS_SET); - /* - * Isolate the name of the shell: - * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f". - * - Remove any argument. E.g., "csh -f" -> "csh". - * But don't allow a space in the path, so that this works: - * "/usr/bin/csh --rcfile ~/.cshrc" - * But don't do that for Windows, it's common to have a space in the path. - */ - p = skiptowhite(p_sh); - if (*p == NUL) { - /* No white space, use the tail. */ - p = vim_strsave(path_tail(p_sh)); - } else { - char_u *p1, *p2; + size_t len = 0; + char_u *p = (char_u *)invocation_path_tail(p_sh, &len); + p = vim_strnsave(p, len); - /* Find the last path separator before the space. */ - p1 = p_sh; - for (p2 = p_sh; p2 < p; mb_ptr_adv(p2)) - if (vim_ispathsep(*p2)) - p1 = p2 + 1; - p = vim_strnsave(p1, (int)(p - p1)); - } { /* * Default for p_sp is "| tee", for p_srr is ">". @@ -2431,6 +2402,7 @@ void set_init_3(void) || fnamecmp(p, "zsh") == 0 || fnamecmp(p, "zsh-beta") == 0 || fnamecmp(p, "bash") == 0 + || fnamecmp(p, "fish") == 0 ) { if (do_sp) { p_sp = (char_u *)"2>&1| tee"; @@ -3569,6 +3541,7 @@ void check_buf_options(buf_T *buf) check_string_option(&buf->b_p_tags); check_string_option(&buf->b_p_dict); check_string_option(&buf->b_p_tsr); + check_string_option(&buf->b_p_lw); } /* @@ -6543,10 +6516,13 @@ void comp_col(void) void unset_global_local_option(char *name, void *from) { struct vimoption *p; - int opt_idx; buf_T *buf = (buf_T *)from; - opt_idx = findoption((uint8_t *)name); + int opt_idx = findoption((uint8_t *)name); + if (opt_idx < 0) { + EMSG2(_("E355: Unknown option: %s"), name); + return; + } p = &(options[opt_idx]); switch ((int)p->indir) @@ -6594,6 +6570,9 @@ void unset_global_local_option(char *name, void *from) case PV_UL: buf->b_p_ul = NO_LOCAL_UNDOLEVEL; break; + case PV_LW: + clear_string_option(&buf->b_p_lw); + break; } } @@ -6623,6 +6602,7 @@ static char_u *get_varp_scope(struct vimoption *p, int opt_flags) case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); case PV_STL: return (char_u *)&(curwin->w_p_stl); case PV_UL: return (char_u *)&(curbuf->b_p_ul); + case PV_LW: return (char_u *)&(curbuf->b_p_lw); } return NULL; /* "cannot happen" */ } @@ -6670,6 +6650,8 @@ static char_u *get_varp(struct vimoption *p) ? (char_u *)&(curwin->w_p_stl) : p->var; case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL ? (char_u *)&(curbuf->b_p_ul) : p->var; + case PV_LW: return *curbuf->b_p_lw != NUL + ? (char_u *)&(curbuf->b_p_lw) : p->var; case PV_ARAB: return (char_u *)&(curwin->w_p_arab); case PV_LIST: return (char_u *)&(curwin->w_p_list); @@ -7022,6 +7004,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_tsr = empty_option; buf->b_p_qe = vim_strsave(p_qe); buf->b_p_udf = p_udf; + buf->b_p_lw = empty_option; /* * Don't copy the options set by ex_help(), use the saved values, diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index a22eec4136..d862ab2761 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -185,7 +185,8 @@ #define SHM_SEARCH 's' /* no search hit bottom messages */ #define SHM_ATTENTION 'A' /* no ATTENTION messages */ #define SHM_INTRO 'I' /* intro messages */ -#define SHM_ALL "rmfixlnwaWtToOsAI" /* all possible flags for 'shm' */ +#define SHM_COMPLETIONMENU 'c' // completion menu messages +#define SHM_ALL "rmfixlnwaWtToOsAIc" /* all possible flags for 'shm' */ /* characters for p_go: */ #define GO_ASEL 'a' /* autoselect */ @@ -683,6 +684,7 @@ enum { , BV_KMAP , BV_KP , BV_LISP + , BV_LW , BV_MA , BV_ML , BV_MOD diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 46aea2bf36..aca7005064 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -3,13 +3,6 @@ #include <assert.h> -// TODO(hinidu): remove after implementing `os_mkdtemp` on top of libuv -#ifdef WIN32 -# include <io.h> -#else -# include <stdlib.h> -#endif - #include "nvim/os/os.h" #include "nvim/ascii.h" #include "nvim/memory.h" @@ -217,6 +210,21 @@ int os_setperm(const char_u *name, int perm) return FAIL; } +/// Changes the ownership of the file referred to by the open file descriptor. +/// +/// @return `0` on success, a libuv error code on failure. +/// +/// @note If the `owner` or `group` is specified as `-1`, then that ID is not +/// changed. +int os_fchown(int file_descriptor, uv_uid_t owner, uv_gid_t group) +{ + uv_fs_t request; + int result = uv_fs_fchown(uv_default_loop(), &request, file_descriptor, + owner, group, NULL); + uv_fs_req_cleanup(&request); + return result; +} + /// Check if a file exists. /// /// @return `true` if `name` exists. @@ -293,18 +301,21 @@ int os_mkdir(const char *path, int32_t mode) } /// Create a unique temporary directory. -/// TODO(hinidu): Implement on top of libuv. ref #850 /// -/// @param[in,out] template Template of the path to the directory with XXXXXX -/// which would be replaced by random chars. -/// @return Pointer to changed `template` for success, `NULL` for failure. -char *os_mkdtemp(char *template) +/// @param[in] template Template of the path to the directory with XXXXXX +/// which would be replaced by random chars. +/// @param[out] path Path to created directory for success, undefined for +/// failure. +/// @return `0` for success, non-zero for failure. +int os_mkdtemp(const char *template, char *path) { -#ifdef WIN32 - return _mktemp(template) && os_mkdir(template, 0700) == 0 ? template : NULL; -#else - return mkdtemp(template); -#endif + uv_fs_t request; + int result = uv_fs_mkdtemp(uv_default_loop(), &request, template, NULL); + if (result == kLibuvSuccess) { + strcpy(path, request.path); + } + uv_fs_req_cleanup(&request); + return result; } /// Remove a directory. diff --git a/src/nvim/os/provider.c b/src/nvim/os/provider.c index 99cc078e94..d94203f683 100644 --- a/src/nvim/os/provider.c +++ b/src/nvim/os/provider.c @@ -158,8 +158,10 @@ static uint64_t get_provider_for(char *method) err: // Ensure we won't try to restart the provider - f->bootstrap_command = NULL; - f->channel_id = 0; + if (f) { + f->bootstrap_command = NULL; + f->channel_id = 0; + } return 0; } diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 9e7940bc2a..af17676ebf 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -16,15 +16,6 @@ * changed beyond recognition. */ -/* - * Some systems have a prototype for select() that has (int *) instead of - * (fd_set *), which is wrong. This define removes that prototype. We define - * our own prototype below. - * Don't use it for the Mac, it causes a warning for precompiled headers. - * TODO: use a configure check for precompiled headers? - */ -# define select select_declared_wrong - #include <errno.h> #include <inttypes.h> #include <stdbool.h> @@ -307,40 +298,6 @@ int use_xterm_mouse(void) return 0; } -int vim_is_iris(char_u *name) -{ - if (name == NULL) - return FALSE; - return STRNICMP(name, "iris-ansi", 9) == 0 - || STRCMP(name, "builtin_iris-ansi") == 0; -} - -int vim_is_vt300(char_u *name) -{ - if (name == NULL) - return FALSE; /* actually all ANSI comp. terminals should be here */ - /* catch VT100 - VT5xx */ - return (STRNICMP(name, "vt", 2) == 0 - && vim_strchr((char_u *)"12345", name[2]) != NULL) - || STRCMP(name, "builtin_vt320") == 0; -} - -/* - * Return TRUE if "name" is a terminal for which 'ttyfast' should be set. - * This should include all windowed terminal emulators. - */ -int vim_is_fastterm(char_u *name) -{ - if (name == NULL) - return FALSE; - if (vim_is_xterm(name) || vim_is_vt300(name) || vim_is_iris(name)) - return TRUE; - return STRNICMP(name, "hpterm", 6) == 0 - || STRNICMP(name, "sun-cmd", 7) == 0 - || STRNICMP(name, "screen", 6) == 0 - || STRNICMP(name, "dtterm", 6) == 0; -} - #if defined(USE_FNAME_CASE) || defined(PROTO) /* * Set the case of the file name, if it already exists. This will cause the @@ -753,16 +710,16 @@ void mch_setmouse(int on) if (ttym_flags == TTYM_URXVT) { out_str_nf((char_u *) (on - ? IF_EB("\033[?1015h", ESC_STR "[?1015h") - : IF_EB("\033[?1015l", ESC_STR "[?1015l"))); + ? "\033[?1015h" + : "\033[?1015l")); ison = on; } if (ttym_flags == TTYM_SGR) { out_str_nf((char_u *) (on - ? IF_EB("\033[?1006h", ESC_STR "[?1006h") - : IF_EB("\033[?1006l", ESC_STR "[?1006l"))); + ? "\033[?1006h" + : "\033[?1006l")); ison = on; } @@ -770,13 +727,13 @@ void mch_setmouse(int on) if (on) /* enable mouse events, use mouse tracking if available */ out_str_nf((char_u *) (xterm_mouse_vers > 1 - ? IF_EB("\033[?1002h", ESC_STR "[?1002h") - : IF_EB("\033[?1000h", ESC_STR "[?1000h"))); + ? "\033[?1002h" + : "\033[?1000h")); else /* disable mouse events, could probably always send the same */ out_str_nf((char_u *) (xterm_mouse_vers > 1 - ? IF_EB("\033[?1002l", ESC_STR "[?1002l") - : IF_EB("\033[?1000l", ESC_STR "[?1000l"))); + ? "\033[?1002l" + : "\033[?1000l")); ison = on; } else if (ttym_flags == TTYM_DEC) { if (on) /* enable mouse events */ @@ -797,8 +754,8 @@ void check_mouse_termcode(void) && use_xterm_mouse() != 3 ) { set_mouse_termcode(KS_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? IF_EB("\233M", CSI_STR "M") - : IF_EB("\033[M", ESC_STR "[M"))); + ? "\233M" + : "\033[M")); if (*p_mouse != NUL) { /* force mouse off and maybe on to send possibly new mouse * activation sequence to the xterm, with(out) drag tracing. */ @@ -814,7 +771,7 @@ void check_mouse_termcode(void) if (!use_xterm_mouse() ) set_mouse_termcode(KS_NETTERM_MOUSE, - (char_u *)IF_EB("\033}", ESC_STR "}")); + (char_u *)"\033}"); else del_mouse_termcode(KS_NETTERM_MOUSE); @@ -822,17 +779,15 @@ void check_mouse_termcode(void) if (!use_xterm_mouse() ) set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? IF_EB("\233", - CSI_STR) : IF_EB("\033[", - ESC_STR "["))); + ? "\233" : "\033[")); else del_mouse_termcode(KS_DEC_MOUSE); /* same as the dec mouse */ if (use_xterm_mouse() == 3 ) { set_mouse_termcode(KS_URXVT_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? IF_EB("\233", CSI_STR) - : IF_EB("\033[", ESC_STR "["))); + ? "\233" + : "\033[")); if (*p_mouse != NUL) { mch_setmouse(FALSE); @@ -844,8 +799,8 @@ void check_mouse_termcode(void) if (use_xterm_mouse() == 4 ) { set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? IF_EB("\233<", CSI_STR "<") - : IF_EB("\033[<", ESC_STR "[<"))); + ? "\233<" + : "\033[<")); if (*p_mouse != NUL) { mch_setmouse(FALSE); diff --git a/src/nvim/os_unix_defs.h b/src/nvim/os_unix_defs.h index 0d79117bfd..2a44ec3412 100644 --- a/src/nvim/os_unix_defs.h +++ b/src/nvim/os_unix_defs.h @@ -24,10 +24,6 @@ # include <unistd.h> #endif -#ifdef HAVE_LIBC_H -# include <libc.h> /* for NeXT */ -#endif - #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> /* defines BSD, if it's a BSD system */ #endif diff --git a/src/nvim/path.c b/src/nvim/path.c index ea6390a688..0c18ab7bd4 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -131,6 +131,35 @@ char_u *path_tail_with_sep(char_u *fname) return tail; } +/// Finds the path tail (or executable) in an invocation. +/// +/// @param[in] invocation A program invocation in the form: +/// "path/to/exe [args]". +/// @param[out] len Stores the length of the executable name. +/// +/// @post if `len` is not null, stores the length of the executable name. +/// +/// @return The position of the last path separator + 1. +const char_u *invocation_path_tail(const char_u *invocation, size_t *len) + FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) +{ + const char_u *tail = get_past_head((char_u *) invocation); + const char_u *p = tail; + while (*p != NUL && *p != ' ') { + bool was_sep = vim_ispathsep_nocolon(*p); + mb_ptr_adv(p); + if (was_sep) { + tail = p; // Now tail points one past the separator. + } + } + + if (len != NULL) { + *len = (size_t)(p - tail); + } + + return tail; +} + /// Get the next path component of a path name. /// /// @param fname A file path. (Must be != NULL.) @@ -897,9 +926,6 @@ expand_in_path ( { char_u *curdir; garray_T path_ga; - char_u *files = NULL; - char_u *s; /* start */ - char_u *e; /* end */ char_u *paths = NULL; curdir = xmalloc(MAXPATHL); @@ -914,28 +940,8 @@ expand_in_path ( paths = ga_concat_strings(&path_ga); ga_clear_strings(&path_ga); - files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0); + globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0); free(paths); - if (files == NULL) - return 0; - - /* Copy each path in files into gap */ - s = e = files; - while (*s != NUL) { - while (*e != '\n' && *e != NUL) - e++; - if (*e == NUL) { - addfile(gap, s, flags); - break; - } else { - /* *e is '\n' */ - *e = NUL; - addfile(gap, s, flags); - e++; - s = e; - } - } - free(files); return gap->ga_len; } @@ -1225,10 +1231,8 @@ addfile ( /* * Append a slash or backslash after directory names if none is present. */ -#ifndef DONT_ADD_PATHSEP_TO_DIR if (isdir && (flags & EW_ADDSLASH)) add_pathsep(p); -#endif GA_APPEND(char_u *, gap, p); } #endif /* !NO_EXPANDPATH */ diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index fd1b6116f2..193c68860d 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -258,6 +258,7 @@ #define RE_MARK 207 /* mark cmp Match mark position */ #define RE_VISUAL 208 /* Match Visual area */ +#define RE_COMPOSING 209 // any composing characters /* * Magic characters have a special meaning, they don't match literally. @@ -1256,12 +1257,6 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) if (reg(REG_NOPAREN, &flags) == NULL) return NULL; - /* Small enough for pointer-storage convention? */ -#ifdef SMALL_MALLOC /* 16 bit storage allocation */ - if (regsize >= 65536L - 256L) - EMSG_RET_NULL(_("E339: Pattern too long")); -#endif - /* Allocate space. */ bt_regprog_T *r = xmalloc(sizeof(bt_regprog_T) + regsize); @@ -2030,6 +2025,10 @@ static char_u *regatom(int *flagp) ret = regnode(RE_VISUAL); break; + case 'C': + ret = regnode(RE_COMPOSING); + break; + /* \%[abc]: Emit as a list of branches, all ending at the last * branch which matches nothing. */ case '[': @@ -4105,10 +4104,12 @@ regmatch ( status = RA_NOMATCH; } } - // Check for following composing character. + // Check for following composing character, unless %C + // follows (skips over all composing chars). if (status != RA_NOMATCH && enc_utf8 && UTF_COMPOSINGLIKE(reginput, reginput + len) - && !ireg_icombine) { + && !ireg_icombine + && OP(next) != RE_COMPOSING) { // raaron: This code makes a composing character get // ignored, which is the correct behavior (sometimes) // for voweled Hebrew texts. @@ -4173,6 +4174,15 @@ regmatch ( status = RA_NOMATCH; break; + case RE_COMPOSING: + if (enc_utf8) { + // Skip composing characters. + while (utf_iscomposing(utf_ptr2char(reginput))) { + mb_cptr_adv(reginput); + } + } + break; + case NOTHING: break; diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 21581d3823..2659eac762 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -85,6 +85,7 @@ enum { NFA_COMPOSING, /* Next nodes in NFA are part of the composing multibyte char */ NFA_END_COMPOSING, /* End of a composing char in the NFA */ + NFA_ANY_COMPOSING, // \%C: Any composing characters. NFA_OPT_CHARS, /* \%[abc] */ /* The following are used only in the postfix form, not in the NFA */ @@ -1350,6 +1351,10 @@ static int nfa_regatom(void) EMIT(NFA_VISUAL); break; + case 'C': + EMIT(NFA_ANY_COMPOSING); + break; + case '[': { int n; @@ -2259,6 +2264,7 @@ static void nfa_set_code(int c) case NFA_MARK_LT: STRCPY(code, "NFA_MARK_LT "); break; case NFA_CURSOR: STRCPY(code, "NFA_CURSOR "); break; case NFA_VISUAL: STRCPY(code, "NFA_VISUAL "); break; + case NFA_ANY_COMPOSING: STRCPY(code, "NFA_ANY_COMPOSING "); break; case NFA_STAR: STRCPY(code, "NFA_STAR "); break; case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break; @@ -2716,6 +2722,7 @@ static int nfa_max_width(nfa_state_T *startstate, int depth) case NFA_NLOWER_IC: case NFA_UPPER_IC: case NFA_NUPPER_IC: + case NFA_ANY_COMPOSING: /* possibly non-ascii */ if (has_mbyte) len += 3; @@ -3714,6 +3721,7 @@ static int match_follows(nfa_state_T *startstate, int depth) continue; case NFA_ANY: + case NFA_ANY_COMPOSING: case NFA_IDENT: case NFA_SIDENT: case NFA_KWORD: @@ -3943,7 +3951,7 @@ skip_add: #endif switch (state->c) { case NFA_MATCH: - nfa_match = TRUE; + //nfa_match = TRUE; break; case NFA_SPLIT: @@ -4573,6 +4581,7 @@ static int failure_chance(nfa_state_T *state, int depth) case NFA_MATCH: case NFA_MCLOSE: + case NFA_ANY_COMPOSING: /* empty match works always */ return 0; @@ -4951,6 +4960,11 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm switch (t->state->c) { case NFA_MATCH: { + // If the match ends before a composing characters and + // ireg_icombine is not set, that is not really a match. + if (enc_utf8 && !ireg_icombine && utf_iscomposing(curc)) { + break; + } nfa_match = TRUE; copy_sub(&submatch->norm, &t->subs.norm); if (nfa_has_zsubexpr) @@ -5430,6 +5444,18 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm } break; + case NFA_ANY_COMPOSING: + // On a composing character skip over it. Otherwise do + // nothing. Always matches. + if (enc_utf8 && utf_iscomposing(curc)) { + add_off = clen; + } else { + add_here = TRUE; + add_off = 0; + } + add_state = t->state->out; + break; + /* * Character classes like \a for alpha, \d for digit etc. */ @@ -5769,12 +5795,13 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm if (!result && ireg_ic) result = vim_tolower(c) == vim_tolower(curc); - /* If there is a composing character which is not being - * ignored there can be no match. Match with composing - * character uses NFA_COMPOSING above. */ - if (result && enc_utf8 && !ireg_icombine - && clen != utf_char2len(curc)) - result = FALSE; + + // If ireg_icombine is not set only skip over the character + // itself. When it is set skip over composing characters. + if (result && enc_utf8 && !ireg_icombine) { + clen = utf_char2len(curc); + } + ADD_STATE_IF_MATCH(t->state); break; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 0d0d068b36..03c59bf584 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -41,7 +41,7 @@ * * The part of the buffer that is displayed in a window is set with: * - w_topline (first buffer line in window) - * - w_topfill (filler line above the first line) + * - w_topfill (filler lines above the first line) * - w_leftcol (leftmost window cell in window), * - w_skipcol (skipped window cells of first line) * @@ -7341,7 +7341,8 @@ int showmode(void) attr = hl_attr(HLF_CM); /* Highlight mode */ if (do_mode) { MSG_PUTS_ATTR("--", attr); - if (edit_submode != NULL) { /* CTRL-X in Insert mode */ + // CTRL-X in Insert mode + if (edit_submode != NULL && !shortmess(SHM_COMPLETIONMENU)) { /* These messages can get long, avoid a wrap in a narrow * window. Prefer showing edit_submode_extra. */ length = (Rows - msg_row) * Columns - 3; @@ -7726,22 +7727,6 @@ void showruler(int always) static void win_redr_ruler(win_T *wp, int always) { -#define RULER_BUF_LEN 70 - char_u buffer[RULER_BUF_LEN]; - int row; - int fillchar; - int attr; - int empty_line = FALSE; - colnr_T virtcol; - int i; - size_t len; - int o; - int this_ru_col; - int off = 0; - int width = Columns; -# define WITH_OFF(x) x -# define WITH_WIDTH(x) x - /* If 'ruler' off or redrawing disabled, don't do anything */ if (!p_ru) return; @@ -7777,6 +7762,7 @@ static void win_redr_ruler(win_T *wp, int always) /* * Check if not in Insert mode and the line is empty (will show "0-1"). */ + int empty_line = FALSE; if (!(State & INSERT) && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) empty_line = TRUE; @@ -7796,6 +7782,13 @@ static void win_redr_ruler(win_T *wp, int always) || wp->w_topfill != wp->w_ru_topfill || empty_line != wp->w_ru_empty) { cursor_off(); + + int width; + int row; + int fillchar; + int attr; + int off; + if (wp->w_status_height) { row = wp->w_winrow + wp->w_height; fillchar = fillchar_status(&attr, wp == curwin); @@ -7810,13 +7803,16 @@ static void win_redr_ruler(win_T *wp, int always) } /* In list mode virtcol needs to be recomputed */ - virtcol = wp->w_virtcol; + colnr_T virtcol = wp->w_virtcol; if (wp->w_p_list && lcs_tab1 == NUL) { wp->w_p_list = FALSE; getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); wp->w_p_list = TRUE; } +#define RULER_BUF_LEN 70 + char_u buffer[RULER_BUF_LEN]; + /* * Some sprintfs return the length, some return a pointer. * To avoid portability problems we use strlen() here. @@ -7824,7 +7820,7 @@ static void win_redr_ruler(win_T *wp, int always) vim_snprintf((char *)buffer, RULER_BUF_LEN, "%" PRId64 ",", (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? (int64_t)0L : (int64_t)wp->w_cursor.lnum); - len = STRLEN(buffer); + size_t len = STRLEN(buffer); col_print(buffer + len, RULER_BUF_LEN - len, empty_line ? 0 : (int)wp->w_cursor.col + 1, (int)virtcol + 1); @@ -7834,20 +7830,20 @@ static void win_redr_ruler(win_T *wp, int always) * On the last line, don't print in the last column (scrolls the * screen up on some terminals). */ - i = (int)STRLEN(buffer); + int i = (int)STRLEN(buffer); get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1); - o = i + vim_strsize(buffer + i + 1); + int o = i + vim_strsize(buffer + i + 1); if (wp->w_status_height == 0) /* can't use last char of screen */ ++o; - this_ru_col = ru_col - (Columns - width); + int this_ru_col = ru_col - (Columns - width); if (this_ru_col < 0) this_ru_col = 0; /* Never use more than half the window/screen width, leave the other * half for the filename. */ - if (this_ru_col < (WITH_WIDTH(width) + 1) / 2) - this_ru_col = (WITH_WIDTH(width) + 1) / 2; - if (this_ru_col + o < WITH_WIDTH(width)) { - while (this_ru_col + o < WITH_WIDTH(width)) { + if (this_ru_col < (width + 1) / 2) + this_ru_col = (width + 1) / 2; + if (this_ru_col + o < width) { + while (this_ru_col + o < width) { if (has_mbyte) i += (*mb_char2bytes)(fillchar, buffer + i); else @@ -7861,19 +7857,19 @@ static void win_redr_ruler(win_T *wp, int always) o = 0; for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len)(buffer + i)) { o += (*mb_ptr2cells)(buffer + i); - if (this_ru_col + o > WITH_WIDTH(width)) { + if (this_ru_col + o > width) { buffer[i] = NUL; break; } } - } else if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width)) - buffer[WITH_WIDTH(width) - this_ru_col] = NUL; + } else if (this_ru_col + (int)STRLEN(buffer) > width) + buffer[width - this_ru_col] = NUL; - screen_puts(buffer, row, this_ru_col + WITH_OFF(off), attr); + screen_puts(buffer, row, this_ru_col + off, attr); i = redraw_cmdline; screen_fill(row, row + 1, - this_ru_col + WITH_OFF(off) + (int)STRLEN(buffer), - (int)(WITH_OFF(off) + WITH_WIDTH(width)), + this_ru_col + off + (int)STRLEN(buffer), + (int)(off + width), fillchar, fillchar, attr); /* don't redraw the cmdline because of showing the ruler */ redraw_cmdline = i; diff --git a/src/nvim/search.c b/src/nvim/search.c index 5c92ef71a9..b0a782a515 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3015,21 +3015,21 @@ current_block ( } curwin->w_cursor = *end_pos; - /* - * Try to exclude the '(', '{', ')', '}', etc. when "include" is FALSE. - * If the ending '}' is only preceded by indent, skip that indent. - * But only if the resulting area is not smaller than what we started with. - */ + // Try to exclude the '(', '{', ')', '}', etc. when "include" is FALSE. + // If the ending '}', ')' or ']' is only preceded by indent, skip that + // indent. But only if the resulting area is not smaller than what we + // started with. while (!include) { incl(&start_pos); sol = (curwin->w_cursor.col == 0); decl(&curwin->w_cursor); - if (what == '{') - while (inindent(1)) { - sol = TRUE; - if (decl(&curwin->w_cursor) != 0) - break; + while (inindent(1)) { + sol = TRUE; + if (decl(&curwin->w_cursor) != 0) { + break; } + } + /* * In Visual mode, when the resulting area is not bigger than what we * started with, extend it to the next block, and then exclude again. @@ -3762,16 +3762,8 @@ current_search ( int forward /* move forward or backwards */ ) { - pos_T start_pos; /* position before the pattern */ - pos_T orig_pos; /* position of the cursor at beginning */ - pos_T pos; /* position after the pattern */ - int i; - int dir; - int result; /* result of various function calls */ bool old_p_ws = p_ws; - int flags = 0; pos_T save_VIsual = VIsual; - int one_char; /* wrapping should not occur */ p_ws = false; @@ -3780,11 +3772,11 @@ current_search ( if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor)) dec_cursor(); - if (VIsual_active) { - orig_pos = curwin->w_cursor; + pos_T orig_pos; /* position of the cursor at beginning */ + pos_T pos; /* position after the pattern */ - pos = curwin->w_cursor; - start_pos = VIsual; + if (VIsual_active) { + orig_pos = pos = curwin->w_cursor; /* make sure, searching further will extend the match */ if (VIsual_active) { @@ -3794,10 +3786,10 @@ current_search ( decl(&pos); } } else - orig_pos = pos = start_pos = curwin->w_cursor; + orig_pos = pos = curwin->w_cursor; /* Is the pattern is zero-width? */ - one_char = is_one_char(spats[last_idx].pat); + int one_char = is_one_char(spats[last_idx].pat); if (one_char == -1) { p_ws = old_p_ws; return FAIL; /* pattern not found */ @@ -3808,17 +3800,14 @@ current_search ( * so that a match at the current cursor position will be correctly * captured. */ - for (i = 0; i < 2; i++) { - if (forward) - dir = i; - else - dir = !i; + for (int i = 0; i < 2; i++) { + int dir = forward ? i : !i; + int flags = 0; - flags = 0; if (!dir && !one_char) flags = SEARCH_END; - result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD), + int result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD), spats[last_idx].pat, (long) (i ? count : 1), SEARCH_KEEP | flags, RE_SEARCH, 0, NULL); @@ -3845,13 +3834,13 @@ current_search ( p_ws = old_p_ws; } - start_pos = pos; - flags = forward ? SEARCH_END : 0; + int flags = forward ? SEARCH_END : 0; + pos_T start_pos = pos; /* move to match, except for zero-width matches, in which case, we are * already on the next match */ if (!one_char) - result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD), + searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD), spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL); if (!VIsual_active) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index ceb8b57f39..d277d71d99 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1261,28 +1261,12 @@ spell_check ( // For a match mip->mi_result is updated. static void find_word(matchinf_T *mip, int mode) { - idx_T arridx = 0; - int endlen[MAXWLEN]; // length at possible word endings - idx_T endidx[MAXWLEN]; // possible word endings - int endidxcnt = 0; - int len; int wlen = 0; int flen; - int c; char_u *ptr; - idx_T lo; - idx_T hi; - idx_T m; - char_u *s; - char_u *p; - int res = SP_BAD; slang_T *slang = mip->mi_lp->lp_slang; - unsigned flags; char_u *byts; idx_T *idxs; - bool word_ends; - bool prefix_found; - int nobreak_result; if (mode == FIND_KEEPWORD || mode == FIND_KEEPCOMPOUND) { // Check for word with matching case in keep-case tree. @@ -1316,6 +1300,13 @@ static void find_word(matchinf_T *mip, int mode) if (byts == NULL) return; // array is empty + idx_T arridx = 0; + int endlen[MAXWLEN]; // length at possible word endings + idx_T endidx[MAXWLEN]; // possible word endings + int endidxcnt = 0; + int len; + int c; + // Repeat advancing in the tree until: // - there is a byte that doesn't match, // - we reach the end of the tree, @@ -1356,10 +1347,10 @@ static void find_word(matchinf_T *mip, int mode) c = ptr[wlen]; if (c == TAB) // <Tab> is handled like <Space> c = ' '; - lo = arridx; - hi = arridx + len - 1; + idx_T lo = arridx; + idx_T hi = arridx + len - 1; while (lo < hi) { - m = (lo + hi) / 2; + idx_T m = (lo + hi) / 2; if (byts[m] > c) hi = m - 1; else if (byts[m] < c) @@ -1393,6 +1384,9 @@ static void find_word(matchinf_T *mip, int mode) } } + char_u *p; + bool word_ends; + // Verify that one of the possible endings is valid. Try the longest // first. while (endidxcnt > 0) { @@ -1410,7 +1404,7 @@ static void find_word(matchinf_T *mip, int mode) word_ends = true; // The prefix flag is before compound flags. Once a valid prefix flag // has been found we try compound flags. - prefix_found = false; + bool prefix_found = false; if (mode != FIND_KEEPWORD && has_mbyte) { // Compute byte length in original word, length may change @@ -1418,7 +1412,7 @@ static void find_word(matchinf_T *mip, int mode) // case-folded word is equal to the keep-case word. p = mip->mi_word; if (STRNCMP(ptr, p, wlen) != 0) { - for (s = ptr; s < ptr + wlen; mb_ptr_adv(s)) + for (char_u *s = ptr; s < ptr + wlen; mb_ptr_adv(s)) mb_ptr_adv(p); wlen = (int)(p - mip->mi_word); } @@ -1428,10 +1422,9 @@ static void find_word(matchinf_T *mip, int mode) // prefix ID. // Repeat this if there are more flags/region alternatives until there // is a match. - res = SP_BAD; for (len = byts[arridx - 1]; len > 0 && byts[arridx] == 0; --len, ++arridx) { - flags = idxs[arridx]; + uint32_t flags = idxs[arridx]; // For the fold-case tree check that the case of the checked word // matches with what the word in the tree requires. @@ -1527,7 +1520,7 @@ static void find_word(matchinf_T *mip, int mode) mip->mi_compoff) != 0) { // case folding may have changed the length p = mip->mi_word; - for (s = ptr; s < ptr + mip->mi_compoff; mb_ptr_adv(s)) + for (char_u *s = ptr; s < ptr + mip->mi_compoff; mb_ptr_adv(s)) mb_ptr_adv(p); } else p = mip->mi_word + mip->mi_compoff; @@ -1577,7 +1570,7 @@ static void find_word(matchinf_T *mip, int mode) else if (flags & WF_NEEDCOMP) continue; - nobreak_result = SP_OK; + int nobreak_result = SP_OK; if (!word_ends) { int save_result = mip->mi_result; @@ -1601,7 +1594,7 @@ static void find_word(matchinf_T *mip, int mode) // the case-folded word is equal to the keep-case word. p = mip->mi_fword; if (STRNCMP(ptr, p, wlen) != 0) { - for (s = ptr; s < ptr + wlen; mb_ptr_adv(s)) + for (char_u *s = ptr; s < ptr + wlen; mb_ptr_adv(s)) mb_ptr_adv(p); mip->mi_compoff = (int)(p - mip->mi_fword); } @@ -1661,6 +1654,7 @@ static void find_word(matchinf_T *mip, int mode) } } + int res = SP_BAD; if (flags & WF_BANNED) res = SP_BANNED; else if (flags & WF_REGION) { @@ -3767,7 +3761,6 @@ char_u *did_set_spelllang(win_T *wp) && !ASCII_ISALPHA(p[3])) { STRLCPY(region_cp, p + 1, 3); memmove(p, p + 3, len - (p - lang) - 2); - len -= 3; region = region_cp; } else dont_use_region = true; @@ -3780,8 +3773,7 @@ char_u *did_set_spelllang(win_T *wp) filename = false; if (len > 3 && lang[len - 3] == '_') { region = lang + len - 2; - len -= 3; - lang[len] = NUL; + lang[len - 3] = NUL; } else dont_use_region = true; @@ -8009,7 +8001,6 @@ static void init_spellfile(void) } // Init the chartab used for spelling for ASCII. -// EBCDIC is not supported! static void clear_spell_chartab(spelltab_T *sp) { int i; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 7dd3453d16..5f6e09925e 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5684,22 +5684,19 @@ static int syn_compare_syntime(const void *v1, const void *v2) */ static void syntime_report(void) { - synpat_T *spp; - proftime_T tm; - int len; - int total_count = 0; - garray_T ga; - time_entry_T *p; - if (!syntax_present(curwin)) { MSG(_(msg_no_items)); return; } + garray_T ga; ga_init(&ga, sizeof(time_entry_T), 50); + proftime_T total_total = profile_zero(); + int total_count = 0; + time_entry_T *p; for (int idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len; ++idx) { - spp = &(SYN_ITEMS(curwin->w_s)[idx]); + synpat_T *spp = &(SYN_ITEMS(curwin->w_s)[idx]); if (spp->sp_time.count > 0) { p = GA_APPEND_VIA_PTR(time_entry_T, &ga); p->total = spp->sp_time.total; @@ -5708,7 +5705,7 @@ static void syntime_report(void) p->match = spp->sp_time.match; total_count += spp->sp_time.count; p->slowest = spp->sp_time.slowest; - tm = profile_divide(spp->sp_time.total, spp->sp_time.count); + proftime_T tm = profile_divide(spp->sp_time.total, spp->sp_time.count); p->average = tm; p->id = spp->sp_syn.id; p->pattern = spp->sp_pattern; @@ -5723,7 +5720,6 @@ static void syntime_report(void) " TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN")); MSG_PUTS("\n"); for (int idx = 0; idx < ga.ga_len && !got_int; ++idx) { - spp = &(SYN_ITEMS(curwin->w_s)[idx]); p = ((time_entry_T *)ga.ga_data) + idx; MSG_PUTS(profile_msg(p->total)); @@ -5745,6 +5741,7 @@ static void syntime_report(void) MSG_PUTS(" "); msg_advance(69); + int len; if (Columns < 80) len = 20; /* will wrap anyway */ else @@ -6690,6 +6687,8 @@ static int hl_has_settings(int idx, int check_link) { return HL_TABLE()[idx].sg_term_attr != 0 || HL_TABLE()[idx].sg_cterm_attr != 0 + || HL_TABLE()[idx].sg_cterm_fg != 0 + || HL_TABLE()[idx].sg_cterm_bg != 0 || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK)); } diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 5c675247dc..a123e9b902 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1516,13 +1516,8 @@ parse_line: if (orgpat.headlen ) { tagp.tagname = lbuf; -#ifdef FEAT_TAG_ANYWHITE - tagp.tagname_end = skiptowhite(lbuf); - if (*tagp.tagname_end == NUL) -#else tagp.tagname_end = vim_strchr(lbuf, TAB); if (tagp.tagname_end == NULL) -#endif { if (vim_strchr(lbuf, NL) == NULL) { /* Truncated line, ignore it. Has been reported for @@ -1557,17 +1552,9 @@ parse_line: for (p = lbuf; p < tagp.tagname_end; ++p) { if (*p == ':') { if (tagp.fname == NULL) -#ifdef FEAT_TAG_ANYWHITE - tagp.fname = skipwhite(tagp.tagname_end); -#else tagp.fname = tagp.tagname_end + 1; -#endif if ( fnamencmp(lbuf, tagp.fname, p - lbuf) == 0 -#ifdef FEAT_TAG_ANYWHITE - && vim_iswhite(tagp.fname[p - lbuf]) -#else && tagp.fname[p - lbuf] == TAB -#endif ) { /* found one */ tagp.tagname = p + 1; @@ -1675,20 +1662,10 @@ parse_line: * Can be a matching tag, isolate the file name and command. */ if (tagp.fname == NULL) -#ifdef FEAT_TAG_ANYWHITE - tagp.fname = skipwhite(tagp.tagname_end); -#else tagp.fname = tagp.tagname_end + 1; -#endif -#ifdef FEAT_TAG_ANYWHITE - tagp.fname_end = skiptowhite(tagp.fname); - tagp.command = skipwhite(tagp.fname_end); - if (*tagp.command == NUL) -#else tagp.fname_end = vim_strchr(tagp.fname, TAB); tagp.command = tagp.fname_end + 1; if (tagp.fname_end == NULL) -#endif i = FAIL; else i = OK; @@ -2152,39 +2129,23 @@ parse_tag_line ( /* Isolate the tagname, from lbuf up to the first white */ tagp->tagname = lbuf; -#ifdef FEAT_TAG_ANYWHITE - p = skiptowhite(lbuf); -#else p = vim_strchr(lbuf, TAB); if (p == NULL) return FAIL; -#endif tagp->tagname_end = p; /* Isolate file name, from first to second white space */ -#ifdef FEAT_TAG_ANYWHITE - p = skipwhite(p); -#else if (*p != NUL) ++p; -#endif tagp->fname = p; -#ifdef FEAT_TAG_ANYWHITE - p = skiptowhite(p); -#else p = vim_strchr(p, TAB); if (p == NULL) return FAIL; -#endif tagp->fname_end = p; /* find start of search command, after second white space */ -#ifdef FEAT_TAG_ANYWHITE - p = skipwhite(p); -#else if (*p != NUL) ++p; -#endif if (*p == NUL) return FAIL; tagp->command = p; diff --git a/src/nvim/tempfile.c b/src/nvim/tempfile.c index c25da77717..33d6f0f37d 100644 --- a/src/nvim/tempfile.c +++ b/src/nvim/tempfile.c @@ -28,26 +28,29 @@ static void vim_maketempdir(void) { static const char *temp_dirs[] = TEMP_DIR_NAMES; // Try the entries in `TEMP_DIR_NAMES` to create the temp directory. - char_u itmp[TEMP_FILE_PATH_MAXLEN]; + char_u template[TEMP_FILE_PATH_MAXLEN]; + char_u path[TEMP_FILE_PATH_MAXLEN]; for (size_t i = 0; i < sizeof(temp_dirs) / sizeof(char *); ++i) { // Expand environment variables, leave room for "/nvimXXXXXX/999999999" - expand_env((char_u *)temp_dirs[i], itmp, TEMP_FILE_PATH_MAXLEN - 22); - if (!os_isdir(itmp)) { // directory doesn't exist + expand_env((char_u *)temp_dirs[i], template, TEMP_FILE_PATH_MAXLEN - 22); + if (!os_isdir(template)) { // directory doesn't exist continue; } - add_pathsep(itmp); + add_pathsep(template); // Concatenate with temporary directory name pattern - STRCAT(itmp, "nvimXXXXXX"); - if (!os_mkdtemp((char *)itmp)) { + STRCAT(template, "nvimXXXXXX"); + + if (os_mkdtemp((const char *)template, (char *)path) != 0) { continue; } - if (vim_settempdir(itmp)) { + + if (vim_settempdir(path)) { // Successfully created and set temporary directory so stop trying. break; } else { - // Couldn't set `vim_tempdir` to itmp so remove created directory. - os_rmdir((char *)itmp); + // Couldn't set `vim_tempdir` to `path` so remove created directory. + os_rmdir((char *)path); } } } @@ -128,8 +131,8 @@ char_u *vim_tempname(void) // There is no need to check if the file exists, because we own the directory // and nobody else creates a file in it. - char_u itmp[TEMP_FILE_PATH_MAXLEN]; - snprintf((char *)itmp, TEMP_FILE_PATH_MAXLEN, + char_u template[TEMP_FILE_PATH_MAXLEN]; + snprintf((char *)template, TEMP_FILE_PATH_MAXLEN, "%s%" PRIu32, tempdir, temp_count++); - return vim_strsave(itmp); + return vim_strsave(template); } diff --git a/src/nvim/term.c b/src/nvim/term.c index 98db1fb9fa..36e433d624 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -265,13 +265,6 @@ static struct builtin_term builtin_termcaps[] = # else {(int)KS_CDL, "\033[%dM"}, # endif -#ifdef BEOS_PR_OR_BETTER -# ifdef TERMINFO - {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, -# else - {(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */ -# endif -#endif {(int)KS_CL, "\033[H\033[2J"}, #ifdef notyet {(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */ @@ -309,9 +302,6 @@ static struct builtin_term builtin_termcaps[] = # else {(int)KS_CRI, "\033[%dC"}, # endif -#if defined(BEOS_DR8) - {(int)KS_DB, ""}, /* hack! see screen.c */ -#endif {K_UP, "\033[A"}, {K_DOWN, "\033[B"}, @@ -324,34 +314,34 @@ static struct builtin_term builtin_termcaps[] = * standard ANSI terminal, default for unix */ {(int)KS_NAME, "ansi"}, - {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, - {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, + {(int)KS_CE, "\033[K"}, + {(int)KS_AL, "\033[L"}, # ifdef TERMINFO - {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, + {(int)KS_CAL, "\033[%p1%dL"}, # else - {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, + {(int)KS_CAL, "\033[%dL"}, # endif - {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, + {(int)KS_DL, "\033[M"}, # ifdef TERMINFO - {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, + {(int)KS_CDL, "\033[%p1%dM"}, # else - {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, + {(int)KS_CDL, "\033[%dM"}, # endif - {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, - {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, - {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, + {(int)KS_CL, "\033[H\033[2J"}, + {(int)KS_ME, "\033[0m"}, + {(int)KS_MR, "\033[7m"}, {(int)KS_MS, "y"}, {(int)KS_UT, "y"}, /* guessed */ {(int)KS_LE, "\b"}, # ifdef TERMINFO - {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, + {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, # else - {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, + {(int)KS_CM, "\033[%i%d;%dH"}, # endif # ifdef TERMINFO - {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, + {(int)KS_CRI, "\033[%p1%dC"}, # else - {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, + {(int)KS_CRI, "\033[%dC"}, # endif # endif @@ -566,83 +556,82 @@ static struct builtin_term builtin_termcaps[] = * - keyboard languages (CSI ? 26 n) */ {(int)KS_NAME, "vt320"}, - {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, - {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, + {(int)KS_CE, "\033[K"}, + {(int)KS_AL, "\033[L"}, # ifdef TERMINFO - {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, + {(int)KS_CAL, "\033[%p1%dL"}, # else - {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, + {(int)KS_CAL, "\033[%dL"}, # endif - {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, + {(int)KS_DL, "\033[M"}, # ifdef TERMINFO - {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, + {(int)KS_CDL, "\033[%p1%dM"}, # else - {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, + {(int)KS_CDL, "\033[%dM"}, # endif - {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, - {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, + {(int)KS_CL, "\033[H\033[2J"}, + {(int)KS_CD, "\033[J"}, {(int)KS_CCO, "8"}, /* allow 8 colors */ - {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, - {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, - {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */ - {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")}, /* normal mode */ - {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")}, /* exit underscore mode */ - {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */ - {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */ - {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */ - {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */ - {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */ - {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */ - {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */ + {(int)KS_ME, "\033[0m"}, + {(int)KS_MR, "\033[7m"}, + {(int)KS_MD, "\033[1m"}, /* bold mode */ + {(int)KS_SE, "\033[22m"}, /* normal mode */ + {(int)KS_UE, "\033[24m"}, /* exit underscore mode */ + {(int)KS_US, "\033[4m"}, /* underscore mode */ + {(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */ + {(int)KS_CZR, "\033[0m"}, /* italic mode end */ + {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ + {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ + {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ + {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ {(int)KS_MS, "y"}, {(int)KS_UT, "y"}, {(int)KS_LE, "\b"}, # ifdef TERMINFO - {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", - ESC_STR "[%i%p1%d;%p2%dH")}, + {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, # else - {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, + {(int)KS_CM, "\033[%i%d;%dH"}, # endif # ifdef TERMINFO - {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, + {(int)KS_CRI, "\033[%p1%dC"}, # else - {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, + {(int)KS_CRI, "\033[%dC"}, # endif - {K_UP, IF_EB("\033[A", ESC_STR "[A")}, - {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, - {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, - {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, - {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, - {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, - {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, - {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, - {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, - {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, - {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, - {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, - {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, - {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, - {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, - {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, - {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, - {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, - {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */ - {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */ - {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, - {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, - {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, - {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, - {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, - {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, - {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, - {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, - {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, - {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, - {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ - {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ - {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ - {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ - {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ + {K_UP, "\033[A"}, + {K_DOWN, "\033[B"}, + {K_RIGHT, "\033[C"}, + {K_LEFT, "\033[D"}, + {K_F1, "\033[11~"}, + {K_F2, "\033[12~"}, + {K_F3, "\033[13~"}, + {K_F4, "\033[14~"}, + {K_F5, "\033[15~"}, + {K_F6, "\033[17~"}, + {K_F7, "\033[18~"}, + {K_F8, "\033[19~"}, + {K_F9, "\033[20~"}, + {K_F10, "\033[21~"}, + {K_F11, "\033[23~"}, + {K_F12, "\033[24~"}, + {K_F13, "\033[25~"}, + {K_F14, "\033[26~"}, + {K_F15, "\033[28~"}, /* Help */ + {K_F16, "\033[29~"}, /* Select */ + {K_F17, "\033[31~"}, + {K_F18, "\033[32~"}, + {K_F19, "\033[33~"}, + {K_F20, "\033[34~"}, + {K_INS, "\033[2~"}, + {K_DEL, "\033[3~"}, + {K_HOME, "\033[1~"}, + {K_END, "\033[4~"}, + {K_PAGEUP, "\033[5~"}, + {K_PAGEDOWN, "\033[6~"}, + {K_KPLUS, "\033Ok"}, /* keypad plus */ + {K_KMINUS, "\033Om"}, /* keypad minus */ + {K_KDIVIDE, "\033Oo"}, /* keypad / */ + {K_KMULTIPLY, "\033Oj"}, /* keypad * */ + {K_KENTER, "\033OM"}, /* keypad Enter */ {K_BS, "\x7f"}, /* for some reason 0177 doesn't work */ # endif @@ -651,169 +640,21 @@ static struct builtin_term builtin_termcaps[] = * Ordinary vt52 */ {(int)KS_NAME, "vt52"}, - {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, - {(int)KS_CD, IF_EB("\033J", ESC_STR "J")}, - {(int)KS_CM, IF_EB("\033Y%+ %+ ", ESC_STR "Y%+ %+ ")}, + {(int)KS_CE, "\033K"}, + {(int)KS_CD, "\033J"}, + {(int)KS_CM, "\033Y%+ %+ "}, {(int)KS_LE, "\b"}, - {(int)KS_AL, IF_EB("\033T", ESC_STR "T")}, - {(int)KS_DL, IF_EB("\033U", ESC_STR "U")}, - {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, - {(int)KS_ME, IF_EB("\033SO", ESC_STR "SO")}, - {(int)KS_MR, IF_EB("\033S2", ESC_STR "S2")}, + {(int)KS_AL, "\033T"}, + {(int)KS_DL, "\033U"}, + {(int)KS_CL, "\033H\033J"}, + {(int)KS_ME, "\033SO"}, + {(int)KS_MR, "\033S2"}, {(int)KS_MS, "y"}, # endif # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) {(int)KS_NAME, "xterm"}, - {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, - {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, -# ifdef TERMINFO - {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, -# else - {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, -# endif - {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, -# ifdef TERMINFO - {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, -# else - {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, -# endif -# ifdef TERMINFO - {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", - ESC_STR "[%i%p1%d;%p2%dr")}, -# else - {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, -# endif - {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, - {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, - {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, - {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, - {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, - {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, - {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, - {(int)KS_MS, "y"}, - {(int)KS_UT, "y"}, - {(int)KS_LE, "\b"}, -# ifdef TERMINFO - {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", - ESC_STR "[%i%p1%d;%p2%dH")}, -# else - {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, -# endif - {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, -# ifdef TERMINFO - {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, -# else - {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, -# endif - {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, - {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, - {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, - {(int)KS_CIE, "\007"}, - {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, - {(int)KS_FS, "\007"}, -# ifdef TERMINFO - {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", - ESC_STR "[8;%p1%d;%p2%dt")}, - {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", - ESC_STR "[3;%p1%d;%p2%dt")}, -# else - {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, - {(int)KS_CWP, IF_EB("\033[3;%d;%dt", ESC_STR "[3;%d;%dt")}, -# endif - {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, - {(int)KS_U7, IF_EB("\033[6n", ESC_STR "[6n")}, - - {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, - {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, - {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, - {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, - /* An extra set of cursor keys for vt100 mode */ - {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, - {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, - {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, - {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, - /* An extra set of function keys for vt100 mode */ - {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, - {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, - {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, - {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, - {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, - {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, - {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, - {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, - {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, - {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, - {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, - {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, - {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, - {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, - {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, - {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, - {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, - {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, - {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, - {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, - {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, - /* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */ - /* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */ - {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, - {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */ - {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */ - {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, - /* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */ - /* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */ - {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, - {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */ - {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, - {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, - {K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")}, - {K_KPLUS, IF_EB("\033O*k", ESC_STR "O*k")}, /* keypad plus */ - {K_KMINUS, IF_EB("\033O*m", ESC_STR "O*m")}, /* keypad minus */ - {K_KDIVIDE, IF_EB("\033O*o", ESC_STR "O*o")}, /* keypad / */ - {K_KMULTIPLY, IF_EB("\033O*j", ESC_STR "O*j")}, /* keypad * */ - {K_KENTER, IF_EB("\033O*M", ESC_STR "O*M")}, /* keypad Enter */ - {K_KPOINT, IF_EB("\033O*n", ESC_STR "O*n")}, /* keypad . */ - {K_KDEL, IF_EB("\033[3;*~", ESC_STR "[3;*~")}, /* keypad Del */ - - {BT_EXTRA_KEYS, ""}, - {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ - {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ - /* F14 and F15 are missing, because they send the same codes as the undo - * and help key, although they don't work on all keyboards. */ - {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ - {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ - {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ - {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ - {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ - - {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ - {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ - {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ - {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ - {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ - {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ - {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ - {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ - {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ - {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ - - {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ - {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ - {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ - {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ - {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ - {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ - {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ -# endif - -# if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) - /* - * iris-ansi for Silicon Graphics machines. - */ - {(int)KS_NAME, "iris-ansi"}, {(int)KS_CE, "\033[K"}, - {(int)KS_CD, "\033[J"}, {(int)KS_AL, "\033[L"}, # ifdef TERMINFO {(int)KS_CAL, "\033[%p1%dL"}, @@ -826,34 +667,20 @@ static struct builtin_term builtin_termcaps[] = # else {(int)KS_CDL, "\033[%dM"}, # endif +# ifdef TERMINFO + {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, +# else + {(int)KS_CS, "\033[%i%d;%dr"}, +# endif {(int)KS_CL, "\033[H\033[2J"}, - {(int)KS_VE, "\033[9/y\033[12/y"}, /* These aren't documented */ - {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, /* These aren't documented */ - {(int)KS_TI, "\033[=6h"}, - {(int)KS_TE, "\033[=6l"}, - {(int)KS_SE, "\033[21;27m"}, - {(int)KS_SO, "\033[1;7m"}, + {(int)KS_CD, "\033[J"}, {(int)KS_ME, "\033[m"}, {(int)KS_MR, "\033[7m"}, {(int)KS_MD, "\033[1m"}, - {(int)KS_CCO, "8"}, /* allow 8 colors */ - {(int)KS_CZH, "\033[3m"}, /* italic mode on */ - {(int)KS_CZR, "\033[23m"}, /* italic mode off */ - {(int)KS_US, "\033[4m"}, /* underline on */ - {(int)KS_UE, "\033[24m"}, /* underline off */ -# ifdef TERMINFO - {(int)KS_CAB, "\033[4%p1%dm"}, /* set background color (ANSI) */ - {(int)KS_CAF, "\033[3%p1%dm"}, /* set foreground color (ANSI) */ - {(int)KS_CSB, "\033[102;%p1%dm"}, /* set screen background color */ - {(int)KS_CSF, "\033[101;%p1%dm"}, /* set screen foreground color */ -# else - {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ - {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ - {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ - {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ -# endif - {(int)KS_MS, "y"}, /* guessed */ - {(int)KS_UT, "y"}, /* guessed */ + {(int)KS_UE, "\033[m"}, + {(int)KS_US, "\033[4m"}, + {(int)KS_MS, "y"}, + {(int)KS_UT, "y"}, {(int)KS_LE, "\b"}, # ifdef TERMINFO {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, @@ -866,54 +693,103 @@ static struct builtin_term builtin_termcaps[] = # else {(int)KS_CRI, "\033[%dC"}, # endif - {(int)KS_CIS, "\033P3.y"}, - {(int)KS_CIE, "\234"}, /* ST "String Terminator" */ - {(int)KS_TS, "\033P1.y"}, - {(int)KS_FS, "\234"}, /* ST "String Terminator" */ + {(int)KS_KS, "\033[?1h\033="}, + {(int)KS_KE, "\033[?1l\033>"}, + {(int)KS_CIS, "\033]1;"}, + {(int)KS_CIE, "\007"}, + {(int)KS_TS, "\033]2;"}, + {(int)KS_FS, "\007"}, # ifdef TERMINFO - {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, - {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, + {(int)KS_CWS, "\033[8;%p1%d;%p2%dt"}, + {(int)KS_CWP, "\033[3;%p1%d;%p2%dt"}, # else - {(int)KS_CWS, "\033[203;%d;%d/y"}, - {(int)KS_CWP, "\033[205;%d;%d/y"}, + {(int)KS_CWS, "\033[8;%d;%dt"}, + {(int)KS_CWP, "\033[3;%d;%dt"}, # endif - {K_UP, "\033[A"}, - {K_DOWN, "\033[B"}, - {K_LEFT, "\033[D"}, - {K_RIGHT, "\033[C"}, - {K_S_UP, "\033[161q"}, - {K_S_DOWN, "\033[164q"}, - {K_S_LEFT, "\033[158q"}, - {K_S_RIGHT, "\033[167q"}, - {K_F1, "\033[001q"}, - {K_F2, "\033[002q"}, - {K_F3, "\033[003q"}, - {K_F4, "\033[004q"}, - {K_F5, "\033[005q"}, - {K_F6, "\033[006q"}, - {K_F7, "\033[007q"}, - {K_F8, "\033[008q"}, - {K_F9, "\033[009q"}, - {K_F10, "\033[010q"}, - {K_F11, "\033[011q"}, - {K_F12, "\033[012q"}, - {K_S_F1, "\033[013q"}, - {K_S_F2, "\033[014q"}, - {K_S_F3, "\033[015q"}, - {K_S_F4, "\033[016q"}, - {K_S_F5, "\033[017q"}, - {K_S_F6, "\033[018q"}, - {K_S_F7, "\033[019q"}, - {K_S_F8, "\033[020q"}, - {K_S_F9, "\033[021q"}, - {K_S_F10, "\033[022q"}, - {K_S_F11, "\033[023q"}, - {K_S_F12, "\033[024q"}, - {K_INS, "\033[139q"}, - {K_HOME, "\033[H"}, - {K_END, "\033[146q"}, - {K_PAGEUP, "\033[150q"}, - {K_PAGEDOWN, "\033[154q"}, + {(int)KS_CRV, "\033[>c"}, + {(int)KS_U7, "\033[6n"}, + + {K_UP, "\033O*A"}, + {K_DOWN, "\033O*B"}, + {K_RIGHT, "\033O*C"}, + {K_LEFT, "\033O*D"}, + /* An extra set of cursor keys for vt100 mode */ + {K_XUP, "\033[1;*A"}, + {K_XDOWN, "\033[1;*B"}, + {K_XRIGHT, "\033[1;*C"}, + {K_XLEFT, "\033[1;*D"}, + /* An extra set of function keys for vt100 mode */ + {K_XF1, "\033O*P"}, + {K_XF2, "\033O*Q"}, + {K_XF3, "\033O*R"}, + {K_XF4, "\033O*S"}, + {K_F1, "\033[11;*~"}, + {K_F2, "\033[12;*~"}, + {K_F3, "\033[13;*~"}, + {K_F4, "\033[14;*~"}, + {K_F5, "\033[15;*~"}, + {K_F6, "\033[17;*~"}, + {K_F7, "\033[18;*~"}, + {K_F8, "\033[19;*~"}, + {K_F9, "\033[20;*~"}, + {K_F10, "\033[21;*~"}, + {K_F11, "\033[23;*~"}, + {K_F12, "\033[24;*~"}, + {K_S_TAB, "\033[Z"}, + {K_HELP, "\033[28;*~"}, + {K_UNDO, "\033[26;*~"}, + {K_INS, "\033[2;*~"}, + {K_HOME, "\033[1;*H"}, + /* {K_S_HOME, "\033O2H"}, */ + /* {K_C_HOME, "\033O5H"}, */ + {K_KHOME, "\033[1;*~"}, + {K_XHOME, "\033O*H"}, /* other Home */ + {K_ZHOME, "\033[7;*~"}, /* other Home */ + {K_END, "\033[1;*F"}, + /* {K_S_END, "\033O2F"}, */ + /* {K_C_END, "\033O5F"}, */ + {K_KEND, "\033[4;*~"}, + {K_XEND, "\033O*F"}, /* other End */ + {K_ZEND, "\033[8;*~"}, + {K_PAGEUP, "\033[5;*~"}, + {K_PAGEDOWN, "\033[6;*~"}, + {K_KPLUS, "\033O*k"}, /* keypad plus */ + {K_KMINUS, "\033O*m"}, /* keypad minus */ + {K_KDIVIDE, "\033O*o"}, /* keypad / */ + {K_KMULTIPLY, "\033O*j"}, /* keypad * */ + {K_KENTER, "\033O*M"}, /* keypad Enter */ + {K_KPOINT, "\033O*n"}, /* keypad . */ + {K_KDEL, "\033[3;*~"}, /* keypad Del */ + + {BT_EXTRA_KEYS, ""}, + {TERMCAP2KEY('k', '0'), "\033[10;*~"}, /* F0 */ + {TERMCAP2KEY('F', '3'), "\033[25;*~"}, /* F13 */ + /* F14 and F15 are missing, because they send the same codes as the undo + * and help key, although they don't work on all keyboards. */ + {TERMCAP2KEY('F', '6'), "\033[29;*~"}, /* F16 */ + {TERMCAP2KEY('F', '7'), "\033[31;*~"}, /* F17 */ + {TERMCAP2KEY('F', '8'), "\033[32;*~"}, /* F18 */ + {TERMCAP2KEY('F', '9'), "\033[33;*~"}, /* F19 */ + {TERMCAP2KEY('F', 'A'), "\033[34;*~"}, /* F20 */ + + {TERMCAP2KEY('F', 'B'), "\033[42;*~"}, /* F21 */ + {TERMCAP2KEY('F', 'C'), "\033[43;*~"}, /* F22 */ + {TERMCAP2KEY('F', 'D'), "\033[44;*~"}, /* F23 */ + {TERMCAP2KEY('F', 'E'), "\033[45;*~"}, /* F24 */ + {TERMCAP2KEY('F', 'F'), "\033[46;*~"}, /* F25 */ + {TERMCAP2KEY('F', 'G'), "\033[47;*~"}, /* F26 */ + {TERMCAP2KEY('F', 'H'), "\033[48;*~"}, /* F27 */ + {TERMCAP2KEY('F', 'I'), "\033[49;*~"}, /* F28 */ + {TERMCAP2KEY('F', 'J'), "\033[50;*~"}, /* F29 */ + {TERMCAP2KEY('F', 'K'), "\033[51;*~"}, /* F30 */ + + {TERMCAP2KEY('F', 'L'), "\033[52;*~"}, /* F31 */ + {TERMCAP2KEY('F', 'M'), "\033[53;*~"}, /* F32 */ + {TERMCAP2KEY('F', 'N'), "\033[54;*~"}, /* F33 */ + {TERMCAP2KEY('F', 'O'), "\033[55;*~"}, /* F34 */ + {TERMCAP2KEY('F', 'P'), "\033[56;*~"}, /* F35 */ + {TERMCAP2KEY('F', 'Q'), "\033[57;*~"}, /* F36 */ + {TERMCAP2KEY('F', 'R'), "\033[58;*~"}, /* F37 */ # endif # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) @@ -1100,10 +976,9 @@ static struct builtin_term builtin_termcaps[] = {(int)KS_NAME, "dumb"}, {(int)KS_CL, "\014"}, #ifdef TERMINFO - {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", - ESC_STR "[%i%p1%d;%p2%dH")}, + {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, #else - {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, + {(int)KS_CM, "\033[%i%d;%dH"}, #endif /* @@ -1148,9 +1023,7 @@ static struct builtin_term *find_builtin_term(char_u *term) while (p->bt_string != NULL) { if (p->bt_entry == (int)KS_NAME) { #ifdef UNIX - if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) - return p; - else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) + if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) return p; else #endif @@ -1545,31 +1418,6 @@ int set_termname(char_u *term) set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); # endif - -#ifdef USE_TERM_CONSOLE - /* DEFAULT_TERM indicates that it is the machine console. */ - if (STRCMP(term, DEFAULT_TERM) != 0) - term_console = FALSE; - else { - term_console = TRUE; - } -#endif - -#if defined(UNIX) - /* - * 'ttyfast' is default on for xterm, iris-ansi and a few others. - */ - if (vim_is_fastterm(term)) - p_tf = TRUE; -#endif -#ifdef USE_TERM_CONSOLE - /* - * 'ttyfast' is default on consoles - */ - if (term_console) - p_tf = TRUE; -#endif - ttest(TRUE); /* make sure we have a valid set of terminal codes */ full_screen = TRUE; /* we can use termcap codes from now on */ @@ -2164,7 +2012,7 @@ static void term_color(char_u *s, int n) #endif sprintf(buf, fmt, - i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233", + i == 2 ? "\033[" : "\233", s[i] == '3' ? (n >= 16 ? "38;5;" : "9") : (n >= 16 ? "48;5;" : "10")); OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index c93706fce2..21f2928593 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -29,7 +29,7 @@ SCRIPTS := test_autoformat_join.out \ test91.out test92.out test93.out test94.out test95.out \ test96.out test97.out test98.out test99.out test100.out \ test101.out test102.out test103.out test104.out test105.out \ - test106.out + test106.out test107.out SCRIPTS_GUI := test16.out diff --git a/src/nvim/testdir/test100.in b/src/nvim/testdir/test100.in index e42331946c..f9f5f9119f 100644 --- a/src/nvim/testdir/test100.in +++ b/src/nvim/testdir/test100.in @@ -37,6 +37,14 @@ STARTTEST :call UndoLevel() :%w >> test.out :"sleep 10 +:" +:" Testing 'lispwords' +:" +:setglobal lispwords=foo,bar,baz +:setlocal lispwords-=foo | setlocal lispwords+=quux +:redir >> test.out | echon "\nTesting 'lispwords' local value" | setglobal lispwords? | setlocal lispwords? | echo &lispwords . "\n" | redir end +:setlocal lispwords< +:redir >> test.out | echon "\nTesting 'lispwords' value reset" | setglobal lispwords? | setlocal lispwords? | echo &lispwords . "\n" | redir end :qa! ENDTEST diff --git a/src/nvim/testdir/test100.ok b/src/nvim/testdir/test100.ok index 95b318461c..477106b8f2 100644 --- a/src/nvim/testdir/test100.ok +++ b/src/nvim/testdir/test100.ok @@ -39,3 +39,13 @@ THREE: expecting global undolevels: 50, local undolevels: -123456 (default) undolevels=50 global undolevels=-123456 local + +Testing 'lispwords' local value + lispwords=foo,bar,baz + lispwords=bar,baz,quux +bar,baz,quux + +Testing 'lispwords' value reset + lispwords=foo,bar,baz + lispwords=foo,bar,baz +foo,bar,baz diff --git a/src/nvim/testdir/test107.in b/src/nvim/testdir/test107.in new file mode 100644 index 0000000000..9143380f18 --- /dev/null +++ b/src/nvim/testdir/test107.in @@ -0,0 +1,38 @@ +Tests for adjusting window and contents vim: set ft=vim : + +STARTTEST +:so small.vim +:new +:call setline(1, range(1,256)) +:let r=[] +:func! GetScreenStr(row) +: let str = "" +: for c in range(1,3) +: let str .= nr2char(screenchar(a:row, c)) +: endfor +: return str +:endfunc +: +:exe ":norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+" +:let s3=GetScreenStr(1) +:wincmd p +:call add(r, [line("w0"), s3]) +: +:exe ":norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+" +:let s3=GetScreenStr(1) +:wincmd p +:call add(r, [line("w0"), s3]) +: +:exe ":norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+" +:let s3=GetScreenStr(1) +::wincmd p +:call add(r, [line("w0"), s3]) +: +:bwipeout! +:$put=r +:call garbagecollect(1) +:" +:/^start:/,$wq! test.out +ENDTEST + +start: diff --git a/src/nvim/testdir/test107.ok b/src/nvim/testdir/test107.ok new file mode 100644 index 0000000000..3e0eda1fe7 --- /dev/null +++ b/src/nvim/testdir/test107.ok @@ -0,0 +1,4 @@ +start: +[1, '1 '] +[50, '50 '] +[59, '59 '] diff --git a/src/nvim/testdir/test2.in b/src/nvim/testdir/test2.in deleted file mode 100644 index b7b5a51066..0000000000 --- a/src/nvim/testdir/test2.in +++ /dev/null @@ -1,29 +0,0 @@ - -This is a test if a URL is recognized by "gf", with the cursor before and -after the "://". Also test ":\\". - -STARTTEST -:so small.vim -/^first -/tmp -:call append(0, expand("<cfile>")) -/^second -/URL -:call append(1, expand("<cfile>")) -:if has("ebcdic") -: set isf=@,240-249,/,.,-,_,+,,,$,:,~,\ -:else -: set isf=@,48-57,/,.,-,_,+,,,$,:,~,\ -:endif -/^third -/name -:call append(2, expand("<cfile>")) -/^fourth -/URL -:call append(3, expand("<cfile>")) -5GdG:wq! test.out -ENDTEST -first test for URL://machine.name/tmp/vimtest2a and other text -second test for URL://machine.name/tmp/vimtest2b. And other text -third test for URL:\\machine.name\vimtest2c and other text -fourth test for URL:\\machine.name\tmp\vimtest2d, and other text diff --git a/src/nvim/testdir/test2.ok b/src/nvim/testdir/test2.ok deleted file mode 100644 index 32978825f8..0000000000 --- a/src/nvim/testdir/test2.ok +++ /dev/null @@ -1,4 +0,0 @@ -URL://machine.name/tmp/vimtest2a -URL://machine.name/tmp/vimtest2b -URL:\\machine.name\vimtest2c -URL:\\machine.name\tmp\vimtest2d diff --git a/src/nvim/testdir/test69.in b/src/nvim/testdir/test69.in index 75317b4954..674dc32812 100644 --- a/src/nvim/testdir/test69.in +++ b/src/nvim/testdir/test69.in @@ -180,6 +180,13 @@ byteidx byteidxcomp STARTTEST +/^substitute +:let y = substitute('123', '\zs', 'a', 'g') | put =y +ENDTEST + +substitute + +STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/^Results/,$wq! test.out ENDTEST diff --git a/src/nvim/testdir/test69.ok b/src/nvim/testdir/test69.ok index 41cd9d02c3..af8befb0c7 100644 --- a/src/nvim/testdir/test69.ok +++ b/src/nvim/testdir/test69.ok @@ -160,3 +160,7 @@ byteidxcomp [0, 1, 3, 4, -1] [0, 1, 2, 4, 5, -1] + +substitute +a1a2a3a + diff --git a/src/nvim/testdir/test95.in b/src/nvim/testdir/test95.in index 568563f88d..b2b9de772e 100644 --- a/src/nvim/testdir/test95.in +++ b/src/nvim/testdir/test95.in @@ -50,7 +50,11 @@ STARTTEST :call add(tl, [1, "\u05b9\u05bb", " y\u05b9 x\u05b9\u05bb ", "x\u05b9\u05bb"]) :call add(tl, [2, ".\u05b9\u05bb", " y\u05bb x\u05b9\u05bb ", "x\u05b9\u05bb"]) :call add(tl, [2, "a", "ca\u0300t"]) +:call add(tl, [2, "ca", "ca\u0300t"]) :call add(tl, [2, "a\u0300", "ca\u0300t", "a\u0300"]) +:call add(tl, [2, 'a\%C', "ca\u0300t", "a\u0300"]) +:call add(tl, [2, 'ca\%C', "ca\u0300t", "ca\u0300"]) +:call add(tl, [2, 'ca\%Ct', "ca\u0300t", "ca\u0300t"]) :"""" Test \Z @@ -90,15 +94,15 @@ STARTTEST : try : let l = matchlist(text, pat) : catch -: $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"' +: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"' : endtry :" check the match itself : if len(l) == 0 && len(t) > matchidx -: $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"' +: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"' : elseif len(l) > 0 && len(t) == matchidx -: $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match' +: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match' : elseif len(t) > matchidx && l[0] != t[matchidx] -: $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"' +: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"' : else : $put ='OK ' . engine . ' - ' . pat : endif @@ -111,7 +115,7 @@ STARTTEST : let e = t[matchidx + i] : endif : if l[i] != e -: $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"' +: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"' : endif : endfor : unlet i diff --git a/src/nvim/testdir/test95.ok b/src/nvim/testdir/test95.ok index e2baee8d29..6762994c12 100644 --- a/src/nvim/testdir/test95.ok +++ b/src/nvim/testdir/test95.ok @@ -70,9 +70,21 @@ OK 2 - .ֹֻ OK 0 - a OK 1 - a OK 2 - a +OK 0 - ca +OK 1 - ca +OK 2 - ca OK 0 - à OK 1 - à OK 2 - à +OK 0 - a\%C +OK 1 - a\%C +OK 2 - a\%C +OK 0 - ca\%C +OK 1 - ca\%C +OK 2 - ca\%C +OK 0 - ca\%Ct +OK 1 - ca\%Ct +OK 2 - ca\%Ct OK 0 - ú\Z OK 1 - ú\Z OK 2 - ú\Z diff --git a/src/nvim/testdir/test97.in b/src/nvim/testdir/test97.in index 59bb62d15c..d4ff6d9295 100644 --- a/src/nvim/testdir/test97.in +++ b/src/nvim/testdir/test97.in @@ -8,12 +8,15 @@ STARTTEST :" consistent sorting of file names :set nofileignorecase :e test.out -:put =glob('Xxx\{') -:put =glob('Xxx\$') +:$put =glob('Xxx\{') +:$put =glob('Xxx\$') :w! Xxx{ :w! Xxx\$ -:put =glob('Xxx\{') -:put =glob('Xxx\$') +:$put =glob('Xxx\{') +:$put =glob('Xxx\$') +:" +:$put =string(globpath('sautest/autoload', '*.vim')) +:$put =string(globpath('sautest/autoload', '*.vim', 0, 1)) :w :qa! ENDTEST diff --git a/src/nvim/testdir/test97.ok b/src/nvim/testdir/test97.ok index afa96a4de4..32cdcbf1be 100644 --- a/src/nvim/testdir/test97.ok +++ b/src/nvim/testdir/test97.ok @@ -3,3 +3,6 @@ Xxx{ Xxx$ +'sautest/autoload/Test104.vim +sautest/autoload/footest.vim' +['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim'] diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 96b83a3e2d..8c7b5b38e9 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1119,10 +1119,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash) if (os_get_file_info((char *)buf->b_ffname, &file_info_old) && os_get_file_info((char *)file_name, &file_info_new) && file_info_old.stat.st_gid != file_info_new.stat.st_gid -# ifdef HAVE_FCHOWN /* sequent-ptx lacks fchown() */ - && fchown(fd, (uid_t)-1, file_info_old.stat.st_gid) != 0 -# endif - ) { + && os_fchown(fd, -1, file_info_old.stat.st_gid) != 0) { os_setperm(file_name, (perm & 0707) | ((perm & 07) << 3)); } # ifdef HAVE_SELINUX diff --git a/src/nvim/version.c b/src/nvim/version.c index 8214cb60b4..246ce02f1f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -61,11 +61,7 @@ static char *(features[]) = { "+conceal", "+cscope", "+cursorbind", -#ifdef CURSOR_SHAPE "+cursorshape", -#else // ifdef CURSOR_SHAPE - "-cursorshape", -#endif // ifdef CURSOR_SHAPE "+dialog_con", "+diff", "+digraphs", @@ -145,11 +141,7 @@ static char *(features[]) = { "+syntax", "+tag_binary", "+tag_old_static", -#ifdef FEAT_TAG_ANYWHITE - "+tag_any_white", -#else // ifdef FEAT_TAG_ANYWHITE "-tag_any_white", -#endif // ifdef FEAT_TAG_ANYWHITE #if defined(UNIX) // only Unix can have terminfo instead of termcap @@ -193,6 +185,52 @@ static char *(features[]) = { static int included_patches[] = { // Add new patch number below this line + //410, + //409, + //408, + //407, + //406, + //405, + //404, + //403, + //402, + //401, + //400, + //399, + //398, + //397, + //396, + //395, + //394, + //393, + //392, + //391, + //390, + //389, + //388, + //387, + //386, + //385, + //384, + //383, + //382, + //381, + //380 NA + //379, + //378, + //377, + //376, + //375, + //374, + //373, + //372, + //371, + //370, + //369, + //368, + //367, + //366, + //365, //364, //363, //362, @@ -201,7 +239,7 @@ static int included_patches[] = { //359, //358, //357, - //356, + //356 NA //355, //354, //353, @@ -215,62 +253,62 @@ static int included_patches[] = { //345, //344, //343, - //342, + //342 NA //341, - //340, + //340 NA //339, //338, //337, //336, - //335, + 335, //334, - //333, - //332, - //331, + //333 NA + //332 NA + 331, //330, - //329, - //328, - //327, - //326, - //325, + 329, + 328, + 327, + //326 NA + 325, //324, - //323, - //322, - //321, + 323, + //322 NA + //321 NA //320, - //319, - //318, + //319 NA + 318, //317, - //316, - //315, - //314, + //316 NA + 315, + 314, //313, //312, //311, //310, 309, 308, - //307, + //307 NA 306, //305, - //304, + //304 NA 303, 302, 301, - //300, - //299, + //300 NA + //299 NA 298, //297, //296, 295, - //294, - //293, + 294, + 293, 292, 291, 290, 289, 288, - //287, + //287 NA 286, 285, 284, @@ -278,16 +316,16 @@ static int included_patches[] = { 282, 281, 280, - //279, + 279, //278, 277, - //276, + 276, 275, 274, - //273, + //273 NA 272, //271, - //270, + //270 NA 269, 268, 267, @@ -299,13 +337,13 @@ static int included_patches[] = { 261, 260, //259, - //258, - //257, + //258 NA + //257 NA //256, //255, //254, 253, - //252, + //252 NA 251, //250, //249, @@ -327,76 +365,76 @@ static int included_patches[] = { 233, 232, //231, - //230, + 230, 229, - //228, - //227, + //228 NA + //227 NA 226, - //225, - //224, - //223, - //222, + //225 NA + //224 NA + //223 NA + //222 NA 221, //220, 219, 218, - //217, - //216, + //217 NA + //216 NA 215, - //214, + //214 NA 213, - //212, + //212 NA //211, 210, 209, - //208, + //208 NA 207, - //206, + //206 NA 205, 204, 203, - //202, - //201, - //200, + //202 NA + 201, + //200 NA 199, - //198, - //197, - //196, - //195, - //194, + //198 NA + //197 NA + //196 NA + //195 NA + //194 NA 193, 192, 191, - //190, + //190 NA //189, - //188, + //188 NA 187, 186, //185, 184, - //183, - //182, + //183 NA + //182 NA 181, - //180, - //179, + //180 NA + //179 NA 178, - //177, + //177 NA //176, - //175, - //174, + //175 NA + //174 NA 173, 172, 171, 170, 169, - //168, + //168 NA 167, 166, - //165, - //164, - //163, - //162, - //161, + 165, + //164 NA + //163 NA + //162 NA + //161 NA 160, 159, 158, diff --git a/src/nvim/window.c b/src/nvim/window.c index 7e4934bdfe..050f5e2acd 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1445,7 +1445,6 @@ win_equal_rec ( } for (fr = topfr->fr_child; fr != NULL; fr = fr->fr_next) { - n = m = 0; wincount = 1; if (fr->fr_next == NULL) /* last frame gets all that remains (avoid roundoff error) */ @@ -1566,7 +1565,6 @@ win_equal_rec ( } for (fr = topfr->fr_child; fr != NULL; fr = fr->fr_next) { - n = m = 0; wincount = 1; if (fr->fr_next == NULL) /* last frame gets all that remains (avoid roundoff error) */ @@ -3398,12 +3396,19 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri return; } - /* sync undo before leaving the current buffer */ - if (undo_sync && curbuf != wp->w_buffer) + // sync undo before leaving the current buffer + if (undo_sync && curbuf != wp->w_buffer) { u_sync(FALSE); - /* may have to copy the buffer options when 'cpo' contains 'S' */ - if (wp->w_buffer != curbuf) + } + + // Might need to scroll the old window before switching, e.g., when the + // cursor was moved. + update_topline(); + + // may have to copy the buffer options when 'cpo' contains 'S' + if (wp->w_buffer != curbuf) { buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); + } if (!curwin_invalid) { prevwin = curwin; /* remember for CTRL-W p */ curwin->w_redr_status = TRUE; @@ -4479,7 +4484,12 @@ void win_new_height(win_T *wp, int height) if (wp->w_height > 0) { if (wp == curwin) { - validate_cursor(); // w_wrow needs to be valid + // w_wrow needs to be valid. When setting 'laststatus' this may + // call win_new_height() recursively. + validate_cursor(); + } + if (wp->w_height != prev_height) { + return; // Recursive call already changed the size, bail out. } if (wp->w_wrow != wp->w_prev_fraction_row) { set_fraction(wp); |